Skip to content

[upstream #1086] D3D12.X: seek to textures overlapping sparse CPU writes - #70

Closed
ufoptg wants to merge 1 commit into
mainfrom
upstream-pr/1086
Closed

ufoptg wants to merge 1 commit into
mainfrom
upstream-pr/1086

Conversation

@ufoptg

@ufoptg ufoptg commented Nov 24, 2026

Copy link
Copy Markdown
Owner

Each 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_va placement 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 xcl-dev#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_active keep 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]).

Tested

  • Ryzen 9 5900X, Radeon RX 6800 (driver 32.0.21045.29003), Windows build 26300, Rust 1.100.0 MSVC. Debug workspace and release xcl builds.
  • 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 on main 384f7f7. The same three fail in both: placed_title_textures_share_vram_and_preserve_pixels (3D texture, subresource 2 mismatch), and transitions_apply_when_their_list_is_submitted and d32s8_targets_take_their_own_size_of_video_memory on the lock it poisons.
  • SKIPPED in both, no D3D12 debug layer: 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.
  • 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:
textures pages written full scan this PR
512 4 4.029 0.307 13.1x
512 16 6.199 1.897 3.3x
4096 4 40.353 0.368 109.5x
4096 16 53.251 2.173 24.5x
8192 4 99.095 0.406 244.2x

The ratio varies by run: two earlier runs of the 4096 / 4 row measured 72x and 90x.

Regression run

The first pair, main then PR. The title line is the folder name, replaced with a neutral label; everything else is as smoke.ps1 printed it.

main:

xcl-smoke v1
commit: 384f7f7f8c79fa4d4dee59336d650a4021af4c7e
gpu: AMD Radeon RX 6800
title: retail-title-1.0.2.1
seconds: 45
exit: 0x0
frames shown: 1036 (PresentX 1037)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 15113 MB

PR:

xcl-smoke v1
commit: 3d5e3b139717b95ef16d44830e7615c6535a2079
gpu: AMD Radeon RX 6800
title: retail-title-1.0.2.1
seconds: 45
exit: 0x0
frames shown: 977 (PresentX 977)
presents per 2 s (last 3): 60 60 46
device removals: 0
crashes: 0
peak commit: 15513 MB

All five pairs of those two builds, frames shown (no crash and no device removal in any):

pair run first main PR
1 main 1036 977
2 main 1039 991
3 PR 986 787
4 PR 1045 1011
5 PR 1017 1034

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

AI use

  • Codex in T3 Code with GPT 6.2 Sol wrote the change, the test and the benchmark. Claude Code with Claude Opus 5.5 reviewed the diff, ran the tests, benchmark and smoke runs, and wrote this description.

Mirror of xcl-dev#1086 (auto-synced, do not edit).

Use the placement index to select uploads when a submit dirties a few pages. Check remapped CPU sources separately and preserve resource order. First uploads and dense writes still use the full scan.

Co-Authored-By: GPT 6.2 Sol <noreply@openai.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ufoptg

ufoptg commented Nov 25, 2026

Copy link
Copy Markdown
Owner Author

Upstream PR xcl-dev#1086 was closed or merged.

@ufoptg ufoptg closed this Nov 25, 2026
@ufoptg
ufoptg deleted the upstream-pr/1086 branch November 25, 2026 00:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants