DARNER_TAKE_BLOCKS sends pages whole for copies shaders write where nobody declared #494
No reviewers
Labels
No labels
AMD
audio
bug
confirmed
crash
cutscene
dlss
documentation
duplicate
enhancement
fixed-on-main
frame-generation
hle
input
INTEL
lighting
linux-proton
memory
MULDER
needs-info
needs-logs
needs-rebase
NVIDIA
performance
post-merge
pr-diagnostics
pr-docs
pre-merge
pr-feature
pr-fix
pr-performance
pr-refactor
pr-tests
question
RAYTRACING
relevance
high
relevance
low
relevance
medium
relevance
very-high
rendering
report
roadmap-proposal
saves
series-s
shaders
startup
status
blocked-by-rework
status
needs-test-report
status
needs-triage
status
ready-for-review
status
stale
status
superseded
status
wip
tools
ui
upstream
wontfix
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
TrustNo1/Darner!494
Loading…
Reference in a new issue
No description provided.
Delete branch "italianar15/Darner:fix/take-blocks-undeclared-writes"
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?
Not run in the game. Found by reading the code and by review in a private fork; unit-tested here. Nothing changes with no switch set: the new guard acts only when
DARNER_PICKED_WRITESfinds a writer orDARNER_ROOT_UAV_MBcuts a writing root UAV short.Contributor role (optional)
What it changes
The problem on main (read from the code, not seen in a game run):
DARNER_TAKE_BLOCKSis on by default and skips only copies withleftset (Shadow::takein crates/darner-gpu/src/shadow.rs). Two kinds of shader write are never declared, so they never come back to the CPU's side:DARNER_PICKED_WRITESis off by default, so nothing finds these);DARNER_ROOT_UAV_MB.After either, the card holds the shader's value and the CPU's side still holds the title's last value. When the title then writes that same last value again (resetting a counter or an indirect argument each frame, for example), the 4 KiB block compares alike, nothing is sent, and the card keeps the shader's value. Before TAKE_BLOCKS the whole page went up and the title's value won. In the fork, a "send only what changed" switch of our own failed the same way: a room drew with wrong lighting and geometry because a same-value rewrite by the title no longer covered a shader's leftover on the card. A growing indirect count can also hang the card.
This change:
unseen. Once set it is never cleared. It is set in two places:picked::foundsets it the first time picked finds a copy written through views picked from the heap (newShadow::written_unseen()).Shadow::root_uav_declared(address, limit, writes)replacess.left(a).min(limit)indraw.rsroot_uav. It returns the same length, and setsunseenwhen a writing root UAV is cut short byDARNER_ROOT_UAV_MB.Shadow::take. It is nowtake_blocks() && !left && !unseen: a marked copy skips the block compare, and its page goes up whole, as before TAKE_BLOCKS.take_blocksdoc comment. It now says what the switch rests on, what this covers, and what stays open (below).With nothing set, behaviour is unchanged (from the code):
picked::declarereturns emptyRangeswhen!on(), and the rangesHost::picked_foundwalks come only from there, sofoundis never called withDARNER_PICKED_WRITESunset.DARNER_ROOT_UAV_MBunset or not a number,limitisu64::MAX, so the cut never happens androot_uav_declaredreturns exactlyleft.min(limit).Still open, and not fixed here:
DARNER_PICKED_WRITESunset (the default), nothing is found, so every buffer written through picked views stays exposed. The safe default may be to keep block taking off unlessDARNER_PICKED_WRITES=2; that changes a default, so it is left to you and an A/B.take_landedfinds pages of such a copy alike and sends nothing, compare those pieces ahead on the card in the same submission, or treat a copy as unchecked again after N frames.DARNER_SEND_CHANGED/changes_only) is untouched.DARNER_UPCOPY_CHECK=1style checking (count words a send puts over a card value the title left as the CPU's side held it) sees this case; a refresh check does not.How it was tested
405b191on top of maind91d8e4.shadow::landing_tests:an_unmarked_copy_takes_only_the_blocks_that_changed;a_copy_found_written_unseen_goes_up_whole;a_copy_past_a_cut_writing_root_uav_goes_up_whole: no limit, a limit that fits, or a cut read-only view do not mark the copy; a cut writing view does, and its next take sends the whole range.DARNER_TAKE_BLOCKS=0. With theunseenguard removed for a moment, the found test and the root-UAV test both failed; the file was then restored.DARNER_PICKED_WRITESorDARNER_ROOT_UAV_MBset). Checked by the tests above.405b191:cargo clippy --workspace --all-targets --locked -- -D warnings: exit 0.cargo clippy --workspace --all-targets --all-features --locked -- -D warnings: exit 0.cargo xtask policy:asset policy: 564 files ok.cargo test --workspace --locked: not green, in tests this change does not touch:apps/darner/tests/picked_folders.rs(4 tests) fails on this machine only becauseVICTORY_HOMEis set (darner-core/src/renamed.rscopiesVICTORY_*toDARNER_*; the test clearsDARNER_HOMEbut notVICTORY_HOME). WithVICTORY_HOMEunset: 8 of 8 pass.darner-gpuhost::card_steps::tests::shared_scratch_eliminates_flight_settle_end_to_endfails here, and it also failed 6 of 6 runs on maind91d8e4on this machine.darner-gpuhost::refresh_tests::chunked_nothing_new_with_matches_individualfailed once, while another build was testing on the same machine; it passed in an earlier full run and 5 of 5 runs alone. Not checked on main.darner-shaderlib tests: stopped after a long debug run, so that result is incomplete, not a pass.darner-gpulib: 1794 passed, 2 failed as above, 81 ignored).DARNER_PICKED_WRITESon.Checklist
main.docs/asset-policy.md.Checked for overlap
DARNER_TAKE_BLOCKSno longer compares copies that keep no mirror) handles a different case of the same switch. Both add tests at the same place inshadow::landing_tests, so whichever lands second may need a trivial rebase.[pr-fix][memory] DARNER_TAKE_BLOCKS sends pages whole for copies shaders write where nobody declaredto DARNER_TAKE_BLOCKS sends pages whole for copies shaders write where nobody declaredTest needed — commit
405b1915; what to check:The problem on main (read from the code, not seen in a game run):
DARNER_TAKE_BLOCKSis on by default and skips only copies withleftset (Shadow::takein crates/darner-gpu/src/shadow.rs). Two kinds of shader write are never declared, so they never come back to the CPU's side:DARNER_PICKED_WRITESis off by default, so nothing finds these);DARNER_ROOT_UAV_MB.After either, the card holds the shader's value and the CPU's side still holds the title's last value. When the title then writes that same last value again (resetting a counter or an indirect argument each frame, for example), the 4 KiB block compares alike, nothing is sent, and the card keeps the shader's value. Before TAKE_BLOCKS the whole page went up and the title's value won. In the fork, a "send only what changed" switch of our own failed the same way: a room drew with wrong lighting and geometry because a same-value rewrite by the title no longer covered a shader's leftover on the card. A growing indirect count can also hang the card.
This change:
Evidence to post: card + driver, settings, commit tested, before/after (switch off vs on, two runs each), fps median and p99, and one line saying you looked at the picture.
Reply
testingto take this run; it's free again after 24 h with no results.View command line instructions
Manual merge helper
Use this merge commit message when completing the merge manually.
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.