Device::raw: a lost VkDevice stays alive until the next raw call
The device's line keeps the generation a root handle's Device::raw lent until a later raw call lends another, so a lost VkDevice whose handles raw answered outlives the runtime's own objects made on it. That is kept: DeviceHandles is Copy and holds references into the generation, which a drop at the recovery would leave dangling under a live borrow, and a consumer that made its own objects with the handles (a swapchain, an import) needs the device alive to destroy them. Device::raw, DeviceHandles and the runtime README's device-loss section now say so: the lost VkDevice stays alive until a later raw call of a root handle, so the consumer destroys what it made with its handles first. Docs only. (cherry picked from commit e675a9868f6a52598f86289dc76fe09f938eda77)
This commit is contained in:
1 parent
b4723c1b81
commit
1db0b7cd3f
2 files changed
+9
-3
No files matched your search
@@ -625,7 +625,8 @@ meanwhile wait for it.
|
||||
reads 2 until then. `vk_devices_made` and `device_recoveries` count the rest.
|
||||
- Each recovery is announced (`device-recovered`), naming the hang's command buffer.
|
||||
- `Device::raw` answers the new `VkDevice`'s handles once a later call asks; the handles it
|
||||
answered before stay valid until then.
|
||||
answered before stay valid until then, and the lost `VkDevice` stays alive until then, so the
|
||||
consumer destroys what it made with those handles (a swapchain, an import) first.
|
||||
- A device the consumer made (`Device::from_raw`) is not made again: it answers `DeviceLost` from
|
||||
the loss on.
|
||||
|
||||
|
||||
@@ -7,7 +7,10 @@ use std::ffi::CStr;
|
||||
/// No Metal counterpart: the Vulkan objects behind a runtime device, with the function tables the
|
||||
/// runtime loaded for them: what the caller needs to read the device, or to make its own objects
|
||||
/// on it (a surface's swapchain, for example). The runtime keeps owning all of them; the
|
||||
/// references live as long as the borrow of the device.
|
||||
/// references live as long as the borrow of the device. A root handle's are of the `VkDevice`
|
||||
/// that served at the [`Device::raw`] call: after a recovery from its loss, that `VkDevice` stays
|
||||
/// alive until a later `raw` call of a root handle, so what the caller made with it is destroyed
|
||||
/// first (`Device::raw`).
|
||||
#[non_exhaustive]
|
||||
#[derive(Clone, Copy)]
|
||||
pub struct DeviceHandles<'a> {
|
||||
@@ -163,7 +166,9 @@ impl Device {
|
||||
/// A root handle's (the device the program made, and its clones) are of the `VkDevice` that
|
||||
/// serves at the call. Once a recovery made a new one (`Degradation::DeviceRecovered`,
|
||||
/// [`Device::recover_for_test`]), they stay valid until a later call of a root handle's
|
||||
/// returns the new one's; after that the caller uses them no more.
|
||||
/// returns the new one's; after that the caller uses them no more. The lost `VkDevice` stays
|
||||
/// alive until then, though the runtime's own objects made on it went, so the caller
|
||||
/// destroys what it made with these handles (a swapchain, an import) before that call.
|
||||
pub unsafe fn raw(&self) -> DeviceHandles<'_> {
|
||||
let shared = match &self.0 {
|
||||
super::Pin::Generation(shared) => &**shared,
|
||||
|
||||
Reference in new issue
Block a user