aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorValentin Popov <valentin@popov.link>2026-07-03 15:55:19 +0300
committerValentin Popov <valentin@popov.link>2026-07-03 15:55:19 +0300
commit29bf4830cf9fffbf662051f4d9c55cbfa1dfd073 (patch)
tree974ced3041dd2f01c7c98213e5306e0b121b9a3c
parent8a8ef614f2660c53274512724e81f39afe6c070a (diff)
downloadfparkan-29bf4830cf9fffbf662051f4d9c55cbfa1dfd073.tar.xz
fparkan-29bf4830cf9fffbf662051f4d9c55cbfa1dfd073.zip
fix(vulkan): capture shutdown validation after owner drop
-rw-r--r--adapters/fparkan-render-vulkan/src/ffi/smoke.rs47
1 files changed, 21 insertions, 26 deletions
diff --git a/adapters/fparkan-render-vulkan/src/ffi/smoke.rs b/adapters/fparkan-render-vulkan/src/ffi/smoke.rs
index d42970e..e92a7a0 100644
--- a/adapters/fparkan-render-vulkan/src/ffi/smoke.rs
+++ b/adapters/fparkan-render-vulkan/src/ffi/smoke.rs
@@ -31,28 +31,20 @@ fn take_runtime_owners_in_dependency_order<Instance, Validation, Surface, Device
instance.take();
}
-fn take_runtime_owners_with_validation_snapshot<
- Instance,
- Validation,
- Surface,
- Device,
- Swapchain,
- Snapshot,
- Capture,
->(
- instance: &mut Option<Instance>,
- validation: &mut Option<Validation>,
+fn take_runtime_children_with_validation_snapshot<Surface, Device, Swapchain, Validation, Snapshot, Capture>(
surface: &mut Option<Surface>,
device: &mut Option<Device>,
swapchain: &mut Option<Swapchain>,
+ validation: &Option<Validation>,
capture: Capture,
) -> Option<Snapshot>
where
Capture: FnOnce(&Validation) -> Snapshot,
{
- let snapshot = validation.as_ref().map(capture);
- take_runtime_owners_in_dependency_order(instance, validation, surface, device, swapchain);
- snapshot
+ swapchain.take();
+ device.take();
+ surface.take();
+ validation.as_ref().map(capture)
}
struct RollbackOnDrop<T, F>
@@ -668,15 +660,16 @@ impl VulkanSmokeRenderer {
})?;
}
self.destroy_device_owned_resources();
- let validation = take_runtime_owners_with_validation_snapshot(
- &mut self.instance,
- &mut self.validation,
+ let validation = take_runtime_children_with_validation_snapshot(
&mut self.surface,
&mut self.device,
&mut self.swapchain,
+ &self.validation,
VulkanValidationMessenger::report,
)
.unwrap_or_default();
+ self.validation.take();
+ self.instance.take();
Ok(VulkanSmokeShutdownReport {
renderer_report: self.report.clone(),
swapchain_recreate_count: self.swapchain_recreate_count,
@@ -690,14 +683,15 @@ impl VulkanSmokeRenderer {
let _ = unsafe { device.device().device_wait_idle() };
}
self.destroy_device_owned_resources();
- let _ = take_runtime_owners_with_validation_snapshot(
- &mut self.instance,
- &mut self.validation,
+ let _ = take_runtime_children_with_validation_snapshot(
&mut self.surface,
&mut self.device,
&mut self.swapchain,
+ &self.validation,
VulkanValidationMessenger::report,
);
+ self.validation.take();
+ self.instance.take();
}
}
@@ -710,7 +704,7 @@ impl Drop for VulkanSmokeRenderer {
#[cfg(test)]
mod tests {
use super::{
- take_runtime_owners_in_dependency_order, take_runtime_owners_with_validation_snapshot,
+ take_runtime_children_with_validation_snapshot, take_runtime_owners_in_dependency_order,
RollbackOnDrop,
};
use std::cell::RefCell;
@@ -850,7 +844,7 @@ mod tests {
}
#[test]
- fn final_validation_snapshot_is_captured_before_validation_drop() {
+ fn final_validation_snapshot_is_captured_after_surface_device_swapchain_drop() {
let log = Rc::new(RefCell::new(Vec::new()));
let mut instance = Some(tracker(TeardownStep::Instance, &log));
let mut validation = Some(tracker(TeardownStep::Validation, &log));
@@ -858,17 +852,18 @@ mod tests {
let mut device = Some(tracker(TeardownStep::Device, &log));
let mut swapchain = Some(tracker(TeardownStep::Swapchain, &log));
- let snapshot = take_runtime_owners_with_validation_snapshot(
- &mut instance,
- &mut validation,
+ let snapshot = take_runtime_children_with_validation_snapshot(
&mut surface,
&mut device,
&mut swapchain,
+ &validation,
|_| {
log.borrow_mut().push(TeardownStep::Snapshot);
TeardownStep::Validation
},
);
+ validation.take();
+ instance.take();
assert_eq!(snapshot, Some(TeardownStep::Validation));
assert_eq!(
@@ -876,10 +871,10 @@ mod tests {
.expect("all drop trackers released")
.into_inner(),
vec![
- TeardownStep::Snapshot,
TeardownStep::Swapchain,
TeardownStep::Device,
TeardownStep::Surface,
+ TeardownStep::Snapshot,
TeardownStep::Validation,
TeardownStep::Instance,
]