Repository navigation
GPU: refresh texture views when shared host textures are replaced - #3288
fuzeofficlal wants to merge 1 commit into
Conversation
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 replaces the memory's HostTexture in shared_texture, existing shader-visible descriptor heap slots and read-only sibling Resource handles stayed bound to the stale pre-replacement host texture. Bindless shaders and subsequent resource operations therefore kept reading stale zeroed texels instead of the GPU-rendered target. Track replaced host textures in resource::shared_texture, retarget read-only title-written sibling resources whose HostTexture has not been written on the host to the upgraded HostTexture when compatible, refresh any shader-visible view heap slots still holding a replaced texture during descriptor::sync_heaps, generalize HostHeap::mirror's remake check to non-placed texture SRVs, and skip bindless CPU uploads once a texture has been upgraded to a GPU-written host texture.
Dukestar69
left a comment
There was a problem hiding this comment.
Reviewed the diff and verified locally on Windows 11 x64 (RTX 5090):
- Tracking replaced host textures (
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).
|
WARP verification report (test report only, no code changes)
AI use: Claude Code (Claude Sonnet 5.5) |
|
I checked this exact 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 |
Summary
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.