[PR #469] [CLOSED] d3d12/vulkan: implement hardware depth-bounds testing (D3D-DEPTH-BOUNDS) #520

Closed
opened 2026-11-26 20:18:09 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/469
Author: @jujumoneylol
Created: 11/24/2026
Status: ❌ Closed

Base: main ← Head: pr/d3d12-depth-bounds


📝 Commits (1)

  • b75e451 d3d12/vulkan: implement hardware depth-bounds testing (DEPTH_STENCIL1/2 + OMSetDepthBounds)

📊 Changes

12 files changed (+605 additions, -36 deletions)

View changed files

📝 runtime/CMakeLists.txt (+9 -0)
📝 runtime/shims/d3d12_com.cpp (+18 -0)
📝 runtime/shims/d3d12_com.h (+1 -1)
📝 runtime/shims/d3d12_vulkan_device.cpp (+31 -30)
📝 runtime/src/command_list.h (+2 -0)
📝 runtime/src/vulkan_backend.h (+4 -3)
📝 runtime/src/vulkan_replay.h (+12 -0)
➕ runtime/test/d3d12_depth_bounds_test.cpp (+503 -0)
📝 runtime/test/d3d12_mesh_test.cpp (+7 -1)
📝 runtime/test/d3d12_vulkan_device_test.cpp (+16 -1)
📝 runtime/test/replay_cpu_bench.cpp (+1 -0)
📝 runtime/test/vk_test_device.h (+1 -0)

📄 Description

Claimed in the coordination issue as: D3D-DEPTH-BOUNDS (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7123223139)

What and why

Implements hardware depth-bounds testing end-to-end in the D3D12 → Vulkan runtime, clearing one of the live frame-loop PSO stream refusals recorded in docs/retail_boot_intel_host.md section 3 (depth-bounds stream subobject):

  • Vulkan device feature: enables VkPhysicalDeviceFeatures::depthBounds where advertised by the GPU in create_vulkan_device_standalone (runtime/shims/d3d12_vulkan_device.cpp) and vktest::Device (runtime/test/vk_test_device.h), exposing it through VulkanDeviceInfo::features.depthBounds.
  • Feature query: reports D3D12_FEATURE_DATA_D3D12_OPTIONS2::DepthBoundsTestSupported = state_.info.features.depthBounds ? TRUE : FALSE instead of hardcoded FALSE.
  • Pipeline state stream (DEPTH_STENCIL1 / DEPTH_STENCIL2):
    • parse_pipeline_stream records DepthBoundsTestEnable from D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_DEPTH_STENCIL1 and DEPTH_STENCIL2 instead of unconditionally returning E_NOTIMPL.
    • PipelineState::create_graphics enables VkPipelineDepthStencilStateCreateInfo::depthBoundsTestEnable, refuses with E_NOTIMPL only when VulkanDeviceInfo::features.depthBounds is false, and appends VK_DYNAMIC_STATE_DEPTH_BOUNDS to the dynamic state list (for both regular and mesh PSOs) when enabled.
  • Command list & replay (OMSetDepthBounds → vkCmdSetDepthBounds):
    • Implements ID3D12GraphicsCommandList1::OMSetDepthBounds(Min, Max) in runtime/shims/d3d12_com.cpp (defaults to [0.0f, 1.0f] on create/reset, refused in bundles per D3D12 spec), carries (depth_bounds_min, depth_bounds_max) on leonida::Draw for both vertex and mesh draws, and replays vkCmdSetDepthBounds (clamped to [0.0f, 1.0f] / NaN-safe for Vulkan spec compliance) in runtime/src/vulkan_replay.h.
  • Tests:
    • Adds self-contained runtime/test/d3d12_depth_bounds_test.cpp (in-memory SPIR-V 1.3 fullscreen VS + solid PS, no external shader compiler needed) verifying feature reporting, feature-off E_NOTIMPL refusal, bundle refusal, and 8 live GPU draw cases compared pixel-for-pixel against the host Windows D3D12 runtime on the same adapter.
    • Updates d3d12_vulkan_device_test (OPTIONS2.DepthBoundsTestSupported invariant + toggle test), d3d12_mesh_test (DepthBoundsTestEnable follows vk.enabled.depthBounds), and replay_cpu_bench.

Tested

  • Built d3d12_depth_bounds_test, d3d12_vulkan_device_test, and replay_cpu_bench with MSVC 19.44 (vcvars64) + Ninja on top of main 8f481cf16.
  • d3d12_depth_bounds_test: ALL 8 CASES PASSED (EXACT MATCH vs host D3D12) on NVIDIA GeForce GTX 1650 (DepthBoundsTestSupported=TRUE), matching host pixels bit-for-bit across default [0.0, 1.0], [0.25, 0.75] pass, [0.6, 0.9] reject, [0.1, 0.4] reject, [0.5, 0.5] inclusive boundary pass, DEPTH_STENCIL2 pass/reject, and Reset() restoring [0.0, 1.0], plus feature-off E_NOTIMPL and bundle refusal checks.
  • d3d12_vulkan_device_test: PASSED (including new OPTIONS2.DepthBoundsTestSupported host parity and toggle check).
  • py -3.13 -I scripts/check_no_game_data.py on all 12 touched files: clean.

GPUs tested: NVIDIA GeForce GTX 1650 Mobile 4 GB (driver 592.00, Vulkan 1.4.325, Windows 11 26200)

AI-assisted: yes

Checklist

  • Based on current main and merges cleanly (a conflicting pull request is labeled needs rebase).
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed. (n/a — D3D12 → Vulkan runtime only)

🔄 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/469 **Author:** [@jujumoneylol](https://github.com/jujumoneylol) **Created:** 11/24/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `pr/d3d12-depth-bounds` --- ### 📝 Commits (1) - [`b75e451`](https://github.com/ubiquitarianism/leonida/commit/b75e4518961a228e4e2ad9dbcbbb35cf7f86c9e1) d3d12/vulkan: implement hardware depth-bounds testing (DEPTH_STENCIL1/2 + OMSetDepthBounds) ### 📊 Changes **12 files changed** (+605 additions, -36 deletions) <details> <summary>View changed files</summary> 📝 `runtime/CMakeLists.txt` (+9 -0) 📝 `runtime/shims/d3d12_com.cpp` (+18 -0) 📝 `runtime/shims/d3d12_com.h` (+1 -1) 📝 `runtime/shims/d3d12_vulkan_device.cpp` (+31 -30) 📝 `runtime/src/command_list.h` (+2 -0) 📝 `runtime/src/vulkan_backend.h` (+4 -3) 📝 `runtime/src/vulkan_replay.h` (+12 -0) ➕ `runtime/test/d3d12_depth_bounds_test.cpp` (+503 -0) 📝 `runtime/test/d3d12_mesh_test.cpp` (+7 -1) 📝 `runtime/test/d3d12_vulkan_device_test.cpp` (+16 -1) 📝 `runtime/test/replay_cpu_bench.cpp` (+1 -0) 📝 `runtime/test/vk_test_device.h` (+1 -0) </details> ### 📄 Description Claimed in the coordination issue as: D3D-DEPTH-BOUNDS (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7123223139) ### What and why Implements hardware depth-bounds testing end-to-end in the D3D12 → Vulkan runtime, clearing one of the live frame-loop PSO stream refusals recorded in `docs/retail_boot_intel_host.md` section 3 (depth-bounds stream subobject): - **Vulkan device feature**: enables `VkPhysicalDeviceFeatures::depthBounds` where advertised by the GPU in `create_vulkan_device_standalone` (`runtime/shims/d3d12_vulkan_device.cpp`) and `vktest::Device` (`runtime/test/vk_test_device.h`), exposing it through `VulkanDeviceInfo::features.depthBounds`. - **Feature query**: reports `D3D12_FEATURE_DATA_D3D12_OPTIONS2::DepthBoundsTestSupported = state_.info.features.depthBounds ? TRUE : FALSE` instead of hardcoded `FALSE`. - **Pipeline state stream (`DEPTH_STENCIL1` / `DEPTH_STENCIL2`)**: - `parse_pipeline_stream` records `DepthBoundsTestEnable` from `D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_DEPTH_STENCIL1` and `DEPTH_STENCIL2` instead of unconditionally returning `E_NOTIMPL`. - `PipelineState::create_graphics` enables `VkPipelineDepthStencilStateCreateInfo::depthBoundsTestEnable`, refuses with `E_NOTIMPL` only when `VulkanDeviceInfo::features.depthBounds` is false, and appends `VK_DYNAMIC_STATE_DEPTH_BOUNDS` to the dynamic state list (for both regular and mesh PSOs) when enabled. - **Command list & replay (`OMSetDepthBounds` → `vkCmdSetDepthBounds`)**: - Implements `ID3D12GraphicsCommandList1::OMSetDepthBounds(Min, Max)` in `runtime/shims/d3d12_com.cpp` (defaults to `[0.0f, 1.0f]` on create/reset, refused in bundles per D3D12 spec), carries `(depth_bounds_min, depth_bounds_max)` on `leonida::Draw` for both vertex and mesh draws, and replays `vkCmdSetDepthBounds` (clamped to `[0.0f, 1.0f]` / NaN-safe for Vulkan spec compliance) in `runtime/src/vulkan_replay.h`. - **Tests**: - Adds self-contained `runtime/test/d3d12_depth_bounds_test.cpp` (in-memory SPIR-V 1.3 fullscreen VS + solid PS, no external shader compiler needed) verifying feature reporting, feature-off `E_NOTIMPL` refusal, bundle refusal, and 8 live GPU draw cases compared pixel-for-pixel against the host Windows D3D12 runtime on the same adapter. - Updates `d3d12_vulkan_device_test` (`OPTIONS2.DepthBoundsTestSupported` invariant + toggle test), `d3d12_mesh_test` (`DepthBoundsTestEnable` follows `vk.enabled.depthBounds`), and `replay_cpu_bench`. ### Tested - Built `d3d12_depth_bounds_test`, `d3d12_vulkan_device_test`, and `replay_cpu_bench` with MSVC 19.44 (`vcvars64`) + Ninja on top of `main` `8f481cf16`. - `d3d12_depth_bounds_test`: **ALL 8 CASES PASSED (EXACT MATCH vs host D3D12)** on NVIDIA GeForce GTX 1650 (`DepthBoundsTestSupported=TRUE`), matching host pixels bit-for-bit across default `[0.0, 1.0]`, `[0.25, 0.75]` pass, `[0.6, 0.9]` reject, `[0.1, 0.4]` reject, `[0.5, 0.5]` inclusive boundary pass, `DEPTH_STENCIL2` pass/reject, and `Reset()` restoring `[0.0, 1.0]`, plus feature-off `E_NOTIMPL` and bundle refusal checks. - `d3d12_vulkan_device_test`: PASSED (including new `OPTIONS2.DepthBoundsTestSupported` host parity and toggle check). - `py -3.13 -I scripts/check_no_game_data.py` on all 12 touched files: clean. GPUs tested: NVIDIA GeForce GTX 1650 Mobile 4 GB (driver 592.00, Vulkan 1.4.325, Windows 11 26200) AI-assisted: yes ### Checklist - [x] Based on current `main` and merges cleanly (a conflicting pull request is labeled `needs rebase`). - [x] One topic; follow-up work goes in a new pull request. - [x] No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here. - [x] A new translator rule is in the contract table of `docs/design.md`, with how it was confirmed. (n/a — D3D12 → Vulkan runtime only) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
4ld0 2026-11-26 20:18:09 +01:00
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#520
No description provided.