Skip to content

Commit

Permalink
hacks for running (and screenshotting) the examples in CI on a github…
Browse files Browse the repository at this point in the history
… runner (bevyengine#9220)

# Objective

- Enable capturing screenshots of all examples in CI on a GitHub runner

## Solution

- Shorten duration of a run
- Disable `desktop_app` mode - as there isn't any input in CI, examples
using this take way too long to run
- Change the default `ClusterConfig` - the runner are not able to do all
the clusters with the default settings
- Send extra `WindowResized` events - this is needed only for the
`split_screen` example, because CI doesn't trigger that event unlike all
the other platforms

---------

Co-authored-by: Rob Parrett <robparrett@gmail.com>
  • Loading branch information
2 people authored and ameknite committed Nov 6, 2023
1 parent ec14490 commit 0f9f6df
Show file tree
Hide file tree
Showing 5 changed files with 288 additions and 13 deletions.
16 changes: 16 additions & 0 deletions tools/example-showcase/extra-window-resized-events.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
diff --git a/crates/bevy_winit/src/lib.rs b/crates/bevy_winit/src/lib.rs
index 46b3e3e19..81ffad2b5 100644
--- a/crates/bevy_winit/src/lib.rs
+++ b/crates/bevy_winit/src/lib.rs
@@ -432,6 +432,11 @@ pub fn winit_runner(mut app: App) {
};

runner_state.window_event_received = true;
+ event_writers.window_resized.send(WindowResized {
+ window: window_entity,
+ width: window.width(),
+ height: window.height(),
+ });

match event {
WindowEvent::Resized(size) => {
13 changes: 13 additions & 0 deletions tools/example-showcase/fixed-window-position.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git a/crates/bevy_window/src/window.rs b/crates/bevy_window/src/window.rs
index 10bdd8fe8..dda272569 100644
--- a/crates/bevy_window/src/window.rs
+++ b/crates/bevy_window/src/window.rs
@@ -232,7 +232,7 @@ impl Default for Window {
cursor: Default::default(),
present_mode: Default::default(),
mode: Default::default(),
- position: Default::default(),
+ position: WindowPosition::Centered(MonitorSelection::Primary),
resolution: Default::default(),
internal: Default::default(),
composite_alpha_mode: Default::default(),
15 changes: 15 additions & 0 deletions tools/example-showcase/reduce-light-cluster-config.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
diff --git a/crates/bevy_pbr/src/light.rs b/crates/bevy_pbr/src/light.rs
index 3e8c0d451..07aa7d586 100644
--- a/crates/bevy_pbr/src/light.rs
+++ b/crates/bevy_pbr/src/light.rs
@@ -694,8 +694,8 @@ impl Default for ClusterConfig {
// 24 depth slices, square clusters with at most 4096 total clusters
// use max light distance as clusters max `Z`-depth, first slice extends to 5.0
Self::FixedZ {
- total: 4096,
- z_slices: 24,
+ total: 128,
+ z_slices: 4,
z_config: ClusterZConfig::default(),
dynamic_resizing: true,
}
21 changes: 21 additions & 0 deletions tools/example-showcase/remove-desktop-app-mode.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
diff --git a/crates/bevy_winit/src/winit_config.rs b/crates/bevy_winit/src/winit_config.rs
index c71a92814..b138d07a0 100644
--- a/crates/bevy_winit/src/winit_config.rs
+++ b/crates/bevy_winit/src/winit_config.rs
@@ -47,15 +47,7 @@ impl WinitSettings {
/// [`Reactive`](UpdateMode::Reactive) if windows have focus,
/// [`ReactiveLowPower`](UpdateMode::ReactiveLowPower) otherwise.
pub fn desktop_app() -> Self {
- WinitSettings {
- focused_mode: UpdateMode::Reactive {
- wait: Duration::from_secs(5),
- },
- unfocused_mode: UpdateMode::ReactiveLowPower {
- wait: Duration::from_secs(60),
- },
- ..Default::default()
- }
+ Self::game()
}

/// Returns the current [`UpdateMode`].
Loading

0 comments on commit 0f9f6df

Please sign in to comment.