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

Open
opened 2026-11-24 12:27:29 +00:00 by Xvania7 · 4 comments
Xvania7 commented 2026-11-24 12:27:29 +00:00 (Migrated from github.com)
Contributor

Imported from Marvisak/VIctory. Originally posted by Xvania7 on 2026-11-24T12:27:29Z.


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)

<!-- greyfinch-sync:Marvisak/VIctory:issue:6581773534 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/issues/849). Originally posted by [Xvania7](https://github.com/Xvania7) on 2026-11-24T12:27:29Z. --- 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)
MichaelSmithAI commented 2026-11-24 13:02:15 +00:00 (Migrated from github.com)
Author
Contributor

Imported from Marvisak/VIctory. Originally posted by MichaelSmithAI on 2026-11-24T12:53:44Z.


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

<!-- greyfinch-sync:Marvisak/VIctory:comment:7132065149 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/issues/849#issuecomment-7132065149). Originally posted by [MichaelSmithAI](https://github.com/MichaelSmithAI) on 2026-11-24T12:53:44Z. --- 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://github.com/Marvisak/VIctory/pull/158)
Xvania7 commented 2026-11-24 13:02:18 +00:00 (Migrated from github.com)
Author
Contributor

Imported from Marvisak/VIctory. Originally posted by Xvania7 on 2026-11-24T13:00:36Z.


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!

<!-- greyfinch-sync:Marvisak/VIctory:comment:7132221391 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/issues/849#issuecomment-7132221391). Originally posted by [Xvania7](https://github.com/Xvania7) on 2026-11-24T13:00:36Z. --- 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!
Marvisak commented 2026-11-25 07:03:25 +00:00 (Migrated from github.com)
Author
Contributor

Imported from Marvisak/VIctory. Originally posted by Marvisak on 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

<!-- greyfinch-sync:Marvisak/VIctory:comment:7155248748 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/issues/849#issuecomment-7155248748). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T06:52:28Z. --- <!-- 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)_
potatoe0100 commented 2026-11-26 15:02:27 +00:00 (Migrated from github.com)
Author
Contributor

Imported from Marvisak/VIctory. Originally posted by potatoe0100 on 2026-11-26T14:11:15Z.


#158 (the depth bounds PR the triage pointed to) has merged into main as 842b0cb, and the README now lists "depth bounds on supporting adapters" under GPU: world. So this request looks covered on current main.

AI-assisted (Claude)

<!-- greyfinch-sync:Marvisak/VIctory:comment:7194398927 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/issues/849#issuecomment-7194398927). Originally posted by [potatoe0100](https://github.com/potatoe0100) on 2026-11-26T14:11:15Z. --- #158 (the depth bounds PR the triage pointed to) has merged into `main` as 842b0cb, and the README now lists "depth bounds on supporting adapters" under GPU: world. So this request looks covered on current `main`. AI-assisted (Claude)
Sign in to join this conversation.
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#849
No description provided.