Repository navigation
d3d12_pso_fuzz_test: random blend, logic-op, depth-stencil, rasterizer, viewport and MRT state against the same GPU's D3D12 - #5637
Conversation
…GPU's D3D12, every byte compared Each program clears a colour target (UNORM, sRGB, 10:10:10:2, half, float, R11G11B10) and an optional D16/D24S8/D32/D32S8 target, then draws triangles through PSOs with random blend state (all non-dual- source factors, all ops, write masks, OMSetBlendFactor), depth-stencil state (all functions and stencil ops, masks, both faces, OMSetStencilRef) and rasterizer state (cull, winding, constant DepthBias, depth clip), and compares every byte of the colour target and every depth-stencil plane. Triangles have one depth and a flat colour on pixel corners, so only the state can differ; blending may round by one code or ulp. The reference is the host's D3D12 on the layer's GPU by LUID (--warp for WARP, which differs from GPUs within D3D12's rules); --reduce SEED shrinks a differing program. Over 400 seeds on an RTX 5060 Ti it finds DepthBias applied about twice (26 seeds, all depth), which ProjectLeonida#2718 (VK_EXT_depth_bias_control) fixes: 0 of 400 with it. The default 40 seeds pass on main. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… scissors per draw Half the draws get a viewport other than the whole target: whole-pixel offsets from -16 to 24, sizes 8 to 48, and a depth range in 64ths. A third get a scissor rect. Vertices stay on pixel corners or half-pixels and depths stay exact. This covers the layer's viewport y-flip and depth range. Over 600 seeds against the RTX 5060 Ti's D3D12, only the DepthBias seeds (ItsNotRexed#2718) differ; with ItsNotRexed#2718, 0 of 600. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Pushed |
|
Independent Windows check of head
One actionable oracle issue: in |
|
Tested
How this fits the other runs: the five seeds in 1..200 (45, 68, 154, 160, 195) are the same five @SirKingg lists on the RTX 4070 Ti, so Ada and Ampere agree over that range; seeds 201..400 add 12 more here. The description's RTX 5060 Ti (Blackwell) run has 26 of 400 and seeds 64, 77, 89 and 100 in its first 100, which are not in this list, so the differing set is not the same across generations. I did not investigate why. Not tested: #2718 (it conflicts with AI-assisted. Synthetic only; no game data. |
A third of the programs draw to two targets (a second random format) through a pixel shader that writes the colour to SV_Target0 and its bgra swizzle to SV_Target1. Half their draws set IndependentBlendEnable with RenderTarget[1]'s own blend state and write mask. Both targets are compared. Over 600 seeds (197 with two targets) against the RTX 5060 Ti's D3D12, only the DepthBias seeds differ; with ItsNotRexed#2718, 0 of 600. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Pushed |
…as behind --all Four UINT target formats (R8G8B8A8, R16G16B16A16, R32G32B32A32, R32) drawn by a pixel shader that writes the colour's bits, so both sides see exact integers; where both devices report OutputMergerLogicOp, half their draws enable one of the sixteen logic ops. UINT texels compare exactly. --verbose names both targets and says whether logic ops run. A nonzero DepthBias is now generated only with --all: on NVIDIA the layer applies about twice D3D12's bias (D3D-325, fixed by ItsNotRexed#2718), and the default run should stay green on main until that lands. With --all and ItsNotRexed#2718, 0 of 600 differ. RTX 5060 Ti against its own D3D12: default 40 seeds and 1,000 seeds under validation, 0 differ, 0 validation messages; --all 600 seeds, 25 differ, all DepthBias. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Pushed |
|
Tested Windows 11 build 26300, MSVC 14.44 + Ninja, RelWithDebInfo, Vulkan SDK 1.4.363.1; reference = the host's D3D12 on the same GPU (
Reduced on the RX 9070, each to one triangle on D16 with a constant Two notes from the log: this AMD driver has no |
…State; exact clears --stream creates each PSO from a pipeline-state stream (d3dx12.h layout) on both the layer and the reference: subobjects in a random order, one equal to its default left out half the time, and DEPTH_STENCIL or DEPTH_STENCIL1 alternately. The stream layout comes from its own generator, so the programs are the same as without --stream. On main every PSO is refused (no CreatePipelineState yet). On ItsNotRexed#1712 (D3D-29), 1,000 seeds give 0 differences, and the results match the desc path seed for seed. UNORM targets are now cleared to 0 or 1 per channel. A clear value between two codes rounds by the clear's rules, which d3d12_clear_fuzz_test checks and where NVIDIA's D3D12 and D3D12's ties-to-even part (a 2-bit alpha of 0.5); this test checks the draws. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Pushed
Default run 40/40, |
…nderPass Even seeds clear through the pass (BEGINNING_ACCESS_TYPE_CLEAR with the clear values; stencil NO_ACCESS on depth-only formats), odd seeds clear first and begin PRESERVE; every pass ends PRESERVE. On main the layer logs BeginRenderPass as unimplemented and 18 of 20 seeds differ; on ProjectLeonida#2064 (D3D-27), 1,000 seeds under validation give 0 differences and 0 validation messages. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Pushed |
|
Tested 5bd5840 on NVIDIA GeForce RTX 4080, driver 617.42: d3d12_pso_fuzz_test with its default run exits 0 and prints "pso fuzz (layer against NVIDIA GeForce RTX 4080): 40 seeds run, 0 differ, 0 refused by the layer; 0 texels within the rounding tolerance". Only the default run was executed; --all, --stream, --render-pass, the 1,000-seed run and --warp were not. AI-assisted. |
|
Tested The branch is 1,806 commits behind
No game files. AI-assisted (Claude Code). |
|
Tested 5bd5840 on Windows 11, AMD Radeon RX 9070 XT (RDNA4), driver 32.0.32029.2010: pass
AI-assisted (Claude Code). |
Claimed in the coordination issue: #5256 (comment)
What and why
This is a seeded differential fuzzer for graphics pipeline state: the draw counterpart of the copy (#5272), clear (#5425) and fence (#5180) fuzzers. Every draw the game makes goes through this state, and nothing compared it systematically with D3D12.
Each program does the following:
Targets: it clears a 32x32 colour target and an optional depth-stencil target. Colour formats:
Depth formats: D16, D24S8, D32, D32S8. A third of the float/UNORM programs add a second render target of a random format. Formats are kept where both devices support them (CheckFeatureSupport).
Draws: 1-5 batches of triangles, each through its own PSO with random state:
OMSetBlendFactor; with two targets,IndependentBlendEnablehalf the time, givingRenderTarget[1]its own blend state and mask;D3D12_LOGIC_OPs, where both devices reportOutputMergerLogicOp;OMSetStencilRef;DepthClipEnableon/off, z from -0.125 to 1.125 so clipping and clamping both happen, and a constantDepthBiaswith--all(see below);Comparison: every byte of every colour target and of every depth-stencil plane is compared.
So that only the state can make a difference:
flat/nointerpolationfrom the first vertex, which D3D12 and Vulkan both use; UINT targets get the colour's bits);Blending may still round within D3D12's tolerance, so the comparison allows:
The reference is the host's D3D12 on the layer's own GPU, matched by LUID (the D3D-188 rule other tests use).
--warpcompares with WARP instead. On NVIDIA, WARP and the GPU's own D3D12 disagree within D3D12's rules (an edge through a pixel centre, blending roundings), and the GPU's Vulkan driver shares its D3D12 driver's choices. Against WARP, 8 of 20 seeds differ, and each one matches NVIDIA's D3D12. So the same-GPU host is what isolates the translation.The layer is the device the runtime makes (
create_vulkan_device_standalone, which enablesdepthClamp,independentBlendandlogicOp). Shaders: GLSL stand-ins written to the translator's contract (test/glsl/vs_pso.vert,ps_pso.frag,ps_pso_mrt.frag,ps_pso_uint.frag), found by FSSM hash as ind3d12_typeless_families; the reference runs the same programs in HLSL viad3dcompiler_47.--reduce SEEDshrinks a differing program to its fewest draws and triangles.--verboseprints every program, both target formats, and whether logic ops run.Modes for the open methods
--streamcreates every PSO throughID3D12Device2::CreatePipelineState, on both sides. The pipeline-state stream follows the d3dx12.h layout: subobjects in a random order, one equal to its default left out half the time, andDEPTH_STENCILorDEPTH_STENCIL1alternately. The layout comes from its own generator, so the programs are the same as without it. Onmainevery PSO is refused, since there's noCreatePipelineStateyet. On Runtime: mesh-shader PSOs from pipeline state streams and DispatchMesh (D3D-29) #1712 (D3D-29), 1,000 seeds give 0 differences and match the desc path seed for seed.--render-passruns the draws insideBeginRenderPass/EndRenderPass. Even seeds clear through the pass's CLEAR access; odd seeds clear first and begin PRESERVE; every pass ends PRESERVE. Onmainit's unimplemented and 18 of 20 seeds differ. On Runtime: record and replay D3D12 render passes as Vulkan dynamic rendering (D3D-27) #2064 (D3D-27), 1,000 seeds under validation give 0 differences.UNORM targets are cleared to 0 or 1 per channel. A clear value on a code tie is #5425's subject, and NVIDIA's D3D12 and D3D12's ties-to-even disagree there.
What it found
DepthBiasis applied about twice on NVIDIA. With--allover 600 seeds,maindiffers in 25, all in the depth plane. Examples: D240x34001eagainst0x34000f, and D160xec21against0xec10. A reduced case: one triangle on D24S8 withDepthBias = -6gives 12 codes of bias where D3D12 applies 6. That's the shadow-map case and the open #2718 (D3D-325, exact bias throughVK_EXT_depth_bias_control). On #2718's head with this fuzzer, 0 of 600 differ, bit-identical (measurement). Until it lands, the default run leavesDepthBiasat 0 so ctest stays green onmain, and--allputs it back.Everything else matches the same-GPU host: every blend factor and op, write masks, independent blend on two targets, all sixteen logic ops, every stencil op and function on both faces, culling and winding, depth clip and clamp, and viewport offsets, sizes and depth ranges with scissors.
Tested
RTX 5060 Ti / 621.14, Windows 11 26300, MSVC 14.51, Vulkan SDK 1.4.363.0.
LEONIDA_VK_VALIDATION=1--all, 600 seedsDepthBias(0 on #2718)LEONIDA_VK_VALIDATION=1 ctest -j4with-DLEONIDA_LLVM_MCd3d12_pso_fuzzincludedOne unrelated note: in one full run,
d3d12_fence_timingsegfaulted once under-j4. It passed 10 of 10 alone and in the next full run. It's pre-existing and doesn't involve this test; I'll look into it separately.Not covered yet: MSAA and alpha-to-coverage, slope-scaled bias (constant-depth triangles have no slope), and more than two render targets.
No game files. AI-assisted (Claude Code, Claude Opus 5.5).