diff --git a/demo/magicleap/Cargo.toml b/demo/magicleap/Cargo.toml index 33780e3a..75d5c6e1 100644 --- a/demo/magicleap/Cargo.toml +++ b/demo/magicleap/Cargo.toml @@ -19,9 +19,6 @@ crate-type = ["staticlib"] [features] mocked = ["glutin"] -[profile.release] -debug = true - [dependencies.pathfinder_demo] path = "../common" diff --git a/demo/magicleap/src/lib.rs b/demo/magicleap/src/lib.rs index 523dad3f..08513f16 100644 --- a/demo/magicleap/src/lib.rs +++ b/demo/magicleap/src/lib.rs @@ -38,7 +38,7 @@ pub extern "C" fn magicleap_pathfinder_demo(egl_display: EGLDisplay, egl_context options.ui = false; options.background = Background::None; options.mode = Mode::VR; - options.jobs = Some(2); + options.jobs = Some(3); options.pipeline = 0; let mut app = DemoApp::new(window, window_size, options); diff --git a/demo/magicleap/src/magicleap.rs b/demo/magicleap/src/magicleap.rs index 30c6e1e2..345f10ce 100644 --- a/demo/magicleap/src/magicleap.rs +++ b/demo/magicleap/src/magicleap.rs @@ -62,6 +62,8 @@ use pathfinder_gpu::resources::FilesystemResourceLoader; use pathfinder_gpu::resources::ResourceLoader; use pathfinder_simd::default::F32x4; +use rayon::ThreadPoolBuilder; + use smallvec::SmallVec; use std::ffi::CString; @@ -98,6 +100,10 @@ impl Window for MagicLeapWindow { self.framebuffer_id } + fn customize_rayon(&self, thread_pool_builder: ThreadPoolBuilder) -> ThreadPoolBuilder { + thread_pool_builder.start_handler(|id| unsafe { init_scene_thread(id) }) + } + fn mouse_position(&self) -> Point2DI32 { Point2DI32::new(0, 0) } @@ -151,6 +157,10 @@ impl Window for MagicLeapWindow { } } +extern "C" { + fn init_scene_thread(id: usize); +} + fn get_proc_address(s: &str) -> *const c_void { egl::get_proc_address(s) as *const c_void } diff --git a/demo/magicleap/src/main.cpp b/demo/magicleap/src/main.cpp index 666e6bbc..6de3d895 100644 --- a/demo/magicleap/src/main.cpp +++ b/demo/magicleap/src/main.cpp @@ -4,6 +4,9 @@ #include #include +#include +#include + #ifndef EGL_EGLEXT_PROTOTYPES #define EGL_EGLEXT_PROTOTYPES #endif @@ -28,6 +31,17 @@ // Entry point to the Rust code extern "C" MLResult magicleap_pathfinder_demo(EGLDisplay egl_display, EGLContext egl_context); +// Initialization of the scene thread +extern "C" void init_scene_thread(uint64_t id) { + // https://forum.magicleap.com/hc/en-us/community/posts/360043120832-How-many-CPUs-does-an-immersive-app-have-access-to-?page=1#community_comment_360005035691 + // We pin scene thread 0 to the Denver core. + if (id < 3) { + uint32_t DenverCoreAffinityMask = 1 << (2 + id); // Denver core is CPU2, A57s are CPU3 and 4. + pid_t ThreadId = gettid(); + syscall(__NR_sched_setaffinity, ThreadId, sizeof(DenverCoreAffinityMask), &DenverCoreAffinityMask); + } +} + // Constants const char application_name[] = "com.mozilla.pathfinder.demo";