GPU: refresh texture views when shared host textures are replaced #3288
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!3288
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-3288"
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?
@fuzeofficlal on GitHub · 2026-11-26 16:02 UTC · original
fuzeofficlal:fix/gpu-refresh-replaced-texture-views→main· +536 −25 · 4 files · 1 commits · openSummary
When a title creates or mirrors a read-only texture view at a console memory address before a render target or unordered-access texture at the same address (
MemoryKey) replaces the memory'sHostTextureinresource::shared_texture, existing shader-visible descriptor heap slots and read-only siblingResourceobjects stay permanently bound to the stale pre-replacementHostTexture. Bindless shaders (which do not rewrite already-populated heap slots) and subsequent resource operations therefore continue sampling stale zeroed texels instead of the GPU-rendered target.Root Cause
resource::shared_texturereplaced theMEMORYmap entry with the upgradedHostTexture, but never retargeted compatible read-only title-written siblingResourcehandles or notified shader-visible descriptor heaps that the oldHostTexturewas superseded.descriptor::sync_heapsonly re-mirrored slots whose descriptor memory pages were modified (sync_slots), leaving unmodified slots holding the oldHostTexturestale indefinitely (includingView::Placedslots already materialized viamake_readand regularView::Shaderslots).HostHeap::mirror'sneeds_remakecheck only checked whether the heldID3D12Resourcechanged foris_placed_textureviews, ignoring non-placedView::Shaderslots even when bound through a descriptor table (for_draw == true).bindless::uploadscheckedhost_writtenbut not!texture::title_written, which could upload stale title memory over a texture handle retargeted to a GPU-writtenHostTexture.Fix
crates/victory-gpu/src/resource.rs:HAS_REPLACED+REPLACED_TEXTURES, zero lock/scan cost when no texture is replaced).shared_texture, after releasing theMEMORYlock: if the supersededHostTextureis title-written and nothost_written, retarget compatible siblingResourceobjects at the same address andMemoryKey(using the sameTEXTURES_AT -> r.hostlock order asgive_up/candidates) to the upgradedHostTexture. GPU-writable andhost_writtentextures are left untouched on their owningResourcehandles so rendered/copied contents are never discarded. Always record the replacedID3D12Resourcepointer for heap refresh.crates/victory-gpu/src/descriptor.rs:sync_heapsand callHostHeap::refresh_replacedon shader-visible view heaps (including heaps without page write-tracking).crates/victory-gpu/src/descriptor/host.rs:HostHeap::refresh_replacedto re-mirror only already-materialized title slots (0..count) still holding a replacedHostTexture(never eagerly materializing unmadeView::Placedslots; retiring the old COM reference viakeep).HostHeap::mirror'sneeds_remakecheck to also cover non-placed textureView::Shaderslots.crates/victory-gpu/src/bindless.rs:bindless::uploadswhen a tracked texture is no longertitle_written.Verification
bindless::tests::bindless_placed_srv_sees_render_target_that_replaces_its_host_texturebindless::tests::bindless_resource_srv_sees_render_target_that_replaces_its_host_texturedescriptor::host::tests::non_placed_srv_remakes_on_table_mirror_after_host_texture_replacementdescriptor::host::tests::gpu_written_replaced_host_texture_stays_with_its_owner_while_placed_views_refreshvictory-gputest suites on hardware D3D12 (default &--features diagnosticswith Debug Layer) and WARP (--features diagnosticswith Debug Layer),cargo clippy --workspace --all-targets(default &--all-features,-D warnings),git diff --check, andcargo run --locked -p xtask -- policy.@Dukestar69 on GitHub · 2026-11-26 16:09 UTC · original · approved these changes
Reviewed the diff and verified locally on Windows 11 x64 (RTX 5090):
note_replaced/take_replaced), retargeting read-only sibling title textures while keeping GPU-written ones bridged viaalias_source, and refreshing affected descriptor heap slots and bindless views cleanly prevents stale SRV reads after shared host texture replacement.cargo test -p victory-gpu --lib bindless:: -- --test-threads=1(RTX 5090): 5 passed, 0 failed (includingbindless_placed_srv_sees_render_target_that_replaces_its_host_textureandbindless_resource_srv_sees_render_target_that_replaces_its_host_texture).cargo test -p victory-gpu --lib descriptor:: -- --test-threads=1 --skip dynamic_slots_are_held_until_released(RTX 5090): 23 passed, 0 failed (includinggpu_written_replaced_host_texture_stays_with_its_owner_while_placed_views_refreshandnon_placed_srv_remakes_on_table_mirror_after_host_texture_replacement).cargo test -p victory-gpu --lib resource:: -- --test-threads=1(RTX 5090): 18 passed, 0 failed.cargo clippy -p victory-gpu --all-targets -- -D warnings: clean.cargo xtask policy: 191 files ok.Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
@oni-swr on GitHub · 2026-11-26 16:42 UTC · original
WARP verification report (test report only, no code changes)
d24fd44363bcca43(control); WARP software adapter forced withVICTORY_WARP=1 VICTORY_D3D12_WARP=1,--features diagnostics, d3d10warp.dll 10.0.26100.9818; dxil.dll 1.8.2502.11 (Windows Kit 10.0.26100.0, viaVICTORY_DXIL). No physical GPU. Synthetic tests only, no game data.cargo test -p victory-gpu --lib --features diagnostics --no-run -j 4, then the test binary with--exact <name> --test-threads 1per test, then the whole lib suite.bindless::tests::bindless_placed_srv_sees_render_target_that_replaces_its_host_texture,bindless::tests::bindless_resource_srv_sees_render_target_that_replaces_its_host_texture,descriptor::host::tests::non_placed_srv_remakes_on_table_mirror_after_host_texture_replacement,descriptor::host::tests::gpu_written_replaced_host_texture_stays_with_its_owner_while_placed_views_refresh.retargeted HostTexturepointer check; the placed-view test failsplaced view slot refreshes to the upgraded HostTexture.victory-gpulib suite: PR 249 passed, 1 failed, 1 ignored; main plus the tests 5 failed (the 4 new tests and the failure below).frame::tests::waits_end_on_ticks_and_count_frames; it fails alone in its own process on the PR and on main, so it is not caused by this PR.AI use: Claude Code (Claude Sonnet 5.5)
@andrewpozdnakov7-jpg on GitHub · 2026-11-26 17:35 UTC · original
I checked this exact
d24fd44with the selective mip upload candidate from #1210. They conflict in the bindless upload gate. The integration303628ckeeps this PR's GPU-written texture check. CPU-fed textures that received a host copy reach the subresource refresh, which preserves any mip still backed by that copy.All four replacement-view tests pass on verified app-local Agility 1.620.2/WARP 1.0.22. The selective mip test also passes all three runs with linear/packed textures and both watched and untracked memory. Full GPU diagnostics 252 passed, 0 failed, 1 ignored, including runtime identity. Strict GPU Clippy passed with default and all features, and policy passed.
This resolution is available if both changes are adopted. If folding it into another commit, please retain its Git author or add
Co-authored-by: andrewpozdnakov7-jpg <[email protected]>. AI-assisted with Codex.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.