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