victory-gpu: refresh and route external host textures through one copy #2726
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!2726
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2726"
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?
@mgunes1311-lab on GitHub · 2026-11-25 18:55 UTC · original
mgunes1311-lab:gpu-external-host-texture→main· +716 −30 · 3 files · 6 commits · openSummary
Arc<HostTexture>(resource::host_copy) across use-stamping, content refresh, and state tracking (HostList::move_texture) inexternal::host_texture, preventing concurrent eviction from replacing the host texture between lookup and list state tracking.resource::alias_source->texture::alias_copy) and upload title-written textures (texture::title_written->texture::upload) so host libraries (such asfidelityfxupscaling) sample initialized texels on first use.twin::route: returntwin.planes[0].textureinUNORDERED_ACCESSfor single-plane twins, rejectUNORDERED_ACCESSon multi-plane depth+stencil twins without mutatinglist.twins, and synchronize newer twin writes back into the depth texture before shader or copy reads.capture::note_targetunderdiagnosticswhen an external caller transitions a texture into a write target state.Coordination
Testing
cargo test -p victory-gpu --locked external::tests::(3 synthetic D3D12 GPU tests covering title-written uploads + guarded-page updates, first-read incompatible placed alias copy, and 1-plane/2-plane depth twin routing)cargo test -p victory-hle --test fidelityfx --lockedcargo clippy --workspace --all-targets --all-features --locked -- -D warningscargo run -p xtask --locked -- policy@kotekompotek on GitHub · 2026-11-25 19:01 UTC · original
Verified the semantics against main:
Tests cover exactly the three risky paths (guarded-page upload, alias first-read, 1/2-plane routing). LGTM.
@mgunes1311-lab on GitHub · 2026-11-25 19:19 UTC · original
Good catch — threaded the held
Arc<HostTexture>throughresource::alias_source_for,texture::alias_copy_to, andtexture::upload_copy(withtexture::staging_for) soexternal::host_texturerefreshes and tracks that single held copy without re-resolving or repopulating an evicted slot, and addedexternal::tests::eviction_after_capturing_copy_refreshes_the_held_host_texturecovering eviction betweenhost_copylookup and refresh on both the alias and upload paths.@oni-swr on GitHub · 2026-11-25 19:41 UTC · original
Independent WARP/CPU verification for head
14c54b0b94against origin/main13f91caee2. State check: open, non-draft, clean merge-tree; no oni-swr comment found.Environment: Windows x64, Rust 1.98.1 (48a229cea 2026-09-01), Windows SDK dxil.dll 10.0.26100.0 (file version 1.8.2502.11); VIctory WARP and D3D12 WARP env vars set. CARGO_TARGET_DIR=D:\victory-warp-2720-target.
Commands/results:
Review: no production blocker found in the inspected alias/upload/twin paths. The new eviction regression test currently does not pass with diagnostics enabled, so that configuration needs a test adjustment or explanation.
Not tested: physical GPU, retail title/game behavior, release build. AI disclosure: Codex (gpt-6-luna).
@fuzeofficlal on GitHub · 2026-11-25 19:46 UTC · original
Independent Windows 11 + NVIDIA GeForce RTX 5090 + WARP verification and code review of
14c54b0b(on13f91ca):Verification (
rustc 1.98.1MSVC)cargo xtask policy: 184 files ok;cargo clippy --locked -p victory-gpu --all-targets(default &--features diagnostics): 0 warnings.VICTORY_D3D12_WARP=1,--features diagnostics):cargo test --locked -p victory-gpu --features diagnostics -- --test-threads=1-> 200 passed, 2 failed, 1 ignored (external::tests::eviction_after_capturing_copy_refreshes_the_held_host_texturefails atexternal.rs:549, andhost::batch::a_copy_is_refreshed_once_per_submission_by_the_pages_writtenfails athost.rs:3523).cargo test --locked -p victory-gpu --lib -- external::tests:: --test-threads=1-> 3 passed, 1 failed (reproduces the exact sameexternal.rs:549failure deterministically).eviction_after_capturing_copy_refreshes_the_held_host_textureorhost::batch::a_copy_is_refreshed_once_per_submission_by_the_pages_writtenwithout runningaliased_textures_copy_from_their_gpu_writer_on_first_external_readbeforehand passes 100%.Bug Found in Code Review (Root Cause of the Deterministic
--test-threads=1Failures)upload_copyafteralias_copy_toleaksHostTexture+watch::Trackerinbindless::uploads's staticLIST(crates/victory-gpu/src/external.rs:44-51):alias_source_formatches and callsalias_copy_to,host_writes_copydefers settinghost_written = trueuntil submission (run_deferred).external.rs:48-50runsif crate::texture::title_written(©.texture) { crate::texture::upload_copy(host, resource, copy); }. Becausehost_writtenis stillfalse(andalias_copy_tomarksfirst_use(to | 1)whileupload_copychecksfirst_use(to)),upload_copystill creates aStaging+watch::track_copyand pushesStep::Texture(staging, copy.clone()).host.execute,bindless::uploads(host.rs:1178, which runs beforerun_deferred) seeshost_written == falseand recordscopyintobindless::uploads's globalstatic LIST(bindless.rs:202), keepingcopy(nowhost_written = true) and itsStaging/watch::Trackeralive until a laterbindless::uploadscall resets that list.MEMORYupgrades that still-livehost_written = truecopy (trippingassert!(give_up_now(placed))atexternal.rs:549) and the stalewatch::Trackerbreakshost::batch(left: 0, right: 65536athost.rs:3523).upload_copywhenalias_copy_toalready populatedcopyfrom an aliased GPU writer (else if crate::texture::title_written(©.texture)).crates/victory-gpu/src/texture.rs(host_writes_copy/alias_copy_tovs #2601'sPendingHostWrite/prepare_host_write—host_writes_copywill want to wire intoPendingHostWriteonce #2601 lands).@Marvisak on GitHub · 2026-11-25 23:16 UTC · original
Automated triage for the maintainers.
Holding one
Arc<HostTexture>across stamping, refresh and state tracking inexternal::host_texture(crates/victory-gpu/src/external.rs) is a sensible fix for the eviction race, and the*_for/*_tovariants inresource.rsandtexture.rsread correctly.It is not mergeable as it stands. The
checkCI job fails on this head, and runs reported in the comments showexternal::tests::eviction_after_capturing_copy_refreshes_the_held_host_texturefailing atexternal.rs:549when it runs after the alias test. The likely cause is inhost_texture_for: aftertexture::alias_copy_tofills the copy,texture::upload_copystill runs, becausehost_writtenis only set when the list is submitted. That upload queues title memory over the alias copy and keeps a staging buffer alive inbindless::uploads.What would change the verdict: skip the upload when the alias copy has already run (
else if title_written), and get a green CI run.Generated by Claude Code
@zed6000 on GitHub · 2026-11-26 13:01 UTC · original
Merged onto current
main63bcca4(git merges it without a conflict),cargo test -p victory-gpu --lib --locked -- --test-threads=1on an RX 7900 XTX aborts the test process:The cause is a semantic conflict with
mainthat git doesn't flag. Since219878a0("GPU: a null shader view has no alias source", the fix for the in-game crash in #2847),main'salias_sourcestarts withif placed.is_null() { return None; }. The mergedalias_sourcefrom this PR is nowlet copy = made(resource(placed))?; alias_source_for(placed, ©), which dereferencesplacedbefore any null check, so a null view crashes again. Keeping the null check at the top ofalias_source(beforemade(resource(placed))) should restore it.In the same full run,
external::tests::eviction_after_capturing_copy_refreshes_the_held_host_textureandhost::batch::a_copy_is_refreshed_once_per_submission_by_the_pages_writtenfail too, in two runs out of two. Run on their own, both pass, so something earlier in the suite affects them. I didn't narrow that down. All of this is with this PR's14c54b0;mainalone passes all 231.@DrDarkDK on GitHub · 2026-11-25 19:01 UTC · original · requested changes
The alias refresh can still switch host copies mid-recording.
host_texture()capturescopy, butalias_source()andalias_copy()look up the destination again. If eviction clears the cached host texture afteralias_source()picks a writer,alias_copy()can populate a replacement whilemove_texture()and the return value still use the originalcopy. The heldArckeeps the original alive, but it doesn’t keep it in the resource cache.Could the alias lookup and copy use the destination
Arcalready held byhost_texture()? A regression could force eviction between lookup and refresh and check that the returned texture contains the alias writer’s texels.AI-assisted with Codex.
@DrDarkDK on GitHub · 2026-11-25 19:27 UTC · original · approved these changes
@mgunes1311-lab on GitHub · 2026-11-26 16:42 UTC · original
Updated onto
main(63bcca4) and addressed the review findings:external::host_texture: changedif crate::texture::title_written(©.texture)afteralias_copy_totoelse ifso a title-memory upload neither overwrites a fresh render-target/depth alias copy nor retainscopyinbindless::uploads.resource::alias_source: restored an explicitif placed.is_null() { return None; }guard beforemade(resource(placed))?after merging63bcca4.Re-verified
external::tests::*(--features diagnostics -- --test-threads=1),resource::tests::a_null_view_has_no_alias_source,host::batch::a_copy_is_refreshed_once_per_submission_by_the_pages_written,cargo clippy --workspace --all-targets --all-features --locked -- -D warnings, andcargo xtask policyon Windows 11 (x86_64-pc-windows-msvc).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.