Repository navigation
Conversation
…ed view A DSV made without a description of a typeless depth buffer gets XCL's default view (`default_dsv`, since 38b05b7). It was TEXTURE2D for every 2D buffer, also a 4x MSAA one. Minecraft makes such a view of its 1920x1080 4x MSAA R24G8 depth buffer; the AMD driver (RX 9070) then faulted reading address -1 in ClearDepthStencilView, the device was removed (invalid call) and Minecraft's crash handler ended the process ~2 s in with 0xC0000409, which left no trace in XCL's log. A multisampled buffer now gets TEXTURE2DMS (TEXTURE2DMSARRAY with slices), as `pc_srv` already does for its default SRV.
… recent Since f9e6ac5 the virtual gamepad makes a reading only when its state changes. With nothing pressed, GetCurrentReading kept handing out the reading from the title's start, its timestamp seconds old. Minecraft takes that for a pad that is gone: ~13 s in, its menu showed "your controller was disconnected" (the gamepad_disconnected screen). Before f9e6ac5 every current reading was a new one. The pad now also reports its unchanged state once per poll interval (4 ms), as a connected device does; a change still makes its reading at once, and the retained history and its next / previous readings work as before.
|
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
xcl-smoke blocks (same title, 60 s)Glitches
It looks like the UI drawing from the wrong texture data. Not bisected. Since it started after f5999e4, it may come from 38b05b7 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 Claude Code with Claude Opus 5.5 ran the builds, the smoke runs and the screenshots, and wrote this report; checked by Fonias. |
|
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: 9acc031 "D3D12.X: a submit looks at the textures under its written pages, not at all of them (local test)". It came into Method: each build had this PR's DSV fix (caeff35) on top, plus the GameInput commit where it applied. Each run used
What in 9acc031 does it (all at 9acc031 + DSV fix):
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 (7c18bc4), a submit only takes written pages from 2 MiB blocks written in the last On current main (this PR's head, c4be321):
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
left a comment
There was a problem hiding this comment.
Review of c4be321d: 4 finding(s) (3 high, 1 medium), most severe first.
- High
crates/xcl/src/hle/gameinput.rs:599: REPORT_US (4 ms) equals the poll interval, and the poller sleeps 4 ms between polls, sorecord()now makes a new reading on every poll. (inline) - 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) - 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) - Medium
crates/xcl/src/hle/d3d12x/real.rs:3180:default_dsvpicks the view dimension from SampleDesc.Count and DepthOrArraySize only and never checksd.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.
| /// 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); |
There was a problem hiding this comment.
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.
| 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 { |
There was a problem hiding this comment.
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.
| 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); |
There was a problem hiding this comment.
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.
| } else { | ||
| v.ViewDimension = D3D12_DSV_DIMENSION_TEXTURE2D; | ||
| let slices = u32::from(d.DepthOrArraySize); | ||
| match (d.SampleDesc.Count > 1, slices > 1) { |
There was a problem hiding this comment.
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.
|
@Prime1997 could you take a look at this one for review and merge? My automated review notes are above, if any. |
Two regressions that stopped Minecraft Preview (1.18.30.64) on current main, one commit each.
default_dsv, since 38b05b7) asTEXTURE2D. The AMD driver faulted inClearDepthStencilView(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 nowTEXTURE2DMS/TEXTURE2DMSARRAY, aspc_srvalready does for SRVs. This part overlaps D3D12.X: fix default_dsv MSAA/1D dimensions and DXGI_FORMAT_UNKNOWN on typeless depth buffers #3280 and D3D12.X: match default depth views to MSAA textures #1087 (both conflict with main; D3D12.X: fix default_dsv MSAA/1D dimensions and DXGI_FORMAT_UNKNOWN on typeless depth buffers #3280 also changes 1D views and UNKNOWN formats).GetCurrentReadingkept returning the reading from the title's start. ~13 s in, Minecraft's menu showed "your controller was disconnected" (itsgamepad_disconnectedscreen). Before GameInput: retain recent gamepad readings between polls #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 indefault_dsv_tests)GameInput: an idle gamepad keeps reporting, its current reading stays recent–crates/xcl/src/hle/gameinput.rs(ReadingHistory::record, testan_idle_gamepad_keeps_reporting)Tested
cargo build --workspace && cargo test --workspace --no-fail-fast -- --test-threads=4at c4be321: 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).gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1and_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.a_multisampled_depth_buffer_gets_a_multisampled_view(view dimension 3 instead of 5),an_idle_gamepad_keeps_reporting.Minecraft.Windows.exe.original), release builds of this diff on f07e426 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
xcl-smokeblocks in this PR.Not tested
scripts/smoke.ps1regression runs (main and this head).GetCurrentReading).AI use
XCL_PROBEand disassembly of the title to trace the dialog; a build of 5c6bbc5 to confirm it was a regression), wrote the code, the tests, the commit messages and this description.