Skip to content

Commit

Permalink
feat: added a render graph visualiser
Browse files Browse the repository at this point in the history
  • Loading branch information
Sycrosity committed Sep 1, 2023
1 parent cdc6a80 commit 268b87d
Show file tree
Hide file tree
Showing 5 changed files with 82 additions and 49 deletions.
16 changes: 16 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ bevy_rapier2d = { version = "0.22.0", features = ["serde-serialize", "debug-rend
bevy_asset_loader = { version = "0.17.0", features = ["2d", "standard_dynamic_assets"] }
#handling inputs in a logical, extensible way with options for command combinations or aliases.
leafwing-input-manager = "0.10.0"
#used for debugging the render pipeline
bevy_mod_debugdump = { version = "0.8.0", optional = true }

#(ser)ialising/(de)serialising library
serde = "1"
Expand All @@ -51,6 +53,7 @@ default = []
dynamic_linking = ["bevy/dynamic_linking"]
ci_testing = ["bevy/bevy_ci_testing"]

render_graph = ["bevy_mod_debugdump"]

# long_description

Expand Down
11 changes: 11 additions & 0 deletions bacon.toml
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,15 @@ command = [
need_stdout = true
allow_warnings = true

[jobs.render_graph]
command = [
"zsh", "-c", "cargo build --features render_graph && cargo run --color always --features render_graph | dot -Tsvg -o render_graph.svg && /Applications/Google\\ Chrome.app/Contents/MacOS/Google\\ Chrome `readlink -f render_graph.svg`"

# put launch parameters for your program behind a `--` separator
]
need_stdout = true
allow_warnings = true

[jobs.fast-compile]
command = [
"cargo", "run",
Expand All @@ -99,3 +108,5 @@ shift-r = "job:fast-compile"
b = "job:build"
f = "job:fmt"
shift-f = "job:clippy-fix"
shift-b = "job:build-fast-compile"
g = "job:render_graph"
17 changes: 8 additions & 9 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,9 @@
use galaxy::prelude::*;

fn main() {
App::new()
.insert_resource(ClearColor(Color::BLACK))
let mut app = App::new();
app.insert_resource(ClearColor(Color::BLACK))
.add_state::<EngineState>()
.insert_resource(bevy::winit::WinitSettings {
focused_mode: bevy::winit::UpdateMode::Continuous,
unfocused_mode: bevy::winit::UpdateMode::ReactiveLowPower {
max_wait: bevy::utils::Duration::from_millis(1000),
},
..default()
})
.add_plugins(GalaxyDefaultPlugins)
.add_plugins((
GalaxyDebugPlugin,
Expand All @@ -20,4 +13,10 @@ fn main() {
GalaxyGamePlugin,
GalaxyShaderPlugin,
));

#[cfg(feature = "render_graph")]
bevy_mod_debugdump::print_schedule_graph(&mut app, PreUpdate);

#[cfg(not(feature = "render_graph"))]
app.run();
}
84 changes: 44 additions & 40 deletions src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,48 +31,52 @@ pub fn teardown<T: Component>(
pub struct GalaxyDefaultPlugins;

impl Plugin for GalaxyDefaultPlugins {
fn build(&self, app: &mut App) {
app.add_plugins(
DefaultPlugins
.set(WindowPlugin {
primary_window: Some(Window {
title: "Cosmic Crew: Galaxy".to_string(),
fit_canvas_to_parent: true,
..default()
}),
fn build(&self, mut app: &mut App) {
let mut default_plugins = DefaultPlugins
.set(WindowPlugin {
primary_window: Some(Window {
title: "Cosmic Crew: Galaxy".to_string(),
fit_canvas_to_parent: true,
..default()
})
.set(AssetPlugin {
watch_for_changes: ChangeWatcher::with_delay(Duration::from_millis(200)),
asset_folder: {
if cfg!(all(
target_os = "macos",
not(debug_assertions),
not(features = "dynamic_linking")
)) {
"../Resources/assets".to_string()
} else {
"assets".to_string()
}
},
})
.set({
use bevy::log::LogPlugin;
if cfg!(debug_assertions) {
LogPlugin {
level: bevy::log::Level::DEBUG,
filter: "debug,wgpu_core=warn,wgpu_hal=warn,naga=info,bevy=info".into(),
}
}),
..default()
})
.set(AssetPlugin {
watch_for_changes: ChangeWatcher::with_delay(Duration::from_millis(200)),
asset_folder: {
if cfg!(all(
target_os = "macos",
not(debug_assertions),
not(features = "dynamic_linking")
)) {
"../Resources/assets".to_string()
} else {
// this code is compiled only if debug assertions are disabled (release
// mode)
LogPlugin {
level: bevy::log::Level::INFO,
filter: "info,wgpu_core=warn,wgpu_hal=warn".into(),
}
"assets".to_string()
}
})
.set(ImagePlugin::default_nearest()),
);
},
})
.set({
use bevy::log::LogPlugin;
if cfg!(debug_assertions) {
LogPlugin {
level: bevy::log::Level::DEBUG,
filter: "debug,wgpu_core=warn,wgpu_hal=warn,naga=info,bevy=info".into(),
}
} else {
// this code is compiled only if debug assertions are disabled (release
// mode)
LogPlugin {
level: bevy::log::Level::INFO,
filter: "info,wgpu_core=warn,wgpu_hal=warn".into(),
}
}
})
.set(ImagePlugin::default_nearest());

if cfg!(feature = "render_graph") {
default_plugins = default_plugins.disable::<bevy::log::LogPlugin>();
}

app.add_plugins(default_plugins);
}
}

0 comments on commit 268b87d

Please sign in to comment.