Skip to content

d3d12: serialize depth-plane root signatures explicitly - #2591

Merged
MoonEyes merged 1 commit into
ProjectLeonida:mainfrom
merzleckeier:codex/d3d12-wine-depth-plane
Nov 29, 2026
Merged

MoonEyes merged 1 commit into
ProjectLeonida:mainfrom
merzleckeier:codex/d3d12-wine-depth-plane

Conversation

@merzleckeier

@merzleckeier merzleckeier commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

Claimed in the coordination issue as: D3D12-WINE-DEPTH-PLANE

What and why

Wine's HLSL compiler ignores the RootSignature attribute, so the depth-plane pass cannot create a root signature from the compiled pixel shader. The pass then leaves the depth plane untouched.

Serialize a v1.1 root signature explicitly for both depth-plane shaders. The existing pixel-visible SRV at t0 retains its visibility and descriptor flags. The existing GPU regression test serializes its single b0 draw constant explicitly too, so it can exercise the original texture readback assertions under Wine.

Tested

  • Cross-built the Windows D3D12 runtime and leonida-gpu library tests with cargo xwin in the diag profile.
  • Under Wine, a_depth_planes_twin_is_drawn_into_the_plane fails on bare main at 1bc055e6c with zero descriptor heaps instead of one. It passes with this change, including the per-list heap and depth readback assertions.
  • All three focused Depth and Stencil tests pass on the patched build. These use synthetic textures and require no game files.
  • The diff passes git diff --check and scripts/check_no_game_data.py. It also applies cleanly on top of Linux: build leonida.exe and run it under Proton or Wine #2577 at 32ae9bf82.
  • Independent native Windows 11 retest on current main (4364a4fa6) with an RTX 3090, NVIDIA driver 621.40 and MSVC. All three focused checks passed. Restoring only the old production root signature reproduced the zero-descriptor-heap assertion. The full library suite reported 544 passed, 0 failed and 47 ignored on both trees. Retest by enlight3d

GPUs tested: Desktop NVIDIA GeForce RTX 4070 SUPER (12 GiB, profile M), NVIDIA 620.73.04, CachyOS (kernel 7.3.6-3), Wine 11.22, vkd3d-proton 71cae091, DXVK DXGI 3.1.1.

AI-assisted: Codex.

Checklist

  • Based on current main at 1bc055e6c.
  • One topic.
  • No game data.

Wine can compile the depth-plane shader without embedding its RootSignature attribute. Serialize the matching v1.1 signature from the host parameter instead, and give the existing depth-plane GPU test an explicit signature for its readback draw.
@merzleckeier

merzleckeier commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor Author

The fork workflows are awaiting maintainer approval. I ran the full-tree No Game Data check locally on 5b3477768, and it passed.

I also ran the Linux semantic suite with SPIRV-Tools required on both this PR and bare main at 1bc055e6c. Both ran 6,484 tests in 522 files and reported the same two clamp subtest failures in the single file test_valu_cvt_f16_int16_mods.py. That baseline issue already has an owner. Existing coordination claim CI run

Combined Linux check with #2577. I merged 7ff494f3c and this PR's 5b3477768 into main at aa918e5d9 and built the Windows runtime and GPU tests with cargo-xwin in profile diag. On CachyOS, Wine 11.22 and a physical RTX 4070 SUPER (620.73.04), all four synthetic GPU tests passed offline. They covered the scaled premultiplied compositor readback, the depth and stencil plane readbacks, and the depth twin round trip. I replaced the early fixture returns with assertions in the local test build so lack of a host device or required resource twin fails the test. The combined tree also passed the No Game Data check.

AI-assisted with Codex.

@lixonik lixonik left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 5b3477768 against main 1bc055e6c. The explicit v1.1 signatures preserve the pixel-visible SRV at t0 for the two plane shaders and the one 32-bit constant at b0 for the fixture.

The exact PR's a_depth_planes_twin_is_drawn_into_the_plane passed on native Windows 10 22H2 (19045) with RTX 5070 (610.88), profile diag, MSVC target. For the A/B I made the two early returns in the draw fixture hard assertions in local copies, requiring a real host device and a depth twin. The draw/readback and depth-twin round-trip both passed on main and on the PR. This independently checks native D3D12 compatibility; the Wine regression is covered by the author's run. The pair with #2577 also merges cleanly in git merge-tree.

AI-assisted.

@Maticcm

Maticcm commented Nov 28, 2026

Copy link
Copy Markdown
Contributor

Native Windows regression check for 5b3477768cafdbf0f3dfe3867e51089a6ae15642 against parent 1bc055e6c2dedaa0de23ec79d8c4007c1dff1fb3. Windows 11 build 26340, RTX 3080 selected through LEONIDA_ADAPTER (driver 630.20), pinned Rust 1.98.1 MSVC, diag profile, Rust leonida-gpu library tests.

Both revisions passed the depth-plane GPU readback, the stencil-plane GPU readback, and the depth/stencil footprint check (3/3 each). I used the same local fixture-only guard on both revisions to require native D3D12 device initialization. The device-initialized marker printed for both GPU tests on each revision before their readback assertions passed.

This covers native Windows parity for the explicit root signature change. The Wine result is covered separately by the author's report. Synthetic textures. AI-assisted (Codex).

@enlight3d

Copy link
Copy Markdown
Contributor

RUN of #2591 (native Windows, no Wine, no game files)

Heads: PR 5b34777 (base = main 1bc055e, so no merge needed).
Machine: NVIDIA GeForce RTX 3090 24 GB, driver 621.40, Windows 11 Pro 10.0.26300, rustc 1.98.1.

Command (in d3d12/, filters after the separator because cargo takes one name before it):
cargo test -j 8 -p leonida-gpu --lib -- a_depth_planes_twin a_stencil_planes_twin depth_stencil_footprints

  • GREEN (PR head): 3 passed, 0 failed (a_depth_planes_twin_is_drawn_into_the_plane, a_stencil_planes_twin_reaches_the_plane, depth_stencil_footprints_follow_the_pc_plane_order).
  • Main (unchanged tests and code): the same 3 pass. Expected: native Windows compilers honour the RootSignature attribute, so this fix is not visible here.
  • RED, build failure: PR test file with main's host.rs: error[E0425] cannot find function plane_root_signature in crate::host (the test uses the new helper).
  • RED, behavioural (simulates a compiler that drops the attribute, as Wine's does): PR head with only PlanePass reverted to CreateRootSignature(0, pixel shader bytes). The depth-plane test fails at the per-list heap assertion, left: 0, right: 1 (zero descriptor heaps instead of one), the same symptom the PR reports under Wine. The other two tests still pass.
  • Worktree restored to the PR head after the red runs.

Not checked here: the real Wine / vkd3d-proton run (needs Linux).

@timbot103 timbot103 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Static audit of 5b3477768 against 48bae6cad. No findings.

The explicit v1.1 signatures match the depth shaders' pixel-visible t0 binding and the fixture's single b0 constant. The supplied results cover the R16 depth readback on Wine and native Windows. The float variant shares the same table layout and has no dedicated depth readback in the supplied tests.

AI-assisted.

@merzleckeier

Copy link
Copy Markdown
Contributor Author

Thanks for pointing out the missing float readback. I tested the public PR head 5b3477768 on main 5844b6481 with the separate synthetic float-depth fixture applied.

The integer and float depth-plane readbacks, stencil-plane readback, and depth-twin round trip passed on both the RTX 4070 SUPER (NVIDIA 620.73.04) and Radeon 610M (RADV 26.3.1), under Wine 11.22 on CachyOS with VKD3D-Proton 71cae091. I then restored the old shader-derived root signature in the production integer and float passes while keeping the same fixture. Both depth tests failed on each GPU at the descriptor-heap assertion (zero heaps, one expected), before readback.

The fixture uses synthetic textures. The No Game Data scan of the two changed files and the diff check passed. AI-assisted with OpenAI Codex (GPT-6).

@enlight3d

Copy link
Copy Markdown
Contributor

RUN: PR #2591 re-run on current main (red/green)

Heads: PR 5b34777, main 4364a4f. Merged locally with git merge --no-ff (clean, only host.rs and resource.rs touched, nothing pushed).

Command (d3d12/, MSVC target, vcvars64):
cargo test -j 8 -p leonida-gpu --lib -- a_depth_planes_twin a_stencil_planes_twin depth_stencil_footprints

  • Green (main + PR): 3 passed, 0 failed.
  • Red (only the PlanePass root signature put back to CreateRootSignature(0, &ps[..]), tests kept): behavioural failure. a_depth_planes_twin_is_drawn_into_the_plane fails at the per-list heap assertion (left: 0, right: 1: no descriptor heap is set), the symptom seen under Wine. The other two still pass. Restored afterwards.
  • cargo check -p leonida-gpu --tests on the merged tree: clean (warnings only).
  • Whole --lib suite: merged tree 544 passed, 0 failed, 47 ignored; plain main 544 passed, 0 failed, 47 ignored. No difference.

Machine: RTX 3090 24 GB, NVIDIA 621.40, Windows 11 (native D3D12).

Not checked: Wine/vkd3d-proton.

@MoonEyes

Copy link
Copy Markdown
Collaborator

Merging. Head 5b3477768 has red/green verdicts from reviewers other than the author (above), merges cleanly with main 3be7be011, does not force a rebase of #2566, and carries a claim ID. Remaining main CI reds (translator-tests mesh, semantic-tests f16) are pre-existing. Merged by MoonEyes.

AI-assisted (Claude Code).

@MoonEyes
MoonEyes merged commit 7c66bc5 into ProjectLeonida:main Nov 29, 2026
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