D3D12.X / GameInput: Minecraft no longer crashes at start or loses its controller #3618

Open
ivall wants to merge 2 commits from upstream-pr/3618 into main
ivall commented 2026-12-01 21:39:11 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by ivall on 2026-12-01T21:39:11Z.


Two regressions that stopped Minecraft Preview (1.18.30.64) on current main, one commit each.

  • A DSV made without a description of Minecraft's 4x MSAA depth buffer got XCL's default view (default_dsv, since 38b05b7b) as TEXTURE2D. The AMD driver faulted in ClearDepthStencilView (a read at -1), the device was removed (invalid call) and the title ended ~2 s in with 0xC0000409, with nothing in XCL's log (its own crash handler fail-fasts). The default DSV of a multisampled buffer is now TEXTURE2DMS / TEXTURE2DMSARRAY, as pc_srv already does for SRVs. This part overlaps #3280 and #1087 (both conflict with main; #3280 also changes 1D views and UNKNOWN formats).
  • Since #565 (f9e6ac5f) the virtual gamepad makes a GameInput reading only when its state changes, so with nothing pressed GetCurrentReading kept returning the reading from the title's start. ~13 s in, Minecraft's menu showed "your controller was disconnected" (its gamepad_disconnected screen). Before #565 every current reading was a new one. The pad now also reports its unchanged state once per poll interval (4 ms); a change still makes its reading at once, and the retained history works as before.

What is in it

  • D3D12.X: a default DSV of a multisampled depth buffer is a multisampled view – crates/xcl/src/hle/d3d12x/real.rs (default_dsv, tests in default_dsv_tests)
  • GameInput: an idle gamepad keeps reporting, its current reading stays recent – crates/xcl/src/hle/gameinput.rs (ReadingHistory::record, test an_idle_gamepad_keeps_reporting)

Tested

  • AMD Radeon RX 9070 (driver 32.0.32029.2010), AMD Ryzen 7 9700X, Windows 11 Home build 26200, Rust 1.96.0; tests in debug, game runs in release.
  • cargo build --workspace && cargo test --workspace --no-fail-fast -- --test-threads=4 at c4be321d: 2899 passed, 8 failed, 51 ignored; SKIPPED: 2 (two_pass_binds_set_the_shared_view_heap, heap_window_out_of_memory_falls_back_to_the_switch_form: no heap windows).
  • The 8 failures fail the same way on main f07e426d on this machine (rerun there): gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1 and _3, gpu::recomp::heap_window_tests::gpu_smem_flat_descriptor_windows_and_limits, gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu, gpu::recomp::tests::gpu_f32_compares_with_nan, gpu::recomp::tests::gpu_float_compares_random, gpu::recomp::tests::gpu_ps_readfirstlane_loop_on_a_primitive_edge_ends, gpu_two_pass_cache_e2e::two_pass_driver_cache_reuses_both_passes_and_recovers_corrupt_blobs.
  • The new tests fail without their fixes: a_multisampled_depth_buffer_gets_a_multisampled_view (view dimension 3 instead of 5), an_idle_gamepad_keeps_reporting.
  • Minecraft Preview 1.18.30.64 (Minecraft.Windows.exe.original), release builds of this diff on f07e426d before it was committed: main ends ~2 s in with 0xC0000409; with the DSV fix alone it runs at 60 fps but shows the controller-disconnected dialog ~13 s in; with both a 30 s run reaches the main menu with no dialog (frame dumps), 60 fps, 0 ERROR lines, exit 0. A longer run was also checked by hand in the menu.

Regression run

  • Not run: no xcl-smoke blocks in this PR.

Not tested

  • scripts/smoke.ps1 regression runs (main and this head).
  • NVIDIA and Intel GPUs; Fortnite, XDefiant, Unicorn Overlord (only Minecraft was run).
  • Titles with GameInput reading callbacks: while one is registered they now also get a reading about every 4 ms with an unchanged state (Minecraft only calls GetCurrentReading).
  • A physical controller against the GameInput change.

AI use

  • Claude Code with Claude Opus 5.5: found both causes (a small debugger for the silent fail-fast; XCL_PROBE and disassembly of the title to trace the dialog; a build of 5c6bbc52 to confirm it was a regression), wrote the code, the tests, the commit messages and this description.
<!-- greyfinch-sync:ivall/xcl:issue:5595035175 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3618). Originally posted by [ivall](https://github.com/ivall) on 2026-12-01T21:39:11Z. --- Two regressions that stopped Minecraft Preview (1.18.30.64) on current main, one commit each. - A DSV made without a description of Minecraft's 4x MSAA depth buffer got XCL's default view (`default_dsv`, since 38b05b7b) as `TEXTURE2D`. The AMD driver faulted in `ClearDepthStencilView` (a read at -1), the device was removed (invalid call) and the title ended ~2 s in with 0xC0000409, with nothing in XCL's log (its own crash handler fail-fasts). The default DSV of a multisampled buffer is now `TEXTURE2DMS` / `TEXTURE2DMSARRAY`, as `pc_srv` already does for SRVs. This part overlaps #3280 and #1087 (both conflict with main; #3280 also changes 1D views and UNKNOWN formats). - Since #565 (f9e6ac5f) the virtual gamepad makes a GameInput reading only when its state changes, so with nothing pressed `GetCurrentReading` kept returning the reading from the title's start. ~13 s in, Minecraft's menu showed "your controller was disconnected" (its `gamepad_disconnected` screen). Before #565 every current reading was a new one. The pad now also reports its unchanged state once per poll interval (4 ms); a change still makes its reading at once, and the retained history works as before. **What is in it** - `D3D12.X: a default DSV of a multisampled depth buffer is a multisampled view` – `crates/xcl/src/hle/d3d12x/real.rs` (`default_dsv`, tests in `default_dsv_tests`) - `GameInput: an idle gamepad keeps reporting, its current reading stays recent` – `crates/xcl/src/hle/gameinput.rs` (`ReadingHistory::record`, test `an_idle_gamepad_keeps_reporting`) **Tested** - AMD Radeon RX 9070 (driver 32.0.32029.2010), AMD Ryzen 7 9700X, Windows 11 Home build 26200, Rust 1.96.0; tests in debug, game runs in release. - `cargo build --workspace && cargo test --workspace --no-fail-fast -- --test-threads=4` at c4be321d: 2899 passed, 8 failed, 51 ignored; SKIPPED: 2 (`two_pass_binds_set_the_shared_view_heap`, `heap_window_out_of_memory_falls_back_to_the_switch_form`: no heap windows). - The 8 failures fail the same way on main f07e426d on this machine (rerun there): `gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1` and `_3`, `gpu::recomp::heap_window_tests::gpu_smem_flat_descriptor_windows_and_limits`, `gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu`, `gpu::recomp::tests::gpu_f32_compares_with_nan`, `gpu::recomp::tests::gpu_float_compares_random`, `gpu::recomp::tests::gpu_ps_readfirstlane_loop_on_a_primitive_edge_ends`, `gpu_two_pass_cache_e2e::two_pass_driver_cache_reuses_both_passes_and_recovers_corrupt_blobs`. - The new tests fail without their fixes: `a_multisampled_depth_buffer_gets_a_multisampled_view` (view dimension 3 instead of 5), `an_idle_gamepad_keeps_reporting`. - Minecraft Preview 1.18.30.64 (`Minecraft.Windows.exe.original`), release builds of this diff on f07e426d before it was committed: main ends ~2 s in with 0xC0000409; with the DSV fix alone it runs at 60 fps but shows the controller-disconnected dialog ~13 s in; with both a 30 s run reaches the main menu with no dialog (frame dumps), 60 fps, 0 ERROR lines, exit 0. A longer run was also checked by hand in the menu. **Regression run** - Not run: no `xcl-smoke` blocks in this PR. **Not tested** - `scripts/smoke.ps1` regression runs (main and this head). - NVIDIA and Intel GPUs; Fortnite, XDefiant, Unicorn Overlord (only Minecraft was run). - Titles with GameInput reading callbacks: while one is registered they now also get a reading about every 4 ms with an unchanged state (Minecraft only calls `GetCurrentReading`). - A physical controller against the GameInput change. **AI use** - Claude Code with Claude Opus 5.5: found both causes (a small debugger for the silent fail-fast; `XCL_PROBE` and disassembly of the title to trace the dialog; a build of 5c6bbc52 to confirm it was a regression), wrote the code, the tests, the commit messages and this description.
capy-ai[bot] commented 2026-12-01 21:40:42 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by capy-ai[bot] on 2026-12-01T21:40:42Z.

Code review location: crates/xcl/src/hle/gameinput.rs; line 599

@@ -590,8 +592,11 @@ impl ReadingHistory {
         self.readings.back().map_or(0, |r| r.reading().sequence)
     }
 
+    /// A new reading when the state changed, or the same state again a report interval after
+    /// the last one: a connected pad keeps reporting, and to a title a current reading that
+    /// stays old is a pad that is gone (Minecraft shows "controller disconnected").
     fn record(&mut self, state: GamepadState, now: u64) -> bool {
-        let changed = self.readings.back().is_none_or(|r| r.reading().state != state);
+        let changed = self.readings.back().is_none_or(|r| r.reading().state != state || now.saturating_sub(r.reading().timestamp) >= REPORT_US);

Runtime changes lack required smoke regression evidence

Medium Severity

CONTRIBUTING.md requires runtime changes to include scripts/smoke.ps1 runs on main and the committed PR head, with both generated xcl-smoke blocks under Regression run. This PR changes descriptor creation and gamepad reporting but explicitly reports that those runs were not performed; the described manual game runs do not supply the required frame, memory, and crash comparison. Run the required comparison against this head and attach its generated evidence before merging.

Open in Capy

<!-- greyfinch-sync:ivall/xcl:review-comment:4761393211 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3618#discussion_r4761393211). Originally posted by [capy-ai[bot]](https://github.com/apps/capy-ai) on 2026-12-01T21:40:42Z. **Code review location:** `crates/xcl/src/hle/gameinput.rs`; line 599 ~~~~diff @@ -590,8 +592,11 @@ impl ReadingHistory { self.readings.back().map_or(0, |r| r.reading().sequence) } + /// A new reading when the state changed, or the same state again a report interval after + /// the last one: a connected pad keeps reporting, and to a title a current reading that + /// stays old is a pad that is gone (Minecraft shows "controller disconnected"). fn record(&mut self, state: GamepadState, now: u64) -> bool { - let changed = self.readings.back().is_none_or(|r| r.reading().state != state); + let changed = self.readings.back().is_none_or(|r| r.reading().state != state || now.saturating_sub(r.reading().timestamp) >= REPORT_US); ~~~~ --- ### Runtime changes lack required smoke regression evidence **Medium Severity** CONTRIBUTING.md requires runtime changes to include scripts/smoke.ps1 runs on main and the committed PR head, with both generated xcl-smoke blocks under Regression run. This PR changes descriptor creation and gamepad reporting but explicitly reports that those runs were not performed; the described manual game runs do not supply the required frame, memory, and crash comparison. Run the required comparison against this head and attach its generated evidence before merging. <!-- capy-badge:start --> <a href="https://capy.ai/pull/xcl-dev/xcl/3618"><picture><source media="(prefers-color-scheme: dark)" srcset="https://capy.ai/badge/neutral-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://capy.ai/badge/neutral-light.svg"><img alt="Open in Capy" src="https://capy.ai/badge/neutral-light.svg"></picture></a> <!-- capy-badge:end -->
capy-ai[bot] commented 2026-12-01 21:40:42 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by capy-ai[bot] on 2026-12-01T21:40:42Z.

Review: COMMENTED


Capy found 1 potential issue (1 medium).

View 2 other findings in Capy.

Open in Capy

<!-- greyfinch-sync:ivall/xcl:review:6140645821 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3618#pullrequestreview-6140645821). Originally posted by [capy-ai[bot]](https://github.com/apps/capy-ai) on 2026-12-01T21:40:42Z. **Review:** COMMENTED --- Capy found 1 potential issue (1 medium). View 2 other findings in Capy. <!-- capy-badge:start --> <a href="https://capy.ai/pull/xcl-dev/xcl/3618"><picture><source media="(prefers-color-scheme: dark)" srcset="https://capy.ai/badge/neutral-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://capy.ai/badge/neutral-light.svg"><img alt="Open in Capy" src="https://capy.ai/badge/neutral-light.svg"></picture></a> <!-- capy-badge:end -->
Foniass commented 2026-12-01 22:02:47 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T22:02:47Z.


Tested on NVIDIA: the crash is fixed there too, but the menus have texture glitches that the Nov 23 build doesn't have.

Setup: RTX 5070 Ti (driver 32.0.16.2114), Ryzen 7 7800X3D, Windows 11 Pro build 26300, release builds. Same title and version as in the PR description.

Crash

  • main f07e426d: device removed (0x887a0001) ~6.6 s in, right after the 4x MSAA depth buffer, then an AV in nvwgf2umx.dll. Same on 5b3c9a4f (Nov 29). f5999e43 (Nov 23) runs fine.
  • This PR (c4be321d): fixed. 60 s smoke run, 3001 frames, 0 device removals, 0 crashes, 0 ERROR lines.
xcl-smoke blocks (same title, 60 s)
xcl-smoke v1
commit: f07e426dade72aa7112cf6bfe08ca6f6ff5a9d5c
gpu: NVIDIA GeForce RTX 5070 Ti
title: b4519f03
seconds: 60
exit: 0xc0000005
frames shown: none logged (the run did not reach its end)
presents per 2 s (last 3): 0 0 0
device removals: 1
crashes: 2
peak commit: 1559 MB
xcl-smoke v1
commit: c4be321d7ed25f029754ea753d66c3eff5e2cd31
gpu: NVIDIA GeForce RTX 5070 Ti
title: b4519f03
seconds: 60
exit: 0x0
frames shown: 3001 (PresentX 3001)
presents per 2 s (last 3): 120 120 121
device removals: 0
crashes: 0
peak commit: 3645 MB

Glitches
The world, HUD, inventory, world list and title screen render correctly. f5999e43 (Nov 23, before 38b05b7b) draws all of the following correctly on the same machine. With this PR:

  • Settings: most of the category icons in the left column are wrong: a solid black block, black stripes, striped garbage with red and green, or what look like world block textures. The toggle switches in the world settings page are missing.
  • Pause menu: a black bar behind the top of the button column, and a white box behind the top of the world panel on the right, where its grey background should be. Same every time.
  • Save and quit: for a frame or two the title background has streaky blue and white garbage over its left part.
  • Also seen by hand, not captured: parts of a menu background turn pink or green and stay that way until the menu is closed and reopened.

It looks like the UI drawing from the wrong texture data. Not bisected. Since it started after f5999e43, it may come from 38b05b7b too, but that's a guess. Not tested: AMD (do you see it on your 9070?), the controller fix (no pad in these runs), the test suite.

Also on this machine: without XCL_PREPARE=0 (default shader preparation), the screen stayed black while the title ran at 60 fps. Separate issue, not investigated.

Claude Code with Claude Opus 5.5 ran the builds, the smoke runs and the screenshots, and wrote this report; checked by Fonias.

<!-- greyfinch-sync:ivall/xcl:comment:7327189043 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3618#issuecomment-7327189043). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-01T22:02:47Z. --- Tested on NVIDIA: the crash is fixed there too, but the menus have texture glitches that the Nov 23 build doesn't have. **Setup:** RTX 5070 Ti (driver 32.0.16.2114), Ryzen 7 7800X3D, Windows 11 Pro build 26300, release builds. Same title and version as in the PR description. **Crash** - `main` f07e426d: device removed (`0x887a0001`) ~6.6 s in, right after the 4x MSAA depth buffer, then an AV in `nvwgf2umx.dll`. Same on 5b3c9a4f (Nov 29). f5999e43 (Nov 23) runs fine. - This PR (c4be321d): fixed. 60 s smoke run, 3001 frames, 0 device removals, 0 crashes, 0 ERROR lines. <details><summary>xcl-smoke blocks (same title, 60 s)</summary> ``` xcl-smoke v1 commit: f07e426dade72aa7112cf6bfe08ca6f6ff5a9d5c gpu: NVIDIA GeForce RTX 5070 Ti title: b4519f03 seconds: 60 exit: 0xc0000005 frames shown: none logged (the run did not reach its end) presents per 2 s (last 3): 0 0 0 device removals: 1 crashes: 2 peak commit: 1559 MB ``` ``` xcl-smoke v1 commit: c4be321d7ed25f029754ea753d66c3eff5e2cd31 gpu: NVIDIA GeForce RTX 5070 Ti title: b4519f03 seconds: 60 exit: 0x0 frames shown: 3001 (PresentX 3001) presents per 2 s (last 3): 120 120 121 device removals: 0 crashes: 0 peak commit: 3645 MB ``` </details> **Glitches** The world, HUD, inventory, world list and title screen render correctly. f5999e43 (Nov 23, before 38b05b7b) draws all of the following correctly on the same machine. With this PR: - Settings: most of the category icons in the left column are wrong: a solid black block, black stripes, striped garbage with red and green, or what look like world block textures. The toggle switches in the world settings page are missing. - Pause menu: a black bar behind the top of the button column, and a white box behind the top of the world panel on the right, where its grey background should be. Same every time. - Save and quit: for a frame or two the title background has streaky blue and white garbage over its left part. - Also seen by hand, not captured: parts of a menu background turn pink or green and stay that way until the menu is closed and reopened. It looks like the UI drawing from the wrong texture data. Not bisected. Since it started after f5999e43, it may come from 38b05b7b too, but that's a guess. Not tested: AMD (do you see it on your 9070?), the controller fix (no pad in these runs), the test suite. Also on this machine: without `XCL_PREPARE=0` (default shader preparation), the screen stayed black while the title ran at 60 fps. Separate issue, not investigated. *Claude Code with Claude Opus 5.5 ran the builds, the smoke runs and the screenshots, and wrote this report; checked by Fonias.*
Foniass commented 2026-12-02 00:07:57 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-02T00:07:57Z.


Follow-up on the menu glitches from my earlier comment (wrong icons, black and white boxes, magenta / blue / noise backgrounds). They don't come from this PR. Bisected on the same RTX 5070 Ti machine.

First bad commit: 9acc0314 "D3D12.X: a submit looks at the textures under its written pages, not at all of them (local test)". It came into main with the nvidia-dev merge, #3203 (765b2c5b). Its parent 8ff4b02e is clean in two runs. Every build tested after it shows the glitches.

Method: each build had this PR's DSV fix (caeff359) on top, plus the GameInput commit where it applied. Each run used XCL_PREPARE=0 XCL_NETWORK=0 and the same route: title → world list → world → pause → Settings. Screenshots were compared with a clean build. The glitches vary from run to run, but every bad build showed some on that route.

What in 9acc0314 does it (all at 9acc0314 + DSV fix):

variant result
as is bad
XCL_WATCH_GAP_MB=4 XCL_WATCH_HOT_MS=5000 (old values) bad
submit selection back to every texture instead of touched_by bad
that + recheck_gpu_view_sources back to every texture bad
title_textures.rs from the parent, kernelx.rs kept clean
walk back to STEP 16 MiB + 5 ms pause clean (2 runs)
walk STEP 16 MiB, pause left at 15 ms bad

So the new texture index looks fine. What breaks it is the write-watch timing, and mostly the walk's longer pause.

Likely mechanism (inferred from the code and these runs, not traced): with hot looks (7c18bc41), a submit only takes written pages from 2 MiB blocks written in the last hot_for. A write to any other block is only found by the walk thread. When a CPU write lands in a cold block shortly before a submit that consumes it, the submit doesn't see it. If the consumer is a GPU copy into a texture, the texture gets stale bytes, and after the GPU write XCL no longer uploads it from CPU memory, so it stays wrong until the UI redraws it. 9acc0314 widened that window: blocks go cold after 1.5 s instead of 5 s, and the walk pauses 15 ms instead of 5 ms between passes.

On current main (this PR's head, c4be321d):

  • Putting the walk back to 16 MiB / 5 ms is not enough (still bad); later changes widen the window further.
  • XCL_WATCH_HOT=0 (every look walks all watched memory) is clean in 2 runs out of 2. In this title the look then costs 0.14–0.29 ms a submit (the submit cost log lines), and the game stays at 51–60 fps in menus and the world. So XCL_WATCH_HOT=0 is a workaround for now.

A real fix probably needs a submit not to proceed while CPU writes in cold blocks before it are still unseen, rather than relying on the walk's timing. Turning hot looks off by default would fix this title, but the code's own comment measures 4–7 ms a look on a large retail title, so I haven't proposed it as a patch. Not tested: AMD, other titles, the test suite with any of these changes.

Claude Code with Claude Opus 5.5 did the bisect, the experiments and this write-up; posted at Fonias's request without Fonias checking it first.

<!-- greyfinch-sync:ivall/xcl:comment:7330178924 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3618#issuecomment-7330178924). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-02T00:07:57Z. --- Follow-up on the menu glitches from my earlier comment (wrong icons, black and white boxes, magenta / blue / noise backgrounds). They don't come from this PR. Bisected on the same RTX 5070 Ti machine. **First bad commit: 9acc0314** "D3D12.X: a submit looks at the textures under its written pages, not at all of them (local test)". It came into `main` with the nvidia-dev merge, #3203 (765b2c5b). Its parent 8ff4b02e is clean in two runs. Every build tested after it shows the glitches. **Method:** each build had this PR's DSV fix (caeff359) on top, plus the GameInput commit where it applied. Each run used `XCL_PREPARE=0 XCL_NETWORK=0` and the same route: title → world list → world → pause → Settings. Screenshots were compared with a clean build. The glitches vary from run to run, but every bad build showed some on that route. - main side: 38b05b7b clean, 379725ae / 44eb541c / 5d2ea8f8 / bb9a6b4b / 5b711248 clean; 765b2c5b (#3203) and everything after it bad. - inside #3203: f0e8fdd5 and nvidia-dev tip 54225f58 bad; on nvidia-dev's first-parent line, 8ff4b02e clean (2 runs), 9acc0314 and later bad. **What in 9acc0314 does it** (all at 9acc0314 + DSV fix): | variant | result | |---|---| | as is | bad | | `XCL_WATCH_GAP_MB=4 XCL_WATCH_HOT_MS=5000` (old values) | bad | | submit selection back to every texture instead of `touched_by` | bad | | that + `recheck_gpu_view_sources` back to every texture | bad | | `title_textures.rs` from the parent, `kernelx.rs` kept | clean | | walk back to `STEP` 16 MiB + 5 ms pause | clean (2 runs) | | walk `STEP` 16 MiB, pause left at 15 ms | bad | So the new texture index looks fine. What breaks it is the write-watch timing, and mostly the walk's longer pause. **Likely mechanism** (inferred from the code and these runs, not traced): with hot looks (7c18bc41), a submit only takes written pages from 2 MiB blocks written in the last `hot_for`. A write to any other block is only found by the walk thread. When a CPU write lands in a cold block shortly before a submit that consumes it, the submit doesn't see it. If the consumer is a GPU copy into a texture, the texture gets stale bytes, and after the GPU write XCL no longer uploads it from CPU memory, so it stays wrong until the UI redraws it. 9acc0314 widened that window: blocks go cold after 1.5 s instead of 5 s, and the walk pauses 15 ms instead of 5 ms between passes. **On current main** (this PR's head, c4be321d): - Putting the walk back to 16 MiB / 5 ms is **not enough** (still bad); later changes widen the window further. - `XCL_WATCH_HOT=0` (every look walks all watched memory) is **clean in 2 runs out of 2**. In this title the look then costs 0.14–0.29 ms a submit (the `submit cost` log lines), and the game stays at 51–60 fps in menus and the world. So `XCL_WATCH_HOT=0` is a workaround for now. A real fix probably needs a submit not to proceed while CPU writes in cold blocks before it are still unseen, rather than relying on the walk's timing. Turning hot looks off by default would fix this title, but the code's own comment measures 4–7 ms a look on a large retail title, so I haven't proposed it as a patch. Not tested: AMD, other titles, the test suite with any of these changes. *Claude Code with Claude Opus 5.5 did the bisect, the experiments and this write-up; posted at Fonias's request without Fonias checking it first.*
bmjask commented 2026-12-02 16:10:28 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by bmjask on 2026-12-02T16:10:28Z.

Code review location: crates/xcl/src/hle/gameinput.rs; line 599

@@ -590,8 +592,11 @@ impl ReadingHistory {
         self.readings.back().map_or(0, |r| r.reading().sequence)
     }
 
+    /// A new reading when the state changed, or the same state again a report interval after
+    /// the last one: a connected pad keeps reporting, and to a title a current reading that
+    /// stays old is a pad that is gone (Minecraft shows "controller disconnected").
     fn record(&mut self, state: GamepadState, now: u64) -> bool {
-        let changed = self.readings.back().is_none_or(|r| r.reading().state != state);
+        let changed = self.readings.back().is_none_or(|r| r.reading().state != state || now.saturating_sub(r.reading().timestamp) >= REPORT_US);

High: REPORT_US (4 ms) equals the poll interval, and the poller sleeps 4 ms between polls, so record() now makes a new reading on every poll. Every registered reading callback fires ~250 times a second with an unchanged state, and the sequence number advances constantly. The state != state test is effectively dead and the analog threshold argument is ignored. A title that uses RegisterReadingCallback, or watches GetCurrentReading's sequence/timestamp, to detect input activity (an AFK/idle timer, attract-mode timeout, last-used-device prompt switching, UI auto-repeat) sees a new gamepad reading every 4 ms with nobody touching the pad, so idle timeouts never fire. A REPORT_US much larger than the poll interval (e.g. 100 ms-1 s) would keep the current reading fresh for Minecraft while staying close to change-only.

<!-- greyfinch-sync:ivall/xcl:review-comment:4772554626 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3618#discussion_r4772554626). Originally posted by [bmjask](https://github.com/bmjask) on 2026-12-02T16:10:28Z. **Code review location:** `crates/xcl/src/hle/gameinput.rs`; line 599 ~~~~diff @@ -590,8 +592,11 @@ impl ReadingHistory { self.readings.back().map_or(0, |r| r.reading().sequence) } + /// A new reading when the state changed, or the same state again a report interval after + /// the last one: a connected pad keeps reporting, and to a title a current reading that + /// stays old is a pad that is gone (Minecraft shows "controller disconnected"). fn record(&mut self, state: GamepadState, now: u64) -> bool { - let changed = self.readings.back().is_none_or(|r| r.reading().state != state); + let changed = self.readings.back().is_none_or(|r| r.reading().state != state || now.saturating_sub(r.reading().timestamp) >= REPORT_US); ~~~~ --- **High**: REPORT_US (4 ms) equals the poll interval, and the poller sleeps 4 ms between polls, so `record()` now makes a new reading on every poll. Every registered reading callback fires ~250 times a second with an unchanged state, and the sequence number advances constantly. The `state != state` test is effectively dead and the analog threshold argument is ignored. A title that uses RegisterReadingCallback, or watches GetCurrentReading's sequence/timestamp, to detect input activity (an AFK/idle timer, attract-mode timeout, last-used-device prompt switching, UI auto-repeat) sees a new gamepad reading every 4 ms with nobody touching the pad, so idle timeouts never fire. A REPORT_US much larger than the poll interval (e.g. 100 ms-1 s) would keep the current reading fresh for Minecraft while staying close to change-only.
bmjask commented 2026-12-02 16:10:28 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by bmjask on 2026-12-02T16:10:28Z.

Review: COMMENTED


Review of c4be321d: 4 finding(s) (3 high, 1 medium), most severe first.

  1. High crates/xcl/src/hle/gameinput.rs:599: REPORT_US (4 ms) equals the poll interval, and the poller sleeps 4 ms between polls, so record() now makes a new reading on every poll. (inline)
  2. High crates/xcl/src/hle/gameinput.rs:600: With a reading every 4 ms, the callback dispatcher delivers every one in order, so a guest callback that takes more than ~4 ms falls permanently behind. (inline)
  3. High crates/xcl/src/hle/gameinput.rs:601: Idle readings now fill the history to HISTORY_CAPACITY and rotate it every 4 ms, so a reading a title holds expires after 500 ms even when nothing happened, which breaks the "tap after idle" recovery #565 added the history for. (inline)
  4. Medium crates/xcl/src/hle/d3d12x/real.rs:3180: default_dsv picks the view dimension from SampleDesc.Count and DepthOrArraySize only and never checks d.Dimension, so a typeless 1D depth resource gets a TEXTURE2D or TEXTURE2DARRAY DSV, the same class of wrong default view this PR f.... (inline)

These findings come from an AI-assisted review (Claude Code) and focus on correctness. Each is a candidate; please check it before acting on it.

<!-- greyfinch-sync:ivall/xcl:review:6154610994 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3618#pullrequestreview-6154610994). Originally posted by [bmjask](https://github.com/bmjask) on 2026-12-02T16:10:28Z. **Review:** COMMENTED --- Review of `c4be321d`: 4 finding(s) (3 high, 1 medium), most severe first. 1. **High** `crates/xcl/src/hle/gameinput.rs:599`: REPORT_US (4 ms) equals the poll interval, and the poller sleeps 4 ms between polls, so `record()` now makes a new reading on every poll. (inline) 2. **High** `crates/xcl/src/hle/gameinput.rs:600`: With a reading every 4 ms, the callback dispatcher delivers every one in order, so a guest callback that takes more than ~4 ms falls permanently behind. (inline) 3. **High** `crates/xcl/src/hle/gameinput.rs:601`: Idle readings now fill the history to HISTORY_CAPACITY and rotate it every 4 ms, so a reading a title holds expires after 500 ms even when nothing happened, which breaks the "tap after idle" recovery #565 added the history for. (inline) 4. **Medium** `crates/xcl/src/hle/d3d12x/real.rs:3180`: `default_dsv` picks the view dimension from SampleDesc.Count and DepthOrArraySize only and never checks `d.Dimension`, so a typeless 1D depth resource gets a TEXTURE2D or TEXTURE2DARRAY DSV, the same class of wrong default view this PR f.... (inline) --- _These findings come from an AI-assisted review (Claude Code) and focus on correctness. Each is a candidate; please check it before acting on it._
bmjask commented 2026-12-02 16:10:29 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by bmjask on 2026-12-02T16:10:29Z.

Code review location: crates/xcl/src/hle/gameinput.rs; line 600

@@ -590,8 +592,11 @@ impl ReadingHistory {
         self.readings.back().map_or(0, |r| r.reading().sequence)
     }
 
+    /// A new reading when the state changed, or the same state again a report interval after
+    /// the last one: a connected pad keeps reporting, and to a title a current reading that
+    /// stays old is a pad that is gone (Minecraft shows "controller disconnected").
     fn record(&mut self, state: GamepadState, now: u64) -> bool {
-        let changed = self.readings.back().is_none_or(|r| r.reading().state != state);
+        let changed = self.readings.back().is_none_or(|r| r.reading().state != state || now.saturating_sub(r.reading().timestamp) >= REPORT_US);
         if changed {

High: With a reading every 4 ms, the callback dispatcher delivers every one in order, so a guest callback that takes more than ~4 ms falls permanently behind. If a title's reading callback does ~5 ms of work (logging, a game mutex, posting to the main thread), the backlog grows until prune drops readings, and from then on each callback gets a reading ~500 ms stale with overrun=true, so a button press reaches the title about half a second late. Before, only state changes were dispatched and there was no backlog.

<!-- greyfinch-sync:ivall/xcl:review-comment:4772554647 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3618#discussion_r4772554647). Originally posted by [bmjask](https://github.com/bmjask) on 2026-12-02T16:10:29Z. **Code review location:** `crates/xcl/src/hle/gameinput.rs`; line 600 ~~~~diff @@ -590,8 +592,11 @@ impl ReadingHistory { self.readings.back().map_or(0, |r| r.reading().sequence) } + /// A new reading when the state changed, or the same state again a report interval after + /// the last one: a connected pad keeps reporting, and to a title a current reading that + /// stays old is a pad that is gone (Minecraft shows "controller disconnected"). fn record(&mut self, state: GamepadState, now: u64) -> bool { - let changed = self.readings.back().is_none_or(|r| r.reading().state != state); + let changed = self.readings.back().is_none_or(|r| r.reading().state != state || now.saturating_sub(r.reading().timestamp) >= REPORT_US); if changed { ~~~~ --- **High**: With a reading every 4 ms, the callback dispatcher delivers every one in order, so a guest callback that takes more than ~4 ms falls permanently behind. If a title's reading callback does ~5 ms of work (logging, a game mutex, posting to the main thread), the backlog grows until prune drops readings, and from then on each callback gets a reading ~500 ms stale with overrun=true, so a button press reaches the title about half a second late. Before, only state changes were dispatched and there was no backlog.
bmjask commented 2026-12-02 16:10:29 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by bmjask on 2026-12-02T16:10:29Z.

Code review location: crates/xcl/src/hle/gameinput.rs; line 601

@@ -590,8 +592,11 @@ impl ReadingHistory {
         self.readings.back().map_or(0, |r| r.reading().sequence)
     }
 
+    /// A new reading when the state changed, or the same state again a report interval after
+    /// the last one: a connected pad keeps reporting, and to a title a current reading that
+    /// stays old is a pad that is gone (Minecraft shows "controller disconnected").
     fn record(&mut self, state: GamepadState, now: u64) -> bool {
-        let changed = self.readings.back().is_none_or(|r| r.reading().state != state);
+        let changed = self.readings.back().is_none_or(|r| r.reading().state != state || now.saturating_sub(r.reading().timestamp) >= REPORT_US);
         if changed {
             let reading = OwnedReading::new(state, self.sequence() + 1, now);

High: Idle readings now fill the history to HISTORY_CAPACITY and rotate it every 4 ms, so a reading a title holds expires after 500 ms even when nothing happened, which breaks the "tap after idle" recovery #565 added the history for. If a title keeps its last processed reading R and later calls GetNextReading(R), with an idle pad R used to stay the newest retained reading indefinitely, so the call returned the press. Now, after more than 500 ms (a loading screen, a pause, a slow frame), R and its successor are pruned, the call returns GAMEINPUT_E_REFERENCE_READING_TOO_OLD, and the title resyncs to the current reading and loses the tap. Refreshing only the reading GetCurrentReading returns (record a fresh one at query time if the newest is old) would fix Minecraft without changing history or callbacks.

<!-- greyfinch-sync:ivall/xcl:review-comment:4772554659 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3618#discussion_r4772554659). Originally posted by [bmjask](https://github.com/bmjask) on 2026-12-02T16:10:29Z. **Code review location:** `crates/xcl/src/hle/gameinput.rs`; line 601 ~~~~diff @@ -590,8 +592,11 @@ impl ReadingHistory { self.readings.back().map_or(0, |r| r.reading().sequence) } + /// A new reading when the state changed, or the same state again a report interval after + /// the last one: a connected pad keeps reporting, and to a title a current reading that + /// stays old is a pad that is gone (Minecraft shows "controller disconnected"). fn record(&mut self, state: GamepadState, now: u64) -> bool { - let changed = self.readings.back().is_none_or(|r| r.reading().state != state); + let changed = self.readings.back().is_none_or(|r| r.reading().state != state || now.saturating_sub(r.reading().timestamp) >= REPORT_US); if changed { let reading = OwnedReading::new(state, self.sequence() + 1, now); ~~~~ --- **High**: Idle readings now fill the history to HISTORY_CAPACITY and rotate it every 4 ms, so a reading a title holds expires after 500 ms even when nothing happened, which breaks the "tap after idle" recovery #565 added the history for. If a title keeps its last processed reading R and later calls GetNextReading(R), with an idle pad R used to stay the newest retained reading indefinitely, so the call returned the press. Now, after more than 500 ms (a loading screen, a pause, a slow frame), R and its successor are pruned, the call returns GAMEINPUT_E_REFERENCE_READING_TOO_OLD, and the title resyncs to the current reading and loses the tap. Refreshing only the reading GetCurrentReading returns (record a fresh one at query time if the newest is old) would fix Minecraft without changing history or callbacks.
bmjask commented 2026-12-02 16:10:29 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by bmjask on 2026-12-02T16:10:29Z.

Code review location: crates/xcl/src/hle/d3d12x/real.rs; line 3180

@@ -3175,15 +3176,63 @@ fn default_dsv(d: &D3D12_RESOURCE_DESC) -> Option<D3D12_DEPTH_STENCIL_VIEW_DESC>
         _ => return None,
     };
     let mut v = D3D12_DEPTH_STENCIL_VIEW_DESC { Format: DXGI_FORMAT(format), ..Default::default() };
-    if d.DepthOrArraySize > 1 {
-        v.ViewDimension = D3D12_DSV_DIMENSION_TEXTURE2DARRAY;
-        v.Anonymous.Texture2DArray = D3D12_TEX2D_ARRAY_DSV { MipSlice: 0, FirstArraySlice: 0, ArraySize: d.DepthOrArraySize as u32 };
-    } else {
-        v.ViewDimension = D3D12_DSV_DIMENSION_TEXTURE2D;
+    let slices = u32::from(d.DepthOrArraySize);
+    match (d.SampleDesc.Count > 1, slices > 1) {

Medium: default_dsv picks the view dimension from SampleDesc.Count and DepthOrArraySize only and never checks d.Dimension, so a typeless 1D depth resource gets a TEXTURE2D or TEXTURE2DARRAY DSV, the same class of wrong default view this PR fixes for MSAA. A title that makes a TEXTURE1D (or 1D array) depth buffer in R32_TYPELESS or R24G8_TYPELESS and calls CreateDepthStencilView with a null desc gets ViewDimension TEXTURE2D(ARRAY) for a 1D resource, which is invalid and can remove the device like the original Minecraft crash. Mapping to TEXTURE1D/TEXTURE1DARRAY, as resource_dim_to_view does, would fix it.

<!-- greyfinch-sync:ivall/xcl:review-comment:4772554680 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3618#discussion_r4772554680). Originally posted by [bmjask](https://github.com/bmjask) on 2026-12-02T16:10:29Z. **Code review location:** `crates/xcl/src/hle/d3d12x/real.rs`; line 3180 ~~~~diff @@ -3175,15 +3176,63 @@ fn default_dsv(d: &D3D12_RESOURCE_DESC) -> Option<D3D12_DEPTH_STENCIL_VIEW_DESC> _ => return None, }; let mut v = D3D12_DEPTH_STENCIL_VIEW_DESC { Format: DXGI_FORMAT(format), ..Default::default() }; - if d.DepthOrArraySize > 1 { - v.ViewDimension = D3D12_DSV_DIMENSION_TEXTURE2DARRAY; - v.Anonymous.Texture2DArray = D3D12_TEX2D_ARRAY_DSV { MipSlice: 0, FirstArraySlice: 0, ArraySize: d.DepthOrArraySize as u32 }; - } else { - v.ViewDimension = D3D12_DSV_DIMENSION_TEXTURE2D; + let slices = u32::from(d.DepthOrArraySize); + match (d.SampleDesc.Count > 1, slices > 1) { ~~~~ --- **Medium**: `default_dsv` picks the view dimension from SampleDesc.Count and DepthOrArraySize only and never checks `d.Dimension`, so a typeless 1D depth resource gets a TEXTURE2D or TEXTURE2DARRAY DSV, the same class of wrong default view this PR fixes for MSAA. A title that makes a TEXTURE1D (or 1D array) depth buffer in R32_TYPELESS or R24G8_TYPELESS and calls CreateDepthStencilView with a null desc gets ViewDimension TEXTURE2D(ARRAY) for a 1D resource, which is invalid and can remove the device like the original Minecraft crash. Mapping to TEXTURE1D/TEXTURE1DARRAY, as `resource_dim_to_view` does, would fix it.
bmjask commented 2026-12-02 16:10:35 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by bmjask on 2026-12-02T16:10:35Z.


@Prime1997 could you take a look at this one for review and merge? My automated review notes are above, if any.

<!-- greyfinch-sync:ivall/xcl:comment:7351554866 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3618#issuecomment-7351554866). Originally posted by [bmjask](https://github.com/bmjask) on 2026-12-02T16:10:35Z. --- @Prime1997 could you take a look at this one for review and merge? My automated review notes are above, if any.
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/3618:upstream-pr/3618'
git switch 'upstream-pr/3618'

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