Repository navigation
d3d12: separate front and back stencil masks (D3D-STENCIL-FACE-MASKS) - #878
Conversation
A DEPTH_STENCIL2 subobject whose FrontFace and BackFace masks differ was refused with E_NOTIMPL, and OPTIONS14 reported IndependentFrontAndBackStencilRefMaskSupported = FALSE although the per-face references of OMSetFrontAndBackStencilRef already reach the draw. Vulkan has a compare and a write mask per face in VkStencilOpState. parse_pipeline_stream keeps the front face's masks in the description and the back face's beside it (PipelineStream::back_stencil), create_graphics takes them as an optional argument for depth.back, and OPTIONS14 now reports the cap. The classic CreateGraphicsPipelineState path and its cached-PSO key are unchanged: D3D12_DEPTH_STENCIL_DESC has one mask pair. d3d12_state_sweep_test builds 16 more PSOs from a stream with DEPTH_STENCIL2 (same, split, front-only and back-only masks; one reference or two through OMSetFrontAndBackStencilRef; front- and back-facing) and compares the colour and stencil readback with the host D3D12 device: 498 cases, 0 differ on an RTX 5070 Ti. Giving the back face the front face's masks makes 6 of them differ. d3d12_vulkan_device_test expects the cap. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Independent testing resultsVerified the expanded stencil state sweep on NVIDIA Blackwell hardware under native Windows, including the additional coverage introduced by this PR. Tested revisions
Test environment
Test configuration
Both revisions compiled successfully in the completed attempt. CTest results
Combined: 30/30 PASS, with no failed or skipped CTest executions. Stencil state sweepThe 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 8All This confirms successful execution of the existing GCL8 interface and separate front/back stencil reference test. Additional regression coverageThe 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 validationThe synchronization validation self-test produced the expected intentional hazard without a barrier and zero validation errors with a barrier. Test execution noteThe 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
ConclusionResult: 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. |
|
Merged. This was compared with #799 for D3D-STENCIL-FACE-MASKS, and it is the better fix:
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). |
Claimed 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
main8f05e09.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, on 5606eab): 293 run, 292 passed. The only failure isd3d12_execute_indirect_validation, which fails onmaintoo (d3d12: ExecuteIndirect accepts the argument ranges newer D3D12 runtimes accept (D3D-EXECIND-RANGE) #337 / d3d12_execute_indirect_validation_test: handle Windows 11 26300 relaxed max=0 and padded-stride bounds #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 d3d12/vulkan: the mesh statistics pool enables no forbidden counter (D3D-291) #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