| //! DINOv3 inference on Meta Quest, via Blade for graphics and Meganeura | |
| //! for the network. | |
| //! | |
| //! The camera image is encoded to DINOv3 patch features and those features | |
| //! are turned back into something viewable, so the user sees the world | |
| //! through a DINO roundtrip. | |
| //! | |
| //! # Layout | |
| //! | |
| //! * [`dinov3`] β the encoder as a meganeura graph, plus its config. | |
| //! * [`preprocess`] β image to patch tensor, with the flattening order the | |
| //! folded patch-embedding matmul requires. | |
| //! * [`weights`] β binding a HuggingFace checkpoint to graph parameters. | |
| //! * [`bench`] β throughput measurement, shared by the desktop and | |
| //! on-device entry points. | |
| //! | |
| //! # Sharing one GPU context | |
| //! | |
| //! The renderer and the network run on a *single* | |
| //! `blade_graphics::Context`, created here and handed to meganeura through | |
| //! `SessionConfig::gpu`. That is why this crate pins the same | |
| //! blade-graphics revision meganeura does β two copies of the crate would | |
| //! make the `Arc<Context>` types incompatible. It also means no | |
| //! external-memory interop is needed: `Session::input_buffer` hands back a | |
| //! `BufferPiece` a render pass can write to directly. | |
| pub mod bench; | |
| pub mod camera; | |
| pub mod decoder; | |
| pub mod dinov3; | |
| pub mod inference; | |
| pub mod pca; | |
| pub mod preprocess; | |
| pub mod render; | |
| pub mod source; | |
| pub mod weights; | |
| use std::sync::Arc; | |
| /// Create the GPU context that both the renderer and inference will share. | |
| /// | |
| /// `xr` stays `None` for headless compute (the benchmark); the XR path | |
| /// fills in an `XrDesc` and everything downstream is unchanged. | |
| pub fn init_context( | |
| xr: Option<blade_graphics::XrDesc>, | |
| ) -> Result<Arc<blade_graphics::Context>, blade_graphics::NotSupportedError> { | |
| let context = unsafe { | |
| blade_graphics::Context::init(blade_graphics::ContextDesc { | |
| presentation: false, | |
| xr, | |
| ray_tracing: false, | |
| // Validation layers are not present on a retail Quest, and | |
| // they cost real time where we can least afford it. | |
| validation: cfg!(debug_assertions) && !cfg!(target_os = "android"), | |
| timing: false, | |
| capture: false, | |
| overlay: false, | |
| device_id: None, | |
| }) | |
| }?; | |
| let info = context.device_information(); | |
| log::info!( | |
| "GPU: {} ({}), driver {}", | |
| info.device_name, | |
| info.driver_name, | |
| info.driver_info | |
| ); | |
| Ok(Arc::new(context)) | |
| } | |