mirror of
https://github.com/bevyengine/bevy
synced 2024-11-10 15:14:50 +00:00
cbadc31d19
# Objective Related to #10472. Not having a hardcoded scale factor makes comparing results from these stress tests difficult. Contributors using high dpi screens may be rendering 4x as many pixels as others (or more). Stress tests may have different behavior when moved from one monitor in a dual setup to another. At very high resolutions, different parts of the engine / hardware are being stressed. 1080p is also a far more common resolution for gaming. ## Solution Use a consistent 1080p with `scale_factor_override: 1.0` everywhere. In #9903, this sort of change was added specifically to `bevymark` and `many_cubes` but it makes sense to do it everywhere. ## Discussion - Maybe we should have a command line option, environment variable, or `CI_TESTING_CONFIG` option for 1080p / 1440p / 4k. - Will these look odd (small text?) when screenshotted and shown in the example showcase? The aspect ratio is the same, but they will be downscaled from 1080p instead of ~720p. - Maybe there are other window properties that should be consistent across stress tests. e.g. `resizable: false`. - Should we add a `stress_test_window(title)` helper or something? - Bevymark (pre-10472) was intentionally 800x600 to match "bunnymark", I believe. I don't personally think this is very important.
74 lines
2.4 KiB
Rust
74 lines
2.4 KiB
Rust
//! Text pipeline benchmark.
|
|
//!
|
|
//! Continuously recomputes a large `Text` component with 100 sections.
|
|
|
|
use bevy::{
|
|
diagnostic::{FrameTimeDiagnosticsPlugin, LogDiagnosticsPlugin},
|
|
prelude::*,
|
|
text::{BreakLineOn, Text2dBounds},
|
|
window::{PresentMode, WindowPlugin, WindowResolution},
|
|
};
|
|
|
|
fn main() {
|
|
App::new()
|
|
.add_plugins((
|
|
DefaultPlugins.set(WindowPlugin {
|
|
primary_window: Some(Window {
|
|
present_mode: PresentMode::AutoNoVsync,
|
|
resolution: WindowResolution::new(1920.0, 1080.0)
|
|
.with_scale_factor_override(1.0),
|
|
..default()
|
|
}),
|
|
..default()
|
|
}),
|
|
FrameTimeDiagnosticsPlugin,
|
|
LogDiagnosticsPlugin::default(),
|
|
))
|
|
.add_systems(Startup, spawn)
|
|
.add_systems(Update, update_text_bounds)
|
|
.run();
|
|
}
|
|
|
|
fn spawn(mut commands: Commands, asset_server: Res<AssetServer>) {
|
|
warn!(include_str!("warning_string.txt"));
|
|
|
|
commands.spawn(Camera2dBundle::default());
|
|
let sections = (1..=50)
|
|
.flat_map(|i| {
|
|
[
|
|
TextSection {
|
|
value: "text".repeat(i),
|
|
style: TextStyle {
|
|
font: asset_server.load("fonts/FiraMono-Medium.ttf"),
|
|
font_size: (4 + i % 10) as f32,
|
|
color: Color::BLUE,
|
|
},
|
|
},
|
|
TextSection {
|
|
value: "pipeline".repeat(i),
|
|
style: TextStyle {
|
|
font: asset_server.load("fonts/FiraSans-Bold.ttf"),
|
|
font_size: (4 + i % 11) as f32,
|
|
color: Color::YELLOW,
|
|
},
|
|
},
|
|
]
|
|
})
|
|
.collect::<Vec<_>>();
|
|
commands.spawn(Text2dBundle {
|
|
text: Text {
|
|
sections,
|
|
alignment: TextAlignment::Center,
|
|
linebreak_behavior: BreakLineOn::AnyCharacter,
|
|
},
|
|
..Default::default()
|
|
});
|
|
}
|
|
|
|
// changing the bounds of the text will cause a recomputation
|
|
fn update_text_bounds(time: Res<Time>, mut text_bounds_query: Query<&mut Text2dBounds>) {
|
|
let width = (1. + time.elapsed_seconds().sin()) * 600.0;
|
|
for mut text_bounds in text_bounds_query.iter_mut() {
|
|
text_bounds.size.x = width;
|
|
}
|
|
}
|