Skip to content

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

Closed
matheusfrta wants to merge 5 commits into
Marvisak:mainfrom
matheusfrta:patch-1795497175
Closed

matheusfrta wants to merge 5 commits into
Marvisak:mainfrom
matheusfrta:patch-1795497175

Conversation

@matheusfrta

Copy link
Copy Markdown

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

Copy link
Copy Markdown

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 DenRakEiw left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

@Marvisak

Copy link
Copy Markdown
Owner

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.

@Marvisak Marvisak closed this Nov 25, 2026
geiyiliyabumo pushed a commit to geiyiliyabumo/VIctory that referenced this pull request Nov 25, 2026
GPU: Reduce repeated write-watch queries on mapped buffers
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.

4 participants