d3d12: separate front and back stencil masks (D3D-STENCIL-FACE-MASKS) #878
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
missing claim
needs rebase
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/ubiquitarianism--leonida!878
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/878/head"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@kawaii-shakal on GitHub · 2026-11-24 14:54 UTC · original
kawaii-shakal:d3d-stencil-face-masks→main· +142 −20 · 4 files · 1 commits · merged 2026-11-24 20:31 UTCClaimed in the coordination issue as: D3D-STENCIL-FACE-MASKS (claim)
What and why
On
main, aD3D12_PIPELINE_STATE_SUBOBJECT_TYPE_DEPTH_STENCIL2subobject whoseFrontFaceandBackFacemasks differ is refused withE_NOTIMPL("separate front and back stencil masks are not supported yet").D3D12_FEATURE_D3D12_OPTIONS14also reportsIndependentFrontAndBackStencilRefMaskSupported = FALSE, althoughID3D12GraphicsCommandList8::OMSetFrontAndBackStencilRef's per-face references already reach the draw (vkCmdSetStencilReferencewith a face mask). Vulkan has a compare mask and a write mask per face inVkStencilOpState, so no device feature is needed.runtime/shims/d3d12_vulkan_device.cpp:parse_pipeline_streamkeeps the front face's masks in theD3D12_GRAPHICS_PIPELINE_STATE_DESC. The back face's go beside it inPipelineStream::back_stencil.create_graphicstakes them as an optional argument, used only fordepth.back.OPTIONS14.IndependentFrontAndBackStencilRefMaskSupportedis TRUE.The classic
CreateGraphicsPipelineStatepath and its cached-PSO key are unchanged, sinceD3D12_DEPTH_STENCIL_DESChas one mask pair. The stream path takes no cached-PSO key.Tests
d3d12_state_sweep_testcompares against the host D3D12 device on the same adapter. It builds 16 more PSOs from a stream withDEPTH_STENCIL2, covering:OMSetFrontAndBackStencilRef;Each draw passes
EQUALwithREPLACEand fails withINVERT, over stored0xa5. The colour and stencil readbacks must be byte-identical with the host's.d3d12_vulkan_device_testnow expects the cap to be TRUE. Its host comparison checks that the cap does not exceed the host's.Tested
Windows 11 Pro 26300, MSVC 19.50.35721.0, Vulkan SDK 1.4.363.0, rebased on
main8f05e09e2.d3d12_state_sweep: 498 cases compared with the host on the RTX 5070 Ti, 0 differ, 0 skipped. Same result withLEONIDA_VK_VALIDATION=1(synchronization validation).ctest -R "d3d12_state_sweep|d3d12_vulkan_device$|gcl8|d3d12_com$|d3d12_depth24|d3d12_m3_frame|d3d12_draw": 6/6 passed, without and with validation.ctest -C RelWithDebInfo(before the rebase, on5606eab23): 293 run, 292 passed. The only failure isd3d12_execute_indirect_validation, which fails onmaintoo (#337 / #306).d3d12_meshwithLEONIDA_VK_VALIDATION=1on the rebased branch: passes with 0 validation errors (theVUID-vkCmdDrawMeshTasksEXT-pipelineStatistics-07076errors seen on the older base were fixed onmainby #540).python -I scripts/check_no_game_data.pyon the changed files: clean.tests/test_docs_*.py: all pass excepttest_docs_links, which flagsdocs/boot_leads.md→CONTRIBUTING.md. That file is not touched here; the failure comes frommain.GPUs tested: NVIDIA GeForce RTX 5070 Ti (Blackwell, PCI 10de:2c05), driver 617.42, Vulkan 1.4.351, Windows 11 Pro 26300
AI-assisted: yes
Checklist
mainand merges cleanly (a conflicting pull request is labeledneeds rebase).docs/design.md, with how it was confirmed. (n/a: no translator change)🤖 Generated with Claude Code
@Timon360SB on GitHub · 2026-11-24 17:48 UTC · original
Independent testing results
Verified the expanded stencil state sweep on NVIDIA Blackwell hardware under native Windows, including the additional coverage introduced by this PR.
Tested revisions
8f05e09e224656740e8a53f5047e1338d7a52588a7d86d8c769f944de0e1c406e41795ca1753707dTest environment
Test configuration
Both revisions compiled successfully in the completed attempt.
CTest results
d3d12_state_sweepd3d12_vulkan_deviced3d12_gcl8d3d12_comvk_sync_validationCombined: 30/30 PASS, with no failed or skipped CTest executions.
Stencil state sweep
The state sweep reported the following results in every repetition:
BASE diagnostic:
HEAD diagnostic:
The 16 additional cases introduced by HEAD completed successfully in all three repetitions, corresponding to 48 additional case executions without reported differences.
Across the three state sweep invocations per revision:
Graphics command list 8
All
d3d12_gcl8executions reported:This confirms successful execution of the existing GCL8 interface and separate front/back stencil reference test.
Additional regression coverage
The COM test reported that all 16 colour, depth and stencil texels matched and that the queue wait held the GPU as expected.
The Vulkan device test reported unchanged results between BASE and HEAD:
The placed-clear comparisons also remained unchanged: 16 plain bytes and zero sRGB-cast bytes differed from the host by one code, within the reported 0.6 ULP tolerance.
The internal resolve skips are distinct from CTest-level skips.
Vulkan validation
The synchronization validation self-test produced the expected intentional hazard without a barrier and zero validation errors with a barrier.
Test execution note
The initial attempt was interrupted before testing by a Git connection failure to github.com:443 (exit code 128).
The subsequent attempt completed successfully. The initial connection failure is excluded from the functional test totals.
Limitations
Conclusion
Result: PASS — no regressions detected within the tested scope.
The expanded state sweep successfully exercised all 498 cases with zero differences against the host and zero skipped cases across all HEAD repetitions.
The additional front/back stencil coverage passed consistently, while the existing GCL8, COM, Vulkan device and synchronization tests remained successful.
AI-assisted log analysis and report preparation.
@aslan2142 on GitHub · 2026-11-24 20:31 UTC · original
Merged. This was compared with #799 for D3D-STENCIL-FACE-MASKS, and it is the better fix:
OPTIONS14.IndependentFrontAndBackStencilRefMaskSupportedto TRUE.a7d86d8c7: 30/30 CTest executions, 498 cases compared with the host, 0 differ. Locally the compile check and the docs tests are clean; the tests themselves are Windows-only.One caveat worth a follow-up: the device test fails on a host whose driver reports the capability as FALSE.
AI-assisted (Claude Code, Claude Fable 5.2 and Claude Opus 5.5).