GPU: a buffer SRV/UAV of zero elements removes the host device (0x887A0001); fix on a fork #912

Open
opened 2026-11-26 04:14:09 +00:00 by github-bot · 5 comments
Owner

@⁠Vaximous on GitHub · 2026-11-24 14:00 UTC · original

Problem

When a title creates a buffer SRV or UAV with NumElements == 0, the host device is removed with DXGI_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_srv and buffer_uav in crates/victory-gpu/src/descriptor/host.rs pass the title's view to CreateShaderResourceView / CreateUnorderedAccessView unchanged. 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 that GetDeviceRemovedReason stays 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 warnings is clean. Without the check, the new test removes the device on an RTX 4070 Ti.
  • Runtime (RTX 4070 Ti, Windows 11): measured on our local integration build (main plus a set of open PRs), not on plain main. Runs that had been removed at world entry reach the world with the check.

#635 adds bounds checks on the same view paths; this branch covers only the zero-element case. Earlier comment there: #635

AI use

Written with Claude Code (Claude Opus 5.5); tested locally.

**@⁠Vaximous** on GitHub · 2026-11-24 14:00 UTC · [original](https://github.com/Marvisak/VIctory/issues/912) ## Problem When a title creates a buffer SRV or UAV with `NumElements == 0`, the host device is removed with `DXGI_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_srv` and `buffer_uav` in `crates/victory-gpu/src/descriptor/host.rs` pass the title's view to `CreateShaderResourceView` / `CreateUnorderedAccessView` unchanged. 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 that `GetDeviceRemovedReason` stays 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 warnings` is clean. Without the check, the new test removes the device on an RTX 4070 Ti. - Runtime (RTX 4070 Ti, Windows 11): measured on our local integration build (main plus a set of open PRs), not on plain main. Runs that had been removed at world entry reach the world with the check. ## Related #635 adds bounds checks on the same view paths; this branch covers only the zero-element case. Earlier comment there: https://git.gtahub.st/github/Marvisak--VIctory/pulls/635 ## AI use Written with Claude Code (Claude Opus 5.5); tested locally.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:14:09 +00:00
Author
Owner

@⁠MichaelSmithAI on GitHub · 2026-11-24 14:03 UTC · original

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

**@⁠MichaelSmithAI** on GitHub · 2026-11-24 14:03 UTC · [original](https://github.com/Marvisak/VIctory/issues/912#issuecomment-7133758653) 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](https://git.gtahub.st/github/Marvisak--VIctory/pulls/635)
Author
Owner

@⁠pickles976 on GitHub · 2026-11-24 14:05 UTC · original

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 through saturating_sub/min (records = (n).min(room / stride) → 0 for n = 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.

**@⁠pickles976** on GitHub · 2026-11-24 14:05 UTC · [original](https://github.com/Marvisak/VIctory/issues/912#issuecomment-7133820664) 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 through `saturating_sub`/`min` (`records = (n).min(room / stride)` → 0 for `n = 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.
Author
Owner

@⁠DaniiL35 on GitHub · 2026-11-24 14:06 UTC · original

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

  • Under Direct3D 12 (D3D12_BUFFER_SRV and D3D12_BUFFER_UAV), NumElements is explicitly required to be non-zero (NumElements > 0). Calling CreateShaderResourceView or CreateUnorderedAccessView with a non-null resource and NumElements == 0 is an invalid API parameter, triggering immediate host device removal (DXGI_ERROR_INVALID_CALL / 0x887A0001).
  • On Xbox console hardware (unified memory architecture), a title binding a buffer view with 0 elements legitimately performs a no-op (reads 0 / ignores writes) without hardware faults.

2. Implementation & Integration Correctness

  • In crates/victory-gpu/src/descriptor/host.rs:
    • buffer_srv & buffer_uav early-exit on buffer.NumElements == 0 with a rate-limited once! warning and return None.
    • In HostHeap::make_at (lines 373–375), receiving kept == None for non-sampler heaps immediately routes to null_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

  • Test Integrity: descriptor::host::tests::buffer_views_of_no_elements_are_null tests placed views with elements = 1 (verifying kept descriptor) and elements = 0 (verifying null slot and asserting GetDeviceRemovedReason().is_ok()) across both SRV and UAV bindings.
  • Rule #1 Policy: Uses pure synthetic descriptor words and registered virtual address ranges (0x7e00_..._u64). No game files or external binaries.

Clean, minimal, and fixes a fatal crash at world entry.

**@⁠DaniiL35** on GitHub · 2026-11-24 14:06 UTC · [original](https://github.com/Marvisak/VIctory/issues/912#issuecomment-7133857699) ### 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 - Under Direct3D 12 (`D3D12_BUFFER_SRV` and `D3D12_BUFFER_UAV`), `NumElements` is explicitly required to be non-zero (`NumElements > 0`). Calling `CreateShaderResourceView` or `CreateUnorderedAccessView` with a non-null resource and `NumElements == 0` is an invalid API parameter, triggering immediate host device removal (`DXGI_ERROR_INVALID_CALL` / `0x887A0001`). - On Xbox console hardware (unified memory architecture), a title binding a buffer view with 0 elements legitimately performs a no-op (reads 0 / ignores writes) without hardware faults. --- ### 2. Implementation & Integration Correctness - In `crates/victory-gpu/src/descriptor/host.rs`: - `buffer_srv` & `buffer_uav` early-exit on `buffer.NumElements == 0` with a rate-limited `once!` warning and return `None`. - In `HostHeap::make_at` (lines 373–375), receiving `kept == None` for non-sampler heaps immediately routes to `null_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 - **Test Integrity**: `descriptor::host::tests::buffer_views_of_no_elements_are_null` tests placed views with `elements = 1` (verifying kept descriptor) and `elements = 0` (verifying null slot and asserting `GetDeviceRemovedReason().is_ok()`) across both SRV and UAV bindings. - **Rule #1 Policy**: Uses pure synthetic descriptor words and registered virtual address ranges (`0x7e00_..._u64`). No game files or external binaries. Clean, minimal, and fixes a fatal crash at world entry.
Author
Owner

@⁠yuruiwang233 on GitHub · 2026-11-24 14:41 UTC · original

Independent check of fix/zero-element-buffer-views (commit a52f612) against main ffe310e, on Windows 11, x86_64-pc-windows-gnu (rustc 1.98.1, MinGW-w64 15.2; GNU toolchain, not the MSVC one CI uses).

  • Diff matches the description: one file, crates/victory-gpu/src/descriptor/host.rs, +54 lines.
  • cargo test -p victory-gpu --lib --locked descriptor::host: 4 passed, 0 failed, including buffer_views_of_no_elements_are_null; GetDeviceRemovedReason stayed S_OK on 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 the offset % element checks in both buffer_srv and buffer_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.

**@⁠yuruiwang233** on GitHub · 2026-11-24 14:41 UTC · [original](https://github.com/Marvisak/VIctory/issues/912#issuecomment-7134802237) Independent check of `fix/zero-element-buffer-views` (commit a52f612) against main `ffe310e`, on Windows 11, x86_64-pc-windows-gnu (rustc 1.98.1, MinGW-w64 15.2; GNU toolchain, not the MSVC one CI uses). - Diff matches the description: one file, `crates/victory-gpu/src/descriptor/host.rs`, +54 lines. - `cargo test -p victory-gpu --lib --locked descriptor::host`: 4 passed, 0 failed, including `buffer_views_of_no_elements_are_null`; `GetDeviceRemovedReason` stayed `S_OK` on 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 the `offset % element` checks in both `buffer_srv` and `buffer_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.
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 06:56 UTC · original

Automated triage for the maintainers.

This is fixed on main by commit 4051149 ("GPU: null views for title buffer views that are empty or run past their copy", 2026-11-24). In crates/victory-gpu/src/descriptor/host.rs, buffer_srv and buffer_uav now check in_buffer / within, which require count > 0, before creating the view. A zero-element buffer view gets a null descriptor instead of reaching CreateShaderResourceView / CreateUnorderedAccessView.

Proposed for closing as fixed in main. It will be closed in 48 hours unless you reply (for example, if a run of current main still loses the device on a zero-element view) or a maintainer removes the triage: proposed close label.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 06:56 UTC · [original](https://github.com/Marvisak/VIctory/issues/912#issuecomment-7155323993) <!-- victory-issue-triage v1 verdict=proposed-close seen=2026-11-24T14:41:57Z at=2026-11-25T06:56:49Z --> Automated triage for the maintainers. This is fixed on `main` by commit `4051149` ("GPU: null views for title buffer views that are empty or run past their copy", 2026-11-24). In `crates/victory-gpu/src/descriptor/host.rs`, `buffer_srv` and `buffer_uav` now check `in_buffer` / `within`, which require `count > 0`, before creating the view. A zero-element buffer view gets a null descriptor instead of reaching `CreateShaderResourceView` / `CreateUnorderedAccessView`. Proposed for closing as fixed in `main`. It will be closed in 48 hours unless you reply (for example, if a run of current `main` still loses the device on a zero-element view) or a maintainer removes the `triage: proposed close` label. --- _Generated by [Claude Code](https://claude.ai/code)_
This discussion has been locked. Commenting is limited to contributors.
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#912
No description provided.