vulkan: implement Context::reset_status
This commit is contained in:
parent
9e20e32338
commit
5be253dec2
6 changed files with 28 additions and 4 deletions
|
|
@ -243,7 +243,7 @@ struct Context(Rc<VulkanRenderer>);
|
|||
|
||||
impl GfxContext for Context {
|
||||
fn reset_status(&self) -> Option<ResetStatus> {
|
||||
None
|
||||
self.0.device.lost.get().then_some(ResetStatus::Unknown)
|
||||
}
|
||||
|
||||
fn render_node(&self) -> Option<Rc<CString>> {
|
||||
|
|
|
|||
|
|
@ -260,8 +260,12 @@ impl VulkanBoAllocator {
|
|||
slice::from_ref(&submit_info),
|
||||
Fence::null(),
|
||||
)
|
||||
.inspect_err(self.data.device.idl())
|
||||
.map_err(VulkanError::Submit)?;
|
||||
device.device_wait_idle().map_err(VulkanError::WaitIdle)?;
|
||||
device
|
||||
.device_wait_idle()
|
||||
.inspect_err(self.data.device.idl())
|
||||
.map_err(VulkanError::WaitIdle)?;
|
||||
}
|
||||
destroy_image.forget();
|
||||
destroy_memory.forget();
|
||||
|
|
@ -565,8 +569,12 @@ impl VulkanBo {
|
|||
slice::from_ref(&submit_info),
|
||||
Fence::null(),
|
||||
)
|
||||
.inspect_err(self.allocator.device.idl())
|
||||
.map_err(VulkanError::Submit)?;
|
||||
device.device_wait_idle().map_err(VulkanError::WaitIdle)?;
|
||||
device
|
||||
.device_wait_idle()
|
||||
.inspect_err(self.allocator.device.idl())
|
||||
.map_err(VulkanError::WaitIdle)?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ use {
|
|||
push_descriptor,
|
||||
},
|
||||
vk::{
|
||||
DeviceCreateInfo, DeviceQueueCreateInfo, DeviceSize, DriverId,
|
||||
self, DeviceCreateInfo, DeviceQueueCreateInfo, DeviceSize, DriverId,
|
||||
ExternalSemaphoreFeatureFlags, ExternalSemaphoreHandleTypeFlags,
|
||||
ExternalSemaphoreProperties, MAX_MEMORY_TYPES, MemoryPropertyFlags, MemoryType,
|
||||
PhysicalDevice, PhysicalDeviceBufferDeviceAddressFeatures,
|
||||
|
|
@ -44,6 +44,7 @@ use {
|
|||
},
|
||||
isnt::std_1::collections::IsntHashMap2Ext,
|
||||
std::{
|
||||
cell::Cell,
|
||||
ffi::{CStr, CString},
|
||||
rc::Rc,
|
||||
sync::Arc,
|
||||
|
|
@ -78,6 +79,7 @@ pub struct VulkanDevice {
|
|||
pub(super) is_anv: bool,
|
||||
pub(super) uniform_buffer_offset_mask: DeviceSize,
|
||||
pub(super) uniform_buffer_descriptor_size: usize,
|
||||
pub(super) lost: Cell<bool>,
|
||||
}
|
||||
|
||||
impl Drop for VulkanDevice {
|
||||
|
|
@ -103,6 +105,15 @@ impl VulkanDevice {
|
|||
}
|
||||
None
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
pub(super) fn idl(&self) -> impl Fn(&vk::Result) + use<'_> {
|
||||
|res| {
|
||||
if *res == vk::Result::ERROR_DEVICE_LOST {
|
||||
self.lost.set(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl VulkanInstance {
|
||||
|
|
@ -450,6 +461,7 @@ impl VulkanInstance {
|
|||
== DriverId::INTEL_OPEN_SOURCE_MESA,
|
||||
uniform_buffer_offset_mask,
|
||||
uniform_buffer_descriptor_size,
|
||||
lost: Cell::new(false),
|
||||
}))
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1610,6 +1610,7 @@ impl VulkanRenderer {
|
|||
slice::from_ref(&submit_info),
|
||||
release_fence.fence,
|
||||
)
|
||||
.inspect_err(self.device.idl())
|
||||
.map_err(VulkanError::Submit)?;
|
||||
}
|
||||
zone!("export_sync_file");
|
||||
|
|
@ -1919,6 +1920,7 @@ impl VulkanRenderer {
|
|||
log::warn!("Blocking.");
|
||||
unsafe {
|
||||
if let Err(e) = self.device.device.device_wait_idle() {
|
||||
self.device.idl()(&e);
|
||||
log::error!("Could not wait for device idle: {}", ErrorFmt(e));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -296,6 +296,7 @@ impl VulkanShmImage {
|
|||
slice::from_ref(&submit_info),
|
||||
release_fence.fence,
|
||||
)
|
||||
.inspect_err(img.renderer.device.idl())
|
||||
.map_err(VulkanError::Submit)?;
|
||||
}
|
||||
if tt == TransferType::Upload {
|
||||
|
|
|
|||
|
|
@ -298,6 +298,7 @@ impl VulkanShmImage {
|
|||
slice::from_ref(&submit_info),
|
||||
release_fence.fence,
|
||||
)
|
||||
.inspect_err(img.renderer.device.idl())
|
||||
.map_err(VulkanError::Submit)?;
|
||||
}
|
||||
let sync_file = release_fence.export_sync_file()?;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue