Repository navigation
d3d12-gpu: a sparse read of only holes keeps the staged texels' digest (D3D12-GPU-SPARSE-ZERO-READ-DIGEST) - #2841
Conversation
A partly mapped texture is read through its unmapped pages, which come back as zeros. The partial read path stored the digest of every read before rejecting an all-zero one, so a read that caught nothing mapped replaced the digest of the texels already detiled, and the next read that found those same texels detiled and uploaded them again. Last::accept_partial now rejects an all-zero read before touching the digest. The full read path is unchanged and still takes a texture that really is all zeros. After the fix in TaynanGT/Vice-Tay (26aeded). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
KelboLive
left a comment
There was a problem hiding this comment.
The rule is right, and the important part is what it fixes indirectly: Last.hash now describes the staging buffer rather than the last read from title memory, which is what note_held() / unchanged() already assume — so this also stops a wrong "held" digest and stops the alone shortcut marking a texture read when it has only seen holes. 600 passed / 54 ignored here, and restoring the old order fails the new test with left: Some(Digest(..)), right: None.
I checked the invariant separately rather than only the new test:
- a changed last byte after staging still detiles;
- a single non-zero byte among 127 hole bytes is taken, so a real texel at a hole boundary is not skipped (the all-zero test is whole-buffer);
- repeated identical bytes do not detile;
- no order dependence:
copy_mappedzeroes every hole (host.rs:12164,:12250),with_readalways handssizebytes, anddigestis pure over them.
Two asks:
- Pin the invariant in the committed test. It proves the hole-only read no longer poisons the digest, but never that a real change after staging still detiles, nor a mixed texel/hole buffer. Two one-line assertions (I added them temporarily; they pass) would make the test describe the whole rule.
- Add the provenance. The body says this ports
TaynanGT/Vice-Tay 26aeded(GPL-3.0) but the new doc comment cites nothing, while every other port in this file names repo/commit/author/licence (:160,:208,:1663,:1697). Same rule as the docstring PRs: the attribution belongs next to the code, not only in the PR body.
Cosmetic: accept_partial reads backwards (returning true means "changed, detile"); changed_partial would match the caller. The same texels under a different hole layout still hash differently and re-detile — pre-existing and not made worse, but the new comment could say the digest includes the hole zeros.
|
Reviewed and verified PR
GPUs tested: NVIDIA GeForce RTX 5070 12 GB (driver 621.40, Windows 10 Pro 22H2 build 19045, Ryzen 9 5950X 16C/32T) AI-assisted: Antigravity |
…xels Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Pushed to your branch by MoonEyes (maintainer, the branch allows it), on top of your head, nothing rewritten. Say so if you would rather have it another way, and I take it out. The earlier verdicts are for the head before this one. AI-assisted (Claude Code). |
|
I tested 0729d56 together with #2852 c4e286f on 0ff8a53. The cleanly merged Win64 MSVC target passed the partial-texture and physical-page write selection on Radeon Raphael (RADV 26.3.1) and RTX 4070 SUPER (620.73.04), using Wine 11.22. The combined selection also passed on both GPUs with LEONIDA_PAGE_WRITES=slots and with 0 (the bake path). A local digest-before-zero ordering control changes only when this function rejects zero bytes: hash/check/store before rejecting holes, as the old partial path did. Run alone, the stock regression test then fails on the first zero read because the previously empty digest has been populated. The fixed version also checks that a staged texture keeps its digest through holes and accepts different texels afterwards. This is coverage of the partial-read decision and its integration with the neighboring change. MEASURED, AI-assisted (Codex). |
|
Independent red/green on Windows 11 (RTX 5080, NVIDIA 621.24), head
It touches rendering, so the in-game gate is still to do; no in-game run from me yet. AI-assisted (Claude Code), posted for DadaCap. |
Claimed in the coordination issue as: D3D12-GPU-SPARSE-ZERO-READ-DIGEST (#2570 (comment))
What and why
A partly mapped texture is read through its unmapped pages, which come back as zeros (
d3d12/crates/leonida-gpu/src/texture.rs, the partial read path). That path stored the read's digest before it rejected an all-zero read. So a read that caught only holes replaced the digest of the texels already detiled, and the next read that found those same texels again detiled and uploaded them a second time.The change: the decision moves into
Last::accept_partial, which rejects an all-zero read before touching the digest, then compares and stores the digest as before. The full (committed) read path is unchanged and still takes a texture that really is all zeros.This ports a fix from the sibling VIctory tree (TaynanGT/Vice-Tay
26aeded, GPL-3.0).Tested
texture::partial_tests::a_zero_sparse_read_keeps_the_digest_of_the_staged_texels: an all-zero first read stages nothing, a read with texels is taken, a later all-zero read keeps that digest, and the same texels again are not detiled. Withmain's order put back intoaccept_partial(a mutation of this branch), it fails (nothing staged yet: the next read with texels detiles,left: Some(Digest(..)),right: None); with the change it passes.cargo test -p leonida-gpu --lib: 600 passed, 0 failed, 54 ignored (main640b0d0df: 599).cargo clippy -p leonida-gpu --lib --tests: no warning in the changed lines.GPUs tested: n/a (CPU unit tests)
AI-assisted: yes
Checklist
mainand merges cleanly (a conflicting pull request is labeledneeds rebase).docs/design.md, with how it was confirmed. (n/a: no translator change)🤖 Generated with Claude Code