[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.
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.