GPU: a page a refresh took in part is not current #2540
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!2540
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2540"
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?
@Calvix2k on GitHub · 2026-11-25 15:31 UTC · original
Calvix2k:codex/gpu-batch-current-pages→main· +64 −13 · 1 files · 1 commits · openFixes #2473.
The failure
Batch::flushkept a copy's refreshed ranges as the union of the ones that touch, andBatch::addskipped a later refresh covered by it. Two partial refreshes of one 64 KiB page ÔÇö[p, p + 4 KiB)then[p + 4 KiB, p + 64 KiB)ÔÇö union to the whole page, so a later whole-page refresh was skipped.Tracked::takehad copied only parts of it, so the page stayed changed; after the submission a marked page then found it changed with nothing saved, andcopy_back_markedkept the title's bytes instead of the shaders' writes.What the change does
The set holds the pages a refresh took whole (
from.div_ceil(PAGE) .. to / PAGE), andaddskips a request only when every page it spans is in it. A page counted in parts is not there, so the rest of it is copied when it is asked for. Pages are the write watch's own unit, which is what decides whether a page is taken.Two things the old form got for free and this keeps: a copy's refresh in a submission is still done once per range (not once per draw), and a step that writes title memory still clears the set (
title_written).Verification
partial_refreshes_do_not_make_a_page_currentis the issue's scenario: two partial refreshes that together cover a page, then a title write, then a whole-page refresh. With the union the refresh copied 0 bytes (the page was never taken); now it copies the page. I did not keep a separate red run of the old code, but the two branches are one condition apart: with the union[p, p + PAGE)is incurrentandaddreturns beforeflush.cargo test -p victory-gpu --features diagnostics --libon Windows 10 19045 / RX 7800 XT after rebasing ontoda82e44: 198 passed, 1 ignored, plus the known placed-view failure on a runtime withoutID3D12Device10(#1999, identical onmain); clippy-D warningsclean.@Marvisak on GitHub · 2026-11-25 18:33 UTC · original
Automated triage for the maintainers.
This fixes #2473:
Batch::flush(crates/victory-gpu/src/host.rs) merged touching partial refreshes of one page into a "current" range, so a later whole-page refresh was skipped. The fix replaces the range with a per-copyBTreeSetof whole pages. The change is safe, because it can only refresh more. CI passes.However, #2474 fixes the same issue in the same function and is the better candidate:
copy_back_markedreturning the page. It also checks that whole pages meeting at a boundary still merge without a second copy. This PR's test only checks thatflush()copies something.This PR also has two costs #2474 avoids:
from.div_ceil(PAGE)..to / PAGEuses raw page boundaries rather than the tracked range thatTracked::take_splitclamps to. Edge pages of buffers that are not page-aligned (including every sub-page buffer) are never recorded as current, so they are re-added on each list.addnow walkspages.range(first..=last).count()for every request.Proposed for closing as a duplicate of #2474. The PR will be closed in 48 hours unless the author pushes a change or a maintainer removes the label.
Generated by Claude Code
@Kajanos on GitHub · 2026-11-26 00:07 UTC · original
Windows 11 / NVIDIA test run, head
67f4bb4b0emerged ontomain63bcca43c6.Setup: Windows 11 Home build 26300, RTX 5080, NVIDIA 621.40, rustc 1.98.1 MSVC, VS 2022 Build Tools, Windows SDK 10.0.26100 (
dxil.dllfrom the SDK).cargo test --locked -p victory-gpu: 232 passed, 0 failed, 1 ignored (main: 231).draw::tests::a_texture_written_in_one_format_reads_in_another_through_a_placed_viewfailed once (round 0: a copy only where not shared, lefttrue, rightfalse, draw.rs:2876). It did not come back in 5 runs of that test alone or in 18 more full runs, and 18 full runs onmainwere clean too. So I can't attribute it to this PR, but it's worth knowing in case the sharing decision depends on timing.Not run: the retail title, clippy, and other crates.
AI-assisted (Claude Code)
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.