Repository navigation
gpu: take the presented texture's move to COPY_SOURCE through its list (VIctory #2545) - #158
Conversation
A presented texture the title already left in COPY_SOURCE was given an illegal COPY_SOURCE -> COPY_SOURCE barrier before and after the copy up, and its recorded state was swapped from the presenting thread, outside Host::submitted: a list submitted meanwhile could record a move from a state the card was not in. The present's list now records the move as any list does (settle: its first use records nothing), and the list's prelude makes it from the texture's real state at submission, under the lock, recording no barrier when it is there already. The copy leaves it in COPY_SOURCE, which is what the prelude then records as its real state. Reimplementation of Marvisak/VIctory #2545, whose fix moves the state from a move_texture call on the present's copy list; this tree already had that bookkeeping, so only the present had to stop bypassing it. Co-authored-by: shh <marek8788@proton.me> VICTORY_PRESENT_PRELUDE=0 records the barrier by hand again. Not tested in a game run.
|
No actionable comments were generated in the recent review. Walkthrough
Change: Bug fix Merge Risk:
|
|
On the retained concern (present lists keep their source texture until reset): that is deliberate, and it is what |
What
A presented texture the title already left in
COPY_SOURCEgot an illegalCOPY_SOURCE -> COPY_SOURCEbarrierbefore and after the copy up, and its recorded state was swapped from the presenting thread, outside
Host::submitted.queue::presentno longer callsresource::host_transition(which swappedHostTexture::stateoutside thesubmission lock) and no longer reads the texture through an un-owned
&'static ID3D12Resource: it passes theArc<HostTexture>fromresource::host_copy, which the present list now holds until it is reset.Host::presentrecords the move with the present list's own state bookkeeping (HostList::settle, one list'sfirst use of a texture records nothing) instead of writing two barriers by hand. The list's
preludemakes themove from the texture's real state at submission, under the lock, and records no barrier at all when the
texture is there already. The copy leaves it in
COPY_SOURCE, which is what the prelude then records as itsreal state, so the title's own lists move it from there.
resource::host_transitionis now test-only (#[cfg(all(windows, test))]), as in #2545.What this changes under vkd3d-proton (why it is not cosmetic on RADV)
vkd3d-proton turns each D3D12 transition into a Vulkan pipeline barrier whose
srcStage/srcAccesscome from thetransition's
StateBeforeand whosedstStage/dstAccesscome fromStateAfter. Two consequences:COPY_SOURCE -> COPY_SOURCEis an invalid transition in D3D12 (debug layer error) and, translated, is a barrierfrom the copy stage to the copy stage that nobody needed: no writer's cache is flushed by it, and the case only
appeared because the state was moved for the caller rather than tracked.
HostTexture::statefrom the presenting thread meant a list submitted at the same time couldrecord its prelude barriers from a state the resource was not in. vkd3d-proton then derives
srcStage/srcAccessfrom that wrongStateBefore, so the barrier does not order the real writer's writes before theread: on RADV (real caches) that is a stale or torn presented frame or omitted depth/colour sync, while WARP,
whose "caches" are a host-side buffer, would look fine. With the move inside the prelude the swap happens under
Host::submitted, in submission order, exactly once.The
fillpath (title content uploaded into the presented texture in the present's own list) now starts inCOPY_DESTand is given back toCOPY_SOURCEinside the list, which is where the extra barrier stays.Test
cargo xwin test -p victory-gpuunder Wine on the RADV card (VICTORY_TEST_ADAPTER=hw, real vkd3d-protondevice), hand-built committed 64x64 textures, no game data:
a_copy_source_texture_is_moved_nowhere_by_the_present_list: a texture left inCOPY_SOURCE— the presentlist's prelude is
None(no self-transition is recorded) and the recorded state staysCOPY_SOURCE.a_texture_in_another_state_is_moved_to_copy_source_once: fromRENDER_TARGETthe prelude is recorded once andthe state becomes
COPY_SOURCE; a second list records nothing.a_filled_present_starts_in_copy_dest_and_ends_in_copy_source.Gates: 180 passed / 0 failed (2 ignored) for
victory-gpu;cargo xwin clippy --workspace --all-targets -- -D warningsclean; release build dry run (no--execute):build.toml matched, 2 hooks, 5 modules, every onemissing=0;cargo xtask policy236 files ok; name check cleanOff switch
VICTORY_PRESENT_PRELUDE=0records the copy-up's barrier by hand again (from the state it is recorded in, andback), which is the old sequence; a line is in
xcl-bin/notes/joint-session.mdfor the next session.Credit
Reimplementation of Marvisak/VIctory #2545 by
@reeledMarek (GPL-3.0), not a cherry-pick: their fix adds
move_textureon thepresent's copy list, this tree already tracks the same thing per list (
HostList::settle/prelude), so only thepresent had to stop bypassing it.
Co-authored-by:trailer and a CREDITS.md line.Not tested in a game run.
Summary by CodeRabbit