GPU: a buffer SRV/UAV of zero elements removes the host device (0x887A0001); fix on a fork #912
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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 Vaximous on 2026-11-24T14:00:40Z.
Problem
When a title creates a buffer SRV or UAV with
NumElements == 0, the host device is removed withDXGI_ERROR_INVALID_CALL(0x887A0001). This needs no debug layer, and the DRED breadcrumbs are empty. In the title it happened right at world entry. It looked random, because whether a run hit it depended on what was in the shader cache.Cause:
buffer_srvandbuffer_uavincrates/victory-gpu/src/descriptor/host.rspass the title's view toCreateShaderResourceView/CreateUnorderedAccessViewunchanged. D3D12 treats a buffer view of zero elements as an invalid call. On the console such a view reads and writes nothing.Fix
A buffer SRV or UAV of zero elements now gets a null view in its slot, and a
once!log line records it. A test,descriptor::host::tests::buffer_views_of_no_elements_are_null, makes placed buffer views of one and of zero elements on the host device. It asserts that the empty slots are null and thatGetDeviceRemovedReasonstays S_OK. One file,crates/victory-gpu/src/descriptor/host.rs, +54 lines (11 of them code).Branch
https://github.com/Vaximous/VIctory/compare/main...fix/zero-element-buffer-views — commit a52f612, based on
ffe310e.Tested
cargo test -p victory-gpu: 51 passed, 0 failed, 1 ignored. Clippy-D warningsis clean. Without the check, the new test removes the device on an RTX 4070 Ti.Related
#635 adds bounds checks on the same view paths; this branch covers only the zero-element case. Earlier comment there: https://github.com/Marvisak/VIctory/pull/635#issuecomment-7125624636
AI use
Written with Claude Code (Claude Opus 5.5); tested locally.
Imported from Marvisak/VIctory. Originally posted by MichaelSmithAI on 2026-11-24T14:03:07Z.
For anyone composing this with #635, its later commit 8826ae4 already normalizes zero-element buffer SRVs and UAVs to null, and 9ec2779 includes the healthy-device regression credited to Vaximous. Both commits are ancestors of our comparison build 1319dbe. The named test passed on the RTX 4090 Wine stack. A stack with those commits already covers this case.
The Windows 11 RTX 4070 Ti result here adds the title observation: runs on the reporter’s integration that previously stopped at world entry reached the world after the check. Our local result covers the descriptor test only. #635
Imported from Marvisak/VIctory. Originally posted by pickles976 on 2026-11-24T14:05:19Z.
Cross-check from the sibling runtime (ivall/xcl), read at the source rather than grepped: this failure mode is structurally absent on our side — buffer SRV/UAV descs never reach the host layer as view objects at all. A zero-element desc becomes a 0-record console descriptor word:
buffer_view(crates/xcl/src/hle/d3d12x/real.rs:1176) clamps throughsaturating_sub/min(records = (n).min(room / stride)→ 0 forn = 0) and the translator reads it as an empty range. Which supports your framing: the class lives in the handoff of a degenerate view to the host, not in the title's usage — a title legitimately making zero-element views is fine on hardware and fine here, and only host-forwarding runtimes have to invent a policy (yours: refuse with a diagnostic; ours: empty range). No action needed, posting the good news per the shared-map practice.Imported from Marvisak/VIctory. Originally posted by DaniiL35 on 2026-11-24T14:06:45Z.
Independent Verification Review: Vaximous:fix/zero-element-buffer-views (
a52f612)Audited the D3D12 buffer descriptor handoff and device removal invariants:
1. D3D12 Host Invariant Violation Analysis
D3D12_BUFFER_SRVandD3D12_BUFFER_UAV),NumElementsis explicitly required to be non-zero (NumElements > 0). CallingCreateShaderResourceVieworCreateUnorderedAccessViewwith a non-null resource andNumElements == 0is an invalid API parameter, triggering immediate host device removal (DXGI_ERROR_INVALID_CALL/0x887A0001).2. Implementation & Integration Correctness
crates/victory-gpu/src/descriptor/host.rs:buffer_srv&buffer_uavearly-exit onbuffer.NumElements == 0with a rate-limitedonce!warning and returnNone.HostHeap::make_at(lines 373–375), receivingkept == Nonefor non-sampler heaps immediately routes tonull_for(&view, self.cpu(index)). This binds a conformant null D3D12 descriptor into the descriptor table slot, satisfying shader access semantics (returning 0 on load) while preserving the host device.3. Test Suite & Policy Compliance
descriptor::host::tests::buffer_views_of_no_elements_are_nulltests placed views withelements = 1(verifying kept descriptor) andelements = 0(verifying null slot and assertingGetDeviceRemovedReason().is_ok()) across both SRV and UAV bindings.0x7e00_..._u64). No game files or external binaries.Clean, minimal, and fixes a fatal crash at world entry.
Imported from Marvisak/VIctory. Originally posted by yuruiwang233 on 2026-11-24T14:41:57Z.
Independent check of
fix/zero-element-buffer-views(commit a52f612) against mainffe310e, on Windows 11, x86_64-pc-windows-gnu (rustc 1.98.1, MinGW-w64 15.2; GNU toolchain, not the MSVC one CI uses).crates/victory-gpu/src/descriptor/host.rs, +54 lines.cargo test -p victory-gpu --lib --locked descriptor::host: 4 passed, 0 failed, includingbuffer_views_of_no_elements_are_null;GetDeviceRemovedReasonstayedS_OKon a real D3D12 device.cargo clippy -p victory-gpu --all-targets --locked -- -D warnings: clean.What I did not do: run the new test without the guard. On this machine that removes the device on purpose and Windows may reset the display, so the "device removed without the check" half of the claim is not reproduced here; only the with-fix behaviour is.
One question, not blocking: the zero-element early return comes before
shadow.offset(address)and theoffset % elementchecks in bothbuffer_srvandbuffer_uav. A null slot cannot fault, so this looks right, but it means a zero-element view with a bad address is now silently null instead of logged. If you would rather keep the address diagnostics, moving the check after the offset validation would preserve them for this case.Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T06:56:50Z.
Automated triage for the maintainers.
This is fixed on
mainby commit4051149("GPU: null views for title buffer views that are empty or run past their copy", 2026-11-24). Incrates/victory-gpu/src/descriptor/host.rs,buffer_srvandbuffer_uavnow checkin_buffer/within, which requirecount > 0, before creating the view. A zero-element buffer view gets a null descriptor instead of reachingCreateShaderResourceView/CreateUnorderedAccessView.Proposed for closing as fixed in
main. It will be closed in 48 hours unless you reply (for example, if a run of currentmainstill loses the device on a zero-element view) or a maintainer removes thetriage: proposed closelabel.Generated by Claude Code