Repository navigation
D3D12.X: check writability in note_signaled and remove per-frame allocations in WaitFrameEventX - #2692
D3D12.X: check writability in note_signaled and remove per-frame allocations in WaitFrameEventX#2692Decodere wants to merge 1 commit into
Conversation
|
Tested on the Linux/Wine lane, full standard env (AMD rig: Ryzen 9 9900X, 96 GB DDR5, RX 7900 XT 20 GB, Arch kernel 7.2.15, Mesa 26.2.5 RADV, wine-11.0 Proton, rustc 1.94.0; |
|
Test report: passes on NVIDIA. Exact head Tested
Not tested
Claude Code (Claude Opus 5.5) ran the tests and wrote this report. |
|
Tested - native Windows AMD RDNA2, PR head Tool: OpenCode with DeepSeek V4.1 Flash 1017
PR 1 ran second and started with a warmer cache (139 -> 41 DXIL misses); the warm repeat Both trees: 40 mesh refusals, 0 failed pipelines, 0 DXIL failures, no crash and no device Not tested: full workspace, NVIDIA, debug build, world/FPS runs. AI use: OpenCode with DeepSeek V4.1 Flash 1017 ran the tests, read the logs and wrote this comment; the figures and crash lines were checked against the run logs. |
|
RX 6800M verification at exact PR head
This confirms startup presentation and frame-event activity on this AMD card with the uncapped override. The 12-second samples are too short for a performance conclusion and do not establish world-load behavior or exercise every changed edge case. I did not run the full workspace suite on this head. AI-assisted test report with Codex. |
|
Ran the frame hot-path tests at Environment: Windows 11 Pro build 26200 x64, NVIDIA GeForce RTX 5070 Ti (Blackwell, 32-lane waves only, 16 GB) driver 32.0.16.2124, Intel Core i5-12400F, 64 GB RAM, rustc 1.100.0 (0ef1bc386 2026-11-09) MSVC 14.44.35207, DXC 1.9.2609.5, debug build. All eight tests pass, including the three new ones for the writability check ( What this adds: the author measured on an RTX 4060 (Ada) and WARP; this is a second NVIDIA host (Blackwell, different driver), and the thread already has one more NVIDIA report on an RTX 4080 SUPER. Not tested: the full workspace suite, a paired 60 s smoke run, the retail title under AI-assisted (OpenCode), model: DeepSeek V4.1 Flash Free - checked out the PR's head commit in a detached worktree, built it, ran the tests, wrote this report; the worktree was not modified; no game data was used. |
Validate WaitFrameEventX's signaled-index target as committed, unguarded, and writable without touching its pages. Replace ancillary and paced wait handle vectors with fixed stack storage, avoid the scheduled-handle Arc clone on the paced path, and use deques for bounded frame history eviction.\n\nAdapted from xcl-dev#2692.\nPart of #103.\n\nAssisted-by: Google Antigravity (Gemini 4 Neon)\nAssisted-by: Codex (GPT-5.6-sol)
Validate WaitFrameEventX's signaled-index target as committed, unguarded, and writable without touching its pages. Replace ancillary and paced wait handle vectors with fixed stack storage, avoid the scheduled-handle Arc clone on the paced path, and use deques for bounded frame history eviction.\n\nAdapted from xcl-dev#2692.\nPart of #103.\n\nAssisted-by: Google Antigravity (Gemini 4 Neon)\nAssisted-by: Codex (GPT-5.6-sol)
|
Source read of 9a547e2, no run. AI-assisted (Claude Code, Claude Opus 5.5). |
…cations in WaitFrameEventX `note_signaled` previously guarded its `i32` write with `gpu::shader::readable(out, 4)`, which only checks that pages are readable. A pointer to `PAGE_READONLY`, `PAGE_EXECUTE_READ`, or a cross-page straddle ending on a read-only page passed the guard and faulted on write. - Add `writable(p, len)` (via `writable_with_uma`) matching `gpu::shader::readable`'s `Uma::in_committed_window(p, len)` fast path (so non-resident pages in a 4 GiB committed coherent window never fall through to a slow kernel `VirtualQuery` walk, per @upipibi's review), followed by a `K32QueryWorkingSetEx` fast path (`resident_and_writable`) and `VirtualQuery` fallback, and use it in `note_signaled` so read-only, guard, no-access, unmapped, and cross-page non-writable targets are safely skipped without touching pages. - Replace `ancillary`'s `Vec<HANDLE>` with a stack-allocated `AncillaryHandles` (`[HANDLE; 63]` + `len`) and replace the paced `WaitFrameEventX` wait-handle `Vec` with a `[HANDLE; 64]` stack array, removing both per-frame heap allocations on the default paced path. - Only `Arc::clone` the scheduled ancillary handles inside `WaitFrameEventX` when `XCL_FRAME_INTERVAL_US` is set to uncapped (`Some(0)`). - Switch `ISSUED` and `FLIPPED` ring buffers from `Vec` (`remove(0)` / `drain(..n)`) to `VecDeque` (`pop_front()` / `push_back(...)`) for O(1) eviction. - Add unit tests covering `writable` / `note_signaled` (read-only, resident read-only, RW->RO straddle, `PAGE_GUARD`, `PAGE_EXECUTE_READ`, `PAGE_NOACCESS`, reserved-only), the committed coherent UMA window fast path and boundary fallthrough, `AncillaryHandles` boundary cases, and `ISSUED`/`FLIPPED` FIFO eviction order. Part of xcl-dev#103 Assisted-by: Google Antigravity (Gemini 4 Neon)
9a547e2 to
4f9c7ff
Compare
|
Good catch, @upipibi — updated in
|
Validate WaitFrameEventX's signaled-index target as committed, unguarded, and writable without touching its pages. Replace ancillary and paced wait handle vectors with fixed stack storage, avoid the scheduled-handle Arc clone on the paced path, and use deques for bounded frame history eviction.\n\nAdapted from xcl-dev#2692.\nPart of #103.\n\nAssisted-by: Google Antigravity (Gemini 4 Neon)\nAssisted-by: Codex (GPT-5.6-sol)
Validate WaitFrameEventX's signaled-index target as committed, unguarded, and writable without touching its pages. Replace ancillary and paced wait handle vectors with fixed stack storage, avoid the scheduled-handle Arc clone on the paced path, and use deques for bounded frame history eviction. Adapted from xcl-dev#2692. Part of #103. Assisted-by: Google Antigravity (Gemini 4 Neon) Assisted-by: Codex (GPT-5.6-sol)
Validate WaitFrameEventX's signaled-index target as committed, unguarded, and writable without touching its pages. Replace ancillary and paced wait handle vectors with fixed stack storage, avoid the scheduled-handle Arc clone on the paced path, and use deques for bounded frame history eviction. Adapted from #2692. Part of #103. Assisted-by: Google Antigravity (Gemini 4 Neon) Assisted-by: Codex (GPT-5.6-sol)
|
Nothing has happened on this PR for 3 days, so it is marked |
|
Main commit 8aba55b ("Frame clock: remove paced wait allocations and validate writes", "Adapted from #2692") contains this change in AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human. |
|
Closing as superseded: this change is already on Two independent checks found this: Foniass's close list on #1607 and ours against current AI use: Claude Code (Claude Opus 5.5); the per-PR comparison was done by Claude Sonnet 5.5 sub-agents. |
What is in it
Hardens
note_signaledagainst non-writable output pointers and removes per-frame heap allocations, unnecessaryArc::clonetraffic, and O(N) ring-buffer shifts on theWaitFrameEventX/mark_flippedhot path incrates/xcl/src/hle/d3d12x/frame.rs.note_signaled: Replacescrate::gpu::shader::readable(out, 4)withwritable(p, len)(viawritable_with_uma(uma, p, len)):gpu::shader::readable'sUma::in_committed_window(p, len)fast path right after the null/zero/oversize/overflow guards and beforeresident_and_writable/VirtualQuery(per @upipibi's review), so a non-resident page inside a 4 GiB committed coherent window (PAGE_READWRITEas a whole) never falls through to a slow kernelVirtualQuerywalk, while cross-window boundary straddles fall through cleanly.K32QueryWorkingSetExfast path (resident_and_writable, up to 16 pages, treating onlyflags & 1 != 0 && protect != 0entries as resident so non-resident orprotect == 0pages fall through cleanly) and falls back toVirtualQuery, requiringMEM_COMMIT, noPAGE_GUARD, and a writable page protection (PAGE_READWRITE,PAGE_WRITECOPY,PAGE_EXECUTE_READWRITE, orPAGE_EXECUTE_WRITECOPY). Read-only, execute-read, guard, no-access, reserved-only, null, and cross-page RW->RO targets are safely skipped without touching pages or triggering guard faults.WaitFrameEventX: Replacesancillary'sVec<HANDLE>with a stack-allocatedAncillaryHandles([HANDLE; 63]+len, implementingDeref<Target = [HANDLE]>andIntoIterator) and replaces the paced wait-handleVec<HANDLE>with a stack[HANDLE; 64]array.Arc::clonefor uncapped mode: Clonesc.kinds[ty as usize].extrainsidewait_frame_event_xonly wheninterval_override() == Some(0), avoiding an unused atomic reference-count increment/decrement on every default paced frame wait.ISSUEDandFLIPPEDfromVec(remove(0)/drain(..n)) toVecDeque(pop_front()/push_back(...)).writable/note_signaled(read-only, resident read-only, RW->RO cross-page straddle,PAGE_GUARDpreservation,PAGE_EXECUTE_READ,PAGE_NOACCESS, reserved-only, and valid write), the committed coherentUma::with_windows(1, 0x2_0000)fast path (non-resident untouched page,PAGE_GUARDshortcut proof, guard rejections, and end-of-window boundary fallthrough),AncillaryHandlesboundary cases (null,0,63,64,u32::MAX, unreadable list), andISSUED/FLIPPEDFIFO eviction order.Part of #103
Tested
b49be1836844fe0b0cdb3211dce3cb7fb4e21ac7): Confirmed unmodifiedgpu::shader::readableaccepted both aPAGE_READONLYtarget (ro_ok=true) and a 4-bytePAGE_READWRITE -> PAGE_READONLYcross-page straddle (straddle_ok=true), whereas post-fixwritablerejects both andnote_signaledskips them safely.cargo clippy --all-targets -- -A clippy::approx_constant->0new warnings incrates/xcl/src/hle/d3d12x/frame.rs.XCL_ADAPTER=warp,XCL_WARP=1):cargo test -p xcl --lib -- hle::d3d12x::frame::tests:: --nocapture->9 passed; 0 failed; 0 ignored(0skipped,0.25seach across all 3 runs).cargo test --release -p xcl --lib -- hle::d3d12x::frame::tests:: --nocapture->9 passed; 0 failed; 0 ignored(0skipped,0.25seach across all 3 runs).cargo test --release --workspace --no-fail-fast -- --test-threads=4 --nocapture->37test targets,1439 passed; 0 failed; 47 ignored(29pre-existing host-gatedSKIPPEDnotices:21wave64-only tests on a 32-lane GPU,3per-lane wave32 tests refused by the driver,3D3D12 debug layer tests withoutd3d12SDKLayers.dll,1no heap windows,1cannot disable the driver cache).Regression run
Baseline (exact parent
b49be183):Branch (
HEAD):Not tested
d3d12SDKLayers.dll).K32QueryWorkingSetExreportsprotect == 0(covered structurally by falling through toVirtualQuery).XCL_FRAME_INTERVAL_US=0(uncapped override path).AI use
Implemented, unit-tested, and verified with assistance from Google Antigravity (Gemini 4 Neon); every change and test result was reviewed and executed locally.