embree3_arm/
device.rs

1#[cfg(x86_64)]
2use std::arch::x86_64;
3use std::ffi::CString;
4use std::ptr;
5
6use sys::*;
7
8pub struct Device {
9    pub(crate) handle: RTCDevice,
10}
11
12impl Device {
13    pub fn new() -> Device {
14        // Set the flush zero and denormals modes from Embrees's perf. recommendations
15        // https://embree.github.io/api.html#performance-recommendations
16        // Though, in Rust I think we just call the below function to do both
17        #[cfg(x86_64)]
18        unsafe {
19            x86_64::_MM_SET_FLUSH_ZERO_MODE(x86_64::_MM_FLUSH_ZERO_ON);
20        }
21
22        Device {
23            handle: unsafe { rtcNewDevice(ptr::null()) },
24        }
25    }
26    pub fn debug() -> Device {
27        let cfg = CString::new("verbose=4").unwrap();
28        Device {
29            handle: unsafe { rtcNewDevice(cfg.as_ptr()) },
30        }
31    }
32    // TODO: Setup the flush zero and denormals mode needed by Embree
33    // using the Rust SIMD when it's in core
34}
35
36impl Drop for Device {
37    fn drop(&mut self) {
38        unsafe {
39            rtcReleaseDevice(self.handle);
40        }
41    }
42}
43
44unsafe impl Sync for Device {}