HLE GameInput: expand per-device reading history to 256 #3103

Open
fuzeofficlal wants to merge 1 commit from upstream-pr/3105 into main
fuzeofficlal commented 2026-11-26 08:12:08 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-26T08:12:08Z.


Summary

  • Increase HISTORY in crates/victory-hle/src/modules/gameinput.rs from 32 to 256 (~2 seconds at the 8 ms POLL interval) so low-FPS titles (2–5 FPS) do not lose intermediate readings before walking history with GetPreviousReading / GetNextReading.
  • Confirmed Slot::history is a heap-allocated VecDeque<Ref>, avoiding fixed-size stack growth.
  • Added unit tests covering >32 consecutive state changes (bidirectional traversal) and HISTORY + 10 changes (FIFO eviction and GAMEINPUT_E_READING_NOT_FOUND past the oldest retained reading).

(Motivated by the low-FPS history-depth fix in fxceless/victory-fork 04512df4; orthogonal to #2230.)

Verification

  • cargo test -p victory-hle --locked -- modules::gameinput::: 12 passed, 0 failed.
  • cargo clippy -p victory-hle --all-targets --locked -- -D warnings: clean.
  • cargo clippy -p victory-hle --all-targets --all-features --locked -- -D warnings: clean.
  • cargo test -p xtask --locked policy::tests::repository_passes_policy: 1 passed, 0 failed.
<!-- greyfinch-sync:Marvisak/VIctory:issue:5506360402 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3105). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-26T08:12:08Z. --- ## Summary - Increase `HISTORY` in `crates/victory-hle/src/modules/gameinput.rs` from `32` to `256` (~2 seconds at the 8 ms `POLL` interval) so low-FPS titles (2–5 FPS) do not lose intermediate readings before walking history with `GetPreviousReading` / `GetNextReading`. - Confirmed `Slot::history` is a heap-allocated `VecDeque<Ref>`, avoiding fixed-size stack growth. - Added unit tests covering >32 consecutive state changes (bidirectional traversal) and `HISTORY + 10` changes (FIFO eviction and `GAMEINPUT_E_READING_NOT_FOUND` past the oldest retained reading). (Motivated by the low-FPS history-depth fix in `fxceless/victory-fork` `04512df4`; orthogonal to #2230.) ## Verification - `cargo test -p victory-hle --locked -- modules::gameinput::`: 12 passed, 0 failed. - `cargo clippy -p victory-hle --all-targets --locked -- -D warnings`: clean. - `cargo clippy -p victory-hle --all-targets --all-features --locked -- -D warnings`: clean. - `cargo test -p xtask --locked policy::tests::repository_passes_policy`: 1 passed, 0 failed.
Marvisak commented 2026-11-26 09:06:08 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-26T08:24:45Z.


Automated triage for the maintainers.

Needs work: evidence for the new depth. Raising HISTORY from 32 to 256 in crates/victory-hle/src/modules/gameinput.rs changes what GetPreviousReading, GetNextReading and GetTemporalReading return. A reference older than 32 changes ago now resolves instead of failing with REFERENCE_TOO_OLD or not-found. That is emulation behaviour, and the PR gives no evidence for 256:

  • whether the title walks reading history at all, and how far back (the title's own code calling these functions);
  • or how deep the real runtime's history is (public GameInput documentation).

Readings are only kept when the state changes (Hub::update). So 32 entries already covers 32 distinct changes between two frames, not 32 polls, and the "2 seconds at 8 ms" sizing in the comment does not hold.

The new tests cover the traversal and eviction logic well. If evidence shows the title needs more depth, the same tests can back a value that matches it. One cost to keep in mind: relative with no device scans every slot's history under the hub lock, so the depth also costs time per call. CI was still running when this was written.


Generated by Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:comment:7186561966 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3105#issuecomment-7186561966). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-26T08:24:45Z. --- <!-- victory-triage v1 head=161b283dba3c29d856e10fdf6b0e2db7f72ef98c verdict=needs-work at=2026-11-26T08:18:11Z --> Automated triage for the maintainers. **Needs work: evidence for the new depth.** Raising `HISTORY` from 32 to 256 in `crates/victory-hle/src/modules/gameinput.rs` changes what `GetPreviousReading`, `GetNextReading` and `GetTemporalReading` return. A reference older than 32 changes ago now resolves instead of failing with `REFERENCE_TOO_OLD` or not-found. That is emulation behaviour, and the PR gives no evidence for 256: - whether the title walks reading history at all, and how far back (the title's own code calling these functions); - or how deep the real runtime's history is (public GameInput documentation). Readings are only kept when the state changes (`Hub::update`). So 32 entries already covers 32 distinct changes between two frames, not 32 polls, and the "2 seconds at 8 ms" sizing in the comment does not hold. The new tests cover the traversal and eviction logic well. If evidence shows the title needs more depth, the same tests can back a value that matches it. One cost to keep in mind: `relative` with no device scans every slot's history under the hub lock, so the depth also costs time per call. CI was still running when this was written. --- _Generated by [Claude Code](https://claude.ai/code)_
oni-swr commented 2026-11-26 09:06:09 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by oni-swr on 2026-11-26T08:28:29Z.


Independent Windows CPU verification of PR #3105 at 161b283dba (single commit, parent 63bcca43c6 = main). Claim: https://github.com/Marvisak/VIctory/issues/1633#issuecomment-7186472185 . Windows 11 x64, no GPU, no gamepad, cargo test --locked -j 4 -p victory-hle --lib gameinput, synthetic pad states only.

  • Head: 12/12 pass, including the two new tests (walk both ways over 101 readings; FIFO eviction at capacity).
  • Parent: 10/10 pass, so the existing API tests are unchanged in outcome.
  • Control: head tests with HISTORY set back to 32 fail the 100-change bidirectional walk (previous lookup returns an error); the eviction test is written against HISTORY so it passes at either size.
  • Extra scratch test (not committed): after 255, 256, 257 and 515 changes the backward walk from the newest reading takes 254, 255, 255 and 255 steps, then returns READING_NOT_FOUND (exactly 256 retained, oldest evicted first). A reading held by the caller stays valid after it is evicted, and the sequence number keeps counting.

Not checked: source review, real devices, frame timing, other platforms. Test report only; no source changes and no PR from me.

AI use: Claude Code (Claude Sonnet 5.5) ran the checks, coordinated by Codex (gpt-6.2-sol).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7186637388 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3105#issuecomment-7186637388). Originally posted by [oni-swr](https://github.com/oni-swr) on 2026-11-26T08:28:29Z. --- Independent Windows CPU verification of PR #3105 at 161b283dba3c29d856e10fdf6b0e2db7f72ef98c (single commit, parent 63bcca43c6a00a758510398fa43096ce7e4f7df0 = main). Claim: https://github.com/Marvisak/VIctory/issues/1633#issuecomment-7186472185 . Windows 11 x64, no GPU, no gamepad, `cargo test --locked -j 4 -p victory-hle --lib gameinput`, synthetic pad states only. - Head: 12/12 pass, including the two new tests (walk both ways over 101 readings; FIFO eviction at capacity). - Parent: 10/10 pass, so the existing API tests are unchanged in outcome. - Control: head tests with `HISTORY` set back to 32 fail the 100-change bidirectional walk (previous lookup returns an error); the eviction test is written against `HISTORY` so it passes at either size. - Extra scratch test (not committed): after 255, 256, 257 and 515 changes the backward walk from the newest reading takes 254, 255, 255 and 255 steps, then returns READING_NOT_FOUND (exactly 256 retained, oldest evicted first). A reading held by the caller stays valid after it is evicted, and the sequence number keeps counting. Not checked: source review, real devices, frame timing, other platforms. Test report only; no source changes and no PR from me. AI use: Claude Code (Claude Sonnet 5.5) ran the checks, coordinated by Codex (gpt-6.2-sol).
cloph-dsp commented 2026-11-26 11:04:04 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by cloph-dsp on 2026-11-26T10:53:37Z.


Independent local verification of head 161b283 on Windows 11, Rust 1.100.0/MSVC:

  • cargo test --locked -p victory-hle --lib modules::gameinput:: — 12 passed, 0 failed (including the new history tests).
  • git diff --check origin/main HEAD — clean.

Used a worktree-local CARGO_TARGET_DIR to avoid stale shared-target binaries. Synthetic input only; no game assets, extracted data or DRM material used. AI-assisted (Hy4 flash).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7189978638 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3105#issuecomment-7189978638). Originally posted by [cloph-dsp](https://github.com/cloph-dsp) on 2026-11-26T10:53:37Z. --- Independent local verification of head `161b283` on Windows 11, Rust 1.100.0/MSVC: - `cargo test --locked -p victory-hle --lib modules::gameinput::` — 12 passed, 0 failed (including the new history tests). - `git diff --check origin/main HEAD` — clean. Used a worktree-local `CARGO_TARGET_DIR` to avoid stale shared-target binaries. Synthetic input only; no game assets, extracted data or DRM material used. AI-assisted (Hy4 flash).
andrewpozdnakov7-jpg commented 2026-11-28 06:22:07 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-28T06:22:07Z.


The full-history scan mentioned in triage is addressed in #3684. I combined this PR at 161b283 with #3684 at d10b61e in 6fb2440. The 256-entry capacity and both of this PR's history tests are retained.

All 13 GameInput tests passed on Windows, including the wrapped-history test with tied timestamps. Strict HLE Clippy and the asset policy passed. The extracted search matched all 49,872 synthetic queries. At 256 retained entries per device the median was 3,535 ns for the old scan and 166 ns for the binary search. This measures lookup only, outside host polling and the mutex.

For sizing, Microsoft documents a half-second history window. If every 8 ms poll records a change, 32 entries span 248 ms and 64 span 504 ms. Those spans depend on how often state changes. This measurement addresses lookup cost. The author and maintainer can decide what retention behavior to target based on the public API and any gameplay evidence.

Please retain the Git authors on cherry-pick or rebase, or add Co-authored-by: andrewpozdnakov7-jpg <[email protected]> if folding this resolution into another commit.

AI-assisted with OpenAI Codex.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7235249999 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3105#issuecomment-7235249999). Originally posted by [andrewpozdnakov7-jpg](https://github.com/andrewpozdnakov7-jpg) on 2026-11-28T06:22:07Z. --- The full-history scan mentioned in triage is addressed in #3684. I combined this PR at `161b283` with #3684 at `d10b61e` in [6fb2440](https://github.com/andrewpozdnakov7-jpg/VIctory/commit/6fb24403079529a4a6d055bd8776fba305f0f607). The 256-entry capacity and both of this PR's history tests are retained. All 13 GameInput tests passed on Windows, including the wrapped-history test with tied timestamps. Strict HLE Clippy and the asset policy passed. The extracted search matched all 49,872 synthetic queries. At 256 retained entries per device the median was 3,535 ns for the old scan and 166 ns for the binary search. This measures lookup only, outside host polling and the mutex. For sizing, Microsoft documents a [half-second history window](https://learn.microsoft.com/en-us/gaming/gdk/docs/reference/input/gameinput/interfaces/igameinput/methods/igameinput_getpreviousreading?view=gdk-2604#remarks). If every 8 ms poll records a change, 32 entries span 248 ms and 64 span 504 ms. Those spans depend on how often state changes. This measurement addresses lookup cost. The author and maintainer can decide what retention behavior to target based on the public API and any gameplay evidence. Please retain the Git authors on cherry-pick or rebase, or add `Co-authored-by: andrewpozdnakov7-jpg <[email protected]>` if folding this resolution into another commit. AI-assisted with OpenAI Codex.
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/3105:upstream-pr/3105'
git switch 'upstream-pr/3105'

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/3105'
git switch 'upstream-pr/3105'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/3105'
git switch 'upstream-pr/3105'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/3105'
git switch 'main'
git merge --squash 'upstream-pr/3105'
git switch 'main'
git merge --ff-only 'upstream-pr/3105'
git switch 'main'
git merge 'upstream-pr/3105'
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
Marvisak/VIctory!3103
No description provided.