[pr-tests] Shaders: the test host keeps its last device, so each case does not make one again #384
Loading…
Reference in a new issue
No description provided.
Delete branch "ntsthay/shader-host-keeps-device"
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?
Tests only. Nothing here runs in the game.
Contributor role (optional)
What it changes
Host::newin the shader test host made a new D3D12 device every time, and each host was dropped at the end of its case. The GPU tests make a host for every shader they check, so a device was made and destroyed again and again. D3D12 gives one device per adapter while one is alive, and vkd3d-proton does the same (d3d12_find_device_singleton).Host::newnow keeps the last device of each kind (card and WARP) for the life of the process, so the nextD3D12CreateDeviceon that adapter gets the same device back. A kept device that was removed is dropped first, so a removed device is never handed out again.Measured under vkd3d-proton (Proton on Linux, RTX 4080), on
f3840d7:cost_checks::the_median_of_a_value_and_two_constants_is_a_clampmade 56 hosts at 256 ms each. That is 14.3 s of its 25.4 s. Its thread spent three quarters of its time in the kernel.v_mad_u64_u32_matches_its_definitiontakes 7.7 s, down from 9 s.darner-shadercrate with 16 processes: 61 tests over 15 s before, 11 now, in 68 s of wall time.Statics are not dropped, so the kept device is still alive when the process ends. Holding the device in a thread-local instead made the test process hang on exit under vkd3d-proton.
How it was tested
79f3c9f, this branch onf3840d7.cargo nextest run -p darner-shaderunder Proton with 16 processes. Every test that passed onf3840d7still passes, and the ones over 15 s went from 61 to 11. The 4 failures are the same as onf3840d7and are fixed by #347 and #349.cargo clippy -p darner-shader -p darner-gpu --all-targets, with and without--all-features,-D warnings) are clean. Gate 3 ran under Wine, not on Windows.Checklist
main.docs/asset-policy.md.Checked for overlap
on_wine()to the same file, in a different place.One issue with keeping the device at
79f3c9f: the nextHost::makecan callEnableDebugLayerwhile that device is still alive. Microsoft documents that enabling the layer after device creation removes the device. This also matters fordarner translate --check, which uses the same host. D3D12 debug layer documentation752f312 initializes the layer once, before either host creation or test adapter enumeration. It keeps the existing opt-in and leaves the device cache in place. The scoped shader test type-check, asset policy and diff check passed. This machine returned
0x887A002DforD3D12GetDebugInterface, so the debug-enabled path still needs a Windows run with the graphics debug layer installed.If you cherry-pick or rebase this commit, please keep the Git author. If you fold it into another commit, please add this trailer.
Co-authored-by: andrewpozdnakov7-jpg <[email protected]>Thanks, good catch. With the device kept alive, a second
Host::makewould have enabled the debug layer on a live device and removed it. I cherry-picked 752f312 with your authorship kept (now6b79d2don this PR). Clippy is clean, anddarner-shaderunder Proton has the same 4 failures asmain(fixed by #347 and #349).The debug-layer path is still untested on both sides: your machine has no graphics debug layer (
0x887A002D), and Wine has none either. If someone with Windows and the Graphics Tools installed can run a shader test withDARNER_D3D12_DEBUG=1, that would cover it. Without the variable nothing changes.View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.