diff --git a/src/compositor/texture.rs b/src/compositor/texture.rs index 41aa2e4..203d5b3 100644 --- a/src/compositor/texture.rs +++ b/src/compositor/texture.rs @@ -28,6 +28,8 @@ pub mod vulkan { pub format: u32, pub sample_count: u32, } + unsafe impl Send for Texture{} + unsafe impl Sync for Texture{} } #[derive(Debug, Copy, Clone)] diff --git a/src/lib.rs b/src/lib.rs index 0e366a7..f4d8e90 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -52,9 +52,7 @@ pub unsafe fn init(ty: ApplicationType) -> Result { sys::EVRInitError_VRInitError_Init_InterfaceNotFound, )); } - Ok(Context { - live: Cell::new(true), - }) + Ok(Context { live: AtomicBool::new(true) }) } pub struct System(&'static sys::VR_IVRSystem_FnTable); @@ -67,9 +65,7 @@ pub struct Chaperone(&'static sys::VR_IVRChaperone_FnTable); /// At most one of this object may exist at a time. /// /// See safety notes in `init`. -pub struct Context { - live: Cell, -} +pub struct Context { live: AtomicBool } fn load(suffix: &[u8]) -> Result<*const T, InitError> { let mut magic = Vec::from(b"FnTable:".as_ref()); @@ -116,9 +112,10 @@ impl Context { /// attempting to free graphics resources. /// /// No calls to other OpenVR methods may be made after this has been called unless a new `Context` is first + /// constructed. pub unsafe fn shutdown(&self) { - if self.live.replace(false) { + if self.live.swap(false, Ordering::Acquire) { sys::VR_ShutdownInternal(); INITIALIZED.store(false, Ordering::Release); }