Repository navigation
D3D12.X: CopyIntoSubresource makes the blocks it wrote hot at once - #3437
tiagonleal wants to merge 1 commit into
Conversation
With the hot looks on (the default), a look before ExecuteCommandLists asks the write watch only about the 2 MiB blocks written in the last `hot_for` (1.5 s); the walk thread makes another block hot when it finds a written page there, a walk pass later. A write into a block idle for longer than that, followed at once by a submit, reached the GPU one submit late. The test title's "a texture in title memory (XG layout, xcl-dev#44) follows CPU writes" check rewrites a subresource with CopyIntoSubresource and submits at once: it failed now and then under load, and 5 of 5 runs with a 2 s pause before the rewrite (xcl-dev#3382). CopyIntoSubresource is XCL's own code, so it knows what it wrote: it now marks the blocks of the bytes it tiled hot (`mark_hot`, made crate-visible), and the next look takes them from the write watch, whose bits the copy's stores set. Nothing is reset, so a page is not uploaded twice or lost; the cost is one short lock and a map insert per block written. With the 2 s pause, 5 of 5 runs pass. Not covered: raw stores by title code still wait for the walk as before. DirectStorage and the kernelx page writes already go through note_known_write. Part of xcl-dev#3382
|
On current head Each copy touched one 4 KiB page. The current code marked the whole slice or volume hot. After touching all the allocation’s pages to make them resident, I alternated the stock range with a diagnostic control that retained only the actually written 2 MiB block. Both found the same page. The table gives per-process median scan times across four fresh processes, 96 samples per lane per process. Timing starts after the copy and includes choosing the hot ranges and taking the dirty pages.
The one-block control only narrows this fixture’s known footprint. A footprint-aware implementation would need to preserve all touched blocks for larger and noncontiguous mips. The two existing test modules ( |
|
merge-check AI-written and posted by Foniass without a human check of each point. |
|
No other open or merged PR addresses #3382. AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human. |
|
merge-check claim |
|
merge-check |
Part of #3382. With the hot write-watch looks (the default), a look before
ExecuteCommandListsasks the write watch only about the 2 MiB blocks written in the last 1.5 s (hot_for); the walk thread makes any other block hot when it finds a written page there, a walk pass later. A write into a block that was idle for longer, followed at once by a submit, reached the GPU one submit late.CopyIntoSubresourceis one such write, and it is XCL's own code, so it knows what it wrote. It now marks the blocks of the bytes it tiled hot withtitle_textures::mark_hot, which already did this for memory the title had just committed. The next look then takes those pages from the write watch, whose bits the copy's own stores set. Nothing is reset, so no page goes up twice and none is lost. The cost is one short lock and one map insert per 2 MiB block written.This is what makes the test title's check
a texture in title memory (XG layout, #44) follows CPU writesfail now and then in whole-suite runs and on CI: it rewrites a subresource withCopyIntoSubresourceand submits at once.What is in it
xg.rs:copy_intocallsmark_hoton the bytes it wrote, for a 2D level and for a volume leveltitle_textures.rs:mark_hotispub(crate); a#[cfg(test)]readerhot_blockfor the testhle::xg::tests::a_subresource_copy_makes_its_blocks_hot: a copy across a block boundary leaves both blocks hotTested
main0fe06eb0(same diff): with a 2000 ms pause added in the test title before the rewrite (a local change, not in this PR),test_title_runs_under_the_debug_layer_with_dredrun 5 times. Without the twomark_hotcalls: 5 of 5 fail the check withsubresource 2 row 0 differs from the title memory. With them: 5 of 5 pass.a_subresource_copy_makes_its_blocks_hotfails without the two calls (xg.rs, the assert on both blocks) and passes with them.cargo test -p xcl --lib hle::xg: 80 passed, 0 failed.cargo test -p xcl --lib title_textures -- --test-threads=4: 65 passed, 0 failed, 1 ignored.cargo test --workspace --no-fail-fast -j 8 -- --test-threads=4on headf4f2bff7: 2738 passed, 0 failed, 49 ignored (27SKIPPEDlines).main0fe06eb0on this machine: 2737 passed, 0 failed, 49 ignored. This is the second run on this head: in the first the lib test binary ended insideuma_driver::testswithcoherent window could not be restored(the abort Tests: the mixed-window remake tests run in a child process #3187 is open for), before this PR's test had run.Regression run
scripts/smoke.ps1 -Seconds 60 -Title 9cc6a39e(Newer Retail Game), release builds of both commits in clean trees,main0fe06eb0first, one run each,XCL_PREPARE=0, same DXIL cache. A warm-up run ofmaincame before them and is not shown; a second run ofmainafter them showed 1697 frames and a peak commit of 15302 MB.main(0fe06eb0):This PR (
f4f2bff7):Not tested
CopyFromSubresourceis not touched: its destination is the title's linear buffer.kernelxpage writes already tell the looks what they wrote throughnote_known_write.AI use
🤖 Generated with Claude Code