-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Skip the UV calculations for untextured UI nodes #7809
Conversation
Could you check perfs with example |
many_buttons draws lots of text, and each glyph is an image. Try comparing with this example instead: use bevy::{
diagnostic::{FrameTimeDiagnosticsPlugin, LogDiagnosticsPlugin},
prelude::*,
window::{PresentMode, WindowPlugin},
};
fn main() {
App::new()
.add_plugins(DefaultPlugins.set(WindowPlugin {
primary_window: Some(Window {
present_mode: PresentMode::Immediate,
..default()
}),
..default()
}))
.add_plugin(FrameTimeDiagnosticsPlugin::default())
.add_plugin(LogDiagnosticsPlugin::default())
.add_startup_system(setup)
.run();
}
fn setup(mut commands: Commands) {
commands.spawn(Camera2dBundle::default());
let parent = commands.spawn(NodeBundle {
style: Style {
flex_basis: Val::Percent(100.),
flex_wrap: FlexWrap::Wrap,
align_content: AlignContent::FlexStart,
align_items: AlignItems::FlexStart,
justify_content: JustifyContent::FlexStart,
..Default::default()
},
background_color: BackgroundColor(Color::BLACK),
..Default::default()
})
.id();
for _ in 0..100_000 {
let child = commands.spawn(NodeBundle {
style: Style {
size: Size::all(Val::Px(2.0)),
align_self: AlignSelf::FlexStart,
..Default::default()
},
background_color: BackgroundColor(Color::YELLOW),
..Default::default()
})
.id();
commands.entity(parent).add_child(child);
}
} |
Right, forgot that this example has text as it's too small to read 😄 Removing the text, this PR improves perfs by a similar amount 👍 |
Adding to 0.10.1 as this is useful to anyone using UI and is non-breaking. |
Some benches:
A slight performance regression but
Got the |
Objective
The UV calculations in
prepare_uinodes
can be skipped for nodes without images.Solution
Skip the UV calculations if the image handle id is equal to
DEFAULT_IMAGE_HANDLE.id()
.