GPU: refuse raw buffer views that do not start on 16 bytes #123
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/123"
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 Marvisak/VIctory. Originally posted by 9hvn9yt2vk-netizen on 2026-11-24T00:41:27Z.
A raw buffer view on the host must start on a multiple of 16 bytes; the console needs only 4. buffer_srv and buffer_uav move a view's first element by where its memory sits in the host copy, so a title's raw view could land on 4, 8 or 12 bytes past a 16-byte boundary. The host then refuses CreateShaderResourceView (or CreateUnorderedAccessView), and the device is removed (0x887A0001). A user report from the world:
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 (42261210) must be a multiple
of 4 since each element is 4 bytes.
Such a view is now refused like one that is not on an element: the slot gets a null view of its kind (reads zeros) and a warning is logged once. Starting the view 16 bytes lower would need the shader to add the difference.
Type-checked and clippy-clean for x86_64-pc-windows-msvc (cross-checked from Linux with -Zbuild-std); not run against the title.
Imported from Marvisak/VIctory. Originally posted by DaviTostes on 2026-11-24T00:49:19Z.
Tested
828e3cdunder Wine 11.22 + vkd3d-proton 3.1 on Arch Linux x86_64 (AMD RX 9060 XT, RADV 26.3.1), Windows build withcargo xwin ... --target x86_64-pc-windows-msvc: pass, no regression.victory_gpu: 36 passed, 3 failed — the same count and the same three environment-only failures asmain(argument_clamp_builds,a_rejected_blob_gives_an_empty_library, #128'sVirtualQueryupload skip). The diff adds no test for the new 16-byte check, so this run only shows nothing else broke; a syntheticCreateShaderResourceViewwith a non-16-byte-aligned raw offset would cover it (vkd3d-proton is strict about that alignment too).No game data used. AI-assisted (DeepSeek V4.1 Flash coding agent).
Imported from Marvisak/VIctory. Originally posted by oVolkra on 2026-11-24T01:03:57Z.
Tested
828e3cd6(merged onto maind2a4bae1) on RTX 3060, driver 617.14, Windows 11: passcargo test --workspace: 264 passed, 0 failed, 4 ignored (same counts as maind2a4bae1)cargo clippy --workspace --all-targets: no new warnings (the same 2 as main)cargo xtask policy: cleanNot tested: the game was not run, so the 16-byte guard is not exercised on a GPU. The PR adds no unit test for
raw_start_fits, so a passing suite only shows that it builds and breaks nothing else.AI-assisted: this test was run and written up with Claude Code; the numbers above are its unedited output.
Imported from Marvisak/VIctory. Originally posted by ChruutvoLuzi on 2026-11-24T03:00:52Z.
In-game data for the guard, which the comment above says wasn't exercised. RTX 4090, driver 621.01, Windows 11.
828e3cdmerged ontod2a4baetogether with #189, #205, #206, #134 and #89 (it conflicts with #206 inbuffer_srvandbuffer_uav; I kept #206's code and ran this check after it). Diag build, the first mission's opening each time.Across 13 runs that reached the world,
raw buffer view not on 16 bytes of its host copyand its unordered-view twin never fired. Three of those runs did end in0x887A0001, but that was #55 at the time: a check of the device around every descriptor call traced it toCreateRenderTargetViewon a texture #55 had made without render-target use, the case discussed in #55, not to a raw view. The others ended in the0x887A0006hang from #71. So on this card the guard costs nothing in this part of the game, and the raw-view invalid call it prevents didn't come up here.AI-assisted (Claude Code).
Imported from Marvisak/VIctory. Originally posted by mercuryVM on 2026-11-24T07:42:40Z.
Review: APPROVED
Tested
828e3cdon Windows 11, RTX 5070, MSVC:cargo test --workspace --no-fail-fastpasses (254 passed, 0 failed; the branch is based on an older main). Not tested in game.FirstElement % 4 == 0is exactly the rule from the quoted debug-layer message. Checking beforeCreateShaderResourceView/CreateUnorderedAccessViewturns a device removal into a null view plus a one-time warning, which is clearly better.AI-assisted (Claude Code).
Imported from Marvisak/VIctory. Originally posted by 9hvn9yt2vk-netizen on 2026-11-24T09:46:41Z.
Thanks for testing and reviewing! Rebased onto current main (
8e79c80) and added the tests you asked for: raw_views_start_on_16_bytes (which starts the check lets through and refuses, the reported FirstElement 42261210 included) and raw_views_that_fit_are_accepted_by_the_device (every start the check lets through is made as a raw SRV and UAV on the real device, which stays alive). Passes locally on an RTX 4060 with your new CI commands. Agreed that the full fix is the follow-up where the shader adds the offset difference.upstream-sync referenced this pull request2026-11-24 19:03:41 +00:00
Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T00:17:28Z.
Automated triage for the maintainers.
Needs rebase. This PR does not merge cleanly into current
main(ac2525d). Conflicting files:crates/victory-gpu/src/descriptor/host.rs.The content has not been reviewed yet; it will be once the branch is rebased onto
main.Generated by Claude Code
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.