fix(windows-drivers): pf-vdisplay robustness — AdapterInitStatus gate, pooled-device TDR check, MMCSS-optional worker
Batch B of the audit's medium tier (M4+M5+M6): - M4: adapter_init_finished now reads AdapterInitStatus (was ignored) and only stashes the adapter on NT_SUCCESS, per the MS sample. A failed async init previously produced a HUSK adapter: monitors created on it arrive but the OS never assigns a swap-chain — every session black-screens with no visible cause (the exact signature live fault-injection produced after a WUDFHost kill). Unset adapter → ADD fails cleanly (host-retryable) and a re-entrant D0 retries the init; the status is now in the debug log. - M5: pooled_device checks GetDeviceRemovedReason on a cache hit — a TDR'd device was returned for its LUID forever (SetDevice fail-loop, black virtual display until device teardown); now it falls through to a fresh create. - M6: an AvSetMmThreadCharacteristicsW failure no longer aborts the worker before draining (which stalled the monitor and leaked the WDF swap-chain object) — continue unprioritized like the MS sample; revert only if MMCSS actually engaged. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -150,7 +150,16 @@ pub fn pooled_device(luid: LUID) -> Option<Arc<Direct3DDevice>> {
|
||||
if let Some((k, dev)) = pool.as_ref()
|
||||
&& *k == key
|
||||
{
|
||||
return Some(dev.clone());
|
||||
// A TDR / driver reset REMOVES the pooled device permanently; handing it out again gives
|
||||
// every future swap-chain a dead device (SetDevice fail-loop → black virtual display until
|
||||
// device teardown). Detect and fall through to a fresh create instead.
|
||||
// SAFETY: plain status query on the live pooled device.
|
||||
match unsafe { dev.device.GetDeviceRemovedReason() } {
|
||||
Ok(()) => return Some(dev.clone()),
|
||||
Err(e) => {
|
||||
dbglog!("[pf-vd] pooled D3D device was REMOVED ({e:?}) — recreating on {key:#x}");
|
||||
}
|
||||
}
|
||||
}
|
||||
match Direct3DDevice::init(luid) {
|
||||
Ok(d) => {
|
||||
|
||||
Reference in New Issue
Block a user