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

Open
Foniass wants to merge 1 commit from upstream-pr/3477 into main
Foniass commented 2026-11-29 23:37:12 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-11-29T23:37:12Z.


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 d8c75c5c, rebased on main 86e86fcb (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

<!-- greyfinch-sync:ivall/xcl:issue:5556380949 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3477). Originally posted by [Foniass](https://github.com/Foniass) on 2026-11-29T23:37:12Z. --- 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 d8c75c5c, rebased on main 86e86fcb (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](https://claude.com/claude-code)
fromthemoonx commented 2026-12-01 17:36:41 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by fromthemoonx on 2026-12-01T17:36:41Z.


merge-check
base: 6bfb5c5153
head: d8c75c5c13
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)
<!-- greyfinch-sync:ivall/xcl:comment:7319572046 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3477#issuecomment-7319572046). Originally posted by [fromthemoonx](https://github.com/fromthemoonx) on 2026-12-01T17:36:41Z. --- merge-check base: 6bfb5c5153ccc23517daf30aa1071ddb0fadb53c head: d8c75c5c135a368f4ea46efe026dad572d3abe74 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)
vasanex commented 2026-12-02 01:22:59 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by vasanex on 2026-12-02T01:22:59Z.


merge-check claim
head: d8c75c5c13

<!-- greyfinch-sync:ivall/xcl:comment:7331640634 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3477#issuecomment-7331640634). Originally posted by [vasanex](https://github.com/vasanex) on 2026-12-02T01:22:59Z. --- merge-check claim head: d8c75c5c135a368f4ea46efe026dad572d3abe74
vasanex commented 2026-12-02 01:33:30 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by vasanex on 2026-12-02T01:33:30Z.


merge-check
base: 1c8b551475
head: d8c75c5c13
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 1c8b5514: 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.

<!-- greyfinch-sync:ivall/xcl:comment:7331842642 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3477#issuecomment-7331842642). Originally posted by [vasanex](https://github.com/vasanex) on 2026-12-02T01:33:30Z. --- merge-check base: 1c8b551475e1e7bfe48f94448492a4c3544a2e0f head: d8c75c5c135a368f4ea46efe026dad572d3abe74 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 1c8b5514: 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.
bmjask commented 2026-12-02 14:13:09 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by bmjask on 2026-12-02T14:13:09Z.


@Prime1997 could you take a look at this one for review and merge? My automated review notes are above, if any.

<!-- greyfinch-sync:ivall/xcl:comment:7348181877 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3477#issuecomment-7348181877). Originally posted by [bmjask](https://github.com/bmjask) on 2026-12-02T14:13:09Z. --- @Prime1997 could you take a look at this one for review and merge? My automated review notes are above, if any.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/3477:upstream-pr/3477'
git switch 'upstream-pr/3477'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/3477'
git switch 'upstream-pr/3477'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/3477'
git switch 'upstream-pr/3477'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/3477'
git switch 'main'
git merge --squash 'upstream-pr/3477'
git switch 'main'
git merge --ff-only 'upstream-pr/3477'
git switch 'main'
git merge 'upstream-pr/3477'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
xcl-dev/xcl!3477
No description provided.