Skip to content

d3d12-gpu: drop unused SM 6.6 root signature flags in depth_bounds test - #2855

Open
lixonik wants to merge 1 commit into
ProjectLeonida:mainfrom
lixonik:fix/depth-bounds-test-win10-root-sig
Open

lixonik wants to merge 1 commit into
ProjectLeonida:mainfrom
lixonik:fix/depth-bounds-test-win10-root-sig

Conversation

@lixonik

@lixonik lixonik commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

Claim: D3D12-TEST-DEPTH-BOUNDS-WIN10 (#2570 (comment))

Fixes pipeline::host::tests::depth_bounds_pipeline_loads_and_filters_draws failing deterministically on Windows 10 (HRESULT(0x80070057) / E_INVALIDARG).

Root cause

Unit-test binaries do not export D3D12SDKVersion / D3D12SDKPath and therefore run against inbox d3d12.dll. On Windows 10 22H2 (build 19045), inbox d3d12.dll rejects D3D12_ROOT_SIGNATURE_FLAG_CBV_SRV_UAV_HEAP_DIRECTLY_INDEXED | D3D12_ROOT_SIGNATURE_FLAG_SAMPLER_HEAP_DIRECTLY_INDEXED (SM 6.6) passed by root_signature(...) with E_INVALIDARG (0x80070057), even though this test's vs_6_5 / ps_6_5 shaders bind zero descriptors.

Change

In d3d12/crates/leonida-gpu/src/pipeline/host.rs (depth_bounds_pipeline_loads_and_filters_draws), serialize an empty D3D_ROOT_SIGNATURE_VERSION_1_1 root signature with only D3D12_ROOT_SIGNATURE_FLAG_ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT, leaving runtime root_signature(...) untouched.

Verification

  • Before (on main ad7c62edb, solo and 8/8 parallel runs): panicked at pipeline/host.rs:1625:79 with HRESULT(0x80070057).
  • After:
    • cargo test --locked -p leonida-gpu --lib pipeline::host::tests::depth_bounds_pipeline_loads_and_filters_draws -- --exact --nocapture: passed (executed full GPU depth-bounds PSO load, draw, replay, and readback without skipping).
    • cargo test --locked -p leonida-gpu --lib -- --test-threads=1: 600 passed, 0 failed, 55 ignored.

GPUs tested: NVIDIA GeForce RTX 5070 12 GB (driver 621.40, Windows 10 Pro 22H2 build 19045, Ryzen 9 5950X 16C/32T)

AI-assisted: Antigravity

@MoonEyes

MoonEyes commented Dec 1, 2026

Copy link
Copy Markdown
Collaborator

Your claim is there (D3D12-TEST-DEPTH-BOUNDS-WIN10, #2570 (comment)), but the description does not name it. Could you add the ID and that link, so the merge checklist finds it?

AI-assisted (Claude Code).

@lixonik

lixonik commented Dec 1, 2026

Copy link
Copy Markdown
Contributor Author

@MoonEyes Added the claim ID (D3D12-TEST-DEPTH-BOUNDS-WIN10) and link to the PR description.

AI-assisted: Antigravity

@enlight3d

Copy link
Copy Markdown
Contributor

RUN (independent run on Windows, #2855 head 45f7be9, merged locally into main 3393cee with git merge --no-ff, no conflicts. The head still merges cleanly into main bf30e25. CI on the head: change-scope, check, linux-python-and-viewer, no-game-data and semantic-tests all pass.)

This machine runs Windows 11 Pro 26300, where the test does not fail on main. The red in the body (E_INVALIDARG from the inbox d3d12.dll of Windows 10 22H2) cannot be reproduced here; this run checks that the test still passes and still tests something on Windows 11.

Commands, in d3d12/, target x86_64-pc-windows-msvc, toolchain 1.98.1, all with --locked, at low priority:

  • cargo test -p leonida-gpu --lib pipeline::host::tests::depth_bounds_pipeline_loads_and_filters_draws -- --exact --nocapture: passes on main (0.33 s) and on the merge (0.30 s). Neither run prints "no host depth bounds support; skipped" or "no PC dxc.exe; skipped", so the test gets past both early returns and runs its two draws on the RTX 3090.
  • The depth-bounds filter is really exercised: on the merge with OMSetDepthBounds taken out of draw::depth_bounds (production code), the test fails on its first draw check, "depth 0.5 outside [0.6, 1.0] must be rejected", left 255, right 0. So the bounds set through State::set_depth_bounds and replayed by State::replay are what reject that draw. Restored: passes again.
  • cargo test -p leonida-gpu --lib --no-fail-fast on the merge: 601 passed / 0 failed / 55 ignored; with --features diagnostics: 681 / 0 / 55. Main at the same commit: 601 / 0 / 55 in 31 of 32 parallel runs (one watch test failed once, see the d3d12-gpu: fix parallel unit test races in watch, descriptor, and pool #2854 run).
  • cargo clippy -p leonida-gpu --all-targets, default and --features diagnostics, main and merge: the same warnings on both sides, none new.
  • Note: the test now builds its own empty root signature (version 1.1, only ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT). It no longer goes through the runtime's root_signature(...), so it no longer checks a depth-bounds pipeline with the runtime's own root signature and its SM 6.6 heap flags. The runtime is unchanged.

Not covered: Windows 10 (the red), other GPUs.

Machine: Windows 11 Pro 26300, i9-13900K, 64 GB, RTX 3090 24 GB, NVIDIA 621.40, Rust 1.98.1.

@MoonEyes

MoonEyes commented Dec 1, 2026

Copy link
Copy Markdown
Collaborator

Verified by MoonEyes (another person than the author) on head 45f7be90b merged with main cd0c52fcf: I read the whole diff. A test only. cargo test -p leonida-gpu: the only failure seen, committed_and_placed_r32_uint_textures_cast_to_r9g9b9e5_under_legacy_barriers, fails in 2 of 5 parallel runs of plain main too. On Windows 11 it is green on both sides; the red is for Windows 10.

In-game run with the six others of a batch on main 21e6bbf4b: RTX 4060 8 GB, NVIDIA 610.88, Windows 11 26300, -SeriesS -FrameGen 2, about 860 s in the world, then a second one of about 440 s, 0 device lost, 0 panic; pictures of the same scene compared with main, same. Black surfaces in early cutscenes while the PC's memory is full are there on plain main too.

AI-assisted (Claude Code).

@imShangLi

Copy link
Copy Markdown
Contributor

VERIFY-2855 — Linux, Rust 1.98.1 (the pinned toolchain), no GPU device, no game files

Verdict: PASS on what I could check, and one gap worth closing. The change is right and its API use is exact — I checked every field name and function signature against the windows crate's own source. It cannot be run here (it needs Windows, a D3D12 device and DXC), and I found one sibling test with the same problem that this pull request does not fix.

Head 45f7be90, base the current main 88a9f133, merge base 7fbcd456, 1 commit, 1 file, +30/−1: d3d12/crates/leonida-gpu/src/pipeline/host.rs.

1. What it changes

The test depth_bounds_pipeline_loads_and_filters_draws built its root signature with root_signature(&host.device, &[], &[], false). That helper always adds the SM 6.6 flags:

// d3d12/crates/leonida-gpu/src/pipeline/host.rs:1303 root_signature()
Flags: input
    | D3D12_ROOT_SIGNATURE_FLAG_CBV_SRV_UAV_HEAP_DIRECTLY_INDEXED
    | D3D12_ROOT_SIGNATURE_FLAG_SAMPLER_HEAP_DIRECTLY_INDEXED,

The pull request builds the same empty versioned root signature inline, with only D3D12_ROOT_SIGNATURE_FLAG_ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT, so no SM 6.6 flag is set.

2. The flags are the SM 6.6 ones

From windows-0.62.2/src/Windows/Win32/Graphics/Direct3D12/mod.rs:

pub const D3D12_ROOT_SIGNATURE_FLAG_ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT: D3D12_ROOT_SIGNATURE_FLAGS = D3D12_ROOT_SIGNATURE_FLAGS(1i32);
pub const D3D12_ROOT_SIGNATURE_FLAG_CBV_SRV_UAV_HEAP_DIRECTLY_INDEXED:    D3D12_ROOT_SIGNATURE_FLAGS = D3D12_ROOT_SIGNATURE_FLAGS(1024i32);
pub const D3D12_ROOT_SIGNATURE_FLAG_SAMPLER_HEAP_DIRECTLY_INDEXED:        D3D12_ROOT_SIGNATURE_FLAGS = D3D12_ROOT_SIGNATURE_FLAGS(2048i32);

D3D12_ROOT_SIGNATURE_FLAG_CBV_SRV_UAV_HEAP_DIRECTLY_INDEXED and ..._SAMPLER_HEAP_DIRECTLY_INDEXED are the two root-signature flags that arrived with shader model 6.6 (D3D12 1.3), so dropping them is dropping SM 6.6. ✓

3. The API use matches the crate exactly

I checked every name the new code uses against the windows 0.62.2 source:

used in the pull request in the crate
D3D12_VERSIONED_ROOT_SIGNATURE_DESC { Version, Anonymous } pub Version: D3D_ROOT_SIGNATURE_VERSION, pub Anonymous: D3D12_VERSIONED_ROOT_SIGNATURE_DESC_0
D3D12_VERSIONED_ROOT_SIGNATURE_DESC_0 { Desc_1_1: D3D12_ROOT_SIGNATURE_DESC1 { .. } } pub union … { pub Desc_1_0: D3D12_ROOT_SIGNATURE_DESC, pub Desc_1_1: D3D12_ROOT_SIGNATURE_DESC1, pub Desc_1_2: … }
D3D12_ROOT_SIGNATURE_DESC1 { NumParameters, pParameters, NumStaticSamplers, pStaticSamplers, Flags } exactly those five fields, pParameters: *const D3D12_ROOT_PARAMETER1, pStaticSamplers: *const D3D12_STATIC_SAMPLER_DESC, Flags: D3D12_ROOT_SIGNATURE_FLAGS
D3D12SerializeVersionedRootSignature(&desc, &mut blob, None) pub unsafe fn D3D12SerializeVersionedRootSignature(prootsignature: *const D3D12_VERSIONED_ROOT_SIGNATURE_DESC, ppblob: *mut Option<ID3DBlob>, pperrorblob: Option<*mut Option<ID3DBlob>>) -> windows_core::Result<()> — the third argument is an Option, so None is right
blob.GetBufferPointer().cast::<u8>(), blob.GetBufferSize() pub unsafe fn GetBufferPointer(&self) -> *mut core::ffi::c_void, pub unsafe fn GetBufferSize(&self) -> usize
host.device.CreateRootSignature(0, &bytes) pub unsafe fn CreateRootSignature<T: Interface>(&self, nodemask: u32, pblobwithrootsignature: &[u8]) -> windows_core::Result<T>

The types are in scope: pipeline/host.rs:12-13 has use windows::Win32::Graphics::Direct3D::ID3DBlob; and use windows::Win32::Graphics::Direct3D12::*;, and the test module has use super::*;.

The new code also copies the blob into a Vec before dropping the ID3DBlob, which the helper it replaces does not have to do (it reads the blob while it is still alive). That is the safer of the two. ✓

4. An empty root signature is the right thing here

The pull request says "the shaders bind no descriptors". The two shaders the test compiles are:

const VS: &str = "float4 main(uint i : SV_VertexID) : SV_Position { … }";
const PS: &str = "float4 main() : SV_Target { return 1; }";

Neither reads a resource, so there is nothing for a root parameter to bind. ✓ An empty root signature is correct.

The production path is untouched: pipeline/host.rs:826 still calls root_signature(&host.device, &params, &samplers, …) with real parameters, so the runtime keeps the heap-direct-indexing flags it needs.

5. The sibling test with the same problem

a_mesh_pipeline_loads_from_the_library makes the same call with the same empty parameters:

// d3d12/crates/leonida-gpu/src/pipeline/host.rs:1529 (in a_mesh_pipeline_loads_from_the_library)
let (root, root_blob) = root_signature(&host.device, &[], &[], false).unwrap();

so it hits the same SM 6.6 flags, and the same inbox d3d12.dll would reject them the same way. This pull request does not touch it. If the reason for the change is "inbox d3d12.dll rejects SM 6.6 root signature flags", the sibling needs the same treatment.

A cheaper way to cover both, if the maintainer prefers it: root_signature() could leave the two *_HEAP_DIRECTLY_INDEXED flags off when there are no root parameters and no static samplers — an empty root signature has no descriptors for the flags to apply to — and both tests would then need no change at all. I did not measure that on Windows; it is a suggestion about where to put the fix, not a claim that the pull request is wrong.

6. What this pull request does and does not affect in CI

.github/workflows/d3d12.yml:76 runs the workspace tests with

-- --skip depth_bounds_pipeline_loads_and_filters_draws

so the test this pull request changes does not run in CI at all. The fix is for a developer running cargo test -p leonida-gpu on Windows with DXC and a host device. Worth knowing when judging how urgent the sibling in §5 is.

7. What I did not check

  • I could not run the test. It needs Windows, a D3D12 device, dxc.exe, a host GPU with depth-bounds support, and the inbox d3d12.dll; the crate does not build on Linux (upstream's own words: "The crates are Windows-only today (leonida-gpu does not build on macOS); Linux follows Linux: build leonida.exe and run it under Proton or Wine #2577 if it lands"). So the claim that inbox d3d12.dll answers E_INVALIDARG for these flags is the pull request's, and I could not confirm it on a Windows machine.
  • The E_INVALIDARG claim's Windows version. The comment says "on Windows 10"; the CI runner is Windows 11. I did not check which inbox D3D12 version each carries.
  • The rest of the crate's tests, for the same reason.
  • cargo clippy and cargo fmt — the workflow runs clippy as a report only (it already fails on main), and formatting is left out of the d3d12 workflow.
  • The pipeline-library cache key does change (the root blob is part of library::name(…), pipeline/host.rs:1668), which only means the test's pipeline is cached under a different name. I did not check the library code.

AI-assisted: MiniMax M3.1 Flash.

@merzleckeier

Copy link
Copy Markdown
Contributor

I mirrored the two exact empty v1.1 root descriptors in a native inbox root-signature A/B. The base flags are 0xC01 (input assembler, CBV/SRV/UAV heap indexing, sampler heap indexing). The PR flags are 0x1. On both GitHub-hosted Windows Server 2022 and 2025 I created the Microsoft Basic Render Driver via EnumWarpAdapter and logged serialization and CreateRootSignature separately.

  • Server 2022 build 20348, inbox d3d12.dll 10.0.20348.3451 and WARP 10.0.20348.5756, reported SM 6.2. Both signatures serialized and created with S_OK.
  • Server 2025 build 26100, inbox D3D12 and WARP 10.0.26100.33648, reported SM 6.6. Both signatures again serialized and created with S_OK.

The lean descriptor works on both inbox versions. Server 2022 also accepts the old flags despite reporting SM 6.2, so the Windows 10 19045 rejection is still a separate platform result. This checks signature creation, with no rendering workload.

Server 2022 log · Server 2025 log · MEASURED, AI-assisted (Codex).

@lixonik

lixonik commented Dec 1, 2026

Copy link
Copy Markdown
Contributor Author

@imShangLi Thanks for the thorough audit! Two notes on §5:

  1. Verified on Windows 10 Pro 22H2 (build 19045, NVIDIA GeForce RTX 5070 12 GB, driver 621.40): a_mesh_pipeline_loads_from_the_library returns early before root_signature() (no host mesh shader support; skipped), because Windows 10 inbox d3d12.dll does not expose mesh shaders without Agility SDK, whereas Agility SDK / Windows 11 already accept the SM 6.6 root signature flags.
  2. root_signature() intentionally keeps *_HEAP_DIRECTLY_INDEXED even when params and samplers are empty, because an SM 6.6 shader reading ResourceDescriptorHeap / SamplerDescriptorHeap directly can bind zero root parameters.

@merzleckeier Thanks for the Server 2022/2025 WARP check as well!

@KelboLive KelboLive 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.

Test-only, and the root cause checks out: root_signature() adds the two SM 6.6 flags unconditionally (host.rs:1322-1324), the app exports D3D12SDKVersion/D3D12SDKPath (apps/leonida/src/agility.rs:33,49) while test binaries do not, and these vs_6_5/ps_6_5 shaders bind no descriptors — so the empty v1.1 signature is right and production stays on the flagged path.

Verified on Windows 11 / RTX 4070 Ti SUPER: the test passes without skipping, the lib suite is 600/0/55, and replacing the production OMSetDepthBounds with (0.0, 1.0) still fails it at host.rs:1883 (left 255, right 0), so the depth-bounds assertions still bite.

Two notes before merge:

  • #2663 rewrites this same test function in the same hunk (6_5 → 6_0, SM 6.0 gating) and will conflict — a local merge on main fails at that block. Whichever lands second should keep this inline signature in place of root_signature(...).
  • Afterwards, root_signature() is only exercised by a_mesh_pipeline_loads_from_the_library (:1529), which skips on Windows 10. A root_signature_with_flags(...) argument would avoid the 30 duplicated lines and keep the production helper covered on every host.

Minor, expected: switching ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT to NONE still passes, since the test binds no input layout — the flag is not load-bearing here.

Merge is clean against current main; host.rs is unchanged upstream since the base, so the 380-commit gap is not drift.

@imShangLi

Copy link
Copy Markdown
Contributor

The same call is made one function up, and this change leaves it alone.

d3d12/crates/leonida-gpu/src/pipeline/host.rs:1529 — in a_mesh_pipeline_loads_from_the_library:

let (root, root_blob) = root_signature(&host.device, &[], &[], false).unwrap();

root_signature() (host.rs:1303) adds the two shader-model 6.6 flags to every root signature it builds:

Flags: input
    | D3D12_ROOT_SIGNATURE_FLAG_CBV_SRV_UAV_HEAP_DIRECTLY_INDEXED
    | D3D12_ROOT_SIGNATURE_FLAG_SAMPLER_HEAP_DIRECTLY_INDEXED,

(0x400 and 0x800 in windows-0.62.2.) The shaders of that test bind no descriptors either, so the inline empty root signature this pull request writes for the depth-bounds test would serve it just as well — but as it stands the mesh test still asks for an SM 6.6 root signature, and the inbox d3d12.dll that rejects those flags with E_INVALIDARG would reject that one the same way.

It does not show up in CI either way: the mesh test needs a host GPU with mesh shader support and a dxc.exe (it returns early with // no host GPU here), and leonida-gpu's library tests need a device.

Two ways this could go, both fine by me:

  • factor the inline block of this pull request into a small helper in the test module and use it in both tests, or
  • leave this pull request alone and I open a follow-up for the mesh test.

I did not touch it myself: leonida-gpu does not build on Linux (upstream: "The crates are Windows-only today ... Linux follows #2577 if it lands"), so I could not run the test either.

Verified against main in #2855 (comment)

AI-assisted.

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.

6 participants