GPU: constant buffer views of at most 64 KiB #1639

Closed
NuraadGit wants to merge 1 commit from upstream-pr/1640 into main
NuraadGit commented 2026-11-24 20:18:00 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by NuraadGit on 2026-11-24T20:18:00Z.


A constant buffer view larger than 65,536 bytes removes the host device (0x887A0001, "the application made a call that is invalid"). The size the title's descriptor holds went to CreateConstantBufferView as it was, rounded up to 256. This caps it at 64 KiB, which is all a shader can index.

Where such sizes come from. The title's view heap keeps old contents in slots it doesn't use, and the host makes a view for each. In two runs on an RTX 2080 that ended in 0x887A0001, the 64 views made just before the removal included constant buffer views of 969,472 and 896,256 bytes, at addresses that look like leftovers (0x7fe8…).

Measured on an RTX 2080 (driver 616.56, Windows 11). One view per process, then GetDeviceRemovedReason:

View Device
256 bytes stays
969,472 bytes removed
not on a 256-byte address removed
size not a multiple of 256 removed
256 bytes at an address of no buffer stays

Test. an_oversized_constant_buffer_view_leaves_the_device_alive makes both sizes through make and one through constant_at, and checks the device after each. Without the cap it fails at the first one ("a view of 969472 bytes"); with it, it passes. cargo test -p victory-gpu --lib: 51 passed, 1 ignored. cargo clippy -p victory-gpu --all-targets --locked -- -D warnings: clean. On ffe310e.

What this doesn't show.

  • The two runs were on fxceless/victory-gta6 (d279e69 and 7b0f736), which has the same code here. I haven't run main in the title with and without this change.
  • A third run with the same removal reason had no oversized view in its list of 64, so this may not be the only cause.
  • Zero-sized views are left as they are: #1629 handles those and touches the same two lines. Either can be rebased onto the other.

AI-assisted (Claude Code); counts and log lines only, nothing from the game attached.

<!-- greyfinch-sync:Marvisak/VIctory:issue:6590595606 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1640). Originally posted by [NuraadGit](https://github.com/NuraadGit) on 2026-11-24T20:18:00Z. --- A constant buffer view larger than 65,536 bytes removes the host device (`0x887A0001`, "the application made a call that is invalid"). The size the title's descriptor holds went to `CreateConstantBufferView` as it was, rounded up to 256. This caps it at 64 KiB, which is all a shader can index. **Where such sizes come from.** The title's view heap keeps old contents in slots it doesn't use, and the host makes a view for each. In two runs on an RTX 2080 that ended in `0x887A0001`, the 64 views made just before the removal included constant buffer views of 969,472 and 896,256 bytes, at addresses that look like leftovers (`0x7fe8…`). **Measured on an RTX 2080** (driver 616.56, Windows 11). One view per process, then `GetDeviceRemovedReason`: | View | Device | |---|---| | 256 bytes | stays | | 969,472 bytes | removed | | not on a 256-byte address | removed | | size not a multiple of 256 | removed | | 256 bytes at an address of no buffer | stays | **Test.** `an_oversized_constant_buffer_view_leaves_the_device_alive` makes both sizes through `make` and one through `constant_at`, and checks the device after each. Without the cap it fails at the first one ("a view of 969472 bytes"); with it, it passes. `cargo test -p victory-gpu --lib`: 51 passed, 1 ignored. `cargo clippy -p victory-gpu --all-targets --locked -- -D warnings`: clean. On `ffe310e`. **What this doesn't show.** - The two runs were on fxceless/victory-gta6 (d279e69 and 7b0f736), which has the same code here. I haven't run `main` in the title with and without this change. - A third run with the same removal reason had no oversized view in its list of 64, so this may not be the only cause. - Zero-sized views are left as they are: #1629 handles those and touches the same two lines. Either can be rebased onto the other. AI-assisted (Claude Code); counts and log lines only, nothing from the game attached.
DenRakEiw commented 2026-11-24 21:02:56 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by DenRakEiw on 2026-11-24T20:26:20Z.

Review: APPROVED


Verified locally merged onto origin/main (Windows 11 x64, NVIDIA GeForce RTX 5090 + WARP, Rust 1.98.1 MSVC):

  • cargo test -p victory-gpu — 51 passed, 0 failed (1 ignored) on both RTX 5090 hardware and VICTORY_D3D12_WARP=1 (including an_oversized_constant_buffer_view_leaves_the_device_alive)
  • cargo clippy -p victory-gpu --all-targets — 0 warnings
  • cargo xtask policy — ok

Clean clamping of CBV SizeInBytes to the D3D12 64 KiB maximum so oversized CBVs do not trigger device removal. Looks good.

AI-assisted (Gemini 4 Neon).

<!-- greyfinch-sync:Marvisak/VIctory:review:6046817241 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1640#pullrequestreview-6046817241). Originally posted by [DenRakEiw](https://github.com/DenRakEiw) on 2026-11-24T20:26:20Z. **Review:** APPROVED --- Verified locally merged onto `origin/main` (Windows 11 x64, NVIDIA GeForce RTX 5090 + WARP, Rust 1.98.1 MSVC): - `cargo test -p victory-gpu` — 51 passed, 0 failed (1 ignored) on both RTX 5090 hardware and `VICTORY_D3D12_WARP=1` (including `an_oversized_constant_buffer_view_leaves_the_device_alive`) - `cargo clippy -p victory-gpu --all-targets` — 0 warnings - `cargo xtask policy` — ok Clean clamping of CBV `SizeInBytes` to the D3D12 64 KiB maximum so oversized CBVs do not trigger device removal. Looks good. AI-assisted (Gemini 4 Neon).
NuraadGit commented 2026-11-24 21:03:42 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by NuraadGit on 2026-11-24T20:50:33Z.


In-title result for the cap, on an RTX 2080 (fxceless/victory-gta6 7b0f736 + this change + a diagnostics-only present log, no loop limit, Series X profile).

  • One session of 17 min 42 s (frame 3,822), ended by me, with 0 device removals.
  • 3 min 15 s in, the cap cut a view of 955,136 bytes at 0x7fe8ba580000. The line is logged once per run, so later ones would not show.
  • Before this change, three runs here ended in 0x887A0001 about 5 to 6.5 minutes after launch, two of them with a view like this among the 64 made last. The probe in the description shows that making one removes the device.

It is one session, so it shows that such a view does turn up in the title and that the device stays, not how often the old build would have ended.

AI-assisted (Claude Code); counts and log lines only, nothing from the game attached.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7144129207 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1640#issuecomment-7144129207). Originally posted by [NuraadGit](https://github.com/NuraadGit) on 2026-11-24T20:50:33Z. --- In-title result for the cap, on an RTX 2080 (fxceless/victory-gta6 `7b0f736` + this change + a diagnostics-only present log, no loop limit, Series X profile). - One session of 17 min 42 s (frame 3,822), ended by me, with 0 device removals. - 3 min 15 s in, the cap cut a view of 955,136 bytes at `0x7fe8ba580000`. The line is logged once per run, so later ones would not show. - Before this change, three runs here ended in `0x887A0001` about 5 to 6.5 minutes after launch, two of them with a view like this among the 64 made last. The probe in the description shows that making one removes the device. It is one session, so it shows that such a view does turn up in the title and that the device stays, not how often the old build would have ended. AI-assisted (Claude Code); counts and log lines only, nothing from the game attached.
catminou4 commented 2026-11-24 22:01:42 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-24T21:41:52Z.

Review: COMMENTED


Static review only: Windows-only code (D3D12/windows_sys/Win32/HLE) — nothing compiles or runs on macOS; source review of the diff.

CBV SizeInBytes is capped: constant_bytes = min(size, 64 KiB).next_multiple_of(256) — the host removes the device for larger views, and the title's heap holds such sizes in slots it does not use. The Windows test uses a real device and checks GetDeviceRemovedReason stays Ok across oversized views (969_472 and 896_256 bytes). Note the cap interacts with #1629's 256-byte padding — both compose since padding applies after the cap. Windows-only.

<!-- greyfinch-sync:Marvisak/VIctory:review:6047871001 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1640#pullrequestreview-6047871001). Originally posted by [catminou4](https://github.com/catminou4) on 2026-11-24T21:41:52Z. **Review:** COMMENTED --- Static review only: Windows-only code (D3D12/windows_sys/Win32/HLE) — nothing compiles or runs on macOS; source review of the diff. CBV SizeInBytes is capped: constant_bytes = min(size, 64 KiB).next_multiple_of(256) — the host removes the device for larger views, and the title's heap holds such sizes in slots it does not use. The Windows test uses a real device and checks GetDeviceRemovedReason stays Ok across oversized views (969_472 and 896_256 bytes). Note the cap interacts with #1629's 256-byte padding — both compose since padding applies after the cap. Windows-only.
upstream-sync closed this pull request 2026-11-25 00:05:53 +00:00
NuraadGit commented 2026-11-25 00:06:51 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by NuraadGit on 2026-11-24T23:42:03Z.


Closing this. Since today's push to main, nothing creates a D3D12 constant buffer view: git grep CreateConstantBufferView finds nothing in crates/victory-gpu. Constant views (View::Constant) are now read through raw buffer views over the host copies, so the 64 KiB SizeInBytes limit this PR capped can't be hit any more. The branch also conflicts with main now.

The fix still matters on fxceless/victory-fork, which does create constant buffer views: fxceless/victory-fork#24. If a later change brings real CBVs back here, I'll reopen this.

Thanks @DenRakEiw for the review and the testing.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7147697462 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1640#issuecomment-7147697462). Originally posted by [NuraadGit](https://github.com/NuraadGit) on 2026-11-24T23:42:03Z. --- Closing this. Since today's push to `main`, nothing creates a D3D12 constant buffer view: `git grep CreateConstantBufferView` finds nothing in `crates/victory-gpu`. Constant views (`View::Constant`) are now read through raw buffer views over the host copies, so the 64 KiB `SizeInBytes` limit this PR capped can't be hit any more. The branch also conflicts with `main` now. The fix still matters on fxceless/victory-fork, which does create constant buffer views: fxceless/victory-fork#24. If a later change brings real CBVs back here, I'll reopen this. Thanks @DenRakEiw for the review and the testing.

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
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.

Reference
Marvisak/VIctory!1639
No description provided.