diff --git a/crates/metal2vulkan-runtime/README.md b/crates/metal2vulkan-runtime/README.md index 1b1fb15f2..40b56e628 100644 --- a/crates/metal2vulkan-runtime/README.md +++ b/crates/metal2vulkan-runtime/README.md @@ -727,9 +727,12 @@ meanwhile wait for it. and completes on the lost one where the loss came after, its object then one made before the recovery. - The recovery carries the events, the uses of guest RAM (`HostRamUse`), the no-copy buffers, the - `Private` buffers and the buffers in the runtime's fresh pages to the new `VkDevice`: the same + `Private` buffers and the buffers in the runtime's own pages to the new `VkDevice`: the same objects, at the same addresses. An event keeps the value the host saw and its listeners' - notifications. A buffer in fresh pages keeps its bytes and its `contents` pointer. A no-copy + notifications. A buffer in the runtime's own pages keeps its bytes and its `contents` pointer: + a long host-visible buffer's fresh pages, and, on a device whose check found that a held import + of host pages costs its submissions nothing, the blocks of pages the `Shared` and `Managed` + (unified memory) buffers lie in, imported again on the new `VkDevice`. A no-copy buffer is made again over the same pages, so it keeps its bytes and its pointer; its import gate, run resolver and dma-buf source are asked again, on the thread that recovers, and must not call into the device. Its deallocator runs at its release once no `VkDevice` imports its @@ -737,7 +740,9 @@ meanwhile wait for it. - Any other object made before the recovery is refused where it meets the new `VkDevice` (an encoder's bind, a pipeline made from its functions) and in its own calls that need its lost one: `Error::NotImplemented(RuntimeGap::MadeBeforeRecovery)`. That covers pooled `Shared` and - `Managed` buffers (their `contents` pointer is the lost memory's mapping), detached no-copy + `Managed` buffers in memory the device allocated (their `contents` pointer is the lost memory's + mapping): on a device that imports no host pointer, whose check found a held import costs its + submissions or had not answered, and a `Managed` buffer without unified memory; detached no-copy buffers, heaps, textures, pipeline states, libraries and exportable memory or events. Make it again. Metal's objects go on. The recovery's notice counts the buffers and events it carried and left. diff --git a/crates/metal2vulkan-runtime/src/buffer.rs b/crates/metal2vulkan-runtime/src/buffer.rs index de5aabe6d..f94651f82 100644 --- a/crates/metal2vulkan-runtime/src/buffer.rs +++ b/crates/metal2vulkan-runtime/src/buffer.rs @@ -4615,12 +4615,14 @@ impl Buffer { /// its maker (`device/carry.rs`): its parts there, the same buffer (its `ObjectId`, hazard /// key, Metal address with a share of its range, its range token, label and purgeable state), /// kept among `to`'s program resources and live buffers. A buffer in fresh pages lies in the - /// same pages there, imported again, its contents and `contents` pointer as they were; a - /// `Private` one in new memory, its contents lost with the `VkDevice` (it reads zero). Its - /// parts on the generation it leaves are let go of once none of that generation's command - /// buffers may record. Left the lost generation's, refused where it meets the next - /// (`RuntimeGap::MadeBeforeRecovery`): a buffer of pooled host-visible memory, whose - /// `contents` pointer is its block's mapping (or a `Managed` buffer's host copy's), a no-copy + /// same pages there, imported again, its contents and `contents` pointer as they were, and so + /// does one in a block of the runtime's own pages (`memory.rs`'s `Holds::PageBuffers`), at its + /// offset in them; a `Private` one in new memory, its contents lost with the `VkDevice` (it + /// reads zero). Its parts on the generation it leaves are let go of once none of that + /// generation's command buffers may record. Left the lost generation's, refused where it meets + /// the next (`RuntimeGap::MadeBeforeRecovery`): a buffer of pooled host-visible memory the + /// device allocated, whose `contents` pointer is its block's mapping (or a `Managed` buffer's + /// host copy's), a no-copy /// buffer, a heap's, one over the caller's `VkBuffer` or exportable memory, and one whose /// making there fails. pub(crate) fn carry(&self, to: &Device) -> Result { diff --git a/crates/metal2vulkan-runtime/src/device/carry.rs b/crates/metal2vulkan-runtime/src/device/carry.rs index 03113cc36..2933d1697 100644 --- a/crates/metal2vulkan-runtime/src/device/carry.rs +++ b/crates/metal2vulkan-runtime/src/device/carry.rs @@ -21,6 +21,9 @@ //! (`EventShared::carry`). A `Private` buffer: new memory, its contents lost with the //! `VkDevice` (it reads zero). A buffer in fresh pages (`fresh_pages.rs`): the same pages //! imported again, its contents and its `contents` pointer as they were (`Buffer::carry`). A +//! `Shared` or `Managed` buffer in a block of the runtime's own pages (`memory.rs`'s +//! `Holds::PageBuffers`): the block's pages imported again, once for every buffer carried from +//! it, the buffer at its offset there, its contents and `contents` pointer as they were. A //! no-copy buffer: made again over the caller's pages it lies in, of the memory they were given //! as (`HostPages::made_of`), as its making or last rebind made it there (the caller's gate and //! resolver of guest RAM runs asked again, on the recovering thread), its contents and @@ -31,8 +34,12 @@ //! share of its range) and range token, its label and purgeable state. //! - **What stays the lost generation's**, refused where it meets the next //! (`RuntimeGap::MadeBeforeRecovery`): a buffer of pooled host-visible memory (`Shared`, and -//! `Managed`), whose `contents` pointer is its block's mapping, which Vulkan gives no way to -//! keep over new memory; a detached no-copy buffer, or one whose last detach's deallocator waits +//! `Managed`) the device allocated, whose `contents` pointer is its block's mapping, which +//! Vulkan gives no way to keep over new memory (where the device takes no blocks of the +//! runtime's own pages for it: it imports no host pointer, its check found that a held import +//! costs its submissions or has not answered, or no memory type of the buffer's class takes +//! such pages; and a `Managed` buffer's host copy without unified memory); a detached no-copy +//! buffer, or one whose last detach's deallocator waits //! for its next rebind; a heap's buffer, one over the caller's `VkBuffer` or exported memory, //! and an event whose semaphore was made exportable, whose importers hold the lost one. The recovery's notice counts those it kept by kind (`Degradation::DeviceRecovered`): //! every one but a heap's buffer, which its heap holds. diff --git a/crates/metal2vulkan-runtime/src/memory.rs b/crates/metal2vulkan-runtime/src/memory.rs index 2de19af34..564fc4a2d 100644 --- a/crates/metal2vulkan-runtime/src/memory.rs +++ b/crates/metal2vulkan-runtime/src/memory.rs @@ -105,6 +105,26 @@ //! submission about 1 us (`docs/FAST-PATHS.md`). Every other block of buffers, of images and of //! a heap is allocated as before. //! +//! - **Buffers in the runtime's own pages** ([`Holds::PageBuffers`], +//! [`Memory::page_buffer_blocks`]). On a device that imports host pointers and whose submission +//! check found that a held import costs its submissions nothing (`submit_check.rs`'s import +//! tax), the `Shared`, write-combined and `Managed` (with unified memory) buffers the runtime's +//! buffer path makes (`buffer.rs`'s `placed_new_buffer`, as for [`Holds::FdBuffers`]) lie in +//! blocks of anonymous pages the runtime maps and imports by their pointer (`fresh_pages.rs`'s +//! `OwnPages`, [`BlockMaker::make_pages`]), of the host-visible memory types the driver imports +//! such pages as (`vkGetMemoryHostPointerPropertiesEXT`, asked once as the device is made), +//! where the class's best type for such a buffer is one of them. Each buffer there, and the +//! block's buffer of addresses, is made for host allocations +//! (`VUID-vkBindBufferMemory-memory-02985`), and so is an image bound there, which so starts +//! `UNDEFINED` (`VUID-VkImageCreateInfo-pNext-01443`): a texture over such a buffer takes the +//! route a texture over fresh pages takes (`texture/route.rs`). The block's host address is the +//! pages', so a recovery carries its buffers (`device/carry.rs`): the pages are imported again +//! on the next generation, once for every buffer carried from the block, into a block that +//! takes nothing else ([`place_carried`]), each buffer bound at its offset there, its +//! `contents` pointer and bytes as they were. Until the check answers, where it found a tax, and +//! where the system or the driver refuses the pages, the buffers lie in plain blocks, which a +//! recovery leaves on the lost generation. +//! //! - **Blocks made ahead** (`memory/ready.rs`). Each pool the encodings and commits place their //! own resources in ([`keep_room`]) and each pool of exportable buffers ([`allocate_exported`]) //! gets a block made off the program's thread while it grows, and the pool a color texture's diff --git a/docs/API.md b/docs/API.md index a30fdcbb8..cff470872 100644 --- a/docs/API.md +++ b/docs/API.md @@ -3287,8 +3287,10 @@ bound. recovery announced: where a call waited past 10 seconds for the recovery under way, where its command buffers in flight took past 10 seconds to fail, and where its new `VkDevice` could not be made, after which the device answers as a lost one. `Device::recover_for_test` runs the same recovery with no GPU fault. Cost: the events, - uses of guest RAM, no-copy buffers, `Private` buffers and buffers in fresh pages made before it - go on, a `Private` buffer's contents lost (it reads zero); the other objects made before it are + uses of guest RAM, no-copy buffers, `Private` buffers and buffers in the runtime's own pages + (fresh pages, and the blocks of pages the `Shared` and `Managed` buffers lie in where the + device's check found a held host-page import costs its submissions nothing) made before it go + on, a `Private` buffer's contents lost (it reads zero); the other objects made before it are refused (`MadeBeforeRecovery`), where Metal's go on; the calls during it wait for it, and a device call the loss met while it ran runs again after it. A no-copy buffer is made again over the same pages on the new `VkDevice`, as its making or last rebind made it, so the caller's