D3D12.X, KernelX: 2 MiB watch-range blocks and call-budgeted coherent-UMA spans #3677
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3677"
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 iggyvilla on 2026-12-02T07:42:29Z.
TL;DR — Before vs After
origin/amd-dev41aa60ce)amd-watch-tight-ranges)#3649(formerly bundled with hot-gap & hot-retention changes)bvh_want.rs,kernelx.rs,title_textures.rs), standalone onamd-devTable::coarse&mirrors::shown_blocksgranularity16 MiBblocks (1 << 24), pulling up to 16 MiB of adjacent non-texture memory intoGetWriteWatch2 MiBblocks (1 << 21), matchingHOT_BLOCKGetWriteWatch)Table::coh_spanswhen!u.shadowed() && !bvh_want::watching(), call-budgeted viaplan_watch_ranges(..., COH_WATCH_CALLS = 16)so calls never grow unbounded during loading orXCL_WATCH_HOT=0exact_cohsplit / fallback / committed gatingcoh_spansrefcounting,watch_blocks/unwatch_blockscommitted-window gating,exact_cohsplit + committedshown_blocksrouting,shadowed/bvh_want::watching()fallback, andCOH_WATCH_CALLSbudget cappingRX 6650 XT,amd-dev41aa60ce)1654frames (60 61 60,15902 MB)1618frames (60 61 60,16288 MB, 0 removals, 0 crashes)What is in it
Split out from #3649 as a standalone, independently measurable PR on
amd-dev(41aa60ce), addressing review feedback on call budgeting and test coverage:Table::coarse(SRC_COARSE_SHIFT) andkernelx::mirrors::shown_blocks(SHOWN_BLOCK_SHIFT) from16 MiB(24) to2 MiB(21), matchingHOT_BLOCKand trimming adjacent buffer/padding ranges fromcached_watch_rangesandxcl-watch-walk.Table::coh_spans) for textures placed in committed UMA windows (watch_blocks_with/unwatch_blocks_withgated onUma::is_committed).build_watch_ranges(...): when unshadowed and no raytracing BVH tiles are watched (!u.shadowed() && !bvh_want::watching()), skips coarse blocks in committed UMA windows and passescoh_spans+ committedshown_blocksthrough existingplan_watch_ranges(&coh_regions, coh_wanted, COH_WATCH_CALLS)(COH_WATCH_CALLS = 16). This keeps exact texture spans disjoint when few exist while capping totalGetWriteWatchcalls in coherent UMA under load orXCL_WATCH_HOT=0.bvh_want::watching()towatch_key()soWATCH_CACHEinvalidates automatically if BVH watching flips.coh_spans_refcount_and_watch_blocks_gate_by_committed_window,build_watch_ranges_splits_exact_coh_routes_shown_and_falls_back,build_watch_ranges_caps_coherent_uma_calls_to_budget) and updatesa_write_where_a_page_is_kept_is_a_write_to_the_views_showing_itto useSHOWN_BLOCK_SHIFT.Tested
cargo test -p xcl --lib -- coh_spans_refcount build_watch_ranges a_write_where_a_page_is_kept_is_a_write_to_the_views_showing_it): 4 passed, 0 failed.cargo test --workspace --no-fail-fast -- --test-threads=4): 2,961 passed, 13 pre-existing failed, 49 ignored (same pre-existing failures as cleanorigin/amd-dev41aa60ce: 3 RDNA2 f32/NaN tests, 6 parallelsparse/title_texturescontention tests, 2e2etests, 2two_pass_driver_cachetests).cargo build --release -p xcl): succeeded cleanly.Regression run
Baseline (
origin/maind8bd9a38):Baseline (
origin/amd-dev41aa60ce):PR head (
bc033a5e):Not tested
AI use
gap = 0coherent-UMA ranges withplan_watch_ranges(..., COH_WATCH_CALLS)call budgeting, added unit tests for the range builder and committed-window gating, ran workspace tests and 60 s smoke on local AMD hardware, and wrote this description.Imported from ivall/xcl. Originally posted by Foniass on 2026-12-02T07:47:31Z.
Review (head
bc033a5e, diff read, not a merge-check):watch_blocks_with(title_textures.rs~332-336) bumpsCOARSE_GENwhenever a committed-UMA texture gets a new span, even whenexact_cohis off (shadowed UMA, or BVH tiles watched) andcached_watch_ranges(~1922-1927) never readscoh_spans. Each bump invalidatesWATCH_CACHE, so the next submit'srefresh_parts(~2727) copies everycoarsekey and every span under theTEXTURESlock, sorts them and plans again: the per-texture rebuild the base's blocks avoided ("by 16 MiB blocks, not by texture: a title has tens of thousands, and their sources change every submit while it loads", a comment this PR removes). There are no numbers for rebuild frequency or cost while a title loads.SRC_COARSE_SHIFT(~193) andSHOWN_BLOCK_SHIFT(kernelx.rs~397) drop from 16 MiB to 2 MiB on every path, not only unshadowed coherent UMA; outside itwatch_rangesstill merges only across the 4 MiBWATCH_GAPwith no call budget, so blocks 6-14 MiB apart that one range used to cover now each need their ownGetWriteWatchcall, and blocks change state (and bumpCOARSE_GEN) up to 8× as often. It does not depend oncoh_spansand could be its own commit; the only measurement is one 60 s smoke of both together (1618 vs 1654 frames).COH_WATCH_CALLS = 16is not measured.plan_watch_ranges' doc (~4071) still says production keepswatch_ranges"until a Windows measurement establishes a target", and this PR uses it (~1902) with a target of 16 and no call count, look time orWATCH_PLANbytes. Under many textures it bridges all but the 15 largest gaps (e.g. 128 textures 8 MiB apart over 1 GiB become 16 calls covering about 900 MiB), pulling in the coherent buffers the description says this keeps out.title_textures.rstest module (both add a test after the same one, ~6786); textual only. #3676 merges cleanly.Fine:
coh_spansrefcounts stay balanced since every link / unlink / GPU-written path goes throughwatch_blocks/unwatch_blockswith the same(src, size); committed windows are 4 GiB-aligned, so a skipped 2 MiB block never covers memory outside the window;bvh_want::watching()inwatch_keyinvalidates the cache when it flips;build_watch_ranges_splits_exact_coh_routes_shown_and_falls_backand the budget test check the new helper.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 Foniass on 2026-12-02T12:41:27Z.
merge-check
base:
41aa60ce84head:
bc033a5eb4merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2964 passed, 9 failed, 49 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 amd-dev); failing: gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu, gpu::recomp::tests::gpu_fract_f32_edges, hle::d3d12x::sparse::tests::private_physical_pages_reach_the_gpu_on_mapping, hle::d3d12x::title_textures::tests::placed_title_textures_share_vram_and_preserve_pixels, hle::d3d12x::title_textures::tests::remapped_pages_are_compared_with_what_they_held, hle::d3d12x::title_textures::tests::stream_recheck_keeps_the_whole_upload_baseline_over_partial_uploads, hle::d3d12x::title_textures::tests::stream_recheck_partial_upload_without_an_entry_queues_a_whole_upload, hle::d3d12x::title_textures::tests::stream_recheck_schedule_catches_late_writes_and_resets_milestones (the same tests fail on amd-dev
41aa60cealone on this card, so none is from this PR)review: read by one reviewer at this same head; the review is at https://github.com/xcl-dev/xcl/pull/3677#issuecomment-7338613289 and its findings stand. Most serious:
watch_blocks_with(~322-336) bumpsCOARSE_GENfor every new committed-UMA span even withexact_cohoff, so watch ranges are rebuilt per texture, and the global 2 MiBSRC_COARSE_SHIFT(~193) is on the default path unmeasured.performance: 60 s smoke of a retail title, amd-dev
41aa60cevs this merge (bc033a5e): 1671 -> 1687 frames shown (100 %; last presents per 2 s: 60 60 60), peak commit 16722 -> 16707 MB, 0 device removals, 0 crashes.verdict: not yet:
watch_blocks_with(~322-336) bumpsCOARSE_GENfor every new committed-UMA span even withexact_cohoff, so watch ranges are rebuilt per texture, and the global 2 MiBSRC_COARSE_SHIFT(~193) is on the default path unmeasured (see the review)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.
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.