Skip to content

D3D12.X: a look finds the blocks new to the watched ranges by their change - #3477

Open
Foniass wants to merge 1 commit into
xcl-dev:mainfrom
Foniass:d3d12x-look-new-blocks
Open

Foniass wants to merge 1 commit into
xcl-dev:mainfrom
Foniass:d3d12x-look-new-blocks

Conversation

@Foniass

@Foniass Foniass commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

Port of raylitebull's amd-dev commit 5ff2b663. To find blocks newly added to the watched ranges, hot_runs rebuilt a set of every 2 MiB block of every range each time the ranges changed, while holding HOT, which the walk thread also takes. A retail title's world has about 1,800 such blocks. new_blocks now compares the sorted ranges with the last look's:

  • an unchanged range has no new blocks;
  • a block of a changed range is new when no old range touches it.

The result is the set's, but only changed ranges are walked.

What is in it

  • crates/xcl/src/hle/d3d12x/title_textures.rs: new_blocks, hot_runs using it (the known set goes), and the test new_blocks_are_those_no_old_range_meets. The test checks against a set of all old blocks for ranges grown, shifted, merged, new, gone, and in part of a block.
  • Left out from amd-dev: its reasons for a hot block (HOT_NEW, look_stats::HOT_WHY), which main does not have. A new block is put in with its time only, as before.

Review: new_blocks relies on the ranges being sorted and apart. watch_ranges makes them so, and hot_runs already relied on that. If two ranges ever overlapped, the error could only go one way: extra blocks marked hot, never a missed one.

Tested

  • NVIDIA GeForce RTX 5070 Ti (driver 32.0.16.2114), AMD Ryzen 7 7800X3D, Windows 11 build 26300, Rust 1.100.0 (stable-x86_64-pc-windows-msvc), debug tests, release smoke
  • cargo test -p xcl --lib hle::d3d12x::title_textures: 66 passed, 0 failed, 1 ignored
  • cargo test --workspace --no-fail-fast -- --test-threads=4 on d8c75c5, rebased on main 86e86fc (5070 Ti): 2890 passed, 0 failed, 51 ignored. SKIPPED: 28 notices, almost all no wave64 (the others: no D3D12 debug layer, heap windows off, driver cache needs Developer Mode). The narrower runs listed here are from before the rebase.
  • Retail title: 60 s smoke run below.

Regression run

main:

xcl-smoke v1
commit: 86e86fcb33f94fa5d0c809d9b50af7b84bf49cce
gpu: NVIDIA GeForce RTX 5070 Ti
title: 3cb1d8e0
seconds: 60
exit: 0x0
frames shown: 1608 (PresentX 1608)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 15766 MB

this PR:

xcl-smoke v1
commit: d8c75c5c135a368f4ea46efe026dad572d3abe74
gpu: NVIDIA GeForce RTX 5070 Ti
title: 3cb1d8e0
seconds: 60
exit: 0x0
frames shown: 1596 (PresentX 1596)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 16958 MB

Not tested

  • The time saved: the 4 µs vs 1.4 ms in the commit is the test's own timing in a debug build, not a release build or a game
  • AMD GPUs; a 60 s run does not reach the title's world

AI use

  • Claude Code with Claude Opus 5.5: ported the commit to main (without the hot-block reasons), reviewed it, ran the tests and the smoke runs, wrote this description.
  • Original code: raylitebull's amd-dev 5ff2b663.

🤖 Generated with Claude Code

@github-actions github-actions Bot added area:d3d12 D3D12.X runtime, command lists, resources, sparse memory gpu:amd Code is specific to AMD / RDNA / wave64 GPUs (scope tag; see needs:amd-test) labels Nov 29, 2026
…hange

`hot_runs` makes a block new to the watched ranges hot. To find those it
kept a set of all blocks (2 MiB) of the ranges of the last look and, each
time the ranges changed, made the set again over every block of every
range while holding `HOT` (the walk thread takes it too). The ranges are
made again whenever a tile is mapped, a texture is placed, a GPU-view page
is shown: in a retail title's world that is ~3.5 GB in 16 ranges, ~1,800
blocks, and the ranges change between many of the submits.

Now `new_blocks` compares the ranges with the last look's (both sorted and
apart, as `watch_ranges` makes them): a range found among the old ones as
it is has no new block, and a block of a changed range is new when no old
range meets it, which is what the set said. 16 ranges with one changed:
4 µs against 1.4 ms for a set of all their blocks (debug build, the test's
own timing; not measured in a release build or a game).

Test: new_blocks_are_those_no_old_range_meets (against a set of all the
old blocks: ranges grown, shifted, merged, new, gone, in part of a block).

Ported from amd-dev without its reasons for a hot block (`HOT_NEW`,
`look_stats::HOT_WHY`), which main does not have: a new block is put in
with its time only, as before.

(cherry picked from commit 5b660277a9460246eca668b144872fe4c66c1594)
(cherry picked from commit 5ff2b66)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Foniass
Foniass force-pushed the d3d12x-look-new-blocks branch from 62895b1 to d8c75c5 Compare November 30, 2026 23:07
@github-actions github-actions Bot added needs-pr-check Failing the PR description check (CONTRIBUTING.md) and removed needs-pr-check Failing the PR description check (CONTRIBUTING.md) labels Nov 30, 2026
@Foniass Foniass mentioned this pull request Dec 1, 2026
@fromthemoonx

fromthemoonx commented Dec 1, 2026 •

Copy link
Copy Markdown

merge-check
base: 6bfb5c5
head: d8c75c5
merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2905 passed, 0 failed, 51 ignored (base: 2904 passed, 0 failed, 51 ignored); SKIPPED: 25 (22 no wave64, 2 no heap windows, 1 no GPU_UPLOAD heaps), the same set as base; failing: none
review: read the whole diff (title_textures.rs, +93 -15). No correctness problem found.

  • new_blocks gives the old known-set result:
    • A block of a changed range counts as new exactly when no old range overlaps it, which is when the old set lacked it.
    • partition_point on a + n <= lo and the binary_search skip of unchanged ranges both rely on the ranges being sorted and apart. watch_ranges makes them so (the description says this too).
    • h.ranges becomes the last look's ranges, as known did.
  • new_blocks_are_those_no_old_range_meets: 3 of 3 runs passed. Its timing line: 6.6-8.5 µs a call against 1.34-1.39 ms for the set of all blocks (16 ranges, one changed).
  • Mutation: met comparing a <= hi (a range that starts right at the block's end counts as meeting it) fails the test. Good.
  • Mutation: the unchanged-range skip matching on base only (old.iter().any(|&(a, _)| a == base)) fails the test. Good.
  • The test checks new_blocks against the old algorithm. hot_runs itself is reached only through the runtime path, which this machine has no title for.
  • No retail title on this machine: the look on a real title's watched ranges was not run here.
    performance: not measured on a title. The unit test's timing above shows the per-change cost going from milliseconds to microseconds while HOT is held.
    verdict: safe to merge
    hardware / tool and model: RTX 3060 12 GB (610.88), Ryzen 7 5700X, Windows 11 Pro 26300 / Claude Code (Claude Opus 5.5)

@github-actions github-actions Bot added needs-1st-check Passes gates; needs first independent merge-check (#3041) needs:amd-test Needs a test report or merge-check on an AMD GPU needs-2nd-check Has 1 safe merge-check; needs second independent check (#3041) and removed needs-1st-check Passes gates; needs first independent merge-check (#3041) labels Dec 1, 2026
@vasanex

vasanex commented Dec 2, 2026

Copy link
Copy Markdown

merge-check claim
head: d8c75c5

@vasanex

vasanex commented Dec 2, 2026

Copy link
Copy Markdown

merge-check
base: 1c8b551
head: d8c75c5
merge: clean (merged tree 8363e23e, git diff --check clean)
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2910 passed, 0 failed, 51 ignored; SKIPPED: 25 (22 no wave64, 2 no heap windows, 1 cannot disable the driver cache), the same set as on the base; failing: none. Base alone, same machine: 2909 passed, 0 failed, 51 ignored. The new test new_blocks_are_those_no_old_range_meets passes.
review: whole diff read (one file, title_textures.rs, +93/-15). No finding. new_blocks gives what the removed known set gave: a block was in the set exactly when a range of the last look touched it, and met asks that of the sorted, disjoint old ranges by a partition point; a range found unchanged in the old list is skipped, which is right because all its blocks were touched by itself. Both lookups need the ranges sorted by start and apart, which the description says watch_ranges guarantees; the test compares against the set form for grown, shifted, merged, new, gone and partial-block ranges. The first look (no old ranges) makes every block hot, as before. The test prints a timing line and asserts nothing about it.
performance: 60 s smoke of the same title, release, default settings, same machine, one run each. Base 1c8b551: 1608 frames shown, presents per 2 s (last 3) 60 60 61, 0 device removals, 0 crashes, peak commit 19911 MB. Merge result (local merge commit): 1681 frames shown, 60 60 60, 0 device removals, 0 crashes, peak commit 19839 MB. No difference outside the spread; the start and menu phase has few watched blocks, so the saving under HOT in a world is not shown here. By default it does less work than main whenever the ranges change, reasoned.
verdict: safe to merge
hardware / tool and model: NVIDIA GeForce RTX 3080 10 GB (driver 621.40), AMD Ryzen 9 7950X, Windows 11 Pro 26200, rustc 1.100.0, debug suite and release smoke / Claude Code with Claude Fable 5.2. Run and posted without a human check of each point.

@github-actions github-actions Bot added ready-to-merge Has 2 independent safe merge-checks on current head (#3041) and removed needs-2nd-check Has 1 safe merge-check; needs second independent check (#3041) needs:amd-test Needs a test report or merge-check on an AMD GPU labels Dec 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:d3d12 D3D12.X runtime, command lists, resources, sparse memory gpu:amd Code is specific to AMD / RDNA / wave64 GPUs (scope tag; see needs:amd-test) ready-to-merge Has 2 independent safe merge-checks on current head (#3041)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants