diff --git a/crates/xcl/src/hle/d3d12x/bind.rs b/crates/xcl/src/hle/d3d12x/bind.rs index b50b835091..7c52c4a9d5 100644 --- a/crates/xcl/src/hle/d3d12x/bind.rs +++ b/crates/xcl/src/hle/d3d12x/bind.rs @@ -1293,6 +1293,31 @@ pub(super) fn heaps_changed(list: *mut c_void) { with(list, |s| s.heap_bound = false); } +/// Bind the shared view / sampler heaps once per recording until `heaps_changed`, and report +/// whether the shared view heap is among the bound heaps. +unsafe fn ensure_view_heap_cached(this: *mut c_void) -> bool { + let cached = with(this, |s| s.heap_bound.then_some(s.shared_view_bound)); + match cached { + Some(shared) => shared, + None => { + let shared = super::list_x::ensure_view_heap(this); + with(this, |s| { + s.heap_bound = true; + s.shared_view_bound = shared; + }); + shared + } + } +} + +/// Record that `this`'s current recording executed a translated draw or dispatch while the +/// shared view heap was bound, so VRAM eviction tracks its queue epoch. +fn note_shared_view_use(this: *mut c_void, shared_view_bound: bool) { + if shared_view_bound && super::vram::srv_tracking_enabled() { + super::list_x::note_shared_view_heap_use(this); + } +} + pub(super) fn inherit_for_split(from: *mut c_void, to: *mut c_void, allocator: usize) { install_prepared_split(prepare_split(from, to, allocator)); } @@ -2355,12 +2380,14 @@ pub(super) unsafe fn flush_two_pass(this: *mut c_void, why: RunEnd) { return; } let (Some(list), Some(records)) = (ID3D12GraphicsCommandList::from_raw_borrowed(&this), records) else { return }; + let shared_view_bound = ensure_view_heap_cached(this); RUN_ENDS[run_end_index(why)].fetch_add(1, Ordering::Relaxed); let steps: Vec = items.iter().map(RunItem::step).collect(); let cmds = batch_commands(&steps, records.as_raw() as usize, open); let binds: Vec<(usize, Option<&super::pso_async::PipelineResolution>)> = items.iter().filter_map(|i| if let RunItem::Bind { pso, resolution, .. } = i { Some((*pso, resolution.as_ref())) } else { None }).collect(); emit_commands(this, list, &cmds, &draws, &binds); + note_shared_view_use(this, shared_view_bound); with(this, |s| (s.batch_used, s.batch_open) = (0, true)); for d in &draws { mesh_work(this, super::targets::RAN); @@ -2495,7 +2522,7 @@ unsafe fn defer_dispatch_mesh(this: *mut c_void, tp: &Arc Result<(), String> { // the pair is translated with heap windows when they are on (`pso::mem_windows`): as `bind_abi` - super::list_x::ensure_view_heap(this); + let shared_view_bound = ensure_view_heap_cached(this); let stage = prepare_two_pass_stage(this, real_mesh_pso, tp, res_va, compute_pass, 0)?; - emit_two_pass_stage(list, &stage, compute_pass); + record_two_pass_stage(this, list, &stage, compute_pass, shared_view_bound); Ok(()) } @@ -3007,9 +3034,9 @@ struct StageBind { } /// `stage` on `list`: root signature, root views, pipeline. -unsafe fn emit_two_pass_stage(list: &ID3D12GraphicsCommandList, stage: &StageBind, compute_pass: bool) { +unsafe fn emit_two_pass_stage(list: &ID3D12GraphicsCommandList, stage: &StageBind, compute_pass: bool) -> bool { let (rs_raw, pso_raw) = (stage.rs as *mut c_void, stage.pso as *mut c_void); - let (Some(rs), Some(pc)) = (ID3D12RootSignature::from_raw_borrowed(&rs_raw), ID3D12PipelineState::from_raw_borrowed(&pso_raw)) else { return }; + let (Some(rs), Some(pc)) = (ID3D12RootSignature::from_raw_borrowed(&rs_raw), ID3D12PipelineState::from_raw_borrowed(&pso_raw)) else { return false }; if compute_pass { list.SetComputeRootSignature(rs); for (k, &v) in stage.views.iter().enumerate() { @@ -3022,6 +3049,20 @@ unsafe fn emit_two_pass_stage(list: &ID3D12GraphicsCommandList, stage: &StageBin } } list.SetPipelineState(pc); + true +} + +/// Emit `stage` on `list` and record shared view-heap use on `this` when the stage was emitted. +unsafe fn record_two_pass_stage( + this: *mut c_void, + list: &ID3D12GraphicsCommandList, + stage: &StageBind, + compute_pass: bool, + shared_view_bound: bool, +) { + if emit_two_pass_stage(list, stage, compute_pass) { + note_shared_view_use(this, shared_view_bound); + } } /// The binding of a two-pass stage with the title's root arguments as they are now, written to @@ -3383,7 +3424,7 @@ pub(super) unsafe extern "system" fn dispatch_mesh(this: *mut c_void, x: u32, y: let staged = if slices > 1 { // A half-buffer layout is selected only when the requested group count fits. debug_assert_eq!(records, Records::Whole); - super::list_x::ensure_view_heap(this); + let shared_view_bound = ensure_view_heap_cached(this); let mesh = prepare_two_pass_stage(this, pso, &tp, res_va, false, 0)?; let compute = (0..slices) .map(|slice| prepare_two_pass_stage(this, pso, &tp, res_va, true, slice * n)) @@ -3392,7 +3433,7 @@ pub(super) unsafe extern "system" fn dispatch_mesh(this: *mut c_void, x: u32, y: if N.fetch_add(1, Ordering::Relaxed) < 8 { crate::xlog_info!("D3D12.X: two-pass DispatchMesh of {groups} groups in {slices} slices ({n} groups fit the record buffer)"); } - Some((mesh, compute)) + Some((mesh, compute, shared_view_bound)) } else { None }; @@ -3408,9 +3449,9 @@ pub(super) unsafe extern "system" fn dispatch_mesh(this: *mut c_void, x: u32, y: run_two_pass_plan(this, list, &plan, &res_buf, res_va, cap, |slice, compute, va| { let first = slice * n; let count = n.min(draw_groups - first); - if let Some((mesh, stages)) = &staged { + if let Some((mesh, stages, shared_view_bound)) = &staged { let stage = if compute { &stages[slice as usize] } else { mesh }; - emit_two_pass_stage(list, stage, compute); + record_two_pass_stage(this, list, stage, compute, *shared_view_bound); } else { bind_two_pass_stage(this, list, pso, &tp, va, compute)?; } @@ -5195,18 +5236,7 @@ unsafe fn bind_abi_with_root_resolved( } // the shared view and sampler heaps: once a recording until the title sets heaps again // (`heaps_changed`), and whether the shared view heap is among them - let cached = with(this, |s| s.heap_bound.then_some(s.shared_view_bound)); - let shared_view_bound = match cached { - Some(shared) => shared, - None => { - let shared = super::list_x::ensure_view_heap(this); - with(this, |s| { - s.heap_bound = true; - s.shared_view_bound = shared; - }); - shared - } - }; + let shared_view_bound = ensure_view_heap_cached(this); let u = crate::gpu::uma::get().ok_or("no unified memory")?; let first = first_window(super::real::uma_window_va(0), u.shadowed())?; // a compute shader takes no more arguments from registers than it has (`inline_for`) @@ -5239,9 +5269,7 @@ unsafe fn bind_abi_with_root_resolved( if root == 0 { super::real::bind_pipeline_exact(this, original, pso); } - if shared_view_bound && super::vram::srv_tracking_enabled() { - super::list_x::note_shared_view_heap_use(this); - } + note_shared_view_use(this, shared_view_bound); Ok(b) } @@ -10023,4 +10051,238 @@ void ms(uint3 g : SV_GroupID) { o.Store((v * 16u + g.x) * 4u, rec.Load(g.x * 4u) assert_eq!(TWO_PASS[TP_SHRUNK].load(Ordering::Relaxed), shrunk_before); } } + + #[test] + fn two_pass_stage_records_shared_view_heap_use_and_caches_heap_check() { + #[repr(C)] + struct FakeStageList { + vt: *const usize, + refs: AtomicUsize, + set_pso_calls: AtomicUsize, + } + unsafe extern "system" fn add_ref(this: *mut c_void) -> u32 { + (*(this as *const FakeStageList)).refs.fetch_add(1, Ordering::Relaxed) as u32 + 1 + } + unsafe extern "system" fn release(this: *mut c_void) -> u32 { + (*(this as *const FakeStageList)).refs.fetch_sub(1, Ordering::Relaxed) as u32 - 1 + } + unsafe extern "system" fn noop_ptr(_this: *mut c_void, _p: *mut c_void) {} + unsafe extern "system" fn noop_uav(_this: *mut c_void, _slot: u32, _va: u64) {} + unsafe extern "system" fn noop_heaps(_this: *mut c_void, _n: u32, _heaps: *const usize) {} + unsafe extern "system" fn set_pso(this: *mut c_void, _pso: *mut c_void) { + (*(this as *const FakeStageList)).set_pso_calls.fetch_add(1, Ordering::Relaxed); + } + + let mut orig_vt = [0usize; 64]; + orig_vt[1] = add_ref as usize; + orig_vt[2] = release as usize; + orig_vt[25] = set_pso as usize; + orig_vt[28] = noop_heaps as usize; + orig_vt[29] = noop_ptr as usize; + orig_vt[30] = noop_ptr as usize; + orig_vt[41] = noop_uav as usize; + orig_vt[42] = noop_uav as usize; + let mut ext_vt = vec![0usize; 65]; + ext_vt[0] = orig_vt.as_ptr() as usize; + ext_vt[1..].copy_from_slice(&orig_vt); + let fake = Box::new(FakeStageList { + vt: unsafe { ext_vt.as_ptr().add(1) }, + refs: AtomicUsize::new(1), + set_pso_calls: AtomicUsize::new(0), + }); + let this = &*fake as *const FakeStageList as *mut c_void; + let obj_vt = [0usize, resolution_add_ref as usize, resolution_release as usize]; + let mut fake_rs = ResolutionPso { vtable: obj_vt.as_ptr(), refs: AtomicUsize::new(1) }; + let mut fake_pso = ResolutionPso { vtable: obj_vt.as_ptr(), refs: AtomicUsize::new(1) }; + let valid_stage = StageBind { + rs: &mut fake_rs as *mut ResolutionPso as usize, + pso: &mut fake_pso as *mut ResolutionPso as usize, + views: [0x1000; 6], + }; + let empty_tp = super::super::real::TwoPassPso { + compute: 0, + compute_rs: 0, + mesh_rs: 0, + record: Default::default(), + mesh_groups_per_record: 1, + kind: "MS", + }; + + super::super::vram::with_srv_tracking_for_test(|| unsafe { + let list = ID3D12GraphicsCommandList::from_raw_borrowed(&this).unwrap(); + reset(this, 0, 0); + super::super::list_x::seed_shared_view_heap_for_test(this, true); + + // A failing bind caches the heap check without marking shared view-heap use. + assert!(bind_two_pass_stage(this, list, 0, &empty_tp, 0, true).is_err()); + assert_eq!(with(this, |s| (s.heap_bound, s.shared_view_bound)), (true, true)); + assert!(!super::super::list_x::uses_shared_view_heap_for_test(this)); + + // Changing descriptor heaps invalidates the cache, and re-checking sees the updated state. + heaps_changed(this); + assert!(!with(this, |s| s.heap_bound)); + super::super::list_x::seed_shared_view_heap_for_test(this, false); + assert!(!ensure_view_heap_cached(this)); + assert_eq!(with(this, |s| (s.heap_bound, s.shared_view_bound)), (true, false)); + + heaps_changed(this); + super::super::list_x::seed_shared_view_heap_for_test(this, true); + assert!(ensure_view_heap_cached(this)); + + // A null stage emits nothing and does not mark use; a stage without the shared heap does not mark use. + record_two_pass_stage(this, list, &StageBind { rs: 0, pso: 0, views: [0; 6] }, true, true); + assert!(!super::super::list_x::uses_shared_view_heap_for_test(this)); + record_two_pass_stage(this, list, &valid_stage, true, false); + assert!(!super::super::list_x::uses_shared_view_heap_for_test(this)); + + // Emitting either compute or mesh pass with the shared view heap bound records use. + record_two_pass_stage(this, list, &valid_stage, true, true); + assert!(super::super::list_x::uses_shared_view_heap_for_test(this)); + + super::super::list_x::seed_shared_view_heap_for_test(this, true); + record_two_pass_stage(this, list, &valid_stage, false, true); + assert!(super::super::list_x::uses_shared_view_heap_for_test(this)); + assert_eq!(fake.set_pso_calls.load(Ordering::Relaxed), 3); + + forget(this); + super::super::list_x::on_release(this as usize); + }); + } + + #[test] + fn flush_two_pass_records_shared_view_heap_use_only_when_draws_emit() { + #[repr(C)] + struct FakeBatchList { + vt: *const usize, + refs: AtomicUsize, + dispatch_calls: AtomicUsize, + dispatch_mesh_calls: AtomicUsize, + stencil_calls: AtomicUsize, + } + unsafe extern "system" fn add_ref(this: *mut c_void) -> u32 { + (*(this as *const FakeBatchList)).refs.fetch_add(1, Ordering::Relaxed) as u32 + 1 + } + unsafe extern "system" fn release(this: *mut c_void) -> u32 { + (*(this as *const FakeBatchList)).refs.fetch_sub(1, Ordering::Relaxed) as u32 - 1 + } + unsafe extern "system" fn dispatch(this: *mut c_void, _x: u32, _y: u32, _z: u32) { + (*(this as *const FakeBatchList)).dispatch_calls.fetch_add(1, Ordering::Relaxed); + } + unsafe extern "system" fn dispatch_mesh(this: *mut c_void, _x: u32, _y: u32, _z: u32) { + (*(this as *const FakeBatchList)).dispatch_mesh_calls.fetch_add(1, Ordering::Relaxed); + } + unsafe extern "system" fn set_stencil(this: *mut c_void, _r: u32) { + (*(this as *const FakeBatchList)).stencil_calls.fetch_add(1, Ordering::Relaxed); + } + unsafe extern "system" fn noop_ptr(_this: *mut c_void, _p: *mut c_void) {} + unsafe extern "system" fn noop_uav(_this: *mut c_void, _slot: u32, _va: u64) {} + unsafe extern "system" fn noop_barriers(_this: *mut c_void, _n: u32, _b: *const c_void) {} + unsafe extern "system" fn noop_heaps(_this: *mut c_void, _n: u32, _heaps: *const usize) {} + unsafe extern "system" fn noop_indirect(_this: *mut c_void, _sig: usize, _max: u32, _args: usize, _off: u64, _cnt: usize, _cnt_off: u64) {} + + let mut orig_vt = [0usize; 80]; + orig_vt[1] = add_ref as usize; + orig_vt[2] = release as usize; + orig_vt[14] = dispatch as usize; + orig_vt[24] = set_stencil as usize; + orig_vt[25] = noop_ptr as usize; + orig_vt[26] = noop_barriers as usize; + orig_vt[28] = noop_heaps as usize; + orig_vt[29] = noop_ptr as usize; + orig_vt[30] = noop_ptr as usize; + orig_vt[41] = noop_uav as usize; + orig_vt[42] = noop_uav as usize; + orig_vt[59] = noop_indirect as usize; + orig_vt[79] = dispatch_mesh as usize; + let mut ext_vt = vec![0usize; 81]; + ext_vt[0] = orig_vt.as_ptr() as usize; + ext_vt[1..].copy_from_slice(&orig_vt); + let fake = Box::new(FakeBatchList { + vt: unsafe { ext_vt.as_ptr().add(1) }, + refs: AtomicUsize::new(1), + dispatch_calls: AtomicUsize::new(0), + dispatch_mesh_calls: AtomicUsize::new(0), + stencil_calls: AtomicUsize::new(0), + }); + let this = &*fake as *const FakeBatchList as *mut c_void; + + let obj_vt = [0usize, resolution_add_ref as usize, resolution_release as usize]; + let mut fake_rs = ResolutionPso { vtable: obj_vt.as_ptr(), refs: AtomicUsize::new(1) }; + let mut fake_pso = ResolutionPso { vtable: obj_vt.as_ptr(), refs: AtomicUsize::new(1) }; + let mut fake_res = ResolutionPso { vtable: obj_vt.as_ptr(), refs: AtomicUsize::new(1) }; + let stage = StageBind { + rs: &mut fake_rs as *mut ResolutionPso as usize, + pso: &mut fake_pso as *mut ResolutionPso as usize, + views: [0x2000; 6], + }; + let tp = Arc::new(super::super::real::TwoPassPso { + compute: 0, + compute_rs: 0, + mesh_rs: 0, + record: Default::default(), + mesh_groups_per_record: 1, + kind: "MS", + }); + let make_draw = || DeferredDraw { + snap: DrawSnap { compute: stage, mesh: stage, work: DeferredWork::Mesh { groups: 1, mesh_groups: 1 } }, + _tp: tp.clone(), + _mesh_pso: None, + _block: None, + raw_pso: 0, + kind: "MS", + size: [1, 1, 1], + }; + let install_batch_buf = |list: *mut c_void, res_ptr: *mut ResolutionPso| unsafe { + let raw = res_ptr as *mut c_void; + let res = ID3D12Resource::from_raw_borrowed(&raw).unwrap().clone(); + with(list, |s| { + s.batch_buf = Some(TwoPassBuf { res, bytes: 0, dev: 0 }); + s.batch_open = false; + }); + }; + + super::super::vram::with_srv_tracking_for_test(|| unsafe { + reset(this, 0, 0); + + // 1. Un-flushed deferred draws dropped by reset must not mark shared view-heap use. + super::super::list_x::seed_shared_view_heap_for_test(this, true); + with(this, |s| s.deferred.push(RunItem::Draw(make_draw()))); + mark_deferring(this); + reset(this, 0, 0); + assert!(!super::super::list_x::uses_shared_view_heap_for_test(this)); + + // 2. A state-only flush with no draws replays state without marking shared view-heap use. + super::super::list_x::seed_shared_view_heap_for_test(this, true); + with(this, |s| s.deferred.push(RunItem::StencilRef(7))); + mark_deferring(this); + flush_two_pass(this, RunEnd::Close); + assert_eq!(fake.stencil_calls.load(Ordering::Relaxed), 1); + assert!(!super::super::list_x::uses_shared_view_heap_for_test(this)); + + // 3. Flushing draws when the shared view heap is NOT bound leaves use false. + install_batch_buf(this, &mut fake_res); + super::super::list_x::seed_shared_view_heap_for_test(this, false); + heaps_changed(this); + with(this, |s| s.deferred.push(RunItem::Draw(make_draw()))); + mark_deferring(this); + flush_two_pass(this, RunEnd::Close); + assert_eq!(fake.dispatch_calls.load(Ordering::Relaxed), 1); + assert_eq!(fake.dispatch_mesh_calls.load(Ordering::Relaxed), 1); + assert!(!super::super::list_x::uses_shared_view_heap_for_test(this)); + + // 4. Flushing draws when the shared view heap IS bound marks shared view-heap use. + super::super::list_x::seed_shared_view_heap_for_test(this, true); + heaps_changed(this); + with(this, |s| s.deferred.push(RunItem::Draw(make_draw()))); + mark_deferring(this); + flush_two_pass(this, RunEnd::Close); + assert_eq!(fake.dispatch_calls.load(Ordering::Relaxed), 2); + assert_eq!(fake.dispatch_mesh_calls.load(Ordering::Relaxed), 2); + assert!(super::super::list_x::uses_shared_view_heap_for_test(this)); + + with(this, |s| s.batch_buf = None); + forget(this); + super::super::list_x::on_release(this as usize); + }); + } } diff --git a/crates/xcl/src/hle/d3d12x/list_x.rs b/crates/xcl/src/hle/d3d12x/list_x.rs index 0210c522f1..c0c964f29f 100644 --- a/crates/xcl/src/hle/d3d12x/list_x.rs +++ b/crates/xcl/src/hle/d3d12x/list_x.rs @@ -1101,6 +1101,26 @@ pub(super) fn note_shared_view_heap_use(list: *mut c_void) { } } +#[cfg(test)] +pub(super) fn uses_shared_view_heap_for_test(list: *mut c_void) -> bool { + LISTS + .lock() + .unwrap() + .as_ref() + .and_then(|m| m.get(&(list as usize))) + .is_some_and(|state| state.uses_shared_view_heap) +} + +#[cfg(test)] +pub(super) fn seed_shared_view_heap_for_test(list: *mut c_void, shared: bool) { + let mut g = LISTS.lock().unwrap(); + let state = g.get_or_insert_with(HashMap::new).entry(list as usize).or_default(); + state.bindings.heaps = if shared { vec![0x1000_0000, 0x2000_0000] } else { vec![0x3000_0000, 0x4000_0000] }; + state.bindings.has_sampler_heap = true; + state.bindings.shared_view_heap = shared; + state.uses_shared_view_heap = false; +} + fn propagate_bundle_shared_view_use(states: &mut HashMap, parent: usize, bundle: usize) { if states.get(&bundle).is_some_and(|state| state.uses_shared_view_heap) { states.entry(parent).or_default().uses_shared_view_heap = true; @@ -5212,6 +5232,9 @@ pub unsafe extern "system" fn kickoff_x(this: *mut c_void) { } else { None }; + // (before the effects are taken: the deferred two-pass draws it records note their own, the + // shared view heap's use among them) + super::bind::flush_two_pass(this, super::bind::RunEnd::Segment); let (bound_pso, depth_bias, index_buffer, depth_bounds, predication, pred_buf, pred_in_state, active_query, preclose_effects, current_trace) = { let mut g = LISTS.lock().unwrap(); let Some(s) = g.as_mut().and_then(|m| m.get_mut(&(this as usize))) else { @@ -5228,7 +5251,6 @@ pub unsafe extern "system" fn kickoff_x(this: *mut c_void) { (s.bound_pso, s.depth_bias, s.index_buffer, s.depth_bounds, s.predication, pred_buf, pred_in_state, active_query, preclose_effects, current_trace) }; - super::bind::flush_two_pass(this, super::bind::RunEnd::Segment); // End any active occlusion query before Close (PC forbids closing with an open query). if let Some(((h, i), qty)) = active_query { pc::(this, PC_END_QUERY)(this, h, qty, i); @@ -5988,8 +6010,17 @@ pub(super) unsafe fn ensure_view_heap(this: *mut c_void) -> bool { let sampler = ensure_global_sampler_heap(); let view_raw = view.as_ref().map(|h| h.as_raw() as usize); let sampler_raw = sampler.as_ref().map(|h| h.as_raw() as usize); + ensure_view_heap_with(this, view_raw, sampler_raw) +} + +unsafe fn ensure_view_heap_with(this: *mut c_void, view_raw: Option, sampler_raw: Option) -> bool { if view_raw.is_none() && sampler_raw.is_none() { - return false; + return LISTS + .lock() + .unwrap() + .as_ref() + .and_then(|m| m.get(&(this as usize))) + .is_some_and(|s| s.bindings.shared_view_heap); } let mut to_bind: Option> = None; let mut shared_view_bound = false; @@ -8215,6 +8246,21 @@ mod tests { assert!(states[&parent].uses_shared_view_heap, "executing an unused bundle cannot clear prior use"); } + #[test] + fn ensure_view_heap_preserves_already_bound_shared_view_heap() { + let list = 0x7ffe_1b41usize as *mut c_void; + seed_shared_view_heap_for_test(list, true); + assert!( + unsafe { ensure_view_heap_with(list, None, None) }, + "shared view heap set earlier on the list must still report true when no default heaps are injected", + ); + + seed_shared_view_heap_for_test(list, false); + assert!(!unsafe { ensure_view_heap_with(list, None, None) }); + + LISTS.lock().unwrap().as_mut().unwrap().remove(&(list as usize)); + } + #[test] fn queue_identity_changes_when_a_raw_address_is_reused() { let raw = 0x7ffe_1801usize; diff --git a/crates/xcl/src/hle/d3d12x/vram.rs b/crates/xcl/src/hle/d3d12x/vram.rs index 25371e8f97..eeb0114d71 100644 --- a/crates/xcl/src/hle/d3d12x/vram.rs +++ b/crates/xcl/src/hle/d3d12x/vram.rs @@ -154,6 +154,19 @@ pub(super) fn srv_tracking_enabled() -> bool { #[cfg(test)] static SRV_TRACKING_FOR_TEST: std::sync::atomic::AtomicBool = std::sync::atomic::AtomicBool::new(false); +#[cfg(test)] +pub(super) fn with_srv_tracking_for_test(f: impl FnOnce() -> R) -> R { + let _guard = VRAM_TEST_LOCK.lock().unwrap_or_else(|e| e.into_inner()); + struct Reset(bool); + impl Drop for Reset { + fn drop(&mut self) { + SRV_TRACKING_FOR_TEST.store(self.0, std::sync::atomic::Ordering::Relaxed); + } + } + let _reset = Reset(SRV_TRACKING_FOR_TEST.swap(true, std::sync::atomic::Ordering::Relaxed)); + f() +} + #[derive(Clone, Copy, Debug, Eq, PartialEq)] pub(super) struct SharedViewEpoch(u64);