victory-gpu: raw buffer views start on 16 bytes of their host copy (an invalid raw SRV removed the device) #3540
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!3540
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-3540"
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?
@pes7 on GitHub · 2026-11-27 15:47 UTC · original
pes7:fix/raw-view-alignment→main· +77 −3 · 1 files · 1 commits · openThe host refuses a raw buffer view (SRV or UAV) whose first byte is not 16-byte aligned in its buffer. D3D12 treats the call as invalid and removes the device (
DXGI_ERROR_INVALID_CALL, logged as0x887A0004with no breadcrumbs). The console accepts a raw view at any dword.In a title run the debug layer (
VICTORY_D3D12_DEBUG=1) named the call, about 200 s in, in the prison yard:Change
buffer_srvandbuffer_uavaskedshadow::for_viewfor a copy that the view starts on an element (4 bytes) of. A raw view, and a constant buffer (made raw), now asks for 16 bytes instead. A view 4, 8 or 12 bytes past a boundary then gets a copy of its own bytes. That copy starts on 256 (exact), so the view reads the right data instead of a null view.view_copyasks for the same alignment, so the copy that is refreshed and copied back for a view is the one its slot reads.This is the same idea as #3075, which does it for raw UAVs. This change also covers SRVs and constant buffers, and the same views in
view_copy. #123 refuses such views instead, which reads zeros, and needs a rebase.Tested
Windows 11, on
main63bcca4(tests on the default adapter, the integrated AMD Radeon):cargo clippy -p victory-gpu --all-targets -- -D warningsclean, also with--all-features.cargo test -p victory-gpu --lib: 232 passed, 0 failed, including the newraw_views_start_on_16_bytes_of_their_copy. The test checks which views count as raw and which alignment each gets. It deliberately does not register fake buffers in the global shadow registry.In the title, on the tested set in #3409 (
mainplus about 40 open PRs, where this showed up), release +diagnostics, 300 s runs:The same set,
cargo test --workspacewith this change: 930 passed, 0 failed.Not checked: AMD/Intel hosts, and
mainalone in the title. Onmainthe faulting view depends on which copies exist, so it may be rarer there.🤖 Generated with Claude Code
The host refuses a raw SRV or UAV whose first byte is not 16-byte aligned in its buffer: the call is invalid and the device is removed. The console takes a raw view at any dword, and a title run ended so, about 200 s in, with the debug layer naming it: CreateShaderResourceView: When creating a RAW Shader Resource View, the offset of the first element from the start of the buffer must be a multiple of 16 bytes. Thus, FirstElement (2) must be a multiple of 4 buffer_srv and buffer_uav asked shadow::for_view for a copy the view starts on an element (4 bytes) of. A raw view (and a constant buffer, made raw) now asks for 16 bytes instead, so a view 4, 8 or 12 bytes past a boundary gets its own copy, which starts on 256. view_copy asks the same, so the copy refreshed and copied back for a view is the one its slot reads. #3075 does this for raw UAVs; this covers SRVs and constant buffers too. Co-Authored-By: Claude Opus 5.5 <[email protected]>@oni-swr on GitHub · 2026-11-27 16:20 UTC · original
Independent verification of #3540 at
ee3d12dc, base main63bcca43. Verification only, no code pushed, no game data. AI-assisted (Claude Sonnet 5.5).Setup: Windows 11 26200, Windows SDK 26100
dxil.dll,cargo test -p victory-gpu --lib --features diagnostics,cargo clippy -p victory-gpu --all-targets -- -D warnings(with and withoutdiagnostics).63bcca43ee3d12dcVICTORY_WARP=1,VICTORY_D3D12_WARP=1) lib-D warnings(WARP box)The extra test on the head is
raw_views_start_on_16_bytes_of_their_copy, which passes on both WARP and the RX 7800 XT. This covers the AMD case the description marked unchecked, but only as the existing lib suite: there is no title or invalid-raw-SRV reproduction here, so I did not independently confirm the device removal itself.Diff reading:
buffer_srv,buffer_uavandview_copyall go through the samecopy_alignment, so they agree for shader, unordered and placed buffer views. I found no other raw buffer view creation that goes throughfor_view.Non-blocking question (unproven):
view_rawhas aView::Constantbranch, butview_copynever sees one, becausebuffer_rangereturnsNonefor constants.makenow gives a constant slot a 16-aligned exact copy when the address is off 16 within its shadow, whileseen()(bindless.rs) andreadable()(draw.rs) still refreshshadow::find(address, len), the base copy. If a constant buffer can start off 16 bytes inside its copy, would its slot read a copy nothing refreshes? Likely rare, since the console wants 16-byte-aligned constants, and I did not construct a case.@pickles976 on GitHub · 2026-11-27 16:55 UTC · original
Verified exact production head
ee3d12dc356df92a2da49133f11a5f0c98b0291fon Linux6.17 / Wine11 / RTX4060 Laptop8GiB / NVIDIA590.48.1 /16GiB host RAM. Diagnostic-relaxed vkd3d2576c0b4adfae4a+, vendor masking disabled; not stock/native-Windows certification.A local test-only
descriptor::host::tests::misaligned_raw_srv_uav_views_are_gpu_coherentpasses 1/1, eight real GPU dispatch/readback cases: byte offsets4/8/12 and aligned16 control, each across two CPU-update rounds. It uses production placed SRV/UAV construction, heap mirroring, shadow refresh, execution and GPU-write copy-back. Four transformed output words per case, untouched neighbors and unchanged source words are asserted. Backing is fixture-owned VirtualAlloc memory retained through GPU completion; the real NVIDIA device and compiler are mandatory. This checks data, not just descriptor creation or retained shadow identity.Fresh intended-worktree compilation7.97s; test0.67s, zero ignored. Windows-MSVC target, one test thread. Evidence retained locally:
.compat-runtime/logs/verify-pr3540-raw-view-win32-20261127T163417Z/. Production unchanged; local fixture retained. Earlier local harness attempts failed before execution (COFF over-aligned-static LLVM trap, then missing windows-crate feature); replacing only the fixture backing/import resolved those, not a PR production workaround.No CBV coverage, debug-layer certification, title rendering, memory-saving or frame-time claim. This clears the exercised misaligned raw SRV/UAV coherence cases on this Wine/NVIDIA stack.
@cloph-dsp on GitHub · 2026-11-27 17:36 UTC · original
Independent CPU-only verification on Windows / Rust 1.100.0 / MSVC.
ee3d12dc356df92a2da49133f11a5f0c98b0291f, merge base63bcca43c6a00a758510398fa43096ce7e4f7df0.cargo test --locked -p victory-gpu --lib -- descriptor::host::tests::raw_views_start_on_16_bytes_of_their_copy --exact --test-threads=1 --quiettest result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 232 filtered out, exit 0.git grep -F -c raw_views_start_on_16_bytes_of_their_copy 63bcca43 -- .→ exit 1 / 0 hits (test genuinely new); present on PR head.git diff --check 63bcca43 HEAD→ exit 0.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.