| //! Compile-time constraints that dictate how inference is threaded. | |
| //! | |
| //! `blade_graphics::Context` is `Send + Sync` — it guards its queue, | |
| //! memory manager, and XR session state behind mutexes — so an | |
| //! `Arc<Context>` can be shared with a worker thread. | |
| //! | |
| //! `meganeura::Session` is **not** `Send`: it owns a | |
| //! `blade_graphics::CommandEncoder`. The single offending field is | |
| //! `ScratchBuffer::mapped`, a raw pointer into a persistently mapped | |
| //! allocation — everything else is Vulkan handles, which are fine. (Rust has | |
| //! no stable way to *assert* a negative, hence a comment not a test.) | |
| //! | |
| //! That is why [`dinovision::inference`] hands the worker an | |
| //! `Arc<Context>` and has it construct the session in place. A one-line | |
| //! `unsafe impl Send for ScratchBuffer` in blade lifts the constraint — | |
| //! verified, and on the `command-encoder-send` branch there. | |
| fn assert_send<T: Send>() {} | |
| fn assert_sync<T: Sync>() {} | |
| fn context_can_be_shared_across_threads() { | |
| assert_send::<blade_graphics::Context>(); | |
| assert_sync::<blade_graphics::Context>(); | |
| // Buffer handles carry explicit `unsafe impl Send/Sync`, so GPU-side | |
| // results can be published to the render thread by handle. | |
| assert_send::<blade_graphics::Buffer>(); | |
| assert_sync::<blade_graphics::Buffer>(); | |
| } | |