[Ready to merge] Add support for depth bounds in D3D12 translation #849

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

@⁠Xvania7 on GitHub · 2026-11-24 12:27 UTC · original

I have prepared a fix for missing depth bounds support (noted in README under "GPU: world"). Since direct PRs are restricted, the ready-to-merge branch is available in my fork: https://github.com/Xvania7/VIctory/tree/feat/issue-depth-bounds

The code includes synthetic unit tests covering depth bounds min/max translation. All checks pass locally:

cargo test -p victory-gpu: 52 passed, 0 failed, 1 ignored
cargo clippy: 0 warnings
cargo xtask policy: 154 files ok

It can be automatically merged. Maintainers can pull it or let me know if a PR is needed. (Note: AI-assisted fix)

**@⁠Xvania7** on GitHub · 2026-11-24 12:27 UTC · [original](https://github.com/Marvisak/VIctory/issues/849) I have prepared a fix for missing depth bounds support (noted in README under "GPU: world"). Since direct PRs are restricted, the ready-to-merge branch is available in my fork: https://github.com/Xvania7/VIctory/tree/feat/issue-depth-bounds The code includes synthetic unit tests covering depth bounds min/max translation. All checks pass locally: cargo test -p victory-gpu: 52 passed, 0 failed, 1 ignored cargo clippy: 0 warnings cargo xtask policy: 154 files ok It can be automatically merged. Maintainers can pull it or let me know if a PR is needed. (Note: AI-assisted fix)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:14:03 +00:00
Author
Owner

@⁠MichaelSmithAI on GitHub · 2026-11-24 12:53 UTC · original

There is a command-order case worth checking at c47632f. The guest list handler saves and forwards OMSetDepthBounds(min, max). On the next bind of a depth-bounds-enabled pipeline, State::bind replaces that saved range with p.depth_bounds and sends the replacement to the host. The setter test checks the list immediately after the call, so it misses the overwrite at draw time.

On PC the pipeline description ends with the enable flag, and the command list supplies the range. The guest stream parser reads floats at offsets 52 and 56 from the kind-21 payload. A title trace would help establish whether those bytes carry bounds on Xbox and, if so, when they take precedence over an explicit list command. Pipeline layout · Dynamic range

A focused readback would clear depth to 0.5, set list bounds to [0.7, 0.9], then draw with a bounds-enabled pipeline. Under the PC semantics the clear color should survive. #158 already replays the list's range at bind time and has draw and mesh readbacks on native hardware. This finding on #849 is from source review. PR #158

**@⁠MichaelSmithAI** on GitHub · 2026-11-24 12:53 UTC · [original](https://github.com/Marvisak/VIctory/issues/849#issuecomment-7132065149) There is a command-order case worth checking at `c47632f`. The guest list handler saves and forwards `OMSetDepthBounds(min, max)`. On the next bind of a depth-bounds-enabled pipeline, `State::bind` replaces that saved range with `p.depth_bounds` and sends the replacement to the host. The setter test checks the list immediately after the call, so it misses the overwrite at draw time. On PC the pipeline description ends with the enable flag, and the command list supplies the range. The guest stream parser reads floats at offsets 52 and 56 from the kind-21 payload. A title trace would help establish whether those bytes carry bounds on Xbox and, if so, when they take precedence over an explicit list command. [Pipeline layout](https://learn.microsoft.com/en-us/windows/win32/api/d3d12/ns-d3d12-d3d12_depth_stencil_desc1) · [Dynamic range](https://learn.microsoft.com/en-us/windows/win32/api/d3d12/nf-d3d12-id3d12graphicscommandlist1-omsetdepthbounds) A focused readback would clear depth to 0.5, set list bounds to [0.7, 0.9], then draw with a bounds-enabled pipeline. Under the PC semantics the clear color should survive. #158 already replays the list's range at bind time and has draw and mesh readbacks on native hardware. This finding on #849 is from source review. [PR #158](https://git.gtahub.st/github/Marvisak--VIctory/pulls/158)
Author
Owner

@⁠Xvania7 on GitHub · 2026-11-24 13:00 UTC · original

Good catch, @⁠MichaelSmithAI. You're completely right on the command-order issue.

In D3D12, OMSetDepthBounds is dynamic command list state, whereas the pipeline state stream only controls the enable flag (DepthBoundsTestEnable). Overwriting self.depth_bounds inside State::bind from p.depth_bounds clobbers whatever dynamic range the guest command list explicitly configured prior to binding the pipeline.

The proper fix here is:

  1. Decouple the pipeline enable toggle from the dynamic range: the PSO stream only needs DepthBoundsTestEnable (in D3D12_DEPTH_STENCIL_DESC1).
  2. Treat self.depth_bounds on State as the authoritative dynamic command list state, mutated exclusively when the guest invokes OMSetDepthBounds.
  3. In State::bind, never overwrite self.depth_bounds with static PSO values. When binding a bounds-enabled PSO, the host list should simply use the currently active dynamic range from self.depth_bounds.

Also, thanks for pointing out PR #158. Since #158 already implements this dynamic replay and includes native hardware draw/mesh readbacks, it makes total sense to consolidate efforts there instead of carrying a duplicate implementation. Appreciate the sharp code review!

**@⁠Xvania7** on GitHub · 2026-11-24 13:00 UTC · [original](https://github.com/Marvisak/VIctory/issues/849#issuecomment-7132221391) Good catch, @⁠MichaelSmithAI. You're completely right on the command-order issue. In D3D12, `OMSetDepthBounds` is dynamic command list state, whereas the pipeline state stream only controls the enable flag (`DepthBoundsTestEnable`). Overwriting `self.depth_bounds` inside `State::bind` from `p.depth_bounds` clobbers whatever dynamic range the guest command list explicitly configured prior to binding the pipeline. The proper fix here is: 1. Decouple the pipeline enable toggle from the dynamic range: the PSO stream only needs `DepthBoundsTestEnable` (in `D3D12_DEPTH_STENCIL_DESC1`). 2. Treat `self.depth_bounds` on `State` as the authoritative dynamic command list state, mutated exclusively when the guest invokes `OMSetDepthBounds`. 3. In `State::bind`, never overwrite `self.depth_bounds` with static PSO values. When binding a bounds-enabled PSO, the host list should simply use the currently active dynamic range from `self.depth_bounds`. Also, thanks for pointing out PR #158. Since #158 already implements this dynamic replay and includes native hardware draw/mesh readbacks, it makes total sense to consolidate efforts there instead of carrying a duplicate implementation. Appreciate the sharp code review!
Author
Owner

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

Automated triage for the maintainers.

Depth bounds are listed as missing in the README ("GPU: world"), so this fits the project. Pull requests are open to everyone, so a branch can be offered as a pull request directly. Open pull request #158 already carries the depth bounds test, with the list's OMSetDepthBounds range replayed when a pipeline is bound and hardware readbacks; the review above (the range being replaced in State::bind) applies to this branch, and the reporter agreed to consolidate there. The decision is left to the maintainers on #158.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 06:52 UTC · [original](https://github.com/Marvisak/VIctory/issues/849#issuecomment-7155248748) <!-- victory-issue-triage v1 verdict=tracked seen=2026-11-24T13:00:36Z at=2026-11-25T06:52:28Z --> Automated triage for the maintainers. Depth bounds are listed as missing in the README ("GPU: world"), so this fits the project. Pull requests are open to everyone, so a branch can be offered as a pull request directly. Open pull request #158 already carries the depth bounds test, with the list's `OMSetDepthBounds` range replayed when a pipeline is bound and hardware readbacks; the review above (the range being replaced in `State::bind`) applies to this branch, and the reporter agreed to consolidate there. The decision is left to the maintainers on #158. --- _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#849
No description provided.