D3D12.X: seek to textures overlapping sparse CPU writes #1086
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
goal:world-load
good first issue
help wanted
invalid
keep-open
off-goal
question
stale
test-only
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/xcl-dev--xcl!1086
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-1086"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@TG0000 on GitHub · 2026-11-24 11:25 UTC · original
TG0000:perf/dirty-texture-candidates→main· +300 −42 · 1 files · 2 commits · openEach submit that finds written pages checked every tracked title texture against the list of written pages, even when only a few pages were written. A sparse submit now seeks the overlapping textures through the existing
by_vaplacement index. Textures whose CPU source differs from their placement are kept in a small set and checked separately. Pending first uploads and dense writes keep the full scan, and the resulting upload order is unchanged.Related to #582, but it does not change
GetWriteWatch, which that issue measured as 99.7 % of a look. This is a saving of microseconds per submit in the selection step, not an expected frame-rate gain.What is in it
crates/xcl/src/hle/d3d12x/title_textures.rs: indexed selection of upload candidates;insert_active/remove_activekeep the remapped set in step with the placement index; a test against the full scan (aliases, remapped sources, shadowed and restored placements, GPU-written and pending textures, dense writes); a manual release benchmark (#[ignore]).7d92772), same file: theremappedupdate ofrecheck_gpu_view_sourcesis nowTable::recheck_sources, so it runs without a GPU.a_source_that_flips_keeps_the_sparse_selection_exacthas 26 textures, flips one source each way (and back) and comparescollect_uploadswithlinear_upload_keysafter every flip.Tested
xclbuilds.cargo test --workspace --no-fail-fast -- --test-threads=4 --show-output: 735 passed, 3 failed, 42 ignored on this head; 734 passed, 3 failed, 41 ignored onmain384f7f7. The same three fail in both:placed_title_textures_share_vram_and_preserve_pixels(3D texture, subresource 2 mismatch), andtransitions_apply_when_their_list_is_submittedandd32s8_targets_take_their_own_size_of_video_memoryon the lock it poisons.test_title_draws_with_a_root_signature_under_the_debug_layer,uploads_start_from_each_subresources_state.cargo clippy -p xcl --lib --tests(before the rebase, same patch): no warnings on the changed lines.7d92772:cargo test -p xcl --lib d3d12x::title_textures -- --test-threads=4: 14 passed, 1 failed, 1 ignored (the benchmark). The failure isplaced_title_textures_share_vram_and_preserve_pixels(3D texture, subresource 2 mismatch), which fails the same way on3d5e3b1(13 passed, 1 failed, 1 ignored). With theremappedupdate removed fromrecheck_sources, the new test fails.cargo clippy -p xcl --lib --tests: no warning on the changed lines. Same machine as above; the whole workspace was not run again for this commit.cargo test --release -p xcl --lib bench_dirty_texture_candidates -- --ignored --nocapture, median of seven rounds, synthetic textures, µs per submit for the selection alone:The ratio varies by run: two earlier runs of the 4096 / 4 row measured 72x and 90x.
Regression run
On the head
7d92772and on its merge base with main,384f7f7: one release build and one run each, from clean trees at those commits, the same title and 45 s. Other builds and tests ran on the PC during both runs, so the frame counts are not a timing comparison. Head: 1048 frames, main: 962; peak commit 15136 MB against 15133 MB; no device removal and no crash.main:
PR:
Earlier runs, on
3d5e3b1(before the review follow-up). The first pair, main then PR. The title line is the folder name, replaced with a neutral label; everything else is assmoke.ps1printed it.main:
PR:
All five pairs of those two builds, frames shown (no crash and no device removal in any):
Other builds ran on the PC during several of these, and I found no mechanism for a slowdown, but the PR's median is 4 % lower and its third run is below 80 % of main's, so a small cost is not ruled out. Runs 1 and 2 of the PR and run 3 of main peaked at about 15.5 GB, the others at about 15.1 GB. A run on a quiet PC is welcome.
Not tested
PENDINGand nothing takes that count back (existing behaviour, read in the code, not reproduced). Where that happensPENDINGstays above zero and every look uses the full scan, as before.recheck_gpu_view_sources(aSourceenum in place ofsrc) and adds a second path there throught.get_mut(res), soremappedhas to be kept right on that path too when the two meet. #1182 (open) touches this file only in the tests module (one new GPU test), plusvram.rsandkernelx.rs; it does not change the code here.AI use
Table::recheck_sourcesand its test) and updated this description for it.remappedin step, with a test 7d92772462@pvfreis on GitHub · 2026-11-24 14:06 UTC · original
Follow-up at
7d92772. I read the diff only; nothing was built or run here.remappedupdate is nowTable::recheck_sources(title_textures.rs:131-147), with the same two loops in the same order.recheck_gpu_view_sourcescalls it at:516. The guard there is a temporary, so the lock is still released beforeTEXTURES_GENis bumped, as before.a_source_that_flips_keeps_the_sparse_selection_exact(:1690-1752) checks that each look takes the sparse path, asserts theremappedset after every flip, and comparescollect_uploadswithlinear_upload_keys. Dropping the update would fail it.PR checksnow fails at7d92772because the Regression run block names3d5e3b1, and the check wants anxcl-smokeblock made on7d92772.CIshowsaction_requiredat this head, so it has not run yet.Reply by Claude Code (Claude Opus 5.5); checked by a person before posting.
@fromthemoonx on GitHub · 2026-11-24 12:02 UTC · original · edited 2026-11-24 14:07 UTC
Rerun on the new head
7d9277246277acb85a0a982a4a6b29ff1a1640d4(same machine, debug), which your follow-up did not run as a whole:cargo build --workspace, thencargo test --workspace --no-fail-fast -- --test-threads=4: 739 passed, 0 failed, 42 ignored;placed_title_textures_share_vram_and_preserve_pixelspasses here, as beforemain930e8b4(no conflict): 753 passed, 0 failed, 42 ignoredremappedupdate, as you say: with the tworemappedlines inTable::recheck_sourcesremoved,a_source_that_flips_keeps_the_sparse_selection_exactfails withleft: [25], right: [5, 25]hle::d3d12x::title_textures+hle::d3d12x::vramtests, 10 runs: 10 of 10 passed (22 passed, 1 ignored each)main930e8b4The first run, on
3d5e3b1, follows unchanged.NVIDIA run, since Not tested lists NVIDIA. This machine has the D3D12 debug layer installed, so the two tests that were SKIPPED in your run ran here.
Tested
NVIDIA GeForce RTX 3060 12 GB (32-lane waves), driver 32.0.16.1088; AMD Ryzen 7 5700X; native Windows 11 Pro 26H2 (build 26300.9974), Graphics Tools (D3D12 debug layer) installed; rustc 1.100.0
stable-x86_64-pc-windows-msvc; DXC 1.9.2602.17Exact head
3d5e3b139717b95ef16d44830e7615c6535a2079(on its base384f7f7), debug:cargo build --workspace, thencargo test --workspace --no-fail-fast -- --test-threads=4: 738 passed, 0 failed, 42 ignored (lib 695 / 0 / 22). Notable:dirty_texture_candidates_match_the_full_scanpassedplaced_title_textures_share_vram_and_preserve_pixels,transitions_apply_when_their_list_is_submitted,d32s8_targets_take_their_own_size_of_video_memorytest_title_draws_with_a_root_signature_under_the_debug_layer,uploads_start_from_each_subresources_stateMerged onto current
main47efa2e(no conflict): 742 passed, 0 failed, 42 ignoredhle::d3d12x::title_textures+hle::d3d12x::vramtests on the merged tree, 10 runs: 10 of 10 passed (23 passed, 1 ignored each)D3D12 debug layer: the e2e test title's
XCL_D3D12_DEBUG=1run logs the same set of debug-layer errors and warnings on the merged tree as onmain.Release benchmark (
cargo test --release -p xcl --lib bench_dirty_texture_candidates -- --ignored --nocapture), one run, µs per submit for the selection:Same shape as yours: the full scan is faster on this CPU, so the ratios differ, but the PR's times are close to yours.
SKIPPED (no wave64 on this adapter):
gpu_geometry_wave32_prefix_count_over_a_mask,gpu_wave32_program_in_wave64_hardwareNot tested
smoke.ps1here); the benchmark is synthetic, and as you say the saving is per submit, not frame rate.AI use
@JoaoPauluu on GitHub · 2026-11-24 14:21 UTC · original
A regression run under Wine on Linux, on a retail title.
Tested
x86_64-pc-windows-gnu.7d92772as it is (merge base384f7f7) andmain47efa2e, no uncommitted changes. Retail title 1.0.2.1,scripts/linux/smoke.sh(#257) for 60 s, no input. Twelve runs in a row,mainfirst and last, other PRs in between.384f7f7; themainruns are of47efa2e, a later commit ofmain.Regression run
main (first run):
this PR:
The last
mainrun: 1425 frames,exit: 0x0, no device removal, no crash. Under Wine,peak commitreads 0 MB, so these blocks do not check memory.Not tested
AI use
@TG0000 on GitHub · 2026-11-24 13:58 UTC · original · edited 2026-11-24 16:45 UTC
Thank you for the careful review. I checked each point against the code.
Pushed
7d92772on top of3d5e3b1(no force push):remappedupdate moved intoTable::recheck_sources, so it runs without a GPU. The new testa_source_that_flips_keeps_the_sparse_selection_exacthas 26 textures, flips one source each way (and back, twice) and comparescollect_uploadswithlinear_upload_keysafter every flip. It also flips a shadowed texture. With theremappedupdate removed from the method, it fails.title_textures.rsit only adds one GPU test to the tests module, and it editsvram.rsandkernelx.rs, so it does not touch this code. Listed too.Tested:
cargo test -p xcl --lib d3d12x::title_textures -- --test-threads=4: 14 passed, 1 failed, 1 ignored. The failure isplaced_title_textures_share_vram_and_preserve_pixels(subresource 2 mismatch), which fails the same way on3d5e3b1(13 passed, 1 failed, 1 ignored).cargo clippy -p xcl --lib --tests: no warning on the changed lines. Update:xcl-smokeblocks for the new head7d92772and for main384f7f7are now in the description (1048 and 962 frames, no device removal or crash; other work ran on the PC, so not a timing comparison). The whole workspace was not run again for this commit.AI-assisted: this follow-up was written and tested by Claude Code with Claude Sonnet 5.5.
@DavidM1911 on GitHub · 2026-11-25 08:36 UTC · original
Verification on RTX 3060 Ti (Windows 11), branch merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, ~26 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.)Thanks!
@oni-swr on GitHub · 2026-11-25 18:33 UTC · original
RX 7800 XT (RDNA3, wave32/wave64) report on exact head
7d9277246277acb85a0a982a4a6b29ff1a1640d4(as is, on its base384f7f7f; no merge with currentmain, which merges cleanly).Tested
dxc.exefrom Windows SDK 10.0.26100.0.cargo test --workspace --no-fail-fast -- --test-threads=4on this head: 739 passed, 0 failed, 42 ignored (19 targets); lib: 696 passed, 0 failed, 22 ignored.mainatc9ee916a: 1330 passed, 2 failed, 46 ignored (24 targets). The 2 failures aregpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1(seed 722: CPU0x7fffffff, GPU0x1) andgpu::recomp::lower_dxil::tests::a_bridged_mask_write_where_one_half_is_elsewhere_meets_no_barrier.fuzz_validate_and_gpu_1in its output), so the 0 failures here say nothing about them.hle::d3d12x::title_textures::tests::*(includinga_lazily_mapped_page_in_a_gpu_view_is_its_own_source,a_source_that_flips_keeps_the_sparse_selection_exact)SKIPPED: none printed on this older head (the f16 and heap-window tests that skip onmainare not in its output).Not tested
scripts/smoke.ps1run (noxcl-smokeblocks): I did not run an untrusted retail executable. This is a test-suite report only, not the regression run the PR needs.AI use
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.