GPU: refuse raw buffer views that do not start on 16 bytes #123

Open
github-bot wants to merge 2 commits from github-bot/gh-123 into main AGit
Owner

@⁠9hvn9yt2vk-netizen on GitHub · 2026-11-24 00:41 UTC · original
9hvn9yt2vk-netizen:raw-view-alignment → main · +119 −0 · 1 files · 2 commits · open

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.

**@⁠9hvn9yt2vk-netizen** on GitHub · 2026-11-24 00:41 UTC · [original](https://github.com/Marvisak/VIctory/pull/123) `9hvn9yt2vk-netizen:raw-view-alignment` → `main` · +119 −0 · 1 files · 2 commits · open 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.
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.
As the reviews of this change asked: raw_views_start_on_16_bytes checks
which starts the check lets through (elements 0, 4, 8...) and refuses
(4, 8 and 12 bytes past a boundary, the user report's FirstElement
42261210 included); raw_views_that_fit_are_accepted_by_the_device makes
every start the check lets through below 64 as a raw SRV and UAV of a
real buffer and checks the device stays alive.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:51:09 +00:00
Author
Owner

@⁠DaviTostes on GitHub · 2026-11-24 00:49 UTC · original

Tested 828e3cd under Wine 11.22 + vkd3d-proton 3.1 on Arch Linux x86_64 (AMD RX 9060 XT, RADV 26.3.1), Windows build with cargo 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 as main (argument_clamp_builds, a_rejected_blob_gives_an_empty_library, #128's VirtualQuery upload skip). The diff adds no test for the new 16-byte check, so this run only shows nothing else broke; a synthetic CreateShaderResourceView with 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).

**@⁠DaviTostes** on GitHub · 2026-11-24 00:49 UTC · [original](https://github.com/Marvisak/VIctory/pull/123#issuecomment-7118467908) Tested `828e3cd` under **Wine 11.22 + vkd3d-proton 3.1** on Arch Linux x86_64 (AMD RX 9060 XT, RADV 26.3.1), Windows build with `cargo 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 as `main` (`argument_clamp_builds`, `a_rejected_blob_gives_an_empty_library`, #128's `VirtualQuery` upload skip). The diff adds no test for the new 16-byte check, so this run only shows nothing else broke; a synthetic `CreateShaderResourceView` with 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).
Author
Owner

@⁠oVolkra on GitHub · 2026-11-24 01:03 UTC · original

Tested 828e3cd6 (merged onto main d2a4bae1) on RTX 3060, driver 617.14, Windows 11: pass

  • cargo test --workspace: 264 passed, 0 failed, 4 ignored (same counts as main d2a4bae1)
  • cargo clippy --workspace --all-targets: no new warnings (the same 2 as main)
  • cargo xtask policy: clean

Not 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.

**@⁠oVolkra** on GitHub · 2026-11-24 01:03 UTC · [original](https://github.com/Marvisak/VIctory/pull/123#issuecomment-7118717055) Tested 828e3cd6 (merged onto main d2a4bae1) on RTX 3060, driver 617.14, Windows 11: pass - `cargo test --workspace`: 264 passed, 0 failed, 4 ignored (same counts as main d2a4bae1) - `cargo clippy --workspace --all-targets`: no new warnings (the same 2 as main) - `cargo xtask policy`: clean Not 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.
Author
Owner

@⁠ChruutvoLuzi on GitHub · 2026-11-24 03:00 UTC · original

In-game data for the guard, which the comment above says wasn't exercised. RTX 4090, driver 621.01, Windows 11. 828e3cd merged onto d2a4bae together with #189, #205, #206, #134 and #89 (it conflicts with #206 in buffer_srv and buffer_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 copy and its unordered-view twin never fired. Three of those runs did end in 0x887A0001, but that was #55 at the time: a check of the device around every descriptor call traced it to CreateRenderTargetView on a texture #55 had made without render-target use, the case discussed in #55, not to a raw view. The others ended in the 0x887A0006 hang 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).

**@⁠ChruutvoLuzi** on GitHub · 2026-11-24 03:00 UTC · [original](https://github.com/Marvisak/VIctory/pull/123#issuecomment-7120689345) In-game data for the guard, which the comment above says wasn't exercised. RTX 4090, driver 621.01, Windows 11. `828e3cd` merged onto `d2a4bae` together with #189, #205, #206, #134 and #89 (it conflicts with #206 in `buffer_srv` and `buffer_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 copy` and its unordered-view twin never fired. Three of those runs did end in `0x887A0001`, but that was #55 at the time: a check of the device around every descriptor call traced it to `CreateRenderTargetView` on a texture #55 had made without render-target use, the case discussed in #55, not to a raw view. The others ended in the `0x887A0006` hang 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).
Author
Owner

@⁠9hvn9yt2vk-netizen on GitHub · 2026-11-24 09:46 UTC · original

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.

**@⁠9hvn9yt2vk-netizen** on GitHub · 2026-11-24 09:46 UTC · [original](https://github.com/Marvisak/VIctory/pull/123#issuecomment-7127874525) 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.
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 00:17 UTC · original

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

**@⁠Marvisak** on GitHub · 2026-11-25 00:17 UTC · [original](https://github.com/Marvisak/VIctory/pull/123#issuecomment-7148354850) <!-- victory-triage v1 head=bc747281dcd62bccfd36f4692755a12378b32e0d verdict=needs-rebase at=2026-11-25T00:13:20Z --> 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](https://claude.ai/code)_
This pull request has changes conflicting with the target branch.
  • crates/victory-gpu/src/descriptor/host.rs
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/123/head:github-bot/gh-123'
git switch 'github-bot/gh-123'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-123'
git switch 'github-bot/gh-123'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-123'
git switch 'github-bot/gh-123'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-123'
git switch 'main'
git merge --squash 'github-bot/gh-123'
git switch 'main'
git merge --ff-only 'github-bot/gh-123'
git switch 'main'
git merge 'github-bot/gh-123'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No reviewers
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory!123
No description provided.