Refactor quest perf fix (#111)
* cargo fmt and removed the unessecary examples. * fixed android logging errors and moved waitframe to fix perf on quest and fixed android example perf by turning off msaa
This commit is contained in:
@@ -12,6 +12,10 @@ passthrough = []
|
||||
[dev-dependencies]
|
||||
bevy_xr_utils.path = "../bevy_xr_utils"
|
||||
|
||||
[target.'cfg(target_os = "android")'.dependencies]
|
||||
ndk-context = "0.1"
|
||||
jni = "0.20"
|
||||
|
||||
# bevy can't be placed behind target or proc macros won't work properly
|
||||
[dependencies]
|
||||
bevy.workspace = true
|
||||
|
||||
@@ -21,7 +21,12 @@ fn main() {
|
||||
synchronous_pipeline_compilation: default(),
|
||||
}))
|
||||
.add_plugins(bevy_xr_utils::hand_gizmos::HandGizmosPlugin)
|
||||
.insert_resource(Msaa::Off)
|
||||
.add_systems(Startup, setup)
|
||||
.insert_resource(AmbientLight {
|
||||
color: Default::default(),
|
||||
brightness: 500.0,
|
||||
})
|
||||
.insert_resource(ClearColor(Color::NONE))
|
||||
.run();
|
||||
}
|
||||
@@ -46,13 +51,4 @@ fn setup(
|
||||
transform: Transform::from_xyz(0.0, 0.5, 0.0),
|
||||
..default()
|
||||
});
|
||||
// light
|
||||
commands.spawn(PointLightBundle {
|
||||
point_light: PointLight {
|
||||
shadows_enabled: true,
|
||||
..default()
|
||||
},
|
||||
transform: Transform::from_xyz(4.0, 8.0, 4.0),
|
||||
..default()
|
||||
});
|
||||
}
|
||||
|
||||
@@ -31,7 +31,6 @@ impl Plugin for OxrRenderPlugin {
|
||||
PreUpdate,
|
||||
(
|
||||
init_views.run_if(resource_added::<OxrGraphicsInfo>),
|
||||
wait_frame.run_if(session_started),
|
||||
locate_views.run_if(session_running),
|
||||
update_views.run_if(session_running),
|
||||
)
|
||||
@@ -44,7 +43,8 @@ impl Plugin for OxrRenderPlugin {
|
||||
.chain()
|
||||
.run_if(session_running)
|
||||
.before(TransformSystem::TransformPropagate),
|
||||
);
|
||||
)
|
||||
.add_systems(Last, wait_frame.run_if(session_started));
|
||||
app.sub_app_mut(RenderApp)
|
||||
.add_systems(
|
||||
Render,
|
||||
@@ -353,11 +353,23 @@ pub fn begin_frame(mut frame_stream: ResMut<OxrFrameStream>) {
|
||||
|
||||
pub fn release_image(mut swapchain: ResMut<OxrSwapchain>) {
|
||||
let _span = info_span!("xr_release_image");
|
||||
#[cfg(target_os = "android")]
|
||||
{
|
||||
let ctx = ndk_context::android_context();
|
||||
let vm = unsafe { jni::JavaVM::from_raw(ctx.vm().cast()) }.unwrap();
|
||||
let env = vm.attach_current_thread_as_daemon();
|
||||
}
|
||||
swapchain.release_image().unwrap();
|
||||
}
|
||||
|
||||
pub fn end_frame(world: &mut World) {
|
||||
let _span = info_span!("xr_end_frame");
|
||||
#[cfg(target_os = "android")]
|
||||
{
|
||||
let ctx = ndk_context::android_context();
|
||||
let vm = unsafe { jni::JavaVM::from_raw(ctx.vm().cast()) }.unwrap();
|
||||
let env = vm.attach_current_thread_as_daemon();
|
||||
}
|
||||
world.resource_scope::<OxrFrameStream, ()>(|world, mut frame_stream| {
|
||||
let mut layers = vec![];
|
||||
for layer in world.resource::<OxrRenderLayers>().iter() {
|
||||
|
||||
Reference in New Issue
Block a user