d3d12: parallelize shadow page sync with guarded 64 KiB digests and surface Stage::Shadow #498

Merged
DrArroway merged 1 commit from upstream-pr/498 into main 2026-11-29 18:28:36 +00:00
DrArroway commented 2026-11-29 17:04:11 +00:00 (Migrated from github.com)

Imported from brcly/TuxBox. Originally posted by DrArroway on 2026-11-29T17:04:11Z.


Summary

  • Surface Stage::Shadow (shadow) in TUXBOX_SUBMIT_PROFILE=1 whenever live shadow imports exist (has_shadow_imports()), making sync_shadow_imports() directly visible in submission profiles (fixes the blind spot reported in #472).
  • Replace per-shadow Mutex locking, per-page VirtualQuery syscalls, and single-threaded 2× DRAM reads (diff_copy_chunks reading both guest and baseline) with:
    • 64 KiB block Digest caching (tuxbox_guarded_digest / guarded_copy_read) so clean blocks do 1× guarded DRAM read and zero VirtualQuery syscalls while preserving untouched GPU writes in shadow_base.
    • A persistent striped worker pool (ShadowSyncPool, 8-block / 512 KiB stripes across 2..=12 threads serialized under SYNC_WORK, keeping an inline fast path at <= 16 blocks).
  • Related to #472.

Verification

  • Wine Rust unit tests (GE-Proton11-14):
    • tuxbox-d3d12 (device::heap::shadow, submit_profile): 8 passed, 0 failed (including new parallel_multi_block_shadow_sync_preserves_gpu_writes_and_skips_clean_blocks and shadow_sync_survives_unaccessible_guest_page).
  • tuxbox.py check on RX 6900 XT (1002:73bf, Mesa RADV, GE-Proton11-14):
    • All CI code checks, builds, Lanes + guest fixtures (126/126 passed; lanes-benchmark: submit_us=112.4 roundtrip_us=160.1 copy64k_us=158.1 frame_us=258.0 frame_p99_us=378.1), all 22/22 D3D12 synthetic regression controls, and shader translator GPU checks passed.
  • tuxbox.py check on AMD Raphael iGPU (1002:164e, Mesa RADV, GE-Proton11-14):
    • All CI code checks, builds, Lanes + guest fixtures (125/125 passed; lanes-benchmark: submit_us=72.8 roundtrip_us=129.0 copy64k_us=95.2 frame_us=289.6 frame_p99_us=516.3), all 22/22 D3D12 synthetic regression controls, and shader translator GPU checks passed.
  • ProjectScarlett live run (RX 6900 XT, default section-backed #464 mode, TUXBOX_SUBMIT_PROFILE=1):
    • Menu: 41 → 104 FPS (shadow = 4.3 ms/batch, scanning 174 MiB at ~40.5 GiB/s).
    • Video: 10 → 18.5 FPS (shadow = 17.4 ms/batch, scanning 742 MiB at ~42.6 GiB/s — saturating physical DDR5 bandwidth).
<!-- greyfinch-sync:brcly/TuxBox:issue:5553024963 --> Imported from [brcly/TuxBox](https://github.com/brcly/TuxBox/pull/498). Originally posted by [DrArroway](https://github.com/DrArroway) on 2026-11-29T17:04:11Z. --- ## Summary - Surface `Stage::Shadow` (`shadow`) in `TUXBOX_SUBMIT_PROFILE=1` whenever live shadow imports exist (`has_shadow_imports()`), making `sync_shadow_imports()` directly visible in submission profiles (fixes the blind spot reported in #472). - Replace per-shadow `Mutex` locking, per-page `VirtualQuery` syscalls, and single-threaded `2×` DRAM reads (`diff_copy_chunks` reading both `guest` and `baseline`) with: - 64 KiB block `Digest` caching (`tuxbox_guarded_digest` / `guarded_copy_read`) so clean blocks do `1×` guarded DRAM read and zero `VirtualQuery` syscalls while preserving untouched GPU writes in `shadow_base`. - A persistent striped worker pool (`ShadowSyncPool`, 8-block / 512 KiB stripes across `2..=12` threads serialized under `SYNC_WORK`, keeping an inline fast path at `<= 16` blocks). - Related to #472. ## Verification - **Wine Rust unit tests (`GE-Proton11-14`):** - `tuxbox-d3d12` (`device::heap::shadow`, `submit_profile`): 8 passed, 0 failed (including new `parallel_multi_block_shadow_sync_preserves_gpu_writes_and_skips_clean_blocks` and `shadow_sync_survives_unaccessible_guest_page`). - **`tuxbox.py check` on RX 6900 XT (`1002:73bf`, Mesa RADV, GE-Proton11-14):** - All CI code checks, builds, Lanes + guest fixtures (**126/126 passed**; `lanes-benchmark`: `submit_us=112.4 roundtrip_us=160.1 copy64k_us=158.1 frame_us=258.0 frame_p99_us=378.1`), all **22/22** D3D12 synthetic regression controls, and shader translator GPU checks passed. - **`tuxbox.py check` on AMD Raphael iGPU (`1002:164e`, Mesa RADV, GE-Proton11-14):** - All CI code checks, builds, Lanes + guest fixtures (**125/125 passed**; `lanes-benchmark`: `submit_us=72.8 roundtrip_us=129.0 copy64k_us=95.2 frame_us=289.6 frame_p99_us=516.3`), all **22/22** D3D12 synthetic regression controls, and shader translator GPU checks passed. - **ProjectScarlett live run (RX 6900 XT, default section-backed `#464` mode, `TUXBOX_SUBMIT_PROFILE=1`):** - Menu: **41 → 104 FPS** (`shadow = 4.3 ms/batch`, scanning 174 MiB at ~40.5 GiB/s). - Video: **10 → 18.5 FPS** (`shadow = 17.4 ms/batch`, scanning 742 MiB at ~42.6 GiB/s — saturating physical DDR5 bandwidth).
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
brcly/TuxBox!498
No description provided.