Skip to content

GPU: a buffer view of no elements is made null instead of removing the device - #4

Merged
MagiccConch merged 1 commit into
mainfrom
fix/zero-element-buffer-views
Nov 24, 2026
Merged

MagiccConch merged 1 commit into
mainfrom
fix/zero-element-buffer-views

Conversation

@MagiccConch

Copy link
Copy Markdown
Owner

Fixes (upstream tracking) Marvisak#912.

What changed

One file, crates/victory-gpu/src/descriptor/host.rs (+54, 11 of them code). Port of Vaximous's commit a52f612 on fix/zero-element-buffer-views — the fork's file matches its base (ffe310e) and the patch applies as-is.

  • buffer_srv / buffer_uav: a buffer view with NumElements == 0 no longer reaches CreateShaderResourceView / CreateUnorderedAccessView; the slot gets a null view and a once! line records it.
  • New test buffer_views_of_no_elements_are_null makes placed buffer views of one and of zero elements on a host device, asserts the empty slots are null and GetDeviceRemovedReason stays S_OK (skips without a host GPU, like the other device tests).

Why

D3D12 treats a buffer SRV or UAV with NumElements == 0 as an invalid call and removes the device (DXGI_ERROR_INVALID_CALL, 0x887A0001) — no debug layer, empty DRED breadcrumbs. The title hit this right at world entry, appearing random because it depended on shader-cache contents. On the console a zero-element view reads and writes nothing, which is exactly what the null view does. Upstream verification: RTX 4070 Ti (Windows 11) runs that previously died at world entry reach the world with this check; without it, the new test removes the device. Related: Marvisak#635 bounds-checks the same view paths; this covers only the zero-element case.

Validation here

  • cargo check -p victory-gpu --target x86_64-pc-windows-msvc --all-targets --all-features --locked — clean.
  • cargo clippy -p victory-gpu --target x86_64-pc-windows-msvc --all-targets --all-features --locked -- -D warnings — clean.
  • No GPU on this machine, so the new device test runs in CI (where it skips gracefully) and was hardware-verified upstream; also independently reproduced by two other parties in the upstream thread (Wine RTX 4090 and Windows 10 MSVC).

This PR was created by an AI agent (OpenHands) on behalf of the user.

…e device

Port of Vaximous's a52f612 on fix/zero-element-buffer-views (issue Marvisak#912);
it applies as-is.

D3D12 treats a buffer SRV or UAV with NumElements 0 as an invalid call and
removes the device (DXGI_ERROR_INVALID_CALL), with no debug layer needed.
buffer_srv and buffer_uav passed such a title view straight to the host.
On the console a view of no elements reads and writes nothing, as the null
view the slot now gets does.

The new test makes placed buffer views of one and of no elements on the
host device: without the change the device is removed with 0x887A0001.

Co-authored-by: Vaximous <vaximous@gmail.com>
Co-authored-by: openhands <openhands@all-hands.dev>
@MagiccConch
MagiccConch marked this pull request as ready for review November 24, 2026 20:35
@MagiccConch
MagiccConch merged commit 17d48e8 into main Nov 24, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants