Pin the scene threads to CPUs
This commit is contained in:
parent
6642a2ce1e
commit
8ba56e5597
|
@ -19,9 +19,6 @@ crate-type = ["staticlib"]
|
|||
[features]
|
||||
mocked = ["glutin"]
|
||||
|
||||
[profile.release]
|
||||
debug = true
|
||||
|
||||
[dependencies.pathfinder_demo]
|
||||
path = "../common"
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -4,6 +4,9 @@
|
|||
#include <chrono>
|
||||
#include <cmath>
|
||||
|
||||
#include <unistd.h>
|
||||
#include <sys/syscall.h>
|
||||
|
||||
#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";
|
||||
|
||||
|
|
Loading…
Reference in New Issue