Repository navigation
D3D12.X: GPU timestamps into the title's own memory land after the GPU - #311
emirduran707 wants to merge 1 commit into
Conversation
|
A race in the
Tested on
Alone, the resolved test fails with only the low half, e.g. Outside the tests this means a title polling a 64-bit timestamp can read the new low half with the old high half. Suggestions (either is enough for the tests; the second also covers the title):
Not tested: a retail title; AMD for the failure (these tests use the default adapter, so the RX 9060 XT / Ryzen 5 5600 timing may simply never lose the race). AI use: Claude Code with Claude Opus 5.5 found the race, ran these tests and wrote this comment; the numbers come from those runs. |
Write64BitValueBottomOfPipeX / Write64BitValueTopOfPipeX with a timestamp flag were dropped when the address was outside the unified memory windows, although the same calls with a value already reach such memory through cpu_writes. A retail title asks for them in plain memory from its first frames; the log said "is not 8-byte aligned in unified memory" for 8-byte-aligned addresses, because one message covered both cases. Now such a timestamp is resolved into a per-device readback buffer (one 8-byte slot per query of the timestamp heap) and the cpu_writes worker copies it to the address once the queue's fence is there. Unaligned addresses and memory that is neither unified nor writable each get their own warning. Tests: cpu_writes::resolved_values_land_after_the_queue, and the test title's console list check writes a timestamp into its heap (failed before with "no GPU timestamp in the title's own memory"). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
600f092 to
e39bbfb
Compare
|
Thanks, you were right on both counts. Fixed in e39bbfb (squashed, rebased on db1ddb2):
On the RX 9060 XT the race never shows on its own (each test alone, 10 runs: 0 failures before and after, as you expected for AMD). With your experiment (a 20 ms sleep after each dword store, local only): 5 of 5 failures for each test on 135195f, 0 of 5 on e39bbfb. Suite at e39bbfb: 667 passed, 0 failed, 41 ignored, no On #317: it reshapes AI use: Claude Code with Claude Opus 5.5 made the fix, ran these tests and wrote this reply. |
|
Tested RTX 5060 Ti 8 GB (Blackwell, 32-lane waves), NVIDIA 621.24, Ryzen 5 5600X, Windows 11 Pro 26300 (native, Graphics Tools + XGameRuntime installed, so the debug-layer tests run), rustc 1.100.0 MSVC, debug, Pass: 671 passed, 0 failed, 41 ignored. SKIPPED: only the 2 Run and written with Claude Code (Claude Opus 5.5). |
Write64BitValueBottomOfPipeX/Write64BitValueTopOfPipeXwith a timestamp flag were dropped when the address was outside the unified memory windows, although the same calls with a value already reach such memory throughcpu_writes. The warning said0x…698 is not 8-byte aligned in unified memoryfor 8-byte-aligned addresses, because one message covered both cases.A retail title asks for such timestamps from its first frames. It hits this on a first run, while the coherent window is 512 MB (#284); with a learned window the addresses are inside it.
XCL_COHERENT_MB=512reproduces it on any run.What is in it
hle/d3d12x/cpu_writes.rs: a deferred write is either dwords (as before) or the 8 bytes the GPU resolved into a mapped readback buffer; the worker copies those to the address once the queue's fence is there, as one 8-byte store (a title polling it never sees half a value).hle/d3d12x/list_x.rs:timestamp()resolves a timestamp for the title's own writable memory into a per-device readback buffer (one 8-byte slot per query of the existing timestamp heap) and queues the copy; unified memory goes as before. Unaligned addresses and memory that is neither unified nor writable get their own warnings.cpu_writes::resolved_values_land_after_the_queue; the test title's console list check writes a timestamp into its heap (it failed on main withno GPU timestamp in the title's own memory). Bothcpu_writestests wait for the whole value (review below).Tested
x86_64-pc-windows-msvc; DXC 1.9.2602.17; debug for the suite, release for the runs.cargo test --workspace -- --test-threads=4at e39bbfb: 667 passed, 0 failed, 41 ignored; noSKIPPEDlines.scripts/smoke.ps1(60 s) withXCL_COHERENT_MB=512set, main db1ddb2 vs this PR: main logsWrite64BitValueBottomOfPipeX: … not 8-byte aligned in unified memory – not done4 times (the warning's cap); this PR logs none andbottom-of-pipe writes outside unified memory are done by the CPU after the GPU (2 in the first submission). Frames 561 vs 694, peak commit 15 458 vs 15 483 MB, no crash or device removal in either. I did not see a visible change from the timestamps.cpu_writestest run alone, 10 times, passes on this machine before and after; with a 20 ms sleep after each dword store (local experiment, not committed) both fail 5 of 5 before the fix and 0 of 5 after.Regression run
The
gpu:line names a virtual display adapter of this machine (what #281 / #282 / #285 fix); XCL's log namesbackend 'real' – AMD Radeon RX 9060 XT (16188 MiB VRAM)in both runs.main:
PR:
Not tested
Write64BitValueTopOfPipeXtimestamps into the title's own memory on a retail title (same code path; the test title covers the bottom-of-pipe one).AI use