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