GPU/texture: fall back to copy_mapped for never-filled partly mapped textures under no_wait #1392
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/fxceless--victory-fork!1392
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/1392/head"
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?
@n-romanovich on GitHub · 2026-11-26 22:33 UTC · original
n-romanovich:fix/1284-no-wait-partly-mapped→main· +85 −24 · 1 files · 1 commits · merged 2026-11-26 23:06 UTCRelated to #923 and #1284.
Problem
When
VICTORY_TEXTURE_NO_WAIT=1is active andwatch::title_memory_reading_now()returnsNone(because the runtime is remapping title memory),Staging::refresh_timeddelegates toStaging::refresh_unlocked.refresh_unlockedreads the texture through the kernel viahost::read_into, which fails whenever any page inside[memory, memory + size)is uncommitted.For a partly mapped streamed texture (such as indexed BC7/BC5 character skin textures),
read_intoalways fails while the tail mips are uncommitted. If the staging buffer has never been filled yet (last.hash.is_none()),refresh_unlockedreturns0without detiling anything; an indexed texture that receives no subsequent refresh keeps an all-zero staging buffer and renders black.Changes (
crates/victory-gpu/src/texture.rs)Staging::refresh_unlockedintorefresh_unlocked_withso the unlock-path logic can be unit-tested against virtual memory reservations without a D3D12 device.refresh_unlocked_with, whenhost::read_intoreturnsfalseandlast.hash.is_none():host::copy_mapped(which copies mapped pages and zero-fills uncommitted pages safely).last.hash = Some(blake3::hash(read))andlast.partial = Some(frame::current()), detile into the staging buffer, and returnsize(incrementingUNLOCKED[0]).last.hashasNone, resetlast.asked = 0, and return0.last.hash.is_some()(the staging buffer already holds previously detiled data), preserve the existing early-return behavior onread_intofailure so an already-valid texture is never overwritten with partial/zeroed data during a concurrent remap.Verification
texture::title_memory_tests::no_wait_unlocked_falls_back_for_never_filled_partly_mapped_textureusingVirtualAlloc(MEM_RESERVE+ partialMEM_COMMIT), verifying:refresh_unlocked_withwithlast.hash == Nonedetiles mapped pages and zero-fills the uncommitted tail, settinglast.hashandlast.partial.refresh_unlocked_withwithlast.hash.is_some()and an uncommitted tail returns0, resetslast.asked = 0, and does not invokedetile.cargo test --locked -p victory-gpu --lib:224 passed; 0 failed; 6 ignoredcargo test --locked -p victory-gpu --features diagnostics --lib texture:15 passed; 0 failed; 1 ignoredcargo build --release --locked -p victory