GPU: fix Shadow::sparse_writing tile base for 4 KiB-aligned Map() pointers #100
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/100"
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?
Imported from Belobug/VIctory-Belobug-AMD. Originally posted by luniiya on 2026-11-25T14:04:40Z.
Problem
In
Shadow::sparse_writing(crates/victory-gpu/src/shadow.rs:1949), the start of the mapped 64 KiB tile was computed by masking the host pointer down to a 64 KiB boundary:On Windows WDDM,
ID3D12Resource::Map()on a 32 MiB tile heap returns 64 KiB-aligned pointers, so this happens to land on the tile base. Under Linux / Wine / vkd3d-proton,vkMapMemory/mmaponly guarantees 4 KiB alignment, so masking down to 64 KiB steps before the start of the mapping and crashes immediately with0xc0000005(STATUS_ACCESS_VIOLATION) on world entry when sparse copies are enabled.Fix
Compute the tile base relative to
at % PAGEinstead:data & !(PAGE - 1)whenever the mapping is 64 KiB-aligned (Windows unchanged).crates/victory-gpufor any similar!(PAGE - 1)mask on mapped host pointers; this was the only one.(Complementary to #69: even when sparse copies are turned off by default under Wine, explicitly enabling
VICTORY_SPARSE=1under Wine/vkd3d-proton will no longer segfault.)Tested
x86_64-pc-windows-msvcdiagnostics build withVICTORY_COPY_MEMORY=1and sparse copies enabled.0xc0000005inucrtbase.dll(memcpyfromShadow::sparse_writing) on world entry; with this fix, enters and renders live 3D gameplay cleanly.Imported from Belobug/VIctory-Belobug-AMD. Originally posted by gut0to on 2026-11-25T14:53:46Z.
Review: COMMENTED
AI-assisted review: I traced the old and new tile-base calculations against the reported alignment failure.
Imported from Belobug/VIctory-Belobug-AMD. Originally posted by gut0to on 2026-11-25T14:53:47Z.
Code review location:
crates/victory-gpu/src/shadow.rs; line 1954Could this calculation get a regression test with a 4 KiB-aligned mapped pointer where at % PAGE != 0? That is the case where the old 64 KiB mask returned an address before the mapping, while this subtraction should recover the tile base. AI-assisted review.
Imported from Belobug/VIctory-Belobug-AMD. Originally posted by TobiasFornell on 2026-11-25T21:34:27Z.
Independent confirmation on a different setup: CachyOS, RX 9070 XT (RDNA4, RADV), Proton Experimental,
x86_64-pc-windows-msvcbuild, Belobug base.Without this change we hit the same
0xc0000005inShadow::sparse_writing, about 3.5 minutes into the run. We arrived at the samedata - at % PAGEchange independently. With it: one 480 s run, 0 kernel GPU page faults, no crash (a single run, not a long-term test).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.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.