Repository navigation
tools: a native-D3D12 golden-image conformance harness for the Vulkan device - #3343
Conversation
… device The shim reimplements D3D12 on Vulkan. runtime/test/ covers the device, resources, views, copies, clears and barriers, but nothing checks that a *draw* produces the same pixels as the host's D3D12. This adds the reference half of that check. Seven deterministic scenes (clear, fullscreen, depth_order, scissor, blend, indexed), each naming the exact pixels it must produce, so a mismatch is a coordinate rather than 'the picture looks off'. tools/conformance/spec/scenes.h states the baseline pipeline state every scene inherits - cull mode, topology, sample mask, viewport, scissor convention, clip-space z range, row order - because two implementers guessing differently produce two different images and neither is wrong on its own terms. native/ renders all seven with D3D12 and WIC, reads every pixel back from both the GPU and the PNG on disk, and exits non-zero on any mismatch: 18 checks, 18 passes, on an RTX 5070 Ti and on the AMD iGPU. compare.py (standard library only) checks a render against the contract and diffs two renders with a heatmap. The scenes are proven non-vacuous by scripts/negative-control.ps1: it disables the depth test, the blend state and the scissor rect in a throwaway copy and requires exactly depth_order, blend and scissor to fail at the pixels that name that state. The script throws when a replacement stops matching, so a silenced edit cannot pass. Against the shim at 2e5c0f2 the same scenes report clear OK and the five drawn scenes BLOCKED at ID3D12Device::CreateRootSignature (E_NOTIMPL), which is the order the draw path has to arrive in. No game data is read, nothing is downloaded, and the harness is not part of CI: it needs a D3D12 device, like root_signature_oracle_test.
|
Independent verification (AI-assisted) of open head
I checked the active coordination tracker (#3232), the D3D12 tracker (#313), and the PR discussion. #3232 lists #3343 for CPU review. I found no matching claim or duplicate verification. |
|
Reviewed and tested
Review: I read
AI-assisted (Claude Code); I checked the results. |
|
Tested df61881 on Linux 6.12.113+, Python 3.12.3 (no GPU, no game data): compare.py selftest passes; changes suggested. The native renderer was not built. Ran:
|
Why
runtime/test/covers the shim's device, resources, views, samplers, copies, clears, barriers and tiling — several of them against the host runtime, which is the right pattern (d3d12_copy_compare.h,d3d12_depth24_compare.h).What nothing covers is the end of the chain: that a draw produces the same pixels D3D12 would. Until the first frame lands (#335), a rendering regression has nothing to fail against.
This adds the reference half of that check: a small, deterministic scene set, a native D3D12 renderer that produces the golden images, and a tool that checks a render against them. When the draw path arrives, the shim runs the same scenes and the two image sets are diffed.
What
spec/scenes.h— seven scenes:clear,fullscreen,depth_order,scissor,blend,indexed. Each names the exact pixels it must produce, so a mismatch is a coordinate, not an opinion.The header also states the baseline pipeline state every scene inherits — cull mode, topology, sample mask, render-target write mask, viewport, scissor convention, clip-space z range and row order. That is deliberate: two implementers guessing differently produce two different images and neither is wrong on its own terms.
Two scenes are shaped by a specific failure:
depth_orderdraws the near quad first and the far quad second. The overlap stays green only if the depth test rejects the later draw. Drawing them in reach order would have let a shim with no depth test pass.indexedstores its vertices out of draw order and addresses them with a non-identity index list, so a program that ignores the index buffer draws visibly different triangles.native/— renders all seven with D3D12 and WIC, no third-party code. It reads every declared pixel back from both the GPU and the PNG decoded off disk, prints one line per check with scene, coordinate, expected and actual, and exits non-zero on any mismatch.compare.py— standard library only.expectchecks a render against the contract;diffcompares two renders and writes a heatmap;selftestproves the PNG reader and the metrics without external files.native/scripts/negative-control.ps1— the part that makes the scenes trustworthy: it disables the depth test, the blend state and the scissor rect in a throwaway copy and requires exactlydepth_order,blendandscissorto fail, each at the pixel that names that state. It throws when aString.Replacestops matching, so a silenced edit cannot pass as evidence.Evidence
Measured on an RTX 5070 Ti and on the AMD Radeon iGPU, 18/18 on both. Determinism verified by SHA-256 across two runs.
Against the shim today
The shim-side driver is not in this PR — it currently only reports blocked calls. Measured at
2e5c0f2:clearalready proves the full resource → clear → barrier → copy → readback chain on the Vulkan device. The five drawn scenes then become progress markers, in this order:CreateRootSignature→CreateGraphicsPipelineState→ theSetPipelineState/ root-binding group → viewport and scissor → vertex/index buffers →OMSetRenderTargets→DrawInstanced/DrawIndexedInstanced. I can add the driver here if it is wanted before the draw path exists.Relationship to open work
spec/scenes.his the place to add them.exit 77when no Vulkan device is available. The shim-side driver should follow that convention; the native renderer deliberately does not, because without a D3D12 device it has nothing to compare.Two things worth knowing before review
dxc -T vs_6_6anddxc -spirv -T vs_6_6) and let each renderer take the blob it wants — one workload, one set of expected pixels, no DXIL translator in the shim.root_signature_oracle_testis Windows-only for the same reason. It runs in about two seconds on hardware and on the Basic Render Driver.Not in this PR
No draw path, no shim changes, no game data, no keys.
D:\Leonidawas not modified to produce this.