Skip to content

Commit c34eaf1

Browse files
authored
Add separate option to control font size behavior in many_text2d (#17823)
# Objective I'm working on some PRs involving our font atlases and it would be nice to be able to test these scenarios separately to better understand the performance tradeoffs in different situations. ## Solution Add a `many-font-sizes` option. The old behavior is still available by running with `--many-glyphs --many-font-sizes`. ## Testing `cargo run --example many_text2d --release` `cargo run --example many_text2d --release -- --many-glyphs` `cargo run --example many_text2d --release -- --many-font-sizes` `cargo run --example many_text2d --release -- --many-glyphs --many-font-sizes`
1 parent 15b795d commit c34eaf1

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

examples/stress_tests/many_text2d.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,14 @@ const CODE_POINT_RANGES: [RangeInclusive<u32>; 5] = [
3131
#[derive(FromArgs, Resource)]
3232
/// `many_text2d` stress test
3333
struct Args {
34-
/// whether to use many different glyphs so that multiple separate font atlas textures are used.
34+
/// whether to use many different glyphs to increase the amount of font atlas textures used.
3535
#[argh(switch)]
3636
many_glyphs: bool,
3737

38+
/// whether to use many different font sizes to increase the amount of font atlas textures used.
39+
#[argh(switch)]
40+
many_font_sizes: bool,
41+
3842
/// whether to force the text to recompute every frame by triggering change detection.
3943
#[argh(switch)]
4044
recompute: bool,
@@ -186,7 +190,7 @@ fn print_counts(
186190
}
187191

188192
fn random_text_font(rng: &mut ChaCha8Rng, args: &Args, font: Handle<Font>) -> TextFont {
189-
let font_size = if args.many_glyphs {
193+
let font_size = if args.many_font_sizes {
190194
*[10.0, 20.0, 30.0, 40.0, 50.0, 60.0].choose(rng).unwrap()
191195
} else {
192196
60.0

0 commit comments

Comments
 (0)