[PR #1695] d3d12: realize console streams with their depth-bounds flag and back-face stencil masks (RT-DEPTHBOUNDS-STREAM-EXTRAS) #1709

Open
opened 2026-11-26 20:22:10 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/1695
Author: @thiefyzheng
Created: 11/25/2026
Status: 🔄 Open

Base: main ← Head: fix/depthbounds-stream-extras


📝 Commits (3)

  • a635392 d3d12: support hardware depth-bounds testing and OMSetDepthBounds
  • 6b7bf49 d3d12: realize console streams with their depth-bounds flag and back-face stencil masks
  • bb8e113 d3d12: hash console stream extras into the pipeline key (single KeyBuilder) and map NaN depth bounds to 0

📊 Changes

13 files changed (+259 additions, -21 deletions)

View changed files

📝 docs/d3d12_vulkan.md (+7 -2)
📝 runtime/shims/d3d12_com.cpp (+32 -2)
📝 runtime/shims/d3d12_com.h (+3 -0)
📝 runtime/shims/d3d12_vulkan_device.cpp (+37 -13)
📝 runtime/src/command_list.h (+2 -0)
📝 runtime/src/vulkan_backend.h (+2 -1)
📝 runtime/src/vulkan_replay.h (+11 -0)
📝 runtime/test/d3d12_bundle_forbidden_test.cpp (+3 -0)
📝 runtime/test/d3d12_close_parity_test.cpp (+35 -0)
📝 runtime/test/d3d12_com_test.cpp (+16 -1)
📝 runtime/test/d3d12_mesh_test.cpp (+108 -1)
📝 runtime/test/d3d12_vulkan_device_test.cpp (+2 -1)
📝 runtime/test/vk_test_device.h (+1 -0)

📄 Description

RT-DEPTHBOUNDS-STREAM-EXTRAS — Depends on: #815

Claimed on #1608 (https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7156944266). This fixes @djrolfes' integration finding on #815 (https://github.com/ubiquitarianism/leonida/pull/815#issuecomment-7156015786). @kotekompotek: happy to have this folded into #815 instead of a stacked PR — say so and I'll drop it.

Note: the diff includes #815's commit until it merges, since this branches from its head efea97331.

What

  • PipelineState::resolve_type's std::call_once block (runtime/shims/d3d12_vulkan_device.cpp:7059) realized a console stream with create_graphics(stream.graphics, &stream.ms, &stream.as), silently dropping stream.extras (the depth-bounds flag, #815's GraphicsStreamExtras) and stream.back_stencil (DEPTH_STENCIL2 back-face masks, which parse_pipeline_stream fills right next to the front ones). The eager CreatePipelineState branch passes both. It now passes stream.back_masks?&stream.back_stencil:nullptr and &stream.extras — argument-for-argument identical to the eager call at ~12104.
  • prepare_console_stream (~10367) set the pipeline cache key from pipeline_key(stream.graphics) alone; the plain D3D12_DEPTH_STENCIL_DESC the key hashes cannot see the depth-bounds flag or back-face masks, so two console PSOs differing only in those would collide. The key now post-mixes back_masks, back_stencil.read/.write and extras.depth_bounds_test with the same cached_pso::KeyBuilder/sha256_hex idiom pipeline_key itself uses.
  • Regression test in runtime/test/d3d12_mesh_test.cpp: a console stream (device slot 86, mesh-shader subobject 24) carrying DEPTH_STENCIL1 with DepthBoundsTestEnable and a D32_FLOAT DSV, drawn once inside OMSetDepthBounds(0, 1) (red — depth 0 is inside) and once inside OMSetDepthBounds(0.5, 1) (blue — the discard only happens if the flag reached the pipeline). Without the source fix both draws come out red.

What was run

  • Nothing was compiled or executed on the author host: no GPU, no Vulkan SDK, MSVC-only runtime tests. Not GPU-confirmed.
  • An independent mechanical review verified, against the actual branch sources: the create_graphics signature match (7119–7123), the PipelineStream fields and their parse fill, every identifier the test uses in scope with types lined up, fence values (the new bounds_fence pre-increments from 3, first Signal is 4 — no collision with the earlier Signals 1–3), the readback footprint/offset parity with the file's existing usage, slot 86 = console CreatePipelineState, and subobject 24 = the console mesh shader (consistent with the existing stream test at line 341 and the console→PC remap in d3d12_xs_pso_stream.h:31). That review caught two real defects, both fixed here: the test's second-frame depth barrier indicated a COMMON→DEPTH_WRITE transition from a buffer already in DEPTH_WRITE (now conditional on first_frame), and the cache-key collision above.
  • The guard demonstration owed (run d3d12_mesh_test with the one-line source change reverted and show the bounds case fails) needs a depth-bounds-capable Vulkan device, which the author host does not have. The test skips cleanly when DepthBoundsTestSupported is FALSE or in pc_only builds.

Attribution

AI-assisted: implementation (Claude Sonnet 5.5 worker), independent review and follow-up fixes (GLM 5.3 Flash worker), orchestration and verification by the contributor. No game files were used or are needed; no game data in this PR.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ubiquitarianism/leonida/pull/1695 **Author:** [@thiefyzheng](https://github.com/thiefyzheng) **Created:** 11/25/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix/depthbounds-stream-extras` --- ### 📝 Commits (3) - [`a635392`](https://github.com/ubiquitarianism/leonida/commit/a635392c6b420ea690e45006b2c36711dccfefdb) d3d12: support hardware depth-bounds testing and OMSetDepthBounds - [`6b7bf49`](https://github.com/ubiquitarianism/leonida/commit/6b7bf490dad1aeb7e6451196e9170f8c15205733) d3d12: realize console streams with their depth-bounds flag and back-face stencil masks - [`bb8e113`](https://github.com/ubiquitarianism/leonida/commit/bb8e113146eedcb9e45c45faf904b64361d4c832) d3d12: hash console stream extras into the pipeline key (single KeyBuilder) and map NaN depth bounds to 0 ### 📊 Changes **13 files changed** (+259 additions, -21 deletions) <details> <summary>View changed files</summary> 📝 `docs/d3d12_vulkan.md` (+7 -2) 📝 `runtime/shims/d3d12_com.cpp` (+32 -2) 📝 `runtime/shims/d3d12_com.h` (+3 -0) 📝 `runtime/shims/d3d12_vulkan_device.cpp` (+37 -13) 📝 `runtime/src/command_list.h` (+2 -0) 📝 `runtime/src/vulkan_backend.h` (+2 -1) 📝 `runtime/src/vulkan_replay.h` (+11 -0) 📝 `runtime/test/d3d12_bundle_forbidden_test.cpp` (+3 -0) 📝 `runtime/test/d3d12_close_parity_test.cpp` (+35 -0) 📝 `runtime/test/d3d12_com_test.cpp` (+16 -1) 📝 `runtime/test/d3d12_mesh_test.cpp` (+108 -1) 📝 `runtime/test/d3d12_vulkan_device_test.cpp` (+2 -1) 📝 `runtime/test/vk_test_device.h` (+1 -0) </details> ### 📄 Description ## RT-DEPTHBOUNDS-STREAM-EXTRAS — Depends on: #815 Claimed on #1608 (https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7156944266). This fixes @djrolfes' integration finding on #815 (https://github.com/ubiquitarianism/leonida/pull/815#issuecomment-7156015786). @kotekompotek: happy to have this folded into #815 instead of a stacked PR — say so and I'll drop it. **Note:** the diff includes #815's commit until it merges, since this branches from its head `efea97331`. ### What - `PipelineState::resolve_type`'s `std::call_once` block (`runtime/shims/d3d12_vulkan_device.cpp:7059`) realized a console stream with `create_graphics(stream.graphics, &stream.ms, &stream.as)`, silently dropping `stream.extras` (the depth-bounds flag, #815's `GraphicsStreamExtras`) and `stream.back_stencil` (DEPTH_STENCIL2 back-face masks, which `parse_pipeline_stream` fills right next to the front ones). The eager `CreatePipelineState` branch passes both. It now passes `stream.back_masks?&stream.back_stencil:nullptr` and `&stream.extras` — argument-for-argument identical to the eager call at ~12104. - `prepare_console_stream` (~10367) set the pipeline cache key from `pipeline_key(stream.graphics)` alone; the plain `D3D12_DEPTH_STENCIL_DESC` the key hashes cannot see the depth-bounds flag or back-face masks, so two console PSOs differing only in those would collide. The key now post-mixes `back_masks`, `back_stencil.read/.write` and `extras.depth_bounds_test` with the same `cached_pso::KeyBuilder`/`sha256_hex` idiom `pipeline_key` itself uses. - Regression test in `runtime/test/d3d12_mesh_test.cpp`: a console stream (device slot 86, mesh-shader subobject 24) carrying DEPTH_STENCIL1 with `DepthBoundsTestEnable` and a D32_FLOAT DSV, drawn once inside `OMSetDepthBounds(0, 1)` (red — depth 0 is inside) and once inside `OMSetDepthBounds(0.5, 1)` (blue — the discard only happens if the flag reached the pipeline). Without the source fix both draws come out red. ### What was run - **Nothing was compiled or executed on the author host: no GPU, no Vulkan SDK, MSVC-only runtime tests.** Not GPU-confirmed. - An independent mechanical review verified, against the actual branch sources: the `create_graphics` signature match (7119–7123), the `PipelineStream` fields and their parse fill, every identifier the test uses in scope with types lined up, fence values (the new `bounds_fence` pre-increments from 3, first Signal is 4 — no collision with the earlier Signals 1–3), the readback footprint/offset parity with the file's existing usage, slot 86 = console `CreatePipelineState`, and subobject 24 = the console mesh shader (consistent with the existing stream test at line 341 and the console→PC remap in `d3d12_xs_pso_stream.h:31`). That review caught two real defects, both fixed here: the test's second-frame depth barrier indicated a COMMON→DEPTH_WRITE transition from a buffer already in DEPTH_WRITE (now conditional on `first_frame`), and the cache-key collision above. - The guard demonstration owed (run `d3d12_mesh_test` with the one-line source change reverted and show the bounds case fails) needs a depth-bounds-capable Vulkan device, which the author host does not have. The test skips cleanly when `DepthBoundsTestSupported` is FALSE or in `pc_only` builds. ### Attribution AI-assisted: implementation (Claude Sonnet 5.5 worker), independent review and follow-up fixes (GLM 5.3 Flash worker), orchestration and verification by the contributor. No game files were used or are needed; no game data in this PR. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No labels
bug
pull-request
No milestone
No project
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
starred/leonida#1709
No description provided.