aboutsummaryrefslogtreecommitdiff
path: root/adapters/fparkan-render-vulkan/src/ffi/smoke.rs
diff options
context:
space:
mode:
authorValentin Popov <valentin@popov.link>2026-10-18 11:04:09 +0300
committerValentin Popov <valentin@popov.link>2026-10-18 11:04:09 +0300
commite7b02c879a2b975b6659bbba63a47acb78735b81 (patch)
treeb94fe48c18fa754d233039fcd01841a5b1091e36 /adapters/fparkan-render-vulkan/src/ffi/smoke.rs
parente98876e4c36ce3a5c95d83e0b0e5385b17e43349 (diff)
downloadfparkan-e7b02c879a2b975b6659bbba63a47acb78735b81.tar.xz
fparkan-e7b02c879a2b975b6659bbba63a47acb78735b81.zip
feat(render): expose completed frame readback
Diffstat (limited to 'adapters/fparkan-render-vulkan/src/ffi/smoke.rs')
-rw-r--r--adapters/fparkan-render-vulkan/src/ffi/smoke.rs28
1 files changed, 28 insertions, 0 deletions
diff --git a/adapters/fparkan-render-vulkan/src/ffi/smoke.rs b/adapters/fparkan-render-vulkan/src/ffi/smoke.rs
index b3d5ab3..4ad1c1b 100644
--- a/adapters/fparkan-render-vulkan/src/ffi/smoke.rs
+++ b/adapters/fparkan-render-vulkan/src/ffi/smoke.rs
@@ -1252,6 +1252,34 @@ impl VulkanSmokeRenderer {
self.shutdown_inner()
}
+ /// Returns the latest submitted frame using the existing optional readback copy.
+ ///
+ /// This synchronizes the device before mapping the host-coherent buffer, so
+ /// callers should use it only for bounded diagnostic captures.
+ pub fn readback_last_submitted_frame(
+ &self,
+ ) -> Result<Option<VulkanReadbackArtifact>, VulkanSmokeRendererError> {
+ let device = self.device_ref()?;
+ // SAFETY: The renderer owns this device and all submitted work; idling
+ // prevents the last readback transfer from racing the host buffer map.
+ unsafe { device.device().device_wait_idle() }.map_err(|error| {
+ VulkanSmokeRendererError::VulkanOperation {
+ context: "vkDeviceWaitIdle(readback frame)",
+ result: error,
+ }
+ })?;
+ let Some(bytes) = self.completed_readback(device)? else {
+ return Ok(None);
+ };
+ let format = self.swapchain_ref()?.report.plan.format.format;
+ Ok(Some(VulkanReadbackArtifact {
+ format,
+ width: self.report.swapchain_extent.0,
+ height: self.report.swapchain_extent.1,
+ bytes,
+ }))
+ }
+
/// Requests swapchain recreation for a new drawable extent.
pub fn request_resize(&mut self, extent: (u32, u32)) {
self.pending_extent = Some(extent);