D3D12.X: streamed textures read through their pages are rechecked there #3725
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3725"
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 Lakanya on 2026-12-02T20:16:28Z.
Textures read through physical pages mapped under a GPU view (
CopyPageMappingsBatchX,Entry::paged) were skipped inseed_stream_recheckand pruned inrecheck_streamed_unwatched_at. When the title moves a physical page, its texels are kept away from the view's address, and texels written there after the initial zeroed upload without a write the dirty path saw were never re-uploaded.Paged textures are now seeded and rechecked on the milestone schedule through their resolved page table (
sample_fingerprint_in), sampling three 128-byte probes per 64 KiB page (up to 256 evenly spaced pages, at most 96 KiB read) so late-arriving interior pages are caught. Entries with no mapped pages leave the schedule until a new mapping arrives.Updated after review (head
8a16e245, squashed):refreshadds its pages to the look's dirty pages, sotexture_upload::changedcompares them with what was sent (known) and uploads only the pages that differ. A partial upload leaves the baseline of the last whole upload, so before this a paged texture whose writes had all been sent went up whole again at its next milestone (fromthemoonx's merge-check: 111.5 MiB / 99 whole uploads against 12.5 MiB / 0 on main in a 400-frame scratch test; AAsobu: about +0.5 GB of video memory in a retail world).What is in it
d3d12x::title_textures:sample_fingerprint_inper-64 KiB page probing throughPageMap, seeding (whole uploads only) and milestone recheck forEntry::pagedtextures inseed_stream_recheckandrecheck_streamed_unwatched_at, withPAGED_CHECKS_PER_FRAME(32) paged checks per frame at most; a changed paged texture's pages go to the look's dirty pages (refresh) instead of a whole upload.stream_recheck_catches_a_late_write_under_a_paged_texture(the changed texture's range is returned for the dirty pages, not queued whole),a_paged_texture_whose_writes_were_sent_is_not_uploaded_whole_at_its_milestones,a_paged_fingerprint_sees_a_late_page_inside_the_texture,paged_rechecks_keep_to_the_frame_budget, and a paged case instream_recheck_partial_upload_without_an_entry_queues_a_whole_upload. The paged tests takeTEST_LOCKwhether or not an earlier test poisoned it.Regression run
(both made with
scripts/smoke.ps1run on a hidden desktop,CreateDesktopW, so that no window shows)Tested
cargo test -p xcl --lib -- paged stream_recheck --test-threads=1on8a16e245: 8 passed.a_paged_texture_whose_writes_were_sent_is_not_uploaded_whole_at_its_milestonesandstream_recheck_catches_a_late_write_under_a_paged_texturefail when a changed paged texture is queued whole (the previous behaviour);paged_rechecks_keep_to_the_frame_budgetfails without the budget, and the paged case of the partial-upload test without the partial-upload rule.cargo test -p xcl --lib -- hle::d3d12x::title_textures:: --test-threads=8, twice: 68 passed, 1 failed, 1 ignored each time. The one failure isplaced_title_textures_share_vram_and_preserve_pixels("row 3: new placement readback"), which fails the same way in parallel runs on main on this machine (817eb1fc) and passes alone; all paged tests pass.cargo build --workspacethencargo test --workspace --no-fail-fast -- --test-threads=4on8a16e245: thexcllib test process exits with0x80004005partway ("sparse upload preparation still failed after bounded retries", the stop #3488 reports on an AMD iGPU; main does the same); remaining binaries: 152 passed, 0 failed, 20 ignored.xcllib tests run one module group at a time (cargo test -p xcl --lib -- <module>:: --test-threads=4, 199 groups, all 2,888 tests): 2,852 passed, 4 failed, 32 ignored. Failed:placed_title_textures_share_vram_and_preserve_pixelsand three pre-existingstream_recheck_*tests through theTEST_LOCKit poisons; they fail the same way on817eb1fcand pass alone.C:\gta6), on a local stack (the first version of this change, before the partial-upload rule, the per-frame budget and the dirty-page routing, on top of other local commits over an older main, not this commit alone): 64–4,096 paged textures re-queued per run (none before); the look before submits took the same share of time (26 %). That count may include whole uploads this version no longer makes.Not tested
AI use
817eb1fc.scripts/smoke.ps1regression runs, and PR preparation.🤖 Generated with Claude Code
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-02T20:47:37Z.
Review of
85b53380(code reading only, not a merge-check) · 2 medium, 1 nitIn short: The PR keeps textures read through their pages (
Entry::paged) on the stream-recheck schedule and fingerprints them through their page table. Before, they were skipped at seeding and pruned at the first milestone. The logic and both tests match the description. The change does schedule every paged texture, including those whose pages are write-watched, and its per-check cost on the default path is unmeasured; the 60 s smoke run does not reach that path.Medium
Paged textures are scheduled even when their pages are write-watched.
seed_stream_recheck(title_textures.rs~2425), therange_is_fully_watchedskip now applies only whend.pages.is_none(). Inrecheck_streamed_unwatched_at(~2491),e.pagednever prunes.mirrors::views_of_written, ~2075), so a watched paged texture gains nothing from the schedule.unsent(~2434) and gets alast_fp: Noneentry. The first milestone always queues a whole upload for such an entry, so a streaming texture gets an extra whole upload 4 frames after each partial one.Fix: skip a paged texture when every place its
PageMapresolves to is watched, or at least add noNone-baseline entries for paged partial uploads.The per-check cost has no bound and was not measured on this commit.
sample_fingerprint_in(~2396-2400) makes three reads per 64 KiB page, up to 768 per texture. Each read of a page kept elsewhere is oneReadProcessMemorycall.page_map→mirrors::resolveat every milestone (~2525).Please measure frame time at milestone frames during world load on this commit, or cap the paged checks per frame.
Nit
cpu_writes".d3d12x::cpu_writesis the bottom-of-pipe write worker and has nothing to do with page homes.sample_fingerprint_in(~2376) says "the same slices", but the function uses its own 128-byte probes per page.Checked and fine
sample_fingerprint_in:probeandstepare never 0, the offsets stay inside[start, end), and nothing overflows at realistic sizes.e.src == e.va.page_mapafterTEXTURESis dropped, so there is no new lock-order edge.STREAM_RECHECKand seeded again by the next whole upload.stream_recheck_catches_a_late_write_under_a_paged_texturefails without the change and cleans up its tables. The second test's write falls outside the old start, mid and end slices.XCL_TEXTURE_STREAM_RECHECK=0still turns the recheck off.Written by Claude Code (Claude Opus 5.5) and posted by Foniass without a human check of each point.
Imported from ivall/xcl. Originally posted by Lakanya on 2026-12-02T21:02:04Z.
Thanks, @Foniass. Checked against
85b53380, and addressed in91304b35(squashed, description updated):unsentand got alast_fp: Noneentry, so a streaming texture got a whole upload 4 frames after each partial one. Paged textures now get no entry from a partial upload; their schedule starts at whole uploads. The paged case added tostream_recheck_partial_upload_without_an_entry_queues_a_whole_uploadfails without it. I did not add the "every resolved place is watched" skip: a texture that keeps no entry from partial uploads only rechecks after whole uploads, which is the case the change is for.PAGED_CHECKS_PER_FRAME(32) paged textures are fingerprinted per frame (up to 3 MiB read); the others stay due and are checked in the next frames, since a checked one leaves the due set until its next milestone.paged_rechecks_keep_to_the_frame_budgetchecks 33 due textures: 32, then 33. Frame time at milestone frames during world load is still not measured on this commit (listed under Not tested).cpu_writesreference is gone from the comment, the commit message and the description, and the doc ofsample_fingerprint_innow describes its own probes.The retail count (64–4,096 re-queued) came from the first version and may include the whole uploads of point 1; the description now says so.
AI use: Claude Code, Claude Opus 5.5 (checked the points, wrote the changes, tests and this reply; tests and smoke run on an RTX 5070 Laptop GPU).
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-02T21:12:40Z.
Follow-up review of
91304b35, since85b53380(code reading only, not a merge-check;Build and test (Windows, no GPU)red) · 1 mediumIn short: Since
85b53380the PR is squashed into one commit with three changes:PAGED_CHECKS_PER_FRAME(32) per frame, with a test;That fixes all three earlier points. The one new problem is that the budget test uses a view size another test already uses, so the two can pair with each other's views when they run at the same time.
Medium
The new budget test reuses a view size from a
kernelxtest.paged_rechecks_keep_to_the_frame_budget(title_textures.rs~6793) callspaged_views(199 * PAGE, n), andgpu_view_pages_record_the_physical_page_mapped_into_them(kernelx.rs~4558) uses199 * PAGEfor itscpu_view.mirrors::reservedpairs a GPU view with the newest unpaired CPU view of the same size (unpaired_cpu,kernelx.rs~200). That is why both helpers' docs ask for a size no other test uses. The two tests share no lock.Fix: use a size no other test passes to
mirrors::reserved/cpu_view/paged_views.Checked and fine
last_fp: Noneentries, so no whole upload follows 4 frames later (seed_stream_recheck~2439). The paged case added tostream_recheck_partial_upload_without_an_entry_queues_a_whole_uploadcovers it. Write-watched paged textures are still scheduled, but now under the per-frame cap.>=against the milestone (~2481). The test checks 32 textures, then the 33rd one frame later.sample_fingerprint_in(~2376) no longer namecpu_writesor "the same slices", and the description no longer does either.Written by Claude Code (Claude Opus 5.5) and posted by Foniass without a human check of each point.
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-02T21:35:50Z.
Follow-up review of
7a59f45e, since91304b35(code reading only, not a merge-check) · 1 mediumIn short: This push only changes the commit's author; the code is the same as at
91304b35(git range-diff). The test point from my last review is still open.Medium
kernelxtest (still open).paged_rechecks_keep_to_the_frame_budget(title_textures.rs~6793) usespaged_views(199 * PAGE, n), the sizegpu_view_pages_record_the_physical_page_mapped_into_them(kernelx.rs~4558) uses for itscpu_view.mirrors::reservedpairs views by size, and the two tests share no lock, so on parallel test threads one can pair with the other's view and fail at random. Use a size no other test uses.Checked and fine
Written by Claude Code (Claude Opus 5.5) and posted by Foniass without a human check of each point.
Imported from ivall/xcl. Originally posted by Lakanya on 2026-12-02T22:00:29Z.
Thanks, @Foniass, right:
kernelx.rsuses199 * PAGEforgpu_view_pages_record_the_physical_page_mapped_into_them. Inad7c0a89the budget test uses233 * PAGE, which no other test passes topaged_views/cpu_view/mirrors::reserved(checked withgit grepovercrates/xcl/srcandcrates/xcl/tests).hle::kernelx::andhle::d3d12x::title_textures::run together on 4 threads: 136 passed, 0 failed, 2 ignored. The regression blocks are rerun on the new head (description updated).AI use: Claude Code, Claude Opus 5.5 (the change, the runs and this reply).
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-02T22:01:13Z.
Follow-up review of
ad7c0a89, since7a59f45e(code reading only, not a merge-check) · no new findingsIn short: This push fixes the test point from my last review.
paged_rechecks_keep_to_the_frame_budgetnow uses views of233 * PAGE, which no other test uses, so it can no longer pair withkernelx's views. Nothing else changed, and nothing blocks it.Checked and fine
199 * PAGEfromgpu_view_pages_record_the_physical_page_mapped_into_them.233 * PAGEappears nowhere else in the crate's tests. The otherpaged_viewssizes (179, 181, 191, 193, 197) are unchanged and also unique.Written by Claude Code (Claude Opus 5.5) and posted by Foniass without a human check of each point.
Imported from ivall/xcl. Originally posted by fromthemoonx on 2026-12-03T05:43:55Z.
merge-check
base:
a815de932chead:
8a16e245b1merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 3022 passed, 0 failed, 56 ignored; SKIPPED: 25 (22 no wave64, 2 no heap windows, 1 no GPU_UPLOAD heaps), the same list as on main
395405e4; failing: nonereview: rerun on the new head; the old report is folded below. Read the whole diff (1 file, +266 -27). My point 1 is fixed, and I found no new problem.
refresh. Same numbers in 3 of 3 runs. The main side is the binary from the last check;title_textures.rsandtexture_upload.rshave not changed on main since.refreshthat could drop them, so moving the baseline at that point loses no write.pagedandstream_rechecktests passed 30 of 30 runs. Thetitle_texturesmodule at 8 threads passed 8 of 8 on this head and 8 of 8 on main0c725d5d, soplaced_title_textures_share_vram_and_preserve_pixelsdid not fail here.performance: upload traffic equals main's in the test above. The cost of the fingerprints was not measured; it is capped at 32 textures a frame.
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)
Old report, on
ad7c0a89(not yet)Imported from ivall/xcl. Originally posted by AAsobu on 2026-12-03T10:09:38Z.
merge-check
base:
16c2fd082ahead:
ad7c0a8971merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 3015 passed, 0 failed, 56 ignored; SKIPPED: 28 (22 no wave64, 2 no heap windows, 1 no GPU_UPLOAD heaps, 3 no D3D12 debug layer); failing: none
review: read the whole diff (+190/-12, title_textures.rs); no findings of our own. In-world A/B on a retail title (360 s runs, 3 valid per arm, warmed caches): presents per 2 s equal (median 3.86 main / 3.88 PR), peak commit +~140 MB (within run-to-run noise here, sd ~650 MB), VRAM +~0.5 GB (PR 16467-16497 MB, above every main run 15807-16221 MB). This fits the whole re-uploads fromthemoonx measured, at a moderate cost in a real world load. One PR run hit the device removal main
16c2fd08already shows (0x887a0006, page fault at VA 0x0, same pipeline signature); it is not from this PR, and a repeat run was clean. Not checked: whether the picture changes (no frame captures), AMD.performance: frames unchanged; ~0.5 GB more VRAM by default, measured (3 vs 3 runs).
verdict: safe to merge (frames and commit unchanged here; the ~0.5 GB VRAM it adds in a real world load is the cost to weigh against the fix)
hardware / tool and model: RTX 3090 24 GB (driver 621.24), i5-10600K, 32 GB, Windows 11 26300 / Claude Code (Claude Opus 5.5)
Imported from ivall/xcl. Originally posted by Lakanya on 2026-12-03T11:48:09Z.
Thanks, @fromthemoonx and @AAsobu. Point 1 is fixed in
8a16e245(squashed, description updated), along the lines fromthemoonx proposed:recheck_streamed_unwatchedreturns its range instead of settingpending, andrefreshadds its pages to the look's dirty pages (DIRTY_BUF, page-aligned, sorted and deduplicated), sotexture_upload::changedcompares them with what was last sent (known) and uploads only the pages that differ. The range goes back through the return value, with no new global. The baseline moves to the new fingerprint, so the next milestone finds nothing unless something changed again.stream_recheck_catches_a_late_write_under_a_paged_texturenow checks that the late write's range is returned for the dirty pages and that the texture is not madepending. The newa_paged_texture_whose_writes_were_sent_is_not_uploaded_whole_at_its_milestonescovers a page written and already sent by a partial upload: the first milestone hands its pages to the dirty-page comparison, never a whole upload; the next milestone finds nothing; a write that was never sent is still found at the milestone after it. Both fail when the changed texture is queued whole (the previous head's behaviour).title_texturesat 8 threads, twice: 68 passed, 1 failed, 1 ignored. The failure isplaced_title_textures_share_vram_and_preserve_pixels, which fails the same way in parallel on main on this machine (RTX 5070 Laptop) and passes alone; every paged test passes. The paged tests now takeTEST_LOCKeven after an earlier test poisoned it.xcl-smokeblocks (main0c725d5d, this head) are in the description.Not re-measured: the 400-frame upload traffic and the +0.5 GB of video memory in a retail world. I have no world run of this head; a re-run of either of your measurements would show it.
AI use: Claude Code, Claude Opus 5.5 (the change, the tests, the runs and this reply).
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-03T11:50:22Z.
Follow-up review of
8a16e245, sincead7c0a89(code reading only, not a merge-check) · 1 nitIn short: This push changes what a milestone does when a paged texture's fingerprint changed. Instead of queuing the texture whole, its pages join the look's dirty pages, so
texture_upload::changedsends only those that differ from what was sent. A partial upload leaves the baseline of the last whole one, so before this push a paged texture whose writes were all sent went up whole again at its next milestone. A new test covers that case, and a write that was never sent is still found. Nothing blocks it.Nit
STREAM_RECHECK_HITSstill logs "streamed unwatched re-uploads triggered", but for paged textures it now counts textures whose pages were compared, which may upload nothing. Rename the line, or count paged textures separately.Checked and fine
recheck_streamed_unwatched_atreturns(src, bytes)for changed paged textures, and still setspendingfor the others. The baseline moves to the new fingerprint in both cases, so the next milestone finds nothing unless the bytes change again.DIRTY_BUF, then sorted and deduplicated, so a page already dirty is not compared twice.a_paged_texture_whose_writes_were_sent_is_not_uploaded_whole_at_its_milestoneschecks three things: a sent write gives the range once and no whole upload, the next milestone gives nothing, and an unsent write is found at the following one. The earlier test now expects the range instead ofpending.TEST_LOCKis taken withunwrap_or_else(into_inner)in these tests, so one failing test does not poison the rest.233 * PAGE) and the new one (239 * PAGE) are not used by any other test.Written by Claude Code (Claude Opus 5.5) and posted by Foniass without a human check of each point.
Imported from ivall/xcl. Originally posted by Gevroska on 2026-12-03T13:44:39Z.
@Lakanya I compared
ad7c0a89and8a16e245on my RTX 3080 using the same 128 KiB linear R8 texture. I supplied one ordinary write notification, then changed a 4 KiB stripe in the second backing allocation without notifying the ordinary dirty path. The copy payload came from XCL’sPageMapreads on both revisions.ad7c0a89copied8a16e245copiedAll ten fenced snapshots matched across all 131,072 texels. The already-uploaded stripe retained
0x6a, the missed stripe became0xc5, and its neighbor stayed unchanged.This confirms both parts of the revision for a linear texture with known upload history: it avoided a redundant copy and recovered the missed write. The fixture used the pinned XCL selection code and a standalone D3D12 copy. I haven’t measured full-queue timing or VRAM use.
AI disclosure: OpenAI Codex GPT-6.2 Sol implemented and ran the comparison. A separate Codex reviewer verified the selected payloads and readbacks. GPT-6.2 Astra drafted this comment.
I reviewed and approved this comment before posting.
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.