hle,eh: reclaim partial physical frees, shard lazy VEH, harden dstorage/input/audio #1994

Open
raylitebull wants to merge 2 commits from upstream-pr/2004 into main
raylitebull commented 2026-11-25 00:37:46 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by raylitebull on 2026-11-25T00:37:46Z.


Hardens HLE world streaming, physical-page reclamation, lazy VEH sharding, monitor/mwait patching, audio buffer reuse, and GameInput/KBM playability:

  1. Physical pages & kernelx/lazy.rs:
    • Keeps XMemVirtualAlloc / overflow alloc_physical_home MEM_RESERVE fallbacks below the 40-bit VA ceiling via alloc_below_40bit (VirtualAlloc2, preserving #2157's sparse-layout coherent UMA opt-out); stops large AllocateTitlePhysicalPages pools from stealing pre-committed coherent UMA; skips committing lazy pages on reads while ensuring lazy pages before writes (uses existing upstream XMemIsToolsMemAvailable in kernelx.rs).
    • Replaces PHYS_BLOCKS counters with a per-page live bitmap (PhysBlock) for exact per-page liveness (physical_pages_live + is_live_physical_page), double-free immunity, and immediate coalesced MEM_DECOMMIT + sparse::decommitted on partial FreeTitlePhysicalPages calls.
    • Shards the lazy-page table across 16 contiguous 4 MiB stripes (kernelx/lazy.rs) with atomic LAZY_COUNT / LAZY_COMMITTED_ANY fast paths and batched lazy::mark / unmark.
  2. DirectStorage streaming (dstorage.rs, dstorage/parallel.rs, dstorage/parallel_tests.rs):
    • Unifies #1405 execution-time physical page-list resolution (!dest_on_stack + read_own + kernelx::physical_pages_live + zero-entry reread) inside dstorage.rs::write_dest_physical_pages across sequential execute() and dstorage/parallel.rs (InFlightTask::dest_on_stack), refreshing stale/freed entries on write/read retry (0x89240009 prevention) and extending parallel decompression to physical-page destinations and supported BCPack requests.
  3. Monitorx/Mwaitx & EH (eh.rs):
    • Replaces the global SEEN mutex in emulate_console_only with a lock-free AtomicU16 bitmask and live-patches Monitorx -> nop;nop;nop and Mwaitx -> pause;nop via atomic aligned u64 CAS + FlushInstructionCache (opt-out via XCL_NO_PATCH_MONITORX=1).
  4. Audio (opus.rs, acphal.rs):
    • Caches/reuses unique Media Foundation IMFSample/IMFMediaBuffer pairs across MftDecoder packets; splits XApu stream locks to per-stream mutexes with reusable PCM/float scratch buffers and atomic progress throttling (preserving #471's Channel::connect clear).
  5. GameInput & KBM (gameinput.rs, kbm.rs):
    • Skips disconnected-pad XInput rumble stalls and deduplicates unchanged speeds; adds bounded GetNextReading/GetPreviousReading history; extends XCL_PRESS_AT for triggers/sticks/durations; adds Z/C bumper keys; gates mouse buttons on capture/non-sizing and guards zero-delta poll velocity decay (preserving #552's PlayStation HID fallback).

Part of #1833.

What is in it

  • crates/xcl/src/eh.rs, crates/xcl/src/hle/{acphal.rs, dstorage.rs, dstorage/parallel.rs, dstorage/parallel_tests.rs, gameinput.rs, kbm.rs, kernelx.rs, kernelx/lazy.rs, opus.rs} (10 files).

Tested

  • Toolchain: Windows 11 x64, rustc 1.99.1 (58cf8f9c3 2026-10-13), rebased cleanly onto 73e3aba6 (57560bf5).
  • cargo check --workspace --tests: passed (0 warnings in touched files).
  • cargo test -p xcl --lib -- --test-threads=4 hle::kernelx:: hle::dstorage:: hle::gameinput:: hle::kbm:: hle::acphal:: hle::opus:: eh::tests::: 128 passed, 0 failed, 1 ignored (0.61s, including #1405, #495, #2157, #509, #563, #2048, and all 13 #2004 tests).

Regression run

  • Standalone scripts/smoke.ps1 pair on 57560bf5 vs 73e3aba6 has not been run yet. AMD and NVIDIA reviewers are invited to verify 57560bf5 vs 73e3aba6 (including scripts/smoke.ps1, DirectStorage streaming, and GameInput/KBM paths) and post results in the comments.

Not tested

  • 60 s scripts/smoke.ps1 pair on 57560bf5, full cargo test --workspace suite on 57560bf5, runtime GPU execution across AMD / NVIDIA / Intel hardware, and Linux/Wine/vkd3d-proton.

AI use

  • Antigravity assisted with implementation, rebase onto 73e3aba6, and unit tests; the author reviewed the diff and test output.
<!-- greyfinch-sync:ivall/xcl:issue:5482834617 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2004). Originally posted by [raylitebull](https://github.com/raylitebull) on 2026-11-25T00:37:46Z. --- Hardens HLE world streaming, physical-page reclamation, lazy VEH sharding, monitor/mwait patching, audio buffer reuse, and GameInput/KBM playability: 1. **Physical pages & `kernelx/lazy.rs`:** - Keeps `XMemVirtualAlloc` / overflow `alloc_physical_home` `MEM_RESERVE` fallbacks below the 40-bit VA ceiling via `alloc_below_40bit` (`VirtualAlloc2`, preserving `#2157`'s sparse-layout coherent UMA opt-out); stops large `AllocateTitlePhysicalPages` pools from stealing pre-committed coherent UMA; skips committing lazy pages on reads while ensuring lazy pages before writes *(uses existing upstream `XMemIsToolsMemAvailable` in `kernelx.rs`)*. - Replaces `PHYS_BLOCKS` counters with a per-page live bitmap (`PhysBlock`) for exact per-page liveness (`physical_pages_live` + `is_live_physical_page`), double-free immunity, and immediate coalesced `MEM_DECOMMIT` + `sparse::decommitted` on partial `FreeTitlePhysicalPages` calls. - Shards the lazy-page table across 16 contiguous `4 MiB` stripes (`kernelx/lazy.rs`) with atomic `LAZY_COUNT` / `LAZY_COMMITTED_ANY` fast paths and batched `lazy::mark` / `unmark`. 2. **DirectStorage streaming (`dstorage.rs`, `dstorage/parallel.rs`, `dstorage/parallel_tests.rs`):** - Unifies `#1405` execution-time physical page-list resolution (`!dest_on_stack` + `read_own` + `kernelx::physical_pages_live` + zero-entry reread) inside `dstorage.rs::write_dest_physical_pages` across sequential `execute()` and `dstorage/parallel.rs` (`InFlightTask::dest_on_stack`), refreshing stale/freed entries on write/read retry (`0x89240009` prevention) and extending parallel decompression to physical-page destinations and supported BCPack requests. 3. **`Monitorx`/`Mwaitx` & EH (`eh.rs`):** - Replaces the global `SEEN` mutex in `emulate_console_only` with a lock-free `AtomicU16` bitmask and live-patches `Monitorx` -> `nop;nop;nop` and `Mwaitx` -> `pause;nop` via atomic aligned `u64` CAS + `FlushInstructionCache` (opt-out via `XCL_NO_PATCH_MONITORX=1`). 4. **Audio (`opus.rs`, `acphal.rs`):** - Caches/reuses unique Media Foundation `IMFSample`/`IMFMediaBuffer` pairs across `MftDecoder` packets; splits `XApu` stream locks to per-stream mutexes with reusable PCM/float scratch buffers and atomic progress throttling (preserving `#471`'s `Channel::connect` clear). 5. **GameInput & KBM (`gameinput.rs`, `kbm.rs`):** - Skips disconnected-pad XInput rumble stalls and deduplicates unchanged speeds; adds bounded `GetNextReading`/`GetPreviousReading` history; extends `XCL_PRESS_AT` for triggers/sticks/durations; adds `Z`/`C` bumper keys; gates mouse buttons on capture/non-sizing and guards zero-delta poll velocity decay (preserving `#552`'s PlayStation HID fallback). Part of #1833. **What is in it** - `crates/xcl/src/eh.rs`, `crates/xcl/src/hle/{acphal.rs, dstorage.rs, dstorage/parallel.rs, dstorage/parallel_tests.rs, gameinput.rs, kbm.rs, kernelx.rs, kernelx/lazy.rs, opus.rs}` (`10` files). **Tested** - Toolchain: Windows 11 x64, `rustc 1.99.1 (58cf8f9c3 2026-10-13)`, rebased cleanly onto `73e3aba6` (`57560bf5`). - `cargo check --workspace --tests`: passed (`0` warnings in touched files). - `cargo test -p xcl --lib -- --test-threads=4 hle::kernelx:: hle::dstorage:: hle::gameinput:: hle::kbm:: hle::acphal:: hle::opus:: eh::tests::`: 128 passed, 0 failed, 1 ignored (`0.61s`, including `#1405`, `#495`, `#2157`, `#509`, `#563`, `#2048`, and all 13 `#2004` tests). **Regression run** - Standalone `scripts/smoke.ps1` pair on `57560bf5` vs `73e3aba6` has not been run yet. AMD and NVIDIA reviewers are invited to verify `57560bf5` vs `73e3aba6` (including `scripts/smoke.ps1`, DirectStorage streaming, and GameInput/KBM paths) and post results in the comments. **Not tested** - 60 s `scripts/smoke.ps1` pair on `57560bf5`, full `cargo test --workspace` suite on `57560bf5`, runtime GPU execution across AMD / NVIDIA / Intel hardware, and Linux/Wine/vkd3d-proton. **AI use** - Antigravity assisted with implementation, rebase onto `73e3aba6`, and unit tests; the author reviewed the diff and test output.
raylitebull commented 2026-11-25 01:10:53 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by raylitebull on 2026-11-25T00:47:42Z.


Overlap note: full credit to #565 (@ZekkJJ) for retaining recent GameInput readings for GetNextReading / GetPreviousReading in gameinput.rs.

If #565 lands first, we will drop the reading-history hunks from #2004 and keep #2004 focused on its independent eh, acphal, dstorage, kbm, kernelx, lazy, opus, and XCL_PRESS_AT / rumble changes.

<!-- greyfinch-sync:ivall/xcl:comment:7148882380 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2004#issuecomment-7148882380). Originally posted by [raylitebull](https://github.com/raylitebull) on 2026-11-25T00:47:42Z. --- Overlap note: full credit to **#565** (@ZekkJJ) for retaining recent `GameInput` readings for `GetNextReading` / `GetPreviousReading` in `gameinput.rs`. If #565 lands first, we will drop the reading-history hunks from #2004 and keep #2004 focused on its independent `eh`, `acphal`, `dstorage`, `kbm`, `kernelx`, `lazy`, `opus`, and `XCL_PRESS_AT` / rumble changes.
futurepro62 commented 2026-11-25 01:11:04 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by futurepro62 on 2026-11-25T01:03:50Z.


Full-suite run, since this PR has no test report yet. Tested exact head 462a456 (on its base 6567c5f).

Tested

  • NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 621.40, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.100.0 MSVC, DXC + dxil.dll 1.9.2602.17 (Windows SDK 10.0.26100), debug, D3D12 debug layer installed.
  • cargo build --workspace, then XCL_REQUIRE_GPU=mesh cargo test --workspace -- --test-threads=4 --skip heap_window_out_of_memory_falls_back_to_the_switch_form --skip gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::integer_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::f64_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::const_and_null_mask_operands_agree_with_hlsl_on_the_gpu --skip gpu::dxil::fuzz_tests: 999 passed, 0 failed, 43 ignored. SKIPPED (no wave64): a_2d_or_3d_group_agrees_with_the_hlsl_path_on_the_gpu, a_per_lane_2d_or_3d_group_runs_on_the_gpu, coalesced_guarded_runs_agree_with_the_hlsl_path_on_the_gpu, cross_lane_reads_agree_with_the_hlsl_path_on_the_gpu, gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware, the_wave64_lowering_agrees_with_the_hlsl_path_on_the_gpu.
  • The new tests ran and passed: monitorx_and_mwaitx_patch_to_nop_and_pause_safely, xapu_reuses_stream_scratch_and_supports_concurrent_streams, parallel_decode_supports_physical_page_destinations_and_late_refresh, rumble_skips_disconnected_pad_and_deduplicates_unchanged_speeds, next_and_previous_reading_walk_state_changes_and_terminate, extended_scripted_actions_drive_triggers_sticks_and_durations, mouse_buttons_require_capture_and_not_sizing, high_frequency_zero_polls_do_not_prematurely_decay_velocity, xmem_tools_mem_and_40bit_virtual_alloc, physical_page_reads_skip_commit_writes_ensure_lazy_and_free_unmarks, partial_free_tracks_exact_liveness_decommits_homes_and_ignores_double_free, sharded_lazy_batch_spans_stripes_and_unmarks_cleanly, mft_decoder_reuses_cached_samples_across_packets.
  • Same head on the AMD Radeon integrated GPU (iGPU) of the Ryzen 7 9800X3D (RDNA2, XCL_ADAPTER=radeon), cargo test --workspace -- --test-threads=4 --skip gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1: 1009 passed, 0 failed, 45 ignored. SKIPPED: f16_programs_on_the_gpu (f16 arithmetic, wave32, per-lane form: refused (unsupported V_MUL_F16 (its #1426 semantics differ from the console's))), f16_programs_on_the_gpu (f16 arithmetic, wave64, per-lane form: refused (unsupported V_MUL_F16 (its #1426 semantics differ from the console's))), f16_programs_on_the_gpu (f16 packed, wave32, per-lane form: refused (unsupported V_PK_MUL_F16: VOP3 modifiers (its #1426 semantics differ from the console's))), f16_programs_on_the_gpu (f16 packed, wave64, per-lane form: refused (unsupported V_PK_MUL_F16: VOP3 modifiers (its #1426 semantics differ from the console's))), f32_programs_on_the_gpu (f32 conversions, wave32, per-lane form: refused (unsupported V_CVT_F16_F32 (its #1426 semantics differ from the console's))), f32_programs_on_the_gpu (f32 conversions, wave64, per-lane form: refused (unsupported V_CVT_F16_F32 (its #1426 semantics differ from the console's))), heap_window_out_of_memory_falls_back_to_the_switch_form (no heap windows).
  • --skip leaves out tests that fail on main 7994cd1 too, not because of this PR. On NVIDIA: heap_window_out_of_memory_falls_back_to_the_switch_form (#1651), the four gpu::recomp::lower_dxil::tests::*_programs_on_the_gpu tests and const_and_null_mask_operands_agree_with_hlsl_on_the_gpu (follow-up on #1651) fail because runner::skip_test turns their skips into failures under XCL_REQUIRE_GPU=mesh, and gpu::dxil::fuzz_tests seeds 70, 545, 1019 and 1507 fail CreateComputePipelineState with E_OUTOFMEMORY on this card (drivers 616.64 and 621.40). On AMD: fuzz_validate_and_gpu_1 fails on seed 540 (res[833] 0x7 vs CPU 0x6). The AMD run does not set XCL_REQUIRE_GPU.

Not tested

  • a release build, a game (test run only).

AI use

  • Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.
<!-- greyfinch-sync:ivall/xcl:comment:7149167951 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2004#issuecomment-7149167951). Originally posted by [futurepro62](https://github.com/futurepro62) on 2026-11-25T01:03:50Z. --- Full-suite run, since this PR has no test report yet. Tested exact head `462a456` (on its base `6567c5f`). **Tested** - NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 621.40, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.100.0 MSVC, DXC + dxil.dll 1.9.2602.17 (Windows SDK 10.0.26100), debug, D3D12 debug layer installed. - `cargo build --workspace`, then `XCL_REQUIRE_GPU=mesh cargo test --workspace -- --test-threads=4 --skip heap_window_out_of_memory_falls_back_to_the_switch_form --skip gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::integer_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::f64_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::const_and_null_mask_operands_agree_with_hlsl_on_the_gpu --skip gpu::dxil::fuzz_tests`: **999 passed, 0 failed, 43 ignored**. SKIPPED (no wave64): `a_2d_or_3d_group_agrees_with_the_hlsl_path_on_the_gpu`, `a_per_lane_2d_or_3d_group_runs_on_the_gpu`, `coalesced_guarded_runs_agree_with_the_hlsl_path_on_the_gpu`, `cross_lane_reads_agree_with_the_hlsl_path_on_the_gpu`, `gpu_geometry_wave32_prefix_count_over_a_mask`, `gpu_wave32_program_in_wave64_hardware`, `the_wave64_lowering_agrees_with_the_hlsl_path_on_the_gpu`. - The new tests ran and passed: `monitorx_and_mwaitx_patch_to_nop_and_pause_safely`, `xapu_reuses_stream_scratch_and_supports_concurrent_streams`, `parallel_decode_supports_physical_page_destinations_and_late_refresh`, `rumble_skips_disconnected_pad_and_deduplicates_unchanged_speeds`, `next_and_previous_reading_walk_state_changes_and_terminate`, `extended_scripted_actions_drive_triggers_sticks_and_durations`, `mouse_buttons_require_capture_and_not_sizing`, `high_frequency_zero_polls_do_not_prematurely_decay_velocity`, `xmem_tools_mem_and_40bit_virtual_alloc`, `physical_page_reads_skip_commit_writes_ensure_lazy_and_free_unmarks`, `partial_free_tracks_exact_liveness_decommits_homes_and_ignores_double_free`, `sharded_lazy_batch_spans_stripes_and_unmarks_cleanly`, `mft_decoder_reuses_cached_samples_across_packets`. - Same head on the AMD Radeon integrated GPU (iGPU) of the Ryzen 7 9800X3D (RDNA2, `XCL_ADAPTER=radeon`), `cargo test --workspace -- --test-threads=4 --skip gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1`: **1009 passed, 0 failed, 45 ignored**. SKIPPED: `f16_programs_on_the_gpu` (f16 arithmetic, wave32, per-lane form: refused (unsupported V_MUL_F16 (its #1426 semantics differ from the console's))), `f16_programs_on_the_gpu` (f16 arithmetic, wave64, per-lane form: refused (unsupported V_MUL_F16 (its #1426 semantics differ from the console's))), `f16_programs_on_the_gpu` (f16 packed, wave32, per-lane form: refused (unsupported V_PK_MUL_F16: VOP3 modifiers (its #1426 semantics differ from the console's))), `f16_programs_on_the_gpu` (f16 packed, wave64, per-lane form: refused (unsupported V_PK_MUL_F16: VOP3 modifiers (its #1426 semantics differ from the console's))), `f32_programs_on_the_gpu` (f32 conversions, wave32, per-lane form: refused (unsupported V_CVT_F16_F32 (its #1426 semantics differ from the console's))), `f32_programs_on_the_gpu` (f32 conversions, wave64, per-lane form: refused (unsupported V_CVT_F16_F32 (its #1426 semantics differ from the console's))), `heap_window_out_of_memory_falls_back_to_the_switch_form` (no heap windows). - `--skip` leaves out tests that fail on main `7994cd1` too, not because of this PR. On NVIDIA: `heap_window_out_of_memory_falls_back_to_the_switch_form` (#1651), the four `gpu::recomp::lower_dxil::tests::*_programs_on_the_gpu` tests and `const_and_null_mask_operands_agree_with_hlsl_on_the_gpu` ([follow-up on #1651](https://github.com/xcl-dev/xcl/issues/1651#issuecomment-7146069648)) fail because `runner::skip_test` turns their skips into failures under `XCL_REQUIRE_GPU=mesh`, and `gpu::dxil::fuzz_tests` seeds 70, 545, 1019 and 1507 fail `CreateComputePipelineState` with `E_OUTOFMEMORY` on this card (drivers 616.64 and 621.40). On AMD: `fuzz_validate_and_gpu_1` fails on seed 540 (`res[833]` 0x7 vs CPU 0x6). The AMD run does not set `XCL_REQUIRE_GPU`. **Not tested** - a release build, a game (test run only). **AI use** - Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.
Anon64 commented 2026-11-25 02:08:57 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Anon64 on 2026-11-25T01:47:29Z.


Regression run for this PR: head 462a456, based on main 80f4819. RTX 3060 12 GB (581.80, wave32), Windows 11 26200, release, XCL_NETWORK=0, A pressed every 4 s from 20 s, scripts/smoke.ps1 on a retail title for 60 s, in one batch with the main run.

main 80f4819:

xcl-smoke v1
commit: 80f4819098e921f2e1ab371144d4832f68ffedd6
gpu: NVIDIA GeForce RTX 3060
title: 21222967
seconds: 60
exit: 0x0
frames shown: 1588 (PresentX 1589)
presents per 2 s (last 3): 47 56 27
device removals: 0
crashes: 0
peak commit: 25184 MB

this PR:

xcl-smoke v1
commit: 462a4561b65ae153bf515c8378ceb3e091638df2
gpu: NVIDIA GeForce RTX 3060
title: 21222967
seconds: 60
exit: 0x0
frames shown: 1557 (PresentX 1558)
presents per 2 s (last 3): 57 26 18
device removals: 0
crashes: 0
peak commit: 26606 MB

No device removals or crashes; 98 % of main's frames, 105 % of its peak commit.

Not tested: the whole suite; world loading; whether the title reaches all of the changed code in these 60 s (default settings: XCL_DIRECT_DXIL and XCL_HEAP_WINDOWS unset).

Written with Claude Code (Claude Opus 5.5) from runs on this machine.

<!-- greyfinch-sync:ivall/xcl:comment:7149960168 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2004#issuecomment-7149960168). Originally posted by [Anon64](https://github.com/Anon64) on 2026-11-25T01:47:29Z. --- Regression run for this PR: head `462a456`, based on `main` `80f4819`. RTX 3060 12 GB (581.80, wave32), Windows 11 26200, release, `XCL_NETWORK=0`, A pressed every 4 s from 20 s, `scripts/smoke.ps1` on a retail title for 60 s, in one batch with the `main` run. main `80f4819`: ``` xcl-smoke v1 commit: 80f4819098e921f2e1ab371144d4832f68ffedd6 gpu: NVIDIA GeForce RTX 3060 title: 21222967 seconds: 60 exit: 0x0 frames shown: 1588 (PresentX 1589) presents per 2 s (last 3): 47 56 27 device removals: 0 crashes: 0 peak commit: 25184 MB ``` this PR: ``` xcl-smoke v1 commit: 462a4561b65ae153bf515c8378ceb3e091638df2 gpu: NVIDIA GeForce RTX 3060 title: 21222967 seconds: 60 exit: 0x0 frames shown: 1557 (PresentX 1558) presents per 2 s (last 3): 57 26 18 device removals: 0 crashes: 0 peak commit: 26606 MB ``` No device removals or crashes; 98 % of main's frames, 105 % of its peak commit. **Not tested:** the whole suite; world loading; whether the title reaches all of the changed code in these 60 s (default settings: `XCL_DIRECT_DXIL` and `XCL_HEAP_WINDOWS` unset). Written with Claude Code (Claude Opus 5.5) from runs on this machine.
raylitebull commented 2026-11-25 02:09:02 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by raylitebull on 2026-11-25T01:54:23Z.


Rebased and trimmed #2004 cleanly onto d63071a (4d7d3bb + c57227f):

  • Dropped #563 duplicate: removed our duplicate XMemIsToolsMemAvailable() definition from crates/xcl/src/hle/kernelx.rs (using #563's implementation on main).
  • Integrated #509 (#476): updated dstorage.rs::refresh_stale_pages to use read_own (ReadProcessMemory) so unmapped page arrays never fault while still refreshing stale/freed page entries.
  • Preserved #552 & #471: cleanly kept the PlayStation HID fallback in gameinput.rs and Channel::connect clear in acphal.rs.

Pushed c57227f for GitHub Actions Build and test and fresh verification.

<!-- greyfinch-sync:ivall/xcl:comment:7150096218 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2004#issuecomment-7150096218). Originally posted by [raylitebull](https://github.com/raylitebull) on 2026-11-25T01:54:23Z. --- Rebased and trimmed `#2004` cleanly onto `d63071a` (`4d7d3bb` + `c57227f`): - **Dropped `#563` duplicate:** removed our duplicate `XMemIsToolsMemAvailable()` definition from `crates/xcl/src/hle/kernelx.rs` (using `#563`'s implementation on `main`). - **Integrated `#509` (`#476`):** updated `dstorage.rs::refresh_stale_pages` to use `read_own` (`ReadProcessMemory`) so unmapped page arrays never fault while still refreshing stale/freed page entries. - **Preserved `#552` & `#471`:** cleanly kept the PlayStation HID fallback in `gameinput.rs` and `Channel::connect` clear in `acphal.rs`. Pushed `c57227f` for GitHub Actions `Build and test` and fresh verification.
Toons29 commented 2026-11-25 04:10:37 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Toons29 on 2026-11-25T03:42:02Z.


Regression run of 6bdf9b99 on the retail title, for this PR's Regression run section. Both blocks are from scripts/smoke.ps1 as printed, not edited: main on 568e7db7, this PR on its head commit with no uncommitted changes, same title and time.

xcl-smoke v1
commit: 568e7db7729c8fa6c8f0f4b32d798faaf11462bb
gpu: AMD Radeon RX 9070
title: 34df7c50
seconds: 60
exit: 0x0
frames shown: 1566 (PresentX 1566)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14592 MB
xcl-smoke v1
commit: 6bdf9b9981331956dd61b6b48a817cf621d78ee4
gpu: AMD Radeon RX 9070
title: 34df7c50
seconds: 60
exit: 0x0
frames shown: 1633 (PresentX 1633)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14598 MB

Against the limits in CONTRIBUTING.md: 104 % of main's frames, 100 % of its peak commit, no crash, no device removal.

AMD Radeon RX 9070 (RDNA4, driver 32.0.32029.2010), Ryzen 7 7800X3D, 32 GB, Windows 11 build 26300, Rust 1.100.0, cargo build --release -p xcl, 60 s, XCL_NETWORK=0. This is a regression check only: it does not show whether the run reaches the code this PR changes.

AI use: Claude Code (Claude Opus 5.5) built both trees and ran scripts/smoke.ps1; both blocks are exactly as printed, and I approved posting this.

<!-- greyfinch-sync:ivall/xcl:comment:7152161205 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2004#issuecomment-7152161205). Originally posted by [Toons29](https://github.com/Toons29) on 2026-11-25T03:42:02Z. --- Regression run of `6bdf9b99` on the retail title, for this PR's **Regression run** section. Both blocks are from `scripts/smoke.ps1` as printed, not edited: `main` on `568e7db7`, this PR on its head commit with no uncommitted changes, same title and time. ``` xcl-smoke v1 commit: 568e7db7729c8fa6c8f0f4b32d798faaf11462bb gpu: AMD Radeon RX 9070 title: 34df7c50 seconds: 60 exit: 0x0 frames shown: 1566 (PresentX 1566) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14592 MB ``` ``` xcl-smoke v1 commit: 6bdf9b9981331956dd61b6b48a817cf621d78ee4 gpu: AMD Radeon RX 9070 title: 34df7c50 seconds: 60 exit: 0x0 frames shown: 1633 (PresentX 1633) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14598 MB ``` Against the limits in CONTRIBUTING.md: 104 % of `main`'s frames, 100 % of its peak commit, no crash, no device removal. AMD Radeon RX 9070 (RDNA4, driver 32.0.32029.2010), Ryzen 7 7800X3D, 32 GB, Windows 11 build 26300, Rust 1.100.0, `cargo build --release -p xcl`, 60 s, `XCL_NETWORK=0`. This is a regression check only: it does not show whether the run reaches the code this PR changes. AI use: Claude Code (Claude Opus 5.5) built both trees and ran `scripts/smoke.ps1`; both blocks are exactly as printed, and I approved posting this.
DavidM1911 commented 2026-11-25 04:10:41 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-25T03:51:32Z.


Verification on RTX 3060 Ti (Windows 11): merge conflict with current main — needs a rebase before it can be tested.

<!-- greyfinch-sync:ivall/xcl:comment:7152306179 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2004#issuecomment-7152306179). Originally posted by [DavidM1911](https://github.com/DavidM1911) on 2026-11-25T03:51:32Z. --- Verification on RTX 3060 Ti (Windows 11): **merge conflict with current `main`** — needs a rebase before it can be tested.
raylitebull commented 2026-11-25 11:09:37 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by raylitebull on 2026-11-25T10:57:52Z.


Rebased #2004 cleanly onto 5478c4a7 (52e01595 + 6bdf9b99), integrating #2157 (3e1eab29, keeping alloc_physical_home sparse-layout coherent UMA skip and wiring alloc_below_40bit into its plain MEM_RESERVE fallback).

Verified locally (cargo check --workspace --tests + 126 passed, 0 failed, 1 ignored across kernelx, dstorage, gameinput, kbm, acphal, opus, and eh tests, including both #2157 tests) and pushed 6bdf9b99 — ready for re-testing (ping @DavidM1911)!

<!-- greyfinch-sync:ivall/xcl:comment:7160406109 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2004#issuecomment-7160406109). Originally posted by [raylitebull](https://github.com/raylitebull) on 2026-11-25T10:57:52Z. --- Rebased `#2004` cleanly onto `5478c4a7` (`52e01595` + `6bdf9b99`), integrating `#2157` (`3e1eab29`, keeping `alloc_physical_home` sparse-layout coherent UMA skip and wiring `alloc_below_40bit` into its plain `MEM_RESERVE` fallback). Verified locally (`cargo check --workspace --tests` + `126 passed, 0 failed, 1 ignored` across `kernelx`, `dstorage`, `gameinput`, `kbm`, `acphal`, `opus`, and `eh` tests, including both `#2157` tests) and pushed `6bdf9b99` — ready for re-testing (ping `@DavidM1911`)!
raylitebull commented 2026-11-25 19:09:00 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by raylitebull on 2026-11-25T18:16:47Z.


Rebased #2004 cleanly onto 73e3aba6 (9b81c214 + 57560bf5), integrating #1405 (bb27ed6d execution-time DirectStorage physical page-list resolution):

  • Unified #1405's execution-time physical page-list resolution (!dest_on_stack + read_own + kernelx::physical_pages_live + zero-entry reread) inside dstorage.rs::write_dest_physical_pages so sequential execute() and dstorage/parallel.rs (InFlightTask::dest_on_stack) share identical #1405/#476 semantics.
  • Preserved both kernelx::physical_pages_live and kernelx::is_live_physical_page backed by PhysBlock's exact per-page bitmap, and updated parallel_decode_supports_physical_page_destinations_and_late_refresh to use a heap-allocated vec![stale_page[0]] matching #1405.
  • Verified locally (cargo check --workspace --tests + 128 passed, 0 failed, 1 ignored across kernelx, dstorage, gameinput, kbm, acphal, opus, and eh tests, including #1405, #495, #2157, #509, #563, #2048) and pushed 57560bf5.
<!-- greyfinch-sync:ivall/xcl:comment:7170690589 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2004#issuecomment-7170690589). Originally posted by [raylitebull](https://github.com/raylitebull) on 2026-11-25T18:16:47Z. --- Rebased `#2004` cleanly onto `73e3aba6` (`9b81c214` + `57560bf5`), integrating `#1405` (`bb27ed6d` execution-time DirectStorage physical page-list resolution): - Unified `#1405`'s execution-time physical page-list resolution (`!dest_on_stack` + `read_own` + `kernelx::physical_pages_live` + zero-entry reread) inside `dstorage.rs::write_dest_physical_pages` so sequential `execute()` and `dstorage/parallel.rs` (`InFlightTask::dest_on_stack`) share identical `#1405`/`#476` semantics. - Preserved both `kernelx::physical_pages_live` and `kernelx::is_live_physical_page` backed by `PhysBlock`'s exact per-page bitmap, and updated `parallel_decode_supports_physical_page_destinations_and_late_refresh` to use a heap-allocated `vec![stale_page[0]]` matching `#1405`. - Verified locally (`cargo check --workspace --tests` + `128 passed, 0 failed, 1 ignored` across `kernelx`, `dstorage`, `gameinput`, `kbm`, `acphal`, `opus`, and `eh` tests, including `#1405`, `#495`, `#2157`, `#509`, `#563`, `#2048`) and pushed `57560bf5`.
DavidM1911 commented 2026-11-26 01:05:43 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-26T00:49:42Z.


Re-verification on RTX 3060 Ti (Windows 11), new head merged with current main:

  • cargo test -p xcl --lib: all passed, 0 failed, 27 ignored. The earlier merge conflict is resolved.

Thanks!

— Devin

<!-- greyfinch-sync:ivall/xcl:comment:7179153439 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2004#issuecomment-7179153439). Originally posted by [DavidM1911](https://github.com/DavidM1911) on 2026-11-26T00:49:42Z. --- Re-verification on RTX 3060 Ti (Windows 11), new head merged with current `main`: - `cargo test -p xcl --lib`: all passed, 0 failed, 27 ignored. The earlier merge conflict is resolved. Thanks! — Devin
Prime1997 commented 2026-11-28 09:34:02 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Prime1997 on 2026-11-28T09:34:02Z.


The physical-page release portion of this PR is adapted on our NVIDIA integration branch in 6198b180, with release-notification ordering in ba3036af. Credit to @raylitebull for the partial-home reclamation work, alongside @Babyhamsta's per-page liveness repair and @b3IKK's lazy-mark cleanup.

The adaptation frees only released page homes, rejects stale page IDs and repeated-free sibling retirement, and keeps the mapping lock through decommit. A home or empty reservation occupied by another live page remains held until that occupant leaves. The whole-block notification still runs before its bytes disappear. It preserves NVIDIA's current sparse/source-release paths; the unrelated DirectStorage, audio, input and exception-handler changes from this PR are not imported.

These links are for review and reuse through the existing owner PRs, not a replacement omnibus PR.

Compilation: cargo build --locked --release -p xcl --target-dir <isolated-target> completed on integrated commit 04722e9a71d22e2e23cbbeb859161246023adea4 (exit 0, 229.969 seconds, 8 compiler warnings). This is compilation evidence only.

Interactive follow-up on the combined NVIDIA candidate

An RTX 3060 Ti (8 GiB) run of the same clean integration head 04722e9a71d22e2e23cbbeb859161246023adea4 ended after 3,266 seconds with D3D12 device removal 0x887A0005; 1,060 read-only monitor samples were recorded. Peak logged process commitment was 25,311 MiB and local DXGI usage 9,218 MiB, with a maximum 2,002 MiB overrun of its contemporaneous budget. Immediately before removal, a two-second interval recorded 1,703 draws and 7,023 dispatches with no new presents. DRED state was UNKNOWN and breadcrumbs were unavailable. Budget pressure coincided with failure; the exact GPU fault and causal contribution of any individual patch are not established.

The physical-alias counter reported 1,006 MiB of duplicate address backing avoided; this is allocator accounting, not an isolated measured DXGI reduction. At least 2,048 earlier-run driver blobs were successfully reused. Three matched cached creations took 135–147 ms versus 16,672–31,259 ms previously uncached. These narrow observations do not make the combined candidate gameplay-validated. No unit/GPU test batch or matched main/head smoke comparison was run for this revision, and this report is not an approval to merge the integration or evidence that this individual PR caused the failure.

AI use: Codex (GPT-6), adaptation and source review.

An optional temporary Discord is available to coordinate contributor work, help test and compare results.

<!-- greyfinch-sync:ivall/xcl:comment:7237322969 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2004#issuecomment-7237322969). Originally posted by [Prime1997](https://github.com/Prime1997) on 2026-11-28T09:34:02Z. --- The physical-page release portion of this PR is adapted on our [NVIDIA integration branch](https://github.com/Prime1997/xcl/tree/codex/memory-owners-release-20261128) in [6198b180](https://github.com/Prime1997/xcl/commit/6198b1801b92c2d4ca98d4a64502eb5abbcefa66), with release-notification ordering in [ba3036af](https://github.com/Prime1997/xcl/commit/ba3036af0bfbb910a327a4c6064d917f28227cae). Credit to @raylitebull for the partial-home reclamation work, alongside @Babyhamsta's [per-page liveness repair](https://github.com/xcl-dev/xcl/pull/608) and @b3IKK's [lazy-mark cleanup](https://github.com/xcl-dev/xcl/pull/1221). The adaptation frees only released page homes, rejects stale page IDs and repeated-free sibling retirement, and keeps the mapping lock through decommit. A home or empty reservation occupied by another live page remains held until that occupant leaves. The whole-block notification still runs before its bytes disappear. It preserves NVIDIA's current sparse/source-release paths; the unrelated DirectStorage, audio, input and exception-handler changes from this PR are not imported. These links are for review and reuse through the existing owner PRs, not a replacement omnibus PR. Compilation: `cargo build --locked --release -p xcl --target-dir <isolated-target>` completed on integrated commit `04722e9a71d22e2e23cbbeb859161246023adea4` (exit 0, 229.969 seconds, 8 compiler warnings). This is compilation evidence only. **Interactive follow-up on the combined NVIDIA candidate** An RTX 3060 Ti (8 GiB) run of the same clean integration head `04722e9a71d22e2e23cbbeb859161246023adea4` ended after 3,266 seconds with D3D12 device removal `0x887A0005`; 1,060 read-only monitor samples were recorded. Peak logged process commitment was 25,311 MiB and local DXGI usage 9,218 MiB, with a maximum 2,002 MiB overrun of its contemporaneous budget. Immediately before removal, a two-second interval recorded 1,703 draws and 7,023 dispatches with no new presents. DRED state was UNKNOWN and breadcrumbs were unavailable. Budget pressure coincided with failure; the exact GPU fault and causal contribution of any individual patch are not established. The physical-alias counter reported 1,006 MiB of duplicate address backing avoided; this is allocator accounting, not an isolated measured DXGI reduction. At least 2,048 earlier-run driver blobs were successfully reused. Three matched cached creations took 135–147 ms versus 16,672–31,259 ms previously uncached. These narrow observations do not make the combined candidate gameplay-validated. No unit/GPU test batch or matched main/head smoke comparison was run for this revision, and this report is not an approval to merge the integration or evidence that this individual PR caused the failure. AI use: Codex (GPT-6), adaptation and source review. An [optional temporary Discord](https://discord.gg/gK3y7WRRY) is available to coordinate contributor work, help test and compare results.
Foniass commented 2026-12-01 06:26:09 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T06:26:09Z.


Review (head 57560bf5, diff read, not a merge-check; it conflicts with main and CI / PR description are red, so not built or run):

About 1,670 lines across ten unrelated areas with no reason given for not splitting. Some parts are on main in another form (Monitorx/Mwaitx patching d634138c, GetNext/GetPreviousReading f9e6ac5f, and the hard-coded KBM keys replaced by per-title input profiles b8005022); several useful parts aren't.

  • It fixes a real bug on main: main's physical-page free loop (kernelx.rs ~2409-2431) decrements the block's live count once per page in the array with no per-page record, so freeing the same page twice can release a block whose other pages are still in use. The per-page bitmap here prevents that.
  • read_src_physical_pages (dstorage.rs ~955) rereads the source page list from r.source without the on-stack check the destination path has (dest_on_stack), so a list that was on the enqueuing thread's stack can be reread as reused stack bytes.
  • lazy::unmark_batch (kernelx.rs ~1458) runs after the AWAY lock is released; a concurrent MapTitlePhysicalPages at the same address can mark a new lazy page that then gets unmarked and is never committed.
  • gameinput.rs ~497 changes DEVICE_ID padding from spaces to NULs, which changes the id the title sees and isn't in the description.
  • kernelx.rs ~731 sends plain XMemVirtualAlloc reserves to VirtualAlloc2, skipping the kernelx VirtualAlloc hook (placeholders, GPU-view reservations); no title needing 40-bit addresses is cited. The description also claims large physical-page pools stop taking pre-committed coherent UMA, which isn't in the diff. A narrow window in lazy.rs ~70 can pass on the very first lazy commit fault.
  • AI use names no model.

Fine: reads of physical pages no longer commit untouched pages, and the parallel DirectStorage path for physical pages / BCPack and the XApu per-stream locks look reasonable. Recommendation: close and re-split against current main, one PR each: (a) per-page bitmap / double-free fix with a test; (b) partial-free decommit through main's source_going / mirrors::page_freed; (c) reads that don't commit; (d) DirectStorage parallel physical-page and BCPack requests; (e) source-page reread with the on-stack rule; (f) XApu locks and buffers; (g) Opus sample reuse; (h) rumble skip and dedup; (i) XCL_PRESS_AT extensions; (j) mouse decay on main's input profiles. Lazy sharding and 40-bit placement only with measurements and a named title.

AI review: Claude Code (Claude Opus 5.5), posted by Foniass without a human check of each point.

<!-- greyfinch-sync:ivall/xcl:comment:7302868380 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2004#issuecomment-7302868380). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-01T06:26:09Z. --- Review (head 57560bf5, diff read, not a merge-check; it conflicts with main and CI / `PR description` are red, so not built or run): About 1,670 lines across ten unrelated areas with no reason given for not splitting. Some parts are on main in another form (Monitorx/Mwaitx patching d634138c, GetNext/GetPreviousReading f9e6ac5f, and the hard-coded KBM keys replaced by per-title input profiles b8005022); several useful parts aren't. - **It fixes a real bug on main:** main's physical-page free loop (`kernelx.rs` ~2409-2431) decrements the block's live count once per page in the array with no per-page record, so freeing the same page twice can release a block whose other pages are still in use. The per-page bitmap here prevents that. - `read_src_physical_pages` (`dstorage.rs` ~955) rereads the source page list from `r.source` without the on-stack check the destination path has (`dest_on_stack`), so a list that was on the enqueuing thread's stack can be reread as reused stack bytes. - `lazy::unmark_batch` (`kernelx.rs` ~1458) runs after the `AWAY` lock is released; a concurrent MapTitlePhysicalPages at the same address can mark a new lazy page that then gets unmarked and is never committed. - `gameinput.rs` ~497 changes `DEVICE_ID` padding from spaces to NULs, which changes the id the title sees and isn't in the description. - `kernelx.rs` ~731 sends plain `XMemVirtualAlloc` reserves to `VirtualAlloc2`, skipping the kernelx VirtualAlloc hook (placeholders, GPU-view reservations); no title needing 40-bit addresses is cited. The description also claims large physical-page pools stop taking pre-committed coherent UMA, which isn't in the diff. A narrow window in `lazy.rs` ~70 can pass on the very first lazy commit fault. - AI use names no model. Fine: reads of physical pages no longer commit untouched pages, and the parallel DirectStorage path for physical pages / BCPack and the XApu per-stream locks look reasonable. Recommendation: close and re-split against current main, one PR each: (a) per-page bitmap / double-free fix with a test; (b) partial-free decommit through main's `source_going` / `mirrors::page_freed`; (c) reads that don't commit; (d) DirectStorage parallel physical-page and BCPack requests; (e) source-page reread with the on-stack rule; (f) XApu locks and buffers; (g) Opus sample reuse; (h) rumble skip and dedup; (i) `XCL_PRESS_AT` extensions; (j) mouse decay on main's input profiles. Lazy sharding and 40-bit placement only with measurements and a named title. AI review: Claude Code (Claude Opus 5.5), posted by Foniass without a human check of each point.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/2004:upstream-pr/2004'
git switch 'upstream-pr/2004'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/2004'
git switch 'upstream-pr/2004'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/2004'
git switch 'upstream-pr/2004'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/2004'
git switch 'main'
git merge --squash 'upstream-pr/2004'
git switch 'main'
git merge --ff-only 'upstream-pr/2004'
git switch 'main'
git merge 'upstream-pr/2004'
git push origin 'main'
Sign in to join this conversation.
No reviewers
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
xcl-dev/xcl!1994
No description provided.