Skip to content

d3d12: ignore OMSetFrontAndBackStencilRef on closed command lists - #8809

Closed
DenRakEiw wants to merge 1 commit into
ProjectLeonida:mainfrom
DenRakEiw:fix/d3d12-om-front-back-stencil-closed-noop
Closed

DenRakEiw wants to merge 1 commit into
ProjectLeonida:mainfrom
DenRakEiw:fix/d3d12-om-front-back-stencil-closed-noop

Conversation

@DenRakEiw

Copy link
Copy Markdown
Contributor

Summary

Match Windows 11 D3D12 (live WARP and native NVIDIA GeForce RTX 5090) for ID3D12GraphicsCommandList8::OMSetFrontAndBackStencilRef when called on an already-closed command list:

  • In
    untime/shims/d3d12_com.cpp, change if (list_.closed()) return check(false); to if (list_.closed()) return; (matching OMSetStencilRef and OMSetBlendFactor), so a post-close call is a no-op and does not poison invalid_ for ExecuteCommandLists.
  • Add synthetic host-parity and regression tests in
    untime/test/d3d12_close_parity_test.cpp,
    untime/test/d3d12_com_test.cpp, and
    untime/test/d3d12_gcl8_test.cpp.

Live Windows 11 D3D12 Probe (WARP + NVIDIA GeForce RTX 5090)

  • Open DIRECT list: OMSetFrontAndBackStencilRef(1, 2) -> Close() returns S_OK, ExecuteCommandLists + fence wait succeeds (GetDeviceRemovedReason() == S_OK).
  • Closed DIRECT list: Close() (S_OK) -> OMSetFrontAndBackStencilRef(1, 2) -> ExecuteCommandLists + fence wait succeeds (GetDeviceRemovedReason() == S_OK), second Close() returns E_FAIL, Reset() + Close() returns S_OK.
  • BUNDLE list: open + post-close OMSetFrontAndBackStencilRef -> Close() (S_OK), second Close() (E_FAIL), ExecuteBundle on DIRECT list + Close() (S_OK) + ExecuteCommandLists succeeds (GetDeviceRemovedReason() == S_OK).

Verification

Built in
untime/build (MSVC �cvars64.bat + Ninja RelWithDebInfo, LEONIDA_BUILD_WINDOWS_RUNTIME=ON) and tested on NVIDIA GeForce RTX 5090 with LEONIDA_VK_VALIDATION=1 (0 VUIDs):

  • d3d12_gcl8: Passed
  • d3d12_trace: Passed (19 ordered entries)
  • d3d12_close_parity: Passed (114 cases, 79 match live WARP, 0 failures; post-close OMSetFrontAndBackStencilRef + ExecuteCommandLists + Reset verified on both Leonida Vulkan and live WARP)
  • d3d12_com: Passed (0 validation errors)

Claim: #8683 (comment)

AI-assisted (Gemini 4 Neon).

@lohant27-netizen

Copy link
Copy Markdown

Tested ede13073c on Windows 11 (10.0.26300), NVIDIA GeForce RTX 5070 (driver 32.0.16.2101, subgroup 32), MSVC with SDK 10.0.26100, Release, merged onto main 867d922f0 together with #8815, #8814, #8809, #8784, #8783 and #8813 (no conflicts): pass.

@smowlyy

smowlyy commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Verified head ede13073c merged onto main (867d922f0) on native Windows 11 (10.0.26300.9974, MSVC 19.44, RelWithDebInfo):

  • python -I scripts/check_no_game_data.py on all 4 changed files: clean (exit 0)
  • cmake --build runtime/build --target d3d12_close_parity_test d3d12_com_test d3d12_gcl8_test --parallel: built cleanly
  • ctest --test-dir runtime/build -R '^(d3d12_close_parity|d3d12_com|d3d12_gcl8)$' --output-on-failure -V: 3/3 passed (close parity: 114 cases, 79 match WARP, 0 failures including OMSetFrontAndBackStencilRef)

AI-assisted.

@Mahdi20077

Copy link
Copy Markdown

Tested ede13073c on Windows 11 build 26300, RTX 5060 driver 610.88, and MSVC 19.44. All four checks passed: d3d12_close_parity, d3d12_com, d3d12_gcl8, and d3d12_trace. I added a local regression check that calls OMSetFrontAndBackStencilRef after closing a bundle and verifies that the parent still receives the bundle’s original stencil values. With the fix reverted, that check failed and the direct-list test rejected submission. Both passed with the fix. Synthetic inputs only. Tested without Vulkan validation layers. AI-assisted (Codex).

@marso006

Copy link
Copy Markdown

Tested ede13073c (based on main 867d922f0) on Windows 11, NVIDIA GeForce RTX 5060 Ti (Blackwell), driver 617.42, VS 2026 (scripts/build_runtime.ps1, RelWithDebInfo), Vulkan SDK 1.4.363.0: pass. Synthetic, no game files.

Independent check, claim. AI-assisted (Claude Code).

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