diff --git a/crates/victory-gpu/src/list.rs b/crates/victory-gpu/src/list.rs index 02ad326..cefffc5 100644 --- a/crates/victory-gpu/src/list.rs +++ b/crates/victory-gpu/src/list.rs @@ -1396,16 +1396,43 @@ extern "system" fn set_pipeline(this: This, pipeline: This) { } /// Pipeline syncs: waits for earlier work and cache flushes, at the top or -/// bottom of the pipe `(flags, control, address, size)`. Host lists order -/// their own work and every submission is waited for, so there is nothing -/// to do. +/// bottom of the pipe `(flags, control, address, size)`. The host orders +/// nothing between dispatches by itself: what shaders wrote is waited for +/// here as at the title's barriers (the ray-tracing structure builder has +/// no other wait between its stages). /// (Arguments may be what earlier shaders wrote from here on: /// `State::synced`.) -extern "system" fn sync(this: This, _flags: u32, _control: u32, _address: u64, _size: u64) { +extern "system" fn sync(this: This, flags: u32, control: u32, address: u64, size: u64) { #[cfg(windows)] - with_state(this, |_, state| state.synced()); - #[cfg(not(windows))] - let _ = this; + { + with_state(this, |_, state| state.synced()); + if let Some(list) = host_list(this) { + use windows::Win32::Graphics::Direct3D12::D3D12_RESOURCE_BARRIER; + #[cfg(feature = "diagnostics")] + { + // The shapes of the title's calls, each once. + static SEEN: std::sync::Mutex> = std::sync::Mutex::new(Vec::new()); + let mut seen = SEEN.lock().unwrap_or_else(|e| e.into_inner()); + let shape = (flags, control, address == 0); + if seen.len() < 64 && !seen.contains(&shape) { + seen.push(shape); + tracing::info!( + flags = format_args!("{flags:#x}"), + control = format_args!("{control:#x}"), + address = format_args!("{address:#x}"), + size = format_args!("{size:#x}"), + "a pipeline sync" + ); + } + crate::copystat::add(crate::copystat::C::WaitsForGroups, 1); + } + // SAFETY: the same layout; no resource named. + let barrier = unsafe { std::mem::transmute::(UAV_BARRIER) }; + // SAFETY: an open list. + unsafe { list.list.ResourceBarrier(&[barrier]) }; + } + } + let _ = (this, flags, control, address, size); } /// Reset with console flags `(allocator, pipeline, flags)`; the flags only