Skip to content

GameInput: scripted presses stay down until the title has read them - #1765

Open
wondercrash wants to merge 1 commit into
xcl-dev:mainfrom
wondercrash:pr/press-latch
Open

wondercrash wants to merge 1 commit into
xcl-dev:mainfrom
wondercrash:pr/press-latch

Conversation

@wondercrash

Copy link
Copy Markdown
Contributor

A scripted press (XCL_PRESS_AT / XCL_PRESS_A_AT) is a fixed 200 ms window of host uptime. A title whose reading thread stalls reads its pad less often than that, and the press falls between two reads: in a retail title's run at 4-22 fps (first GetCurrentReading at 16.2 s), the presses at 24, 26, 32 and 120 s were never seen. Now a press stays down until the title has read it: at least 200 ms and two readings, then up for 100 ms and two readings before the next press of the same button, so two presses never merge.

Related: #609 (XCL_PRESS_HOLD=s, a longer fixed hold) fixes the same symptom with a hold the user has to pick. In the run below the reads came up to 12.4 s after a press was due, and the same script has presses 2 s apart (11 and 13 s): a hold long enough for the late ones (≥ 12.4 s) holds the early ones together as one press (#609's test: "presses that overlap are held together"). With the latch neither has to be chosen. If #609 lands first, I will rebase and keep XCL_PRESS_HOLD as the minimum hold. #565 (reading history) and #893 (scripted sticks) touch the same file but not scripted presses; #565 changes the poller thread, so one of the two will need a rebase.

What is in it

  • crates/xcl/src/hle/gameinput.rs, one commit:
    • PressLatch (pure over time and reading): advance(t) moves each press Pending → Down → Up → Done; read(t) is a reading the title is handed and counts it.
    • poll() (what GetCurrentReading and the readings hand the title) counts a reading; the 250 Hz poller only peeks (poll_peek), and a state it pushes to the reading callbacks counts as two readings (scripted_delivered), since a callback is not skipped by a slow reader.
    • Each press logs once when a reading first sees it: GameInput: scripted press 5 (A at 32 s) seen at 42.73 s.
    • Button names in one table (BUTTON_NAMES) for the parser and the log line.
    • Tests: slow_readings_still_see_every_press_and_presses_do_not_merge (reads 500 ms apart), a_press_between_two_distant_readings_is_seen_by_the_next_ones (a 15 s stall), fast_readings_hold_a_press_for_200_ms_and_a_second_press_follows_after_a_gap (1 ms reads). With read() put back to main's 200 ms window, the first two fail on the buttons down.

Tested

  • NVIDIA GeForce RTX 5090 (driver 621.14, 32-lane waves), AMD Ryzen 7 9800X3D, Windows 11 10.0.22631, Rust 1.96.0 MSVC, debug; DXC 1.8.2502 (Windows SDK 10.0.26100).
  • cargo build --workspace && cargo test --workspace -- --test-threads=4:
    • this PR (8cd2f03 on main 85e3826): 878 passed, 0 failed, 42 ignored;
    • main 85e3826: 875 passed, 0 failed, 42 ignored.
    • SKIPPED on both: gpu_geometry_wave32_prefix_count_over_a_mask (no wave64), gpu_wave32_program_in_wave64_hardware (no wave64), heap_window_out_of_memory_falls_back_to_the_switch_form (no heap windows).
  • Retail title, 150 s, XCL_PRESS_AT=11:A,13:A,24:A,26:A,32:A,120:A, on our integration branch (main + other PRs) with this commit: all six presses logged as seen, at 11.03, 13.03, 24.03, 26.03, 42.73 and 132.37 s (the title did not read its pad between 32 and 42.7 s, nor between 120 and 132.4 s). The run before it, same branch and script without this commit: the title first asked for a reading at 16.2 s, and no A was seen at any scripted time (the log's first A is at 73.7 s).

Regression run
.\scripts\smoke.ps1 -Game <retail title> -Seconds 60, no input (both runs stay on the start screen), main first, same machine:

xcl-smoke v1
commit: 85e38262ff94aecd75d6f83fa8156a8b7697bd13
gpu: NVIDIA GeForce RTX 5090
title: retail
seconds: 60
exit: 0x0
frames shown: 1638 (PresentX 1638)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 16114 MB
xcl-smoke v1
commit: 8cd2f03cef50471556c97398fae289ead61a7980
gpu: NVIDIA GeForce RTX 5090
title: retail
seconds: 60
exit: 0x0
frames shown: 1657 (PresentX 1657)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 15802 MB

Not tested

  • The title run above was not on main + this PR alone, but on our integration branch. The regression pair sends no input, so it does not reach the latch.
  • AMD / Intel GPUs (the change is CPU-only), a physical controller together with scripted presses, the e2e title with scripted presses.

AI use

  • omp with Claude Sonnet 5.5 wrote the change and the tests; omp with Claude Opus 5.5 checked the tests against main's window, ran the suite and wrote this description. The title runs are ours, on the hardware above.

A scripted press (XCL_PRESS_AT / XCL_PRESS_A_AT) was a fixed 200 ms window
of host uptime. When the title's reading thread stalls, the window falls
between two reads and the press is never seen: in a retail title's run at
4-22 fps (first GetCurrentReading at 16.2 s), the presses at 24, 26, 32
and 120 s were lost.

Presses are now a latch (PressLatch, pure over time and read): down at their
time, held until 200 ms have passed AND two readings saw them, then up for
100 ms and two readings before the next press of the same button, so presses
cannot merge. The 250 Hz poller peeks without counting; a state it pushes to
reading callbacks counts as enough readings, as a callback is not skipped.
Each press logs once when first seen by a reading. With the latch, a run of
the same title with presses at 11, 13, 24, 26, 32 and 120 s logged all six
as seen, the last two 10.7 s and 12.4 s after they were due.

Tests drive the latch with 500 ms, stalled and 1 ms read sequences; the
500 ms and stalled ones fail with the old 200 ms window.

Assisted-by: omp (Claude Sonnet 5.5)
Assisted-by: omp (Claude Opus 5.5)
@futurepro62

futurepro62 commented Nov 24, 2026 •

Copy link
Copy Markdown

Full-suite run, since this PR has no test report yet. Tested exact head 8cd2f03 (on its base 85e3826).

Tested

  • NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 616.64, 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 pso_measurement_compiles_an_exact_synthetic_record: 876 passed, 0 failed, 42 ignored. SKIPPED (no wave64): gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware.
  • The new tests ran and passed: slow_readings_still_see_every_press_and_presses_do_not_merge, a_press_between_two_distant_readings_is_seen_by_the_next_ones, fast_readings_hold_a_press_for_200_ms_and_a_second_press_follows_after_a_gap.
  • Same head on the AMD Radeon integrated GPU (iGPU) of the Ryzen 7 9800X3D (RDNA2, XCL_ADAPTER=radeon), cargo test --workspace -- --test-threads=4: 878 passed, 0 failed, 42 ignored. SKIPPED: heap_window_out_of_memory_falls_back_to_the_switch_form (no heap windows).
  • Two tests were skipped with --skip on NVIDIA. Both fail on main 7f7e768 too, not because of this PR: under XCL_REQUIRE_GPU=mesh, runner::skip_test turns their skips into failures. heap_window_out_of_memory_falls_back_to_the_switch_form skips when XCL_HEAP_WINDOWS is unset (Tests: heap_window_out_of_memory_falls_back_to_the_switch_form fails under XCL_REQUIRE_GPU=mesh (opt-in skip counted as missing coverage) #1651), and shaders::tests::pso_measurement_compiles_an_exact_synthetic_record skipped because Developer Mode was off. Developer Mode was turned on before the AMD run, and there pso_measurement_compiles_an_exact_synthetic_record ran and passed.

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.

@thehollowedone

Copy link
Copy Markdown

Tested

On 8cd2f03c, a scripted press disappeared after the title unregistered its last reading callback. My fixture registers one GameInput callback, waits for it to receive the scripted B at 0.05 s, and unregisters it successfully before A is due at 0.80 s. The title then makes its first GetCurrentReading at 1.15 s. XCL logs A as seen at 0.80 s, with no callback registered, and the API read at 1.15 s returns A up.

In a local variant, I made the callback dispatch report whether it invoked a callback and counted the poller sample only when it did. The 1.15 s read then returned A down and logged its first delivery. The three stock latch tests and unregister_reading_callback_waits_for_in_flight_and_prevents_uaf also passed in that local variant.

Windows 11 build 26300, Ryzen 7 9800X3D, Rust 1.99.1 MSVC debug. cargo test --offline --locked -p xcl --lib scratch_scripted_press_survives_after_last_callback_unregisters -- --nocapture --test-threads=1 failed 1/1 on the PR with only the fixture added and passed 1/1 with the local change. Zero skips.

Not tested

This is synthetic GameInput API coverage. Retail input and concurrent callback/read delivery were outside the test.

AI-assisted. Codex (GPT-6 family, exact variant unavailable) wrote and ran the fixture and local variant and drafted this report.

@DavidM1911

Copy link
Copy Markdown
Contributor

Verification on RTX 3060 Ti (Windows 11), branch merged with current main:

  • cargo test -p xcl --lib: all passed, 0 failed, ~23 ignored. (Intermittent single-test flake under parallel scheduling; clean on single-threaded rerun — same flake seen on unmodified main.)

Thanks!

@JJAutoCompare

Copy link
Copy Markdown

PR #1765 GameInput verification

Tested clean detached head 8cd2f03cef50471556c97398fae289ead61a7980 on STOR-WINLAB.

Environment

Windows 11 Enterprise Evaluation build 26200.9974, AMD Ryzen 7 3800X, Intel Arc A770 16 GiB with driver 32.0.101.9175. Wave range 8–32, DoublePrecisionFloatShaderOps=0, and no d3d12SDKLayers.dll. Rust 1.100.0 (0ef1bc386), DXC/DXIL 1.9.2609.5, and unoptimized builds with debug info disabled.

Tested

  • cargo build --workspace and cargo test --workspace --no-run succeeded.
  • cargo test -p xcl gameinput -- --nocapture reported 12 passed, 0 failed, 0 ignored, and 0 explicit skips. All three new latch tests passed. They cover presses read 500 ms apart, a press during a 15-second polling stall, and fast polling through the 200 ms hold and 100 ms release gap. The latch requires two down readings before release and two up readings before a repeat of the same button.
  • cargo test --workspace --no-fail-fast -- --test-threads=4 ran once under the shared Arc lock and exited 101. Across 20 test summaries, Cargo reported 860 passed, 18 failed, 42 ignored. All 12 GameInput tests passed again. The 860 includes 4 tests that logged SKIPPED and returned successfully. Those 4 provide no coverage.

Failures and skips

  • 17 GPU unit failures. 13 reported CreateComputePipelineState with 0x80070057. The other four were result mismatches in FMA, texture sample LOD, packed f16, and pixel-shader wave reduction.
  • 1 test-title failure. The RSSetDepthBiasX dynamic depth-bias probe read blue where it expected green.
  • 4 explicit skips. Two required wave64, one required heap windows, and one could not disable the driver cache (0x887A002D).

Not tested

Retail-title input, scripted press delivery through title callbacks, a paired smoke run against main, or other GPU vendors and drivers. The test title skipped audio voices because no audio device was available. The workspace failures have no main baseline from this run.

AI use

T3 Code / Codex (gpt-6.2-sol, reasoningEffort: high) ran the build and verification. Coordinator #2 (T3 Code / Antigravity, gemini-4-neon) verified counts against pr1765-suite.log and published this report.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants