[pr-performance][rendering][memory] Refresh only written mips of tracked BC textures #50
Loading…
Reference in a new issue
No description provided.
Delete branch "holoslicer/Darner:perf-streamed-texture-mips"
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?
Contributor role (optional)
What it changes
Streaming a single mip could make Darner read, detile and upload an entire block-compressed texture. For a fully staged, single-slice 2D BC texture in verified write-watched memory, this change maps written pages to mip levels. It refreshes those levels on the CPU and accumulates them for the GPU upload at submission.
Initial uploads, remaps and writes into a packed mip tail use a full refresh. If two live staging buffers can overwrite the same GPU texture, each submits its full staged image.
How it was tested
Windows x64, Rust 1.98.1. Published commit
0973b6e4aahas the same Git tree as tested commitbc4e62f540. Both have upstream parent4a92569fb8.cargo --config 'profile.test.package.darner-shader.opt-level=3' test --workspace --locked --offline --no-fail-fast -- --test-threads=1) finished with 3,234 passed, two failed and 117 ignored. Both failures also reproduced on unmodified upstream: DXIL depth-output validation and the expected 32-lane wave size. In-game frame times and texture pop-in still need a matched route.Checklist
main.docs/asset-policy.md.Checked for overlap
host.rsfor other changes: #25, #31, #32, #33, #34, #35, #38, #39, #40, #41 and #43.Independent Windows D3D12 check on an RTX 4060 8 GB (driver 621.40, Windows 11 build 26300, Rust 1.98.1).
At
0973b6e4aa,cargo --config 'profile.test.debug=0' test --locked -p darner-gpu --lib texture::mip_upload_tests:: -- --test-threads=1 --nocapturepassed 2/2. I also applied this PR to1a5286a78daaand extended the BC7 test to dirty mip 3, refresh, dirty mip 2, refresh, then submit once. The D3D12 device LUID matched the RTX 4060. The two refreshes read 65,536 and 262,144 bytes from a 5,636,096-byte source. The submission selected both mips, every row in all 12 mips matched a full CPU detile, and the marker in the untouched staging mip stayed out of the GPU readback.This synthetic run covers pending mip accumulation and copies. Gameplay, frame times, and issue #68's black blocks are outside its scope.
Follow-up on a stale mip after a late upload-ahead completion. I reproduced it at
0973b6e4aaon an RTX 4060 8 GB (Windows 11 build 26300, driver 621.40, Rust 1.98.1).With
DARNER_UPLOAD_AHEAD=1andDARNER_PRELUDE_UPLOADS=1, the test sends a synthetic 2048×2048 BC7 chain through the real COPY worker and waits for its D3D12 fence. It delays only the CPU call toahead::finish. An ordinaryupload_fromtimes out inlistedafter ~1.05 s and its prelude uploads the chain. The test then changes mip 3, refreshes staging, and releasesahead::finishbefore the next prelude claims that update.uploads.copied()clears the pending mip 3. A subsequent write to mip 2 submits only mip 2. GPU readback still has0x1bin mip 3 (expected0xb7).main(1a5286a78daa), the same sequence also loses the first update. The later write triggers a full upload and restores mip 3 to0xb7.mainwith this PR and a local guard, both uploads are recorded (masks0x8and0x4). GPU readback gets0xb7for mip 3 and0x4dfor mip 2. The guard checksstaging.oncewhile holdingstaging.lastand only clears pending uploads and records the held hash while the staging buffer still belongs to the one-shot upload. An ordinary list setsonce=falsebefore its refresh, which uses that same lock.The test forces the CPU completion order after the COPY fence has signaled. Concurrent GPU writes across the COPY and DIRECT queues, in-game frequency, and a gameplay symptom are outside the scope of this reproduction.
I replayed
0973b6e4aa48ontomainat57dea7f2367c. Git reported one conflict, intexture/ahead.rs. The resolution keeps #104'slastlock andoncecheck, usesstaging.uploads.copied()inside the check, and updates the held hash from the same lock guard.note_held()would takelastagain. The existing #104 test now checksuploads.dirty(). The staged resolution is tree2005bb6d9cd47c1d88742f551845805b205aa692.On Windows 11 build 26300, RTX 4060 8 GB (driver 621.40), Rust 1.98.1, the integrated tree passed these checks.
DARNER_UPLOAD_AHEADandDARNER_PRELUDE_UPLOADSset to 0 and again with both set to 1. The GPU test exercises the prelude directly.0x8and0x4in the two submissions. The sampled GPU readback bytes were0xb7in mip 3 and0x4din mip 2.watch::run had the same failure on the integrated tree and on unmodified57dea7f(87 passed in each).ask_once_by_res_splits_reservations_without_refusalsrecorded the plain allocation in the write journal. That test passed in isolation on both trees. The staged asset check passed for all seven files.cargo clippy --locked -p darner-gpu --all-targets --all-features -- -D warningspassed with a fresh build directory.The patches below give the conflict resolution against
mainand the optional synthetic fixtures against the resolved tree. I used an isolated Darner home and cache. For the late-completion and two-mip cases I setDARNER_ADAPTER=RTX 4060,DARNER_UPLOAD_AHEAD=1, andDARNER_PRELUDE_UPLOADS=1. The tests cover the CPU publication after a completed COPY and the GPU readback. Frame times and pop-in in gameplay remain unmeasured.Conflict resolution for texture/ahead.rs against main
Optional synthetic fixtures against the resolved tree
One patched attempt completed the two-minute road route at 22.04 rendered FPS, with p99 81.02 ms and five frames over 100 ms. Its control reached 21.84 FPS, p99 83.86 ms, and four frames over 100 ms. The second patched attempt lost the device 12.35 s before the route marker. That leaves one completed pair with variable traffic, and the cause of the hang remains open.
Device loss. Last successful present 2775. At 19:46:07.422896 UTC on December 3 the log recorded a device loss waiting for fence 29550, HRESULT
0x887A0006(DXGI_ERROR_DEVICE_HUNG). DRED page-fault reporting was enabled and returned no page fault. Breadcrumb capture was off. The external input recorder continued after the device loss, but the marked window contained zero successful frame intervals. I excluded it from the performance comparison.Archived builds and setup. Main
1a5286a78d, candidate03d6a98eb1on that base. Git stable patch ID7be7d33a77fe9dcb97b5be947cbede32d50581bfmatches upstream0973b6e4aa. RTX 4070 Ti SUPER 16 GB, driver 617.14, i5-13600KF, 32 GB RAM, Windows 11. Series X, native 2560×1440 SDR, hardware RT off, DLSS off, FG off, 30 FPS cap. Same copied save, warm cache, same outdoor road route. The recordings predate the current release. I could not verify texture pop-in or identify the GPU command that hung.Tested on a full card with hardware RT and frame generation: slower here, and the texture queue grows.
Setup. RTX 5070 Ti 16 GB, Ryzen 7 7800X3D, 31 GB RAM, Series X profile, 1440p, DLAA, frame generation 2x,
DARNER_HW_RT=1. The card runs at its limit in this scene: VRAM peak about 15.9 GB of 16, DLSS VRAM warning in every run. Route: gta-bench-kitcam-city60(65 s of city camera), first 60 s of each log skipped for the log figures.Builds. Both from the same tree,
cargo build --release -p darner --features bench-remote, LTO off,codegen-units=256, so the only difference is this PR:main57dea7fmain57dea7fwith this PR merged (head0973b6e4). Thetexture/ahead.rsfinish()conflict resolved the same way as the resolution posted above.Frame times (median of runs, spread max−min in brackets):
Two of the three PR runs come from an earlier batch with the same exe and settings; the base and PR runs of the last batch were interleaved (base, PR, base).
Texture queue from the game logs (last batch: one PR run between the two base runs):
So on this card the pass hits its time limit on every frame and gets through about a third fewer uploads per second, and the queue of due textures is larger. I haven't looked into why each upload costs more here. The neutral pair above was with RT, frame generation and DLSS off, where the card likely has room; this may only show when VRAM is full.
Holding this PR. The A/B in comment 857813 (5070 Ti, full card, same tree with only this PR added) shows it slower when video memory is saturated:
Together with the 0x887A0006 hang on a PR arm (comment 857251), it can't go in as is. A rework would need to show no loss on a card at its VRAM limit; that's the case that regresses.
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.