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.
91 lines
2.6 KiB
Rust
91 lines
2.6 KiB
Rust
//! Simple text rendering benchmark.
|
|
//!
|
|
//! Creates a `Text` with a single `TextSection` containing `100_000` glyphs,
|
|
//! and renders it with the UI in a white color and with Text2d in a red color.
|
|
//!
|
|
//! To recompute all text each frame run
|
|
//! `cargo run --example many_glyphs --release recompute-text`
|
|
use bevy::{
|
|
diagnostic::{FrameTimeDiagnosticsPlugin, LogDiagnosticsPlugin},
|
|
prelude::*,
|
|
text::{BreakLineOn, Text2dBounds},
|
|
window::{PresentMode, WindowPlugin, WindowResolution},
|
|
};
|
|
|
|
fn main() {
|
|
let mut app = App::new();
|
|
app.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, setup);
|
|
|
|
if std::env::args().any(|arg| arg == "recompute-text") {
|
|
app.add_systems(Update, force_text_recomputation);
|
|
}
|
|
|
|
app.run();
|
|
}
|
|
|
|
fn setup(mut commands: Commands) {
|
|
warn!(include_str!("warning_string.txt"));
|
|
|
|
commands.spawn(Camera2dBundle::default());
|
|
let mut text = Text {
|
|
sections: vec![TextSection {
|
|
value: "0123456789".repeat(10_000),
|
|
style: TextStyle {
|
|
font_size: 4.,
|
|
..default()
|
|
},
|
|
}],
|
|
alignment: TextAlignment::Left,
|
|
linebreak_behavior: BreakLineOn::AnyCharacter,
|
|
};
|
|
|
|
commands
|
|
.spawn(NodeBundle {
|
|
style: Style {
|
|
width: Val::Percent(100.),
|
|
align_items: AlignItems::Center,
|
|
justify_content: JustifyContent::Center,
|
|
..default()
|
|
},
|
|
..default()
|
|
})
|
|
.with_children(|commands| {
|
|
commands.spawn(TextBundle {
|
|
text: text.clone(),
|
|
style: Style {
|
|
width: Val::Px(1000.),
|
|
..Default::default()
|
|
},
|
|
..Default::default()
|
|
});
|
|
});
|
|
|
|
text.sections[0].style.color = Color::RED;
|
|
|
|
commands.spawn(Text2dBundle {
|
|
text,
|
|
text_anchor: bevy::sprite::Anchor::Center,
|
|
text_2d_bounds: Text2dBounds {
|
|
size: Vec2::new(1000., f32::INFINITY),
|
|
},
|
|
..Default::default()
|
|
});
|
|
}
|
|
|
|
fn force_text_recomputation(mut text_query: Query<&mut Text>) {
|
|
for mut text in &mut text_query {
|
|
text.set_changed();
|
|
}
|
|
}
|