rgpui_wgpu/
shared_context.rs1use std::sync::{Arc, OnceLock};
8
9pub struct SharedGpuContext {
11 pub instance: wgpu::Instance,
13 pub device: Arc<wgpu::Device>,
15 pub queue: Arc<wgpu::Queue>,
17}
18
19static SHARED: OnceLock<SharedGpuContext> = OnceLock::new();
20
21pub fn register(instance: wgpu::Instance, device: Arc<wgpu::Device>, queue: Arc<wgpu::Queue>) {
23 let _ = SHARED.set(SharedGpuContext {
24 instance,
25 device,
26 queue,
27 });
28}
29
30pub fn try_get() -> Option<&'static SharedGpuContext> {
32 SHARED.get()
33}