feat(gpu): wire up depth bounds testing on command lists and pipeline streams #582

Closed
matheusfrta wants to merge 5 commits from upstream-pr/582 into main
matheusfrta commented 2026-11-24 05:13:05 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by matheusfrta on 2026-11-24T05:13:05Z.


i wired up OMSetDepthBounds on the command list tables and kept DepthBoundsTestEnable from D3D12_DEPTH_STENCIL_DESC1 in pipeline state streams for both mesh and graphics pipelines. it checks D3D12_FEATURE_D3D12_OPTIONS2 first so adapters without depth bounds support like WARP fall back cleanly without rejecting pipelines or command lists.

<!-- greyfinch-sync:Marvisak/VIctory:issue:6575142313 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/582). Originally posted by [matheusfrta](https://github.com/matheusfrta) on 2026-11-24T05:13:05Z. --- i wired up `OMSetDepthBounds` on the command list tables and kept `DepthBoundsTestEnable` from `D3D12_DEPTH_STENCIL_DESC1` in pipeline state streams for both mesh and graphics pipelines. it checks `D3D12_FEATURE_D3D12_OPTIONS2` first so adapters without depth bounds support like WARP fall back cleanly without rejecting pipelines or command lists.
fromthemoonx commented 2026-11-24 08:02:54 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fromthemoonx on 2026-11-24T07:39:51Z.


Tested 7e78c81 (on main d2a4bae) on NVIDIA, including the new stream path.

Environment: Windows 11 Pro build 26300, AMD Ryzen 7 5700X, 16 GB, NVIDIA GeForce RTX 3060 12 GB (driver 610.88), Rust 1.98.1 x86_64-pc-windows-msvc, debug.

Tested

  • cargo test --locked -p victory-gpu --lib: 43 passed, 0 failed, 1 ignored. every_inline_command_falls_back_to_the_table calls the new slot, which here reaches OMSetDepthBounds on the hardware list. The 0x220/0x230 pair is right: newer_slot moves slot 68 to 70.
  • cargo test --locked --workspace: 264 passed, 0 failed, 4 ignored
  • cargo xtask policy: 151 files ok; git diff --check: clean; clippy: only main's host.rs:267 warning
  • Support query (throwaway test, OPTIONS2): DepthBoundsTestSupported is true on the RTX 3060 and on WARP, and host().depth_bounds() returns true. So the description's "adapters without depth bounds support like WARP" doesn't hold here: WARP takes the same path as hardware. The fallback for unsupported adapters stays untested on both.
  • The new graphics_pipeline stream (throwaway test with a trivial vs_6_0/ps_6_0 pair from the SDK's dxc, root_signature(&[], &[], false) and GraphicsState::default() plus one RGBA8 target): created on the RTX 3060 with depth bounds on and a D32 depth buffer, with depth bounds off, with D24S8, and with depth bounds on and no depth buffer. So the driver accepts the stream layout and the DEPTH_STENCIL1 subobject.

Notes

  • cargo fmt --check adds new diffs over main in the five changed files: draw.rs, host.rs, list.rs and pipeline.rs lose their final newline (\ No newline at end of file in the diff), and pipeline/host.rs has five, including the long mesh_pipeline(...) call and stream lines. Running cargo fmt on those files would clear them.
  • The copy_memory change (dst as *const u8 → dst as *mut u8 passed to committed, which takes *const u8) doesn't change behavior, so it could be left out.
  • With depth bounds enabled, the graphics pipeline now goes through the stream path, so it is cached under a different call (LoadPipeline rather than LoadGraphicsPipeline). The name includes depth_bounds through describe(), so the two shouldn't collide.

Not tested: that pixels outside the bounds are actually discarded (no render-and-read-back test); title pipelines (no game data).

AI-assisted (Claude Code) ran the checks and drafted this comment.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7125234743 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/582#issuecomment-7125234743). Originally posted by [fromthemoonx](https://github.com/fromthemoonx) on 2026-11-24T07:39:51Z. --- Tested `7e78c81` (on `main` `d2a4bae`) on NVIDIA, including the new stream path. **Environment:** Windows 11 Pro build 26300, AMD Ryzen 7 5700X, 16 GB, NVIDIA GeForce RTX 3060 12 GB (driver 610.88), Rust 1.98.1 `x86_64-pc-windows-msvc`, debug. **Tested** - `cargo test --locked -p victory-gpu --lib`: 43 passed, 0 failed, 1 ignored. `every_inline_command_falls_back_to_the_table` calls the new slot, which here reaches `OMSetDepthBounds` on the hardware list. The 0x220/0x230 pair is right: `newer_slot` moves slot 68 to 70. - `cargo test --locked --workspace`: 264 passed, 0 failed, 4 ignored - `cargo xtask policy`: 151 files ok; `git diff --check`: clean; clippy: only `main`'s `host.rs:267` warning - **Support query** (throwaway test, `OPTIONS2`): `DepthBoundsTestSupported` is **true on the RTX 3060 and on WARP**, and `host().depth_bounds()` returns true. So the description's "adapters without depth bounds support like WARP" doesn't hold here: WARP takes the same path as hardware. The fallback for unsupported adapters stays untested on both. - **The new `graphics_pipeline` stream** (throwaway test with a trivial `vs_6_0`/`ps_6_0` pair from the SDK's `dxc`, `root_signature(&[], &[], false)` and `GraphicsState::default()` plus one RGBA8 target): created on the RTX 3060 with depth bounds on and a D32 depth buffer, with depth bounds off, with D24S8, and with depth bounds on and no depth buffer. So the driver accepts the stream layout and the `DEPTH_STENCIL1` subobject. **Notes** - `cargo fmt --check` adds new diffs over `main` in the five changed files: `draw.rs`, `host.rs`, `list.rs` and `pipeline.rs` lose their final newline (`\ No newline at end of file` in the diff), and `pipeline/host.rs` has five, including the long `mesh_pipeline(...)` call and stream lines. Running `cargo fmt` on those files would clear them. - The `copy_memory` change (`dst as *const u8` → `dst as *mut u8` passed to `committed`, which takes `*const u8`) doesn't change behavior, so it could be left out. - With depth bounds enabled, the graphics pipeline now goes through the stream path, so it is cached under a different call (`LoadPipeline` rather than `LoadGraphicsPipeline`). The name includes `depth_bounds` through `describe()`, so the two shouldn't collide. **Not tested:** that pixels outside the bounds are actually discarded (no render-and-read-back test); title pipelines (no game data). AI-assisted (Claude Code) ran the checks and drafted this comment.
DenRakEiw commented 2026-11-24 14:04:11 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by DenRakEiw on 2026-11-24T13:40:28Z.

Review: APPROVED


Tested head 7e78c81 merged cleanly onto main (ffe310e) on Windows 11 x64 (Rust 1.98.1 MSVC) with NVIDIA GeForce RTX 5090 (Blackwell) and WARP (VICTORY_D3D12_WARP=1):

  • cargo test -p victory-gpu (RTX 5090): 50 passed, 0 failed, 1 ignored (includes pipeline::tests::streams_yield_their_shaders with DepthBoundsTestEnable and list::tests::every_inline_command_falls_back_to_the_table with OMSetDepthBounds)
  • VICTORY_D3D12_WARP=1 cargo test -p victory-gpu (WARP): 50 passed, 0 failed, 1 ignored
  • cargo clippy -p victory-gpu --all-targets: 0 warnings
  • cargo xtask policy: ok

Code review looks solid — GraphicsState::depth_bounds is preserved from D3D12_DEPTH_STENCIL_DESC1 (subobject 21), reset on D3D12_DEPTH_STENCIL_DESC (subobject 11), hashed into describe(), and gated on D3D12_FEATURE_DATA_D3D12_OPTIONS2::DepthBoundsTestSupported for both graphics_pipeline / mesh_pipeline streams and OMSetDepthBounds.

Two minor non-blocking nits:

  • Host::depth_bounds(&self) caches the result in a function-local static OnceLock<bool> rather than a field on Host; storing it on Host avoids tying a &self method to process-global state if multiple adapters are ever instantiated in one process.
  • crates/victory-gpu/src/list.rs:768 (dst as *const u8 → dst as *mut u8) is an unrelated change (and a few touched files lost their trailing newline).

Approving.

AI-assisted (Gemini 4 Neon).

<!-- greyfinch-sync:Marvisak/VIctory:review:6040212013 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/582#pullrequestreview-6040212013). Originally posted by [DenRakEiw](https://github.com/DenRakEiw) on 2026-11-24T13:40:28Z. **Review:** APPROVED --- Tested head `7e78c81` merged cleanly onto `main` (`ffe310e`) on Windows 11 x64 (Rust 1.98.1 MSVC) with **NVIDIA GeForce RTX 5090** (Blackwell) and **WARP** (`VICTORY_D3D12_WARP=1`): - `cargo test -p victory-gpu` (RTX 5090): **50 passed, 0 failed, 1 ignored** (includes `pipeline::tests::streams_yield_their_shaders` with `DepthBoundsTestEnable` and `list::tests::every_inline_command_falls_back_to_the_table` with `OMSetDepthBounds`) - `VICTORY_D3D12_WARP=1 cargo test -p victory-gpu` (WARP): **50 passed, 0 failed, 1 ignored** - `cargo clippy -p victory-gpu --all-targets`: **0 warnings** - `cargo xtask policy`: ok Code review looks solid — `GraphicsState::depth_bounds` is preserved from `D3D12_DEPTH_STENCIL_DESC1` (subobject 21), reset on `D3D12_DEPTH_STENCIL_DESC` (subobject 11), hashed into `describe()`, and gated on `D3D12_FEATURE_DATA_D3D12_OPTIONS2::DepthBoundsTestSupported` for both `graphics_pipeline` / `mesh_pipeline` streams and `OMSetDepthBounds`. Two minor non-blocking nits: - `Host::depth_bounds(&self)` caches the result in a function-local `static OnceLock<bool>` rather than a field on `Host`; storing it on `Host` avoids tying a `&self` method to process-global state if multiple adapters are ever instantiated in one process. - `crates/victory-gpu/src/list.rs:768` (`dst as *const u8` → `dst as *mut u8`) is an unrelated change (and a few touched files lost their trailing newline). Approving. AI-assisted (Gemini 4 Neon).
upstream-sync closed this pull request 2026-11-25 01:04:20 +00:00
Marvisak commented 2026-11-25 01:07:46 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T00:25:38Z.


Automated triage for the maintainers. Closing because another open pull request covers the same change.

See #158. Same depth-bounds wiring as #158 (list slot, DEPTH_STENCIL1 flag, OPTIONS2 check) without tests.

If this is mistaken, reply here with what was missed (or push a change and say so) and it will be looked at again. Thank you for the contribution.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7148497706 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/582#issuecomment-7148497706). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T00:25:38Z. --- Automated triage for the maintainers. Closing because another open pull request covers the same change. See #158. Same depth-bounds wiring as #158 (list slot, DEPTH_STENCIL1 flag, OPTIONS2 check) without tests. If this is mistaken, reply here with what was missed (or push a change and say so) and it will be looked at again. Thank you for the contribution.

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!582
No description provided.