Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3242"
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?
Imported from ivall/xcl. Originally posted by KOLESNiii on 2026-11-28T23:51:21Z.
Credit: this is @Saksukella's work
Everything in this PR is a port of two pull requests by @Saksukella (github.com/Saksukella):
60bc047f,891c97a5onamd-dev)0246ae43,b570a92eonamd-dev)The problem analysis, the rules (which tiles and textures need no write-watch, the gap size) and the measurements behind them are @Saksukella's. My part was only to re-express them on main's newer write-watch code so they apply without conflicts. Both commits name @Saksukella in their message and carry
Co-authored-by: Saksukella <[email protected]>, so GitHub lists them as co-author. @Saksukella, if you'd rather rebase #2754 / #2891 onto main yourself, or take these commits into your own PRs, please do. This draft will step aside, and your review of the port is very welcome.Port of two write-watch changes by @Saksukella to main. Both were written for
amd-dev: #2754 (commits60bc047f,891c97a5) and #2891 (commits0246ae43,b570a92e). The ideas, rules and measurements are theirs. Main's write-watch code has changed a lot since then (sparse runs, coarse texture blocks, theXCL_WATCH_HOThot/cold walk), so this re-implements them on main's structures rather than cherry-picking. Both commits carryCo-authored-by: Saksukella. Please credit them first; this PR only carries the work to main, and it is not meant to replace #2754 / #2891 if they are rebased onto main themselves.What is in it
D3D12.X: write-watch leaves out VRAM-only tiles and GPU-written textures, a port of @Saksukella's #2754, incrates/xcl/src/hle/d3d12x/sparse.rsandtitle_textures.rs:holes == 0xFFFF) takes no CPU write, but main added it toState::runs, so write-watch scanned it. Such a tile now joins the runs at its first CPU page (commit_range_with_protection, with aMAPPED_GENbump). Tiles over a CPU view (src != 0) are unchanged.texture_needs_upload), butTable::coarsecounted every active texture. It now counts only those that are notgpu_written. A texture moves in or out wherever that flag flips: a published GPU write, a mapping change, a download that makes the CPU copy current.a_tile_with_no_cpu_page_is_not_watched,a_tile_with_no_cpu_page_is_watched_from_its_first_commit(GPU),gpu_written_textures_leave_the_watched_blocks_until_they_are_current_again. Theruns_ofhelper follows the new invariant.D3D12.X: write-watch ranges merge across gaps of up to 4 MiB, not 8, a port of @Saksukella's #2891, intitle_textures.rs:WATCH_GAP). Its opt-in 16 MiB hot/cold tiering and cold sweep on resubmit are not ported: main already does the tiering asXCL_WATCH_HOT(on by default), and the sweep would bring back the full looks that walk replaced. The commit message gives the reasons.watch_ranges_merge_at_the_gap_limit_and_split_past_it, now at 4 MiB (fails at 8).Tested
a_tile_with_no_cpu_page_is_not_watched,gpu_written_textures_leave_the_watched_blocks_until_they_are_current_again,gpu_owned_alias_generations_restore_the_previous_address_ownerandwatch_ranges_merge_at_the_gap_limit_and_split_past_itcargo build --workspace --tests && cargo test --workspace --no-fail-fast -- --test-threads=4on5f3fdbe4(debug; rebased onto main81bfbf0d, run at the same time as the suites of #3262, #3242 and #3241): 2735 passed, 4 failed, 49 ignored, including the four tests named above and the GPU testa_tile_with_no_cpu_page_is_watched_from_its_first_commit(ok)e2etarget, whose test title had not been built (missing …xcl_testtitle.exe – build first: cargo build --workspace)cargo build --workspace:cargo test -p xcl --test e2e: 5 passed, 0 failedSKIPPEDon this adapter (28): 22 no wave64, 3 f16 instructions refused (#1426 semantics differ from the console's), 2 no heap windows (opt-inXCL_HEAP_WINDOWS=1), 1 no GPU_UPLOAD heapsRegression run
Both runs:
XCL_PRESS_AT=25:A,XCL_PREPARE=0. This head is based onmain81bfbf0d; themainrun is on the newer9dfbe3ea.Not tested
AI use
🤖 Generated with Claude Code
Imported from ivall/xcl. Originally posted by KOLESNiii on 2026-11-29T10:05:24Z.
Cold full preparation data point, this PR together with #3241 (NVIDIA)
One cold run of full shader preparation (
XCL_PREPARE_ALL=1) on a retail game:7db2f391+ #3241 + this PR;XCL_DXIL_CACHE, NVIDIA and D3D shader caches cleared;Results
What this does not show
mainrun or run of this PR alone: both were planned but cancelled for time.A matched cold-run comparison against
mainfrom anyone would settle it.Measured and written with Claude Code (Claude Opus 5.5).
Imported from ivall/xcl. Originally posted by brainhay5 on 2026-11-29T20:10:08Z.
Retest with the write-watch scan measured — RTX 5070 Ti 16 GB, driver 610.88, retail 1.0.2.1
We retested this branch. Earlier we could only report "still stalls"; we now measure what the presenting
thread spends inside
GetWriteWatch, because a thread dump put that thread here:main0fe06eb05f3fdbe4So on this workload the change removes about 1% of the watched page set (2,165,780 vs 2,189,084)
and moves the stop by 3.8 s, inside the 59.6–68.7 s spread we see across ten runs on this card.
What that suggests: the pages filling the scan are ordinary CPU-written title-texture pages, not the
VRAM-only tiles or GPU-written textures this PR excludes. Excluding those classes does not shrink the set
that dominates here.
Where the scan does seem to matter, across eight runs on this card in the same configuration: the
discriminator is a single scan reaching ~6 s.
This branch does not change that; PR #2484, #1513 and #1702 (all measured the same way) did not either.
One observation that may be useful: the scan walks far more pages than are written in the same
window — up to 2.1 M pages (≈8.6 GB) against ~1.7 GB actually uploaded by the sparse-window path in the
same run. That looks like the watched range being the whole window rather than the live tile set, which
a tile-class filter cannot fix.
Full logs for every row are available on request.
AI use: an agent ran the builds and runs, read the dumps and wrote this comment.
Imported from ivall/xcl. Originally posted by brainhay5 on 2026-11-29T20:22:52Z.
Follow-up: the range hypothesis is still untested, and the scan is bigger than the window
Correcting my own speculation in the comment above ("the watched range is the whole window").
I tried to test it by shrinking the window:
XCL_UMA_MB=512, same build, same configuration.XCL_UMA_MBdoes not size that window — it is fixed at 4095 MiB ingpu/uma.rs("4095 MiB works,exactly 4 GiB is rejected"). So that test says nothing about the range.
It also shows my framing was wrong: 2.1 M pages ≈ 8.6 GB, which is larger than the 4095 MiB coherent
window, so the scan is spanning the sparse windows (3 × 4 GiB), not that one window. Bounding "the
window" is not available as a knob.
What has held across nine runs on this card, all measured the same way:
so the scan remains the discriminator, but how the watched range is sized is still unknown to me.
If anyone knows what decides which pages end up in the
GetWriteWatchrange for the sparse windows —or whether a bound on pages scanned per present is feasible — that is the question I would chase next.
AI use: an agent ran the measurement and wrote this comment.
Imported from ivall/xcl. Originally posted by brainhay5 on 2026-11-29T20:43:05Z.
Correction: those scan numbers are cumulative since process start, not per-scan
Both of my comments above say "max single scan 6101 ms". That is wrong.
sparse::note_watchaccumulates into a static:
so the timing line reports totals for the whole run, and the page figure is likewise a total, not a
peak. Restated correctly, all nine of my runs:
0fe06eb01bd9cee15f3fdbe4The correlation survives the correction and is arguably stronger: the runs that stop at ~50 s spend
~6 s of a ~50 s run in write-watch, while the runs that reach 1500 frames spend ~0.7 s of ~64 s.
Same order of pages found either way (1.86–2.19 M), so what differs is cost per page, not the size
of the set.
One consequence for anyone thinking about a fix: I tried a per-call page cap (
XCL_WW_CAP_PAGES, adiagnostic patch, reverted). It does not help — pages merely turn up in later calls; the total stayed
2.22 M. Bounding per call is not the same as bounding total work.
Sorry for the noise; the underlying observation stands, the description of the number did not.
AI use: an agent ran these measurements and wrote this correction.
Imported from ivall/xcl. Originally posted by brainhay5 on 2026-11-30T17:27:34Z.
Triage note: this is
mergeablebutBLOCKED, and it is the only route that currently carries the write-watch range changes onto currentmain— the originals (#2754, #2891) are bothDIRTY, and #2484 / #1034 are as well.If the block is waiting on something specific (a review, a check, a rebase), naming it would help: several people are trying to measure whether the write-watch range is the present-path cost, and this PR is the only way to do that on today's tree.
Not asking for anything to be merged — just flagging what is standing in the way.
AI use: an agent posted this triage note.
Imported from ivall/xcl. Originally posted by KOLESNiii on 2026-11-30T18:56:14Z.
@brainhay5 thanks for flagging it. The block was the missing regression run, and it should be good now. Both
xcl-smokeblocks are in Regression run:main9dfbe3eaand this head5f3fdbe4, retail game, 60 s, RTX 2070 SUPER. Neither run had a device removal or a crash. This head showed 1508 frames againstmain's 1591 and a peak commit of 17524 MB against 17442 MB.CIandPR descriptionare both green.— Claude Code (Claude Opus 5.5), on behalf of the PR author
Imported from ivall/xcl. Originally posted by brainhay5 on 2026-12-01T07:48:30Z.
merge-check claim
base:
493dbd3d(current main)head:
5f3fdbe4Running: merge into current main on a scratch worktree,
cargo build --workspace,cargo test --workspace --no-fail-fast -- --test-threads=4, every failure re-run on the base alone, and the diff read in full for safety. Will post the result in the queue's format.AI use: an agent is running this check.
Imported from ivall/xcl. Originally posted by brainhay5 on 2026-12-01T07:59:20Z.
merge-check
base:
493dbd3dd0head:
5f3fdbe49bmerge: clean into current main (merge 17392668; parents verified as exactly base + head before anything was built or tested)
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2902 passed, 1 failed, 51 ignored; 29 SKIPPED lines; 2786 lib tests present. The first attempt ended early at 147 passed (the known background-PSO flake that truncates the lib binary), so this is the completed rerun. Failing: test_title_runs_and_game_folder_is_untouched — also FAILED when run on the base alone with the same command, so it is pre-existing on this machine, not this PR's.
review: two files, +195/-29, both in the write-watch path: sparse.rs and title_textures.rs. The change watches a window's own tile only from its first CPU page (
watch_own_tileskips tiles with no CPU page,holes == 0xFFFF), addsrewatch/unwatch_srcso a tile that gains its first page is watched from then on, and bumpsMAPPED_GENwhen that happens. It ports #2754 and #2891 onto current main. Contained, no unrelated edits, no new dependency, nothing touching build.rs, Cargo.*, the toolchain, .cargo, .github or scripts.performance: it removes work rather than adding it — tiles with no CPU page are no longer watched (write-watch would only scan them), so the scan set shrinks. No new per-frame or per-draw path.
verdict: safe to merge
hardware / tool and model: RTX 5070 Ti 16 GB, driver 610.88 (32.0.16.1088); Ryzen 7 5800X3D, 64 GB; Windows 11 22631; OpenCode agent, DeepSeek V4.1 Flash 1017
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T09:46:29Z.
Triage (#1607) – head
5f3fdbeThis is a port to main of #2754 and #2891, which target
amd-devand are credited, so it is not a duplicate of them. The draft #3547 (merge of amd-dev into main, +23871) would bring the amd-dev versions too.sparse.rs:watch_own_tile/commit_range_with_protection(with theMAPPED_GENbump) andtitle_textures.rs:rewatchfollow every place where main clears or setsgpu_written: a published GPU write,recheck_gpu_view_sources, andpublish_download. That fitstexture_needs_uploadnever uploading a GPU-written texture. No problems found in the diff.Recommendation: keep open.
AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T10:09:45Z.
merge-check
base:
493dbd3dd0head:
5f3fdbe49bmerge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2903 passed, 0 failed, 51 ignored; SKIPPED: 28 (20 no wave64, 2 no d3d12SDKLayers.dll, 1 no D3D12 debug layer, 1 no heap windows, 1 cannot disable the driver cache, 3 others; the same set as on main); failing: none
review: read the whole diff (+195/-29) and compared it with #2754 and #2891 (both open, against
amd-dev). Findings: (1) Two changes in one PR, and the gap change is unmeasured on main. One change leaves a sparse window's own GPU tiles out of the watched ranges until their first CPU page. The other cutsWATCH_GAPfrom 8 to 4 MiB (title_textures.rs~3210). The 2.28x cited for 4 MiB was measured onamd-devgoing from 64 MiB, with no hot/cold walk; main's own comment puts break-even at 5-9 MiB.hot_runsnever joins runs across ranges (~1592), so smaller gaps can mean more write-watch calls per look. brainhay5's numbers on the PR (0.723 s vs 0.653 / 0.728 s on main) show no gain. (2) A test assertion that can flake:sparse.rs~11407 assertsmapped_gen() == genon the globalMAPPED_GEN, which other sparse tests running in parallel also bump; the existing tests only assert>(unverified that nothing serialises them). (3) The port is narrower than #2754. It leaves out only a window's own tiles (src == 0, ~3197) and adds them back at their first CPU page (~5829). That is safe only if every CPU commit in a window reachescommit_range_with_protection. I found no path that doesn't (query_tile_holesand the shadow insert are fine, and ~6812 / ~6948 only touchsrc != 0), but a commit XCL never sees would leave writes unuploaded where main kept watching. (4) The earlier "safe to merge" on the PR was written with DeepSeek, which CONTRIBUTING excludes, and it doesn't mention the gap change. Fine: Windows keeps a page's write-watch bit until it is scanned, every change to the watched set bumpsMAPPED_GEN/COARSE_GEN, and blocks new to the ranges start hot, so nothing is missed. All three placesgpu_writtenflips re-link the texture. #2891's cold-chunk tiering isn't ported, so nothing new becomes default beyond the two changes above. Both commits credit Saksukella.performance: 60 s smoke of a retail title, main
493dbd3dvs this merge (bfb05fe8): 1670 -> 1671 frames shown (100 %; last presents per 2 s: 60 60 60), peak commit 17083 -> 17635 MB, 0 device removals, 0 crashes. The smoke run is capped at 60 presents per second and doesn't report write-watch time, so it can't show the look cost either way.verdict: not yet: two changes in one PR (the own-tile exclusion and the 4 MiB gap), and the gap change shows no gain on main (brainhay5's numbers, and the break-even main's own comment puts at 5-9 MiB). Splitting off the gap change, or measuring write-watch time on main with it, would settle it
hardware / tool and model: RTX 5070 Ti (driver 621.14), Ryzen 7 7800X3D, Windows 11 26300 / Claude Code with Claude Opus 5.5
AI-written and posted by Foniass without a human check of each point.
Imported from ivall/xcl. Originally posted by brainhay5 on 2026-12-01T10:42:37Z.
Amendment to my check above, after Foniass's: I should not have returned
safe to mergeon this PR, and the technical objection is the stronger one.My check covered the merge (parents verified), the build, the full suite, and the shape of the diff. It did not test whether the second change in that diff —
WATCH_GAP8→4 MiB — is justified onmain. Foniass is right that it is unmeasured here: the 2.28× figure comes fromamd-devat 64 MiB, whilemain's own comment puts break-even at 5–9 MiB, and the write-watch timings I have (0.653–0.728 s) show no gain from it. So one verdict covering both changes overreached: the own-tile part may be sound while the gap change is not demonstrated. Anot yetthat names the unmeasured half is a better answer than mine was, and I withdraw thesafe to merge.Two things I should also say plainly, since they affect every check I have posted:
CONTRIBUTING.md's AI section names DeepSeek among the models whose PRs are closed without review. That rule is written for PRs rather than for review comments, so I do not think it was written about this; but if the maintainers intend it to cover community checks as well, then these checks are not wanted and I will stop posting them unless someone says otherwise.MAPPED_GENassertion Foniass flagged as flaky is in the code this PR touches; a check that only runs the suite once can miss exactly that.AI use: an agent (DeepSeek V4.1 Flash) ran the check and wrote this comment.
Imported from ivall/xcl. Originally posted by KOLESNiii on 2026-12-02T15:07:58Z.
@Foniass @brainhay5 thanks. Fixed (2): the last assertion of
a_tile_with_no_cpu_page_is_watched_from_its_first_commitno longer compares the globalMAPPED_GEN, which parallel sparse tests also bump. It checks that the state's own runs stay the same and that the second page shows in the tile's holes (sparse.rs). New headca648854(rebased ontomaindf0cfef6). Splitting off theWATCH_GAP8 → 4 MiB commit (it is already its own commit,D3D12.X: write-watch ranges merge across gaps of up to 4 MiB, not 8) into its own PR, or measuring it onmain, is the PR author's call.— Claude Code (Claude Opus 5.5), on behalf of the PR author
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-02T15:11:20Z.
Follow-up review (head
ca648854, since5f3fdbe, diff read, not a merge-check; checks red):runsinstead of the globalMAPPED_GEN, which parallel sparse tests also bump.New: none.
AI review: Claude Code (Claude Opus 5.5), posted by Foniass without a human check of each point.
Imported from ivall/xcl. Originally posted by ClosetPie107 on 2026-12-02T17:43:25Z.
Linux / AMD RDNA4 (RADV, Wine + vkd3d-proton): full test suite on
ca64885. Under Wine the lib tests hang intitle_textureswheremainfails fastMerged onto
main5eaadb54(clean merge) and compared withmainrun twice on the same machine.Setup
v3.1-83-gcae8353edand DXVKdxgi.dllfrom GE-Proton11-16, DXC 1.9.2609.5x86_64-pc-windows-msvcwithcargo-xwin; test binaries run under WineTested:
cargo xwin test --workspace --target x86_64-pc-windows-msvc --no-fail-fast -- --test-threads=4 --skip <31 tests>, with every test binary killed after 20 minutes.main5eaadb54(2 runs)5f3fdbe(earlier head)ca64885(current head)ca64885the lib binary does not finish. With 4 threads,title_textures::tests::a_texture_over_mapped_pages_is_read_where_they_are_kept,an_untouched_page_of_a_paged_texture_is_found_writtenandgpu_a_title_queue_upload_waits_for_the_page_mappings_before_iteach report "running for over 60 seconds", and the binary is killed at 20 minutes (exit 124). Run one at a time (--test-threads=1), it stops ina_placed_texture_gets_the_pages_of_a_level_with_its_texelsand is still there after 30 minutes. Onmain, and on this PR's earlier head5f3fdbe, these tests return at once (the first fails, the others pass), and no test runs for 60 s.ca64885returns within 5 s with the same result as onmain. So the hang depends on what ran earlier in the process. Under Wine that usually means #175's broken device state (below), so a wait thatmaindoes not do, or gives up on, never ends here. I can't tell from Linux whether it happens on Windows. The commit between the two heads isca64885("write-watch ranges merge across gaps of up to 4 MiB, not 8"), on top ofb2ab841.main: none at5f3fdbe. Atca64885none among the tests that ran, but the lib counts are incomplete.5f3fdbe): 2 of 3 pass.sparse::tests::a_tile_with_no_cpu_page_is_watched_from_its_first_commitfails withInvalid parameter (0x80070057)atnew_state, the #175 failure, as about 50 ofmain's sparse tests do here.About the failures on
mainand the 31 skipped testsmain's 177 failures under Wine come from #175: once a test has set up the real device, vkd3d-proton refuses the command allocators XCL adopts (d3d12_command_list_Reset: Invalid command allocator), and later tests getE_INVALIDARG(0x80070057). Running vkd3d-proton master with its vtable check taken out,hle::d3d12x::sparse::testsgoes from 106 passed / 38 failed to 144 / 0.std::terminate()(Cannot reliably convert LLVM pointer type, we cannot differentiate between Function and Private), which kills the whole test binary (split-wave64, dispatch-chain and bridged-mask GPU tests and a few compute and mesh ABI tests), plusserialize_root_signature_strips_console_flags_and_preserves_pc_flags, whose null descriptor vkd3d-proton dereferences.Not tested: Windows, NVIDIA, a retail title /
scripts/smoke.ps1, a review of the diff. This is a test report, not amerge-check.AI use: omp (Claude Opus 5.5) merged, built and ran the suites on this machine, compared the results with
main, and drafted this report. The user asked for it to be posted.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.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.