Skip to content

Commit

Permalink
Fix framepace not working
Browse files Browse the repository at this point in the history
  • Loading branch information
aevyrie committed Jun 30, 2024
1 parent 0965b18 commit 8deda87
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 50 deletions.
33 changes: 11 additions & 22 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,16 @@ documentation = "https://docs.rs/bevy_framepace"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
bevy_app = "0.14.0-rc.2"
bevy_ecs = "0.14.0-rc.2"
bevy_diagnostic = "0.14.0-rc.2"
bevy_log = "0.14.0-rc.2"
bevy_render = "0.14.0-rc.2"
bevy_reflect = "0.14.0-rc.2"
bevy_time = "0.14.0-rc.2"
bevy_utils = "0.14.0-rc.2"
bevy_window = "0.14.0-rc.2"
bevy_winit = "0.14.0-rc.2"
bevy_app = "0.14.0-rc.4"
bevy_ecs = "0.14.0-rc.4"
bevy_diagnostic = "0.14.0-rc.4"
bevy_log = "0.14.0-rc.4"
bevy_render = "0.14.0-rc.4"
bevy_reflect = "0.14.0-rc.4"
bevy_time = "0.14.0-rc.4"
bevy_utils = "0.14.0-rc.4"
bevy_window = "0.14.0-rc.4"
bevy_winit = "0.14.0-rc.4"
# Non-bevy
spin_sleep = "1.0"

Expand All @@ -29,18 +29,7 @@ default = ["framepace_debug", "bevy_winit/x11"]
framepace_debug = []

[dev-dependencies]
bevy = { version = "0.14.0-rc.2", default-features = false, features = [
"bevy_gizmos",
"bevy_text",
"bevy_ui",
"default_font",
"multi_threaded",
"x11",
# The following should not be needed: https://github.com/bevyengine/bevy/issues/13571
"ktx2",
"zstd",
"bevy_pbr",
] }
bevy = "0.14.0-rc.4"

[[example]]
name = "demo"
Expand Down
39 changes: 11 additions & 28 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ use bevy_reflect::prelude::*;
use bevy_render::{Render, RenderApp, RenderSet};
use bevy_utils::Instant;

#[cfg(not(target_arch = "wasm32"))]
use bevy_render::pipelined_rendering::RenderExtractApp;
#[cfg(not(target_arch = "wasm32"))]
use bevy_window::prelude::*;
#[cfg(not(target_arch = "wasm32"))]
Expand All @@ -48,12 +46,6 @@ use std::{
#[cfg(feature = "framepace_debug")]
pub mod debug;

/// Bevy does not export `RenderExtractApp` on wasm32, so we create a dummy label to ensure this
/// compiles on wasm32.
#[cfg(target_arch = "wasm32")]
#[derive(Debug, Clone, Copy, Hash, PartialEq, Eq, bevy_app::AppLabel)]
struct RenderExtractApp;

/// Adds framepacing and framelimiting functionality to your [`App`].
#[derive(Debug, Clone, Component)]
pub struct FramepacePlugin;
Expand All @@ -75,26 +67,17 @@ impl Plugin for FramepacePlugin {
#[cfg(not(target_arch = "wasm32"))]
app.add_systems(Update, get_display_refresh_rate);

if let Some(sub_app) = app.get_sub_app_mut(RenderExtractApp) {
sub_app
.insert_resource(FrameTimer::default())
.insert_resource(settings_proxy)
.insert_resource(limit)
.insert_resource(stats)
.add_systems(Main, framerate_limiter);
} else {
app.sub_app_mut(RenderApp)
.insert_resource(FrameTimer::default())
.insert_resource(settings_proxy)
.insert_resource(limit)
.insert_resource(stats)
.add_systems(
Render,
framerate_limiter
.in_set(RenderSet::Cleanup)
.after(World::clear_entities),
);
}
app.sub_app_mut(RenderApp)
.insert_resource(FrameTimer::default())
.insert_resource(settings_proxy)
.insert_resource(limit)
.insert_resource(stats)
.add_systems(
Render,
framerate_limiter
.in_set(RenderSet::Cleanup)
.after(World::clear_entities),
);
}
}

Expand Down

0 comments on commit 8deda87

Please sign in to comment.