From 38452a179c3768677e5a936de44f6a7b37d54400 Mon Sep 17 00:00:00 2001 From: bmjask <> Date: Thu, 26 Nov 2026 06:18:07 -0800 Subject: [PATCH 1/2] D3D12.X: own one dormant restoration coordinator Give the later bind integration one bounded coordinator and an opaque nonblocking classification seam. The accessor does not start workers, enable eviction, install bind state, or wait for restoration. Assisted-by: Codex (GPT-5.6-sol) --- crates/xcl/src/hle/d3d12x/pso_async.rs | 36 ++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/crates/xcl/src/hle/d3d12x/pso_async.rs b/crates/xcl/src/hle/d3d12x/pso_async.rs index e04ab8a840..06b615cfb6 100644 --- a/crates/xcl/src/hle/d3d12x/pso_async.rs +++ b/crates/xcl/src/hle/d3d12x/pso_async.rs @@ -6880,7 +6880,19 @@ enum StructuredResolve { }, } +const PIPELINE_RESTORATION_EVICTIONS: usize = 1024; const PIPELINE_RESOLUTION_RECEIPTS: usize = 1024; +type PipelineRestorationCoordinator = + RestorationCoordinator; + +/// One dormant coordinator identity for the later live classification stage. Merely obtaining it +/// neither starts workers nor enables eviction; no production caller classifies through it yet. +fn pipeline_restoration_coordinator() -> &'static PipelineRestorationCoordinator { + static COORDINATOR: OnceLock = OnceLock::new(); + COORDINATOR.get_or_init(|| { + PipelineRestorationCoordinator::new(1).expect("nonzero pipeline restoration capacities") + }) +} /// Opaque retained resolver decision carried by command-list state. Live callers do not make /// these yet; the later classification stage supplies them without exposing coordinator types. @@ -6888,6 +6900,30 @@ const PIPELINE_RESOLUTION_RECEIPTS: usize = 1024; #[derive(Clone)] pub(super) struct PipelineResolution(StructuredResolve); +/// Wrap one nonblocking decision without exposing coordinator or receipt types to command-list +/// state. This does not start workers and never runs a queued driver build on the caller. +fn begin_pipeline_resolution_on( + original: usize, + pending: &Arc, + coordinator: &RestorationCoordinator, + q: &BuildQueue, +) -> PipelineResolution { + PipelineResolution(classify_structured_on(original, pending, coordinator, q)) +} + +/// Dormant live-queue seam for the later bind integration. There are intentionally no production +/// callers yet; worker startup, state installation, and emission waits remain separate stages. +#[allow(dead_code)] +fn begin_pipeline_resolution(original: usize) -> Option { + let pending = entry(original)?; + Some(begin_pipeline_resolution_on( + original, + &pending, + pipeline_restoration_coordinator(), + queue(), + )) +} + #[cfg(test)] struct PipelineResolutionDropProbe(Option>); From 885e825ce1cae64d2bba91ff817e7fb3e4642390 Mon Sep 17 00:00:00 2001 From: bmjask <> Date: Thu, 26 Nov 2026 06:18:51 -0800 Subject: [PATCH 2/2] Tests: cover the dormant restoration coordinator Exercise stable singleton identity, bounded eviction-ledger exhaustion and reuse, and queue-shutdown refusal without running driver work on the classifier. Assisted-by: Codex (GPT-5.6-sol) --- crates/xcl/src/hle/d3d12x/pso_async.rs | 73 ++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) diff --git a/crates/xcl/src/hle/d3d12x/pso_async.rs b/crates/xcl/src/hle/d3d12x/pso_async.rs index 06b615cfb6..99dcb4e9c3 100644 --- a/crates/xcl/src/hle/d3d12x/pso_async.rs +++ b/crates/xcl/src/hle/d3d12x/pso_async.rs @@ -4211,6 +4211,79 @@ mod used_tests { }) } + #[test] + fn dormant_restoration_coordinator_has_one_stable_identity() { + let first = pipeline_restoration_coordinator() as *const _; + let second = pipeline_restoration_coordinator() as *const _; + assert_eq!(first, second); + assert!(PIPELINE_RESTORATION_EVICTIONS > 0 && PIPELINE_RESOLUTION_RECEIPTS > 0); + + let original = 0x7E57_D010usize; + let pending = structured_pending(Arc::new(Build::new(Box::new(|| { + panic!("dormant classification ran initial driver work inline") + }), false)), false); + PENDING.insert(original, pending.clone()); + let resolution = begin_pipeline_resolution(original).expect("registered pipeline"); + assert_eq!(resolution.identity_for_test(), (original, Arc::as_ptr(&pending) as usize)); + assert!(Arc::ptr_eq(&PENDING.remove(original).unwrap(), &pending)); + } + + #[test] + fn restoration_coordinator_reuses_its_bounded_eviction_capacity() { + let coordinator = RestorationCoordinator::<2, PIPELINE_RESOLUTION_RECEIPTS>::new(510).unwrap(); + let first_build = ledger_build(); + let second_build = ledger_build(); + let third_build = ledger_build(); + let first = coordinator.install_eviction(&first_build, ledger_native(70)).unwrap().commit(); + let second = coordinator.install_eviction(&second_build, ledger_native(71)).unwrap().commit(); + assert!(coordinator.install_eviction(&third_build, ledger_native(72)).is_none()); + + assert!(first_build.clear_eviction_token(&first)); + assert!(coordinator.evicted.finish(&first, EvictedBuildState::Poisoned)); + assert!(coordinator.evicted.retire(&first)); + drop(coordinator.install_eviction(&third_build, ledger_native(72)) + .expect("retired bounded slot was not reusable")); + + assert!(second_build.clear_eviction_token(&second)); + assert!(coordinator.evicted.finish(&second, EvictedBuildState::Poisoned)); + assert!(coordinator.evicted.retire(&second)); + assert!(coordinator.evicted.records(2).is_empty()); + } + + #[test] + fn dormant_resolution_maps_queue_shutdown_without_inline_driver_work() { + let vtable = [0usize, rebuild_fake_add_ref as usize, rebuild_fake_release as usize]; + let mut native = RebuildFakePso { vtable: vtable.as_ptr(), refs: AtomicUsize::new(1) }; + let raw = &mut native as *mut RebuildFakePso as usize; + let calls = Arc::new(AtomicUsize::new(0)); + let build_calls = calls.clone(); + let recipe = Recipe::new(move || { + build_calls.fetch_add(1, Ordering::Relaxed); + raw + }); + let build = Arc::new(Build::new_keyed(recipe.initial_job(), false, None, Some(recipe.clone()))); + let initial = build.job.lock().unwrap().take().unwrap(); complete(&build, initial()); + let pin = recipe.pin_with_residency(raw).0.unwrap(); + let coordinator = RestorationCoordinator::<1, PIPELINE_RESOLUTION_RECEIPTS>::new(511).unwrap(); + let evicted = coordinator.install_eviction(&build, pin.ledger_identity()).unwrap().commit(); + drop(pin); + assert_eq!(try_evict_current(&build), EvictResult::Evicted { generation: 1 }); + let pending = structured_pending(build.clone(), false); + let q = BuildQueue::new(); + q.shutdown(); + + let resolution = begin_pipeline_resolution_on(0x7E57_D011, &pending, &coordinator, &q); + assert_eq!(calls.load(Ordering::Relaxed), 1, "classification ran driver work inline"); + assert!(matches!(resolution.0.wait_exact(), Err(StructuredResolveFailure::Refused))); + assert_eq!(coordinator.reconcile(1), 1); + + assert!(build.clear_eviction_token(&evicted)); + assert!(coordinator.evicted.finish(&evicted, EvictedBuildState::Poisoned)); + assert!(coordinator.evicted.retire(&evicted)); + drop(resolution); drop(pending); drop(build); drop(recipe); + assert_eq!(native.refs.load(Ordering::Relaxed), 0); + } + #[test] fn structured_resolve_retains_pending_across_title_address_reuse() { let original = 0x7E57_D001usize;