wip(nescapture): per-window capture

This commit is contained in:
Wanjohi
2026-10-25 14:00:42 +03:00
parent 10bb1405d6
commit 1674cacb57
3 changed files with 25 additions and 13 deletions
+16 -7
View File
@@ -322,7 +322,7 @@ fn ring_still_serves(
}
unsafe fn ensure_capture_ring(
ds: &crate::state::DeviceState,
ds: &crate::state::Window,
ring: &mut Option<CaptureRing>,
w: u32,
h: u32,
@@ -611,7 +611,16 @@ pub unsafe fn inject_hudless_copy(cb: vk::CommandBuffer, dk: usize) {
Some(e) => e,
None => return,
};
let sc = *ds.swapchain_extent.lock().unwrap();
// The newest window's size: HUD-less copies are a single-window (game)
// feature, and a game's one window is its newest.
let Some(sc) = ds
.newest_window
.lock()
.ok()
.and_then(|w| w.as_ref().map(|w| *w.swapchain_extent.lock().unwrap()))
else {
return;
};
if sc.width > 0 && sc.height > 0 && (ext.width != sc.width || ext.height != sc.height) {
return;
}
@@ -817,7 +826,7 @@ unsafe fn create_timestamp_pool(
/// results, when they are not there yet and `wait` is false, or when the
/// counter wrapped between the pair.
pub unsafe fn blit_gpu_time_ns(
ds: &crate::state::DeviceState,
ds: &crate::state::Window,
slot: usize,
wait: bool,
) -> Option<u64> {
@@ -1046,7 +1055,7 @@ unsafe fn record_blit(
/// Returns `None` when the frame cannot be captured, in which case the caller
/// must present unmodified — the application's semaphores have not been touched.
pub unsafe fn capture_present_frame(
ds: &crate::state::DeviceState,
ds: &crate::state::Window,
queue: vk::Queue,
si: vk::Image,
fmt: vk::Format,
@@ -1226,7 +1235,7 @@ pub unsafe fn capture_present_frame(
/// A present that returns an error may or may not have waited on it, so it can
/// neither be signalled again nor destroyed while it might still be pending.
/// The next capture for that image index creates a fresh one.
pub fn retire_present_semaphore(ds: &crate::state::DeviceState, image_index: usize) {
pub fn retire_present_semaphore(ds: &crate::state::Window, image_index: usize) {
let Ok(mut ring_guard) = ds.capture_ring.lock() else {
return;
};
@@ -1248,7 +1257,7 @@ pub fn retire_present_semaphore(ds: &crate::state::DeviceState, image_index: usi
/// source `VkImage`, and a recreated swapchain's images are new objects even
/// when the indices and the extent are unchanged — so submitting a recording
/// made against the old ones reads destroyed images.
pub fn invalidate_recorded_blits(ds: &crate::state::DeviceState) {
pub fn invalidate_recorded_blits(ds: &crate::state::Window) {
let Ok(mut ring_guard) = ds.capture_ring.lock() else {
return;
};
@@ -1257,7 +1266,7 @@ pub fn invalidate_recorded_blits(ds: &crate::state::DeviceState) {
}
}
pub fn retire_all_present_semaphores(ds: &crate::state::DeviceState) {
pub fn retire_all_present_semaphores(ds: &crate::state::Window) {
let Ok(mut ring_guard) = ds.capture_ring.lock() else {
return;
};
+4 -1
View File
@@ -1155,6 +1155,7 @@ impl PipelineHandle {
let ipc_path = config.ipc_path.clone();
let ipc_cfg = IpcConfig {
source: config.source,
ipc_path: config.ipc_path,
current_codec: current_codec.clone(),
needs_reconfig_flag: needs_reconfig_flag,
@@ -2681,7 +2682,7 @@ struct HeldSlot {
guard: crate::slots::SlotGuard,
slot: usize,
converted: pixelforge::TimelinePoint,
ds: Arc<crate::state::DeviceState>,
ds: Arc<crate::state::Window>,
}
impl HeldSlot {
@@ -2881,6 +2882,8 @@ enum Encoded {
struct IpcConfig {
ipc_path: std::path::PathBuf,
/// What every frame is tagged with. See `PipelineConfig::source`.
source: u32,
current_codec: Arc<AtomicU8>,
needs_reconfig_flag: Arc<AtomicBool>,
encode_ms: Arc<AtomicU32>,
+5 -5
View File
@@ -27,8 +27,8 @@ unsafe fn next<F>(instance: vk::Instance, name: &CStr) -> Option<F> {
#[unsafe(no_mangle)]
pub unsafe extern "system" fn vkCreateXcbSurfaceKHR(
instance: vk::Instance,
p_create_info: *const vk::XcbSurfaceCreateInfoKHR<'_>,
p_allocator: *const vk::AllocationCallbacks<'_>,
p_create_info: *const vk::XcbSurfaceCreateInfoKHR,
p_allocator: *const vk::AllocationCallbacks,
p_surface: *mut vk::SurfaceKHR,
) -> vk::Result {
let Some(create) =
@@ -47,8 +47,8 @@ pub unsafe extern "system" fn vkCreateXcbSurfaceKHR(
#[unsafe(no_mangle)]
pub unsafe extern "system" fn vkCreateXlibSurfaceKHR(
instance: vk::Instance,
p_create_info: *const vk::XlibSurfaceCreateInfoKHR<'_>,
p_allocator: *const vk::AllocationCallbacks<'_>,
p_create_info: *const vk::XlibSurfaceCreateInfoKHR,
p_allocator: *const vk::AllocationCallbacks,
p_surface: *mut vk::SurfaceKHR,
) -> vk::Result {
let Some(create) =
@@ -69,7 +69,7 @@ pub unsafe extern "system" fn vkCreateXlibSurfaceKHR(
pub unsafe extern "system" fn vkDestroySurfaceKHR(
instance: vk::Instance,
surface: vk::SurfaceKHR,
p_allocator: *const vk::AllocationCallbacks<'_>,
p_allocator: *const vk::AllocationCallbacks,
) {
// Before the call down: a handle can be reused the moment it is freed.
SURFACE_WINDOW.remove(&surface.as_raw());