Shader emitter refactor, GPU memory fixes, Sony pads over raw HID; integrates #50 (rebased + cap fix) and #51 #59

Closed
github-bot wants to merge 65 commits from gh-pr/59/head into gh-pr/59/base
Owner

@⁠hatefulpineapple on GitHub · 2026-11-29 21:26 UTC · original
hatefulpineapple:integrate/memory-prs → main · +22381 −19669 · 68 files · 65 commits · closed without merging

Supersedes #54. This branch is the project's working main merged with current origin/main and the two community memory PRs, gated on Windows.

What is inside

Shader emitter refactor (phases 1–2). emit/lower.rs 14,265 → 1,665 lines: method clusters and free functions moved verbatim into emit/lower/ (26 files). Phase 2: emit/mod.rs 3,380 → 204, resource.rs 4,151 → 474, tests split into emit/tests/ and resource/tests/. Visibility rules and a verbatim-move proof script are documented in docs/refactor-victory-shader.md. Gates: macOS cargo test -p victory-shader 205/0/2, Windows 290/0/4, clippy clean on the moved code.

GPU memory fixes. Pool: best-fit placement (tightest hole, exact fit first, lowest address on tie) so holes join into whole blocks the reclaim tick returns; resting pieces accounted separately and no longer credited as room. Promotion gate L0→VRAM: used < room_line(budget) instead of a line a tenth of the budget below it, which steady play never reached; overshoot still bounded (headroom, VICTORY_ROOM_REAL, 64 MB/look, idle + sole-ref). Measured problem: 1.1–1.9 GB free inside blocks while 24,000 textures (2.4 GB) spilled to PC memory (RTX 4070 SUPER).

Sony pads over raw HID. DS4 / DualSense / DualSense Edge read directly (VID 054C), USB + Bluetooth: report layouts, CRC and rumble per the kernel's hid-playstation driver. Touchpad click reads as View. VICTORY_HID_PADS=0: XInput only. Keep-awake: the title-window thread holds ES_SYSTEM_REQUIRED | ES_DISPLAY_REQUIRED while alive (VICTORY_KEEP_AWAKE=0 restores the old behavior).

#50 integrated (rebased + one fix). VICTORY_HEADROOM_SPARES=1 caps speculative empty texture heaps under DXGI-headroom pressure (hysteresis 2560/3072 MiB). The rebase onto current main is mechanical. Follow-up fix: the cap was only enforced on the once-a-second room() tick — the allocation path take_ripe → rested() still read the uncapped global SPARES, so a burst could hold up to 64 empty blocks between ticks. The texture pool now has its own spares atomic (TEXTURES_SPARES, Pool::new_with_spares); staging and PC pools keep SPARES. Regression test included. Credit: @⁠Tristan1019-user.

#51 integrated as-is (opt-in). VICTORY_INPLACE_VIEWS=1: windows over the page pool remapped through the runtime's own views (OwnViews) and opened by address — no copies, no driver pinning of copies; churn cap VICTORY_INPLACE_VIEWS_CHURN; soft writes through the section (SoftViews::write); descriptor remake for let-go copies; plus always-on fixes: the IN_PLACE_PAGES index (was 1.5–3.4 s/frame of remap scanning), window creation outside the LOOSE lock, a GetWriteWatch refusal cache, and a try-lock queue for title_memory_made_real (fixes a 76 s deadlock). Credit: @⁠kc01-8.

Known accepted risk (opt-in only): the shared zero section is PAGE_READWRITE and window buffers are UAV-capable, so a UAV store to a title-unmapped page would write the shared zeros of every window, silently. The fault-retry path was verified safe (xmem::materialize_for maps the section itself before the deferred guard bookkeeping). Runtime A/B on Windows native is pending; the Proton measurements are the author's.

Merge with current main. The block-size/PACK experiments (d871a99), the aliasing-barrier change (cdacce2), texture_in_holes (97f379e) and the launcher settings (aba2e9c) are merged in. The pool.rs conflict keeps best-fit inside Ranges::place with take going through it (free-byte accounting preserved); texture_room() = texture_block() − held − resting.

Verification

  • macOS standalone allocator harness: 12/12 (pool logic, headroom hysteresis, cap regression, room() glue).
  • Windows: cargo test -p victory-gpu 464/0/37, cargo test -p victory-hle 180/0/2; clippy 56 warnings — all pre-existing across gpu+hle, none in the changed code; release victory.exe built and delivered.
  • Runtime A/B plan (one save, ~20 min per mode): baseline / VICTORY_INPLACE=1 / VICTORY_INPLACE=1 VICTORY_INPLACE_VIEWS=1 VICTORY_SOFT_VIEWS=1; for #50: VICTORY_HEADROOM_SPARES=1, watching the texture-blocks line and HOLES_USED. Results will be recorded in docs/bug-journal.md.
**@⁠hatefulpineapple** on GitHub · 2026-11-29 21:26 UTC · [original](https://github.com/readmet3xt-lab/foxhound/pull/59) `hatefulpineapple:integrate/memory-prs` → `main` · +22381 −19669 · 68 files · 65 commits · closed without merging Supersedes #54. This branch is the project's working main merged with current `origin/main` and the two community memory PRs, gated on Windows. ## What is inside **Shader emitter refactor (phases 1–2).** `emit/lower.rs` 14,265 → 1,665 lines: method clusters and free functions moved verbatim into `emit/lower/` (26 files). Phase 2: `emit/mod.rs` 3,380 → 204, `resource.rs` 4,151 → 474, tests split into `emit/tests/` and `resource/tests/`. Visibility rules and a verbatim-move proof script are documented in `docs/refactor-victory-shader.md`. Gates: macOS `cargo test -p victory-shader` 205/0/2, Windows 290/0/4, clippy clean on the moved code. **GPU memory fixes.** Pool: best-fit placement (tightest hole, exact fit first, lowest address on tie) so holes join into whole blocks the reclaim tick returns; resting pieces accounted separately and no longer credited as room. Promotion gate L0→VRAM: `used < room_line(budget)` instead of a line a tenth of the budget below it, which steady play never reached; overshoot still bounded (headroom, `VICTORY_ROOM_REAL`, 64 MB/look, idle + sole-ref). Measured problem: 1.1–1.9 GB free inside blocks while 24,000 textures (2.4 GB) spilled to PC memory (RTX 4070 SUPER). **Sony pads over raw HID.** DS4 / DualSense / DualSense Edge read directly (VID 054C), USB + Bluetooth: report layouts, CRC and rumble per the kernel's `hid-playstation` driver. Touchpad click reads as View. `VICTORY_HID_PADS=0`: XInput only. Keep-awake: the title-window thread holds `ES_SYSTEM_REQUIRED | ES_DISPLAY_REQUIRED` while alive (`VICTORY_KEEP_AWAKE=0` restores the old behavior). **#50 integrated (rebased + one fix).** `VICTORY_HEADROOM_SPARES=1` caps speculative empty texture heaps under DXGI-headroom pressure (hysteresis 2560/3072 MiB). The rebase onto current main is mechanical. Follow-up fix: the cap was only enforced on the once-a-second `room()` tick — the allocation path `take_ripe → rested()` still read the uncapped global `SPARES`, so a burst could hold up to 64 empty blocks between ticks. The texture pool now has its own spares atomic (`TEXTURES_SPARES`, `Pool::new_with_spares`); staging and PC pools keep `SPARES`. Regression test included. Credit: @⁠Tristan1019-user. **#51 integrated as-is (opt-in).** `VICTORY_INPLACE_VIEWS=1`: windows over the page pool remapped through the runtime's own views (`OwnViews`) and opened by address — no copies, no driver pinning of copies; churn cap `VICTORY_INPLACE_VIEWS_CHURN`; soft writes through the section (`SoftViews::write`); descriptor remake for let-go copies; plus always-on fixes: the `IN_PLACE_PAGES` index (was 1.5–3.4 s/frame of remap scanning), window creation outside the `LOOSE` lock, a `GetWriteWatch` refusal cache, and a try-lock queue for `title_memory_made_real` (fixes a 76 s deadlock). Credit: @⁠kc01-8. Known accepted risk (opt-in only): the shared zero section is `PAGE_READWRITE` and window buffers are UAV-capable, so a UAV store to a title-unmapped page would write the shared zeros of every window, silently. The fault-retry path was verified safe (`xmem::materialize_for` maps the section itself before the deferred guard bookkeeping). Runtime A/B on Windows native is pending; the Proton measurements are the author's. **Merge with current main.** The block-size/PACK experiments (`d871a99`), the aliasing-barrier change (`cdacce2`), `texture_in_holes` (`97f379e`) and the launcher settings (`aba2e9c`) are merged in. The `pool.rs` conflict keeps best-fit inside `Ranges::place` with `take` going through it (free-byte accounting preserved); `texture_room()` = `texture_block()` − held − resting. ## Verification - macOS standalone allocator harness: 12/12 (pool logic, headroom hysteresis, cap regression, `room()` glue). - Windows: `cargo test -p victory-gpu` **464/0/37**, `cargo test -p victory-hle` **180/0/2**; clippy 56 warnings — all pre-existing across gpu+hle, none in the changed code; release `victory.exe` built and delivered. - Runtime A/B plan (one save, ~20 min per mode): baseline / `VICTORY_INPLACE=1` / `VICTORY_INPLACE=1 VICTORY_INPLACE_VIEWS=1 VICTORY_SOFT_VIEWS=1`; for #50: `VICTORY_HEADROOM_SPARES=1`, watching the texture-blocks line and `HOLES_USED`. Results will be recorded in `docs/bug-journal.md`.
- pool: best-fit placement keeps big ranges whole and lets holes join
  into whole blocks the reclaim tick can return; resting pieces are no
  longer counted as room, so the queue stops crediting holes it cannot
  take yet
- back_to_card: gate at the room line, not a tenth of the budget below
  it, which steady play never reached (11.3 GB used of an 11.0 GB
  budget, 24,000 textures stuck in PC memory); the line's own headroom
  and VICTORY_ROOM_REAL still bound what comes back

Measured on RTX 4070 SUPER, 2026-11-28 (docs/findings.md). Pool logic
tests 8/8 and gate tests 2/2 run standalone; Windows-target clippy
clean on the changed code. D3D12 paths need the target machine.
DualShock 4, DualSense and DualSense Edge reach the title without an
external emulator: report layouts, button bits, Bluetooth CRC and
rumble reports follow the kernel's hid-playstation driver. Pads take
the XInput slots left free, one reader thread each; VICTORY_HID_PADS=0
keeps XInput only.

Parser and report tests 10/10 on Windows and standalone on macOS;
release built on the target machine. Gyro, touchpad and adaptive
triggers are not read.
Titles bind their map to View, as the PlayStation layout binds it to
the touchpad; the click was dropped, so the map never opened. Share
keeps View too. The PS home button stays dropped.

Parser tests 11/11 on Windows and standalone; release rebuilt on the
target machine.
A gamepad alone does not reset the Windows idle timer, so a pad-only
session slept mid-game. The title's window thread now holds
ES_SYSTEM_REQUIRED | ES_DISPLAY_REQUIRED for as long as it lives; the
process's end clears it. VICTORY_KEEP_AWAKE=0: as before.
Rebase of PR #50 (Tristan1019-user) onto current main: VICTORY_HEADROOM_SPARES=1,
DXGI headroom hysteresis 2560/3072 MiB, texture spares <=2 and ahead <=1 when tight.
Test hunk re-inserted at its current place; logic unchanged.
PR #50 capped empty texture blocks only on the once-a-second room() tick;
take_ripe -> rested() still read the uncapped global SPARES, so a burst could
hold up to 64 empty blocks between ticks. Give the texture pool its own spares
atomic (TEXTURES_SPARES), written by room() with the cap applied; staging and
PC pools keep SPARES. Regression test: rested() trims to the pool's own cap.
PR #51 (kc01-8) applied onto current main for review and Windows gating.
VICTORY_INPLACE_VIEWS=1: OwnViews remap of the title's section pages, opened
by address; churn cap VICTORY_INPLACE_VIEWS_CHURN; soft writes through the
section; descriptor remake for let-go copies; IN_PLACE_PAGES index; lock-free
window creation; GetWriteWatch refusal cache; made_real try_lock queue.
# Conflicts:
#	crates/victory-gpu/src/pool.rs
# Conflicts:
#	crates/victory-gpu/src/pool.rs
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-30 02:24:01 +00:00
github-bot closed this pull request 2026-11-30 02:24:01 +00:00
Author
Owner

@⁠readmet3xt-lab on GitHub · 2026-11-30 02:14 UTC · original

Taken from this PR with credit, in c399996:

  • Sony pads (DualShock 4, DualSense, DualSense Edge) over raw HID; VICTORY_HID_PADS=0 turns it off.
  • Windows kept awake while the title runs; VICTORY_KEEP_AWAKE=0 turns it off.

One change: the once-a-second look for pads now skips every HID device whose path lacks Sony's vendor id (054c) before opening it, so keyboards, mice and headsets are not opened each second. crc32 is test-only now (clippy).

Not taken:

  • The victory-shader refactor: a verbatim move of about 20,000 lines with no runtime change. It conflicts with shader work in progress here and would make every later port into that crate harder.
  • #50's heap cap and #51's in-place views: reasons given in those PRs.
  • The GPU part of #54 was ported earlier (best-fit holes, the back-to-card gate).

Closing this one and #54. Thanks.

**@⁠readmet3xt-lab** on GitHub · 2026-11-30 02:14 UTC · [original](https://github.com/readmet3xt-lab/foxhound/pull/59#issuecomment-7266824397) Taken from this PR with credit, in c399996: - Sony pads (DualShock 4, DualSense, DualSense Edge) over raw HID; `VICTORY_HID_PADS=0` turns it off. - Windows kept awake while the title runs; `VICTORY_KEEP_AWAKE=0` turns it off. One change: the once-a-second look for pads now skips every HID device whose path lacks Sony's vendor id (`054c`) before opening it, so keyboards, mice and headsets are not opened each second. `crc32` is test-only now (clippy). Not taken: - The `victory-shader` refactor: a verbatim move of about 20,000 lines with no runtime change. It conflicts with shader work in progress here and would make every later port into that crate harder. - #50's heap cap and #51's in-place views: reasons given in those PRs. - The GPU part of #54 was ported earlier (best-fit holes, the back-to-card gate). Closing this one and #54. Thanks.

Pull request closed

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