GPU: unbind vertex buffer slots for null view arrays #681

Merged
fuzeofficlal merged 1 commit from upstream-pr/681 into main 2026-11-24 08:22:42 +00:00
fuzeofficlal commented 2026-11-24 06:43:44 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-24T06:43:44Z.


Problem

The vertex-buffer command turns a null view pointer into an empty slice. With a nonzero count this leaves the previous buffers bound in those slots. The D3D12 binding spec defines a null view pointer and a zero-sized buffer view as unbound. D3D12 resource binding specification

Change

Clear the recorded slots covered by the null binding. The ordinary draw path materializes their zero-sized views.

Verification

  • A synthetic draw binds two slots, then calls the normal vertex-buffer command with StartSlot=1, NumViews=1, pViews=null. On RTX 5090 and WARP, the baseline leaves the old green component in all 16 pixels. The patch reads back the expected [0.5, 0, 0.25, 1] in all 16, with slot 0 still contributing red.
  • Explicit zero-sized native views provide the reference on both adapters. The direct native null-pointer call cleared on WARP and retained the old input on this RTX driver. The patch matches the explicit-view control on both.
  • The normal bound and count-zero controls passed. The diagnostics GPU suite reported 45 passed and one existing benchmark ignored per adapter. The asset policy check passed.

All input data was synthetic.

<!-- greyfinch-sync:Marvisak/VIctory:issue:6576241727 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/681). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-24T06:43:44Z. --- ## Problem The vertex-buffer command turns a null view pointer into an empty slice. With a nonzero count this leaves the previous buffers bound in those slots. The D3D12 binding spec defines a null view pointer and a zero-sized buffer view as unbound. [D3D12 resource binding specification](https://microsoft.github.io/DirectX-Specs/d3d/ResourceBinding.html#setting-ibvbsortds-on-a-command-list-or-bundle) ## Change Clear the recorded slots covered by the null binding. The ordinary draw path materializes their zero-sized views. ## Verification - A synthetic draw binds two slots, then calls the normal vertex-buffer command with `StartSlot=1, NumViews=1, pViews=null`. On RTX 5090 and WARP, the baseline leaves the old green component in all 16 pixels. The patch reads back the expected `[0.5, 0, 0.25, 1]` in all 16, with slot 0 still contributing red. - Explicit zero-sized native views provide the reference on both adapters. The direct native null-pointer call cleared on WARP and retained the old input on this RTX driver. The patch matches the explicit-view control on both. - The normal bound and count-zero controls passed. The diagnostics GPU suite reported 45 passed and one existing benchmark ignored per adapter. The asset policy check passed. All input data was synthetic.
LAKSHYA-cmd-tech commented 2026-11-24 06:54:27 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by LAKSHYA-cmd-tech on 2026-11-24T06:45:46Z.

Review: APPROVED


LGTM! Tested on Windows 11 with MSVC Rust 1.98.1. cargo test -p victory-gpu passed cleanly (43 passed, 1 benchmark ignored). Clearing recorded vertex buffer slots when iews is null conforms strictly to the D3D12 resource binding specification.

<!-- greyfinch-sync:Marvisak/VIctory:review:6034820626 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/681#pullrequestreview-6034820626). Originally posted by [LAKSHYA-cmd-tech](https://github.com/LAKSHYA-cmd-tech) on 2026-11-24T06:45:46Z. **Review:** APPROVED --- LGTM! Tested on Windows 11 with MSVC Rust 1.98.1. cargo test -p victory-gpu passed cleanly (43 passed, 1 benchmark ignored). Clearing recorded vertex buffer slots when iews is null conforms strictly to the D3D12 resource binding specification.
catminou4 commented 2026-11-24 07:01:09 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-24T06:55:01Z.

Review: COMMENTED


Static review only (Windows/D3D12 code):

  • VertexView derives Default (address=0, size=0, stride=0), which is the unbound state, and clear_vertex_buffers resets exactly the [start, start+count) slots — consistent with the D3D12 binding spec quoted in the PR.
  • Confirmed items() already maps a null pointer to an empty slice, so before this change a null views with nonzero count silently did nothing (previous buffers stayed bound) — the bug is real.
  • The views.is_null() branch at the FFI boundary is the right place; set_vertex_buffers with an empty slice evidently doesn't clear, so the explicit clear is needed.

Minor: clear_vertex_buffers uses .skip(start as usize).take(count as usize) on the fixed-size vertex array — if a title passes start + count beyond the array length, the tail is silently ignored rather than wrapped; same behavior as the existing set_vertex_buffers path presumably, but worth a glance.

<!-- greyfinch-sync:Marvisak/VIctory:review:6034924206 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/681#pullrequestreview-6034924206). Originally posted by [catminou4](https://github.com/catminou4) on 2026-11-24T06:55:01Z. **Review:** COMMENTED --- Static review only (Windows/D3D12 code): - `VertexView` derives `Default` (address=0, size=0, stride=0), which is the unbound state, and `clear_vertex_buffers` resets exactly the `[start, start+count)` slots — consistent with the D3D12 binding spec quoted in the PR. - Confirmed `items()` already maps a null pointer to an empty slice, so before this change a null `views` with nonzero `count` silently did nothing (previous buffers stayed bound) — the bug is real. - The `views.is_null()` branch at the FFI boundary is the right place; `set_vertex_buffers` with an empty slice evidently doesn't clear, so the explicit clear is needed. Minor: `clear_vertex_buffers` uses `.skip(start as usize).take(count as usize)` on the fixed-size `vertex` array — if a title passes `start + count` beyond the array length, the tail is silently ignored rather than wrapped; same behavior as the existing `set_vertex_buffers` path presumably, but worth a glance.
upstream-sync closed this pull request 2026-11-24 09:05:55 +00:00
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!681
No description provided.