Merge branch 'imbris/tracy' into 'master'

Refactor Client message handling, improve use of tracy, increase coverage of profiling spans in voxygen

See merge request veloren/veloren!2479
This commit is contained in:
Marcel 2021-06-20 23:17:08 +00:00
commit b0574b4ddc
40 changed files with 211 additions and 146 deletions

1
Cargo.lock generated
View File

@ -5718,7 +5718,6 @@ dependencies = [
"authc",
"byteorder",
"clap",
"futures-util",
"hashbrown 0.11.2",
"image",
"num 0.4.0",

View File

@ -5,7 +5,6 @@ authors = ["Joshua Barretto <joshua.s.barretto@gmail.com>"]
edition = "2018"
[features]
tracy = ["common/tracy", "common-base/tracy", "common-state/tracy", "common-systems/tracy", "common-net/tracy", "common-frontend/tracy"]
simd = ["vek/platform_intrinsics"]
plugins = ["common-state/plugins"]
bin_bot = ["common-ecs", "serde", "ron", "clap", "rustyline", "common-frontend", "async-channel"]
@ -21,7 +20,6 @@ common-net = { package = "veloren-common-net", path = "../common/net" }
network = { package = "veloren-network", path = "../network", features = ["compression","quic"], default-features = false }
byteorder = "1.3.2"
futures-util = "0.3.7"
tokio = { version = "1", default-features = false, features = ["rt-multi-thread"] }
quinn = "0.7.2"
image = { version = "0.23.12", default-features = false, features = ["png"] }

View File

@ -43,7 +43,7 @@ use common::{
uid::{Uid, UidAllocator},
vol::RectVolSize,
};
use common_base::span;
use common_base::{prof_span, span};
use common_net::{
msg::{
self, validate_chat_msg,
@ -58,7 +58,6 @@ use common_net::{
use common_state::State;
use common_systems::add_local_systems;
use comp::BuffKind;
use futures_util::FutureExt;
use hashbrown::{HashMap, HashSet};
use image::DynamicImage;
use network::{ConnectAddr, Network, Participant, Pid, Stream};
@ -71,7 +70,7 @@ use std::{
sync::Arc,
time::{Duration, Instant},
};
use tokio::{runtime::Runtime, select};
use tokio::runtime::Runtime;
use tracing::{debug, error, trace, warn};
use vek::*;
@ -760,6 +759,7 @@ impl Client {
where
S: Into<ClientMsg>,
{
prof_span!("send_msg_err");
let msg: ClientMsg = msg.into();
#[cfg(debug_assertions)]
{
@ -1426,6 +1426,7 @@ impl Client {
// 1) Handle input from frontend.
// Pass character actions from frontend input to the player's entity.
if self.presence.is_some() {
prof_span!("handle and send inputs");
if let Err(e) = self
.state
.ecs()
@ -1457,21 +1458,25 @@ impl Client {
// Prepare for new events
{
prof_span!("Last<CharacterState> comps update");
let ecs = self.state.ecs();
for (entity, _) in (&ecs.entities(), &ecs.read_storage::<comp::Body>()).join() {
let mut last_character_states =
ecs.write_storage::<comp::Last<comp::CharacterState>>();
if let Some(client_character_state) =
ecs.read_storage::<comp::CharacterState>().get(entity)
let mut last_character_states = ecs.write_storage::<comp::Last<comp::CharacterState>>();
for (entity, _, character_state) in (
&ecs.entities(),
&ecs.read_storage::<comp::Body>(),
&ecs.read_storage::<comp::CharacterState>(),
)
.join()
{
if let Some(l) = last_character_states
.entry(entity)
.ok()
.map(|l| l.or_insert_with(|| comp::Last(character_state.clone())))
// TODO: since this just updates when the variant changes we should
// just store the variant to avoid the clone overhead
.filter(|l| !character_state.same_variant(&l.0))
{
if let Some(l) = last_character_states
.entry(entity)
.ok()
.map(|l| l.or_insert_with(|| comp::Last(client_character_state.clone())))
.filter(|l| !client_character_state.same_variant(&l.0))
{
*l = comp::Last(client_character_state.clone());
}
*l = comp::Last(character_state.clone());
}
}
}
@ -1520,6 +1525,7 @@ impl Client {
.get(self.entity())
.cloned();
if let (Some(pos), Some(view_distance)) = (pos, self.view_distance) {
prof_span!("terrain");
let chunk_pos = self.state.terrain().pos_key(pos.0.map(|e| e as i32));
// Remove chunks that are too far from the player.
@ -1653,6 +1659,7 @@ impl Client {
frontend_events: &mut Vec<Event>,
msg: ServerGeneral,
) -> Result<(), Error> {
prof_span!("handle_server_msg");
match msg {
ServerGeneral::Disconnect(reason) => match reason {
DisconnectReason::Shutdown => return Err(Error::ServerShutdown),
@ -1805,6 +1812,7 @@ impl Client {
frontend_events: &mut Vec<Event>,
msg: ServerGeneral,
) -> Result<(), Error> {
prof_span!("handle_server_in_game_msg");
match msg {
ServerGeneral::GroupUpdate(change_notification) => {
use comp::group::ChangeNotification::*;
@ -1979,6 +1987,7 @@ impl Client {
#[allow(clippy::unnecessary_wraps)]
fn handle_server_terrain_msg(&mut self, msg: ServerGeneral) -> Result<(), Error> {
prof_span!("handle_server_terrain_mgs");
match msg {
ServerGeneral::TerrainChunkUpdate { key, chunk } => {
if let Some(chunk) = chunk.ok().and_then(|c| c.to_chunk()) {
@ -2004,6 +2013,7 @@ impl Client {
events: &mut Vec<Event>,
msg: ServerGeneral,
) -> Result<(), Error> {
prof_span!("handle_server_character_screen_msg");
match msg {
ServerGeneral::CharacterListUpdate(character_list) => {
self.character_list.characters = character_list;
@ -2034,6 +2044,7 @@ impl Client {
}
fn handle_ping_msg(&mut self, msg: PingMsg) -> Result<(), Error> {
prof_span!("handle_ping_msg");
match msg {
PingMsg::Ping => {
self.send_msg_err(PingMsg::Pong)?;
@ -2054,40 +2065,41 @@ impl Client {
Ok(())
}
async fn handle_messages(
&mut self,
frontend_events: &mut Vec<Event>,
cnt: &mut u64,
) -> Result<(), Error> {
fn handle_messages(&mut self, frontend_events: &mut Vec<Event>) -> Result<u64, Error> {
let mut cnt = 0;
loop {
let (m1, m2, m3, m4, m5) = select!(
msg = self.general_stream.recv().fuse() => (Some(msg), None, None, None, None),
msg = self.ping_stream.recv().fuse() => (None, Some(msg), None, None, None),
msg = self.character_screen_stream.recv().fuse() => (None, None, Some(msg), None, None),
msg = self.in_game_stream.recv().fuse() => (None, None, None, Some(msg), None),
msg = self.terrain_stream.recv().fuse() => (None, None, None, None, Some(msg)),
);
*cnt += 1;
if let Some(msg) = m1 {
self.handle_server_msg(frontend_events, msg?)?;
let cnt_start = cnt;
while let Some(msg) = self.general_stream.try_recv()? {
cnt += 1;
self.handle_server_msg(frontend_events, msg)?;
}
if let Some(msg) = m2 {
self.handle_ping_msg(msg?)?;
while let Some(msg) = self.ping_stream.try_recv()? {
cnt += 1;
self.handle_ping_msg(msg)?;
}
if let Some(msg) = m3 {
self.handle_server_character_screen_msg(frontend_events, msg?)?;
while let Some(msg) = self.character_screen_stream.try_recv()? {
cnt += 1;
self.handle_server_character_screen_msg(frontend_events, msg)?;
}
if let Some(msg) = m4 {
self.handle_server_in_game_msg(frontend_events, msg?)?;
while let Some(msg) = self.in_game_stream.try_recv()? {
cnt += 1;
self.handle_server_in_game_msg(frontend_events, msg)?;
}
if let Some(msg) = m5 {
self.handle_server_terrain_msg(msg?)?;
while let Some(msg) = self.terrain_stream.try_recv()? {
cnt += 1;
self.handle_server_terrain_msg(msg)?;
}
if cnt_start == cnt {
return Ok(cnt);
}
}
}
/// Handle new server messages.
fn handle_new_messages(&mut self) -> Result<Vec<Event>, Error> {
prof_span!("handle_new_messages");
let mut frontend_events = Vec::new();
// Check that we have an valid connection.
@ -2109,18 +2121,9 @@ impl Client {
}
}
let mut handles_msg = 0;
let msg_count = self.handle_messages(&mut frontend_events)?;
let runtime = Arc::clone(&self.runtime);
runtime.block_on(async {
//TIMEOUT 0.01 ms for msg handling
select!(
_ = tokio::time::sleep(std::time::Duration::from_micros(10)).fuse() => Ok(()),
err = self.handle_messages(&mut frontend_events, &mut handles_msg).fuse() => err,
)
})?;
if handles_msg == 0
if msg_count == 0
&& self.state.get_time() - self.last_server_pong > self.client_timeout.as_secs() as f64
{
return Err(Error::ServerTimeout);

View File

@ -6,7 +6,6 @@ edition = "2018"
[features]
no-assets = []
tracy = ["common-base/tracy"]
simd = ["vek/platform_intrinsics"]
bin_csv = ["ron", "csv", "structopt"]
bin_graphviz = ["petgraph"]

View File

@ -6,20 +6,21 @@ pub use userdata_dir::userdata_dir;
#[cfg(feature = "tracy")] pub use tracy_client;
#[cfg(not(feature = "tracy"))]
#[macro_export]
macro_rules! plot {
($name:expr, $value:expr) => {
#[cfg(feature = "tracy")]
{
use $crate::tracy_client::{create_plot, Plot};
static PLOT: Plot = create_plot!($name);
PLOT.point($value);
}
#[cfg(not(feature = "tracy"))]
{
// type check
let _: f64 = $value;
}
// type check
let _: f64 = $value;
};
}
#[cfg(feature = "tracy")]
#[macro_export]
macro_rules! plot {
($name:expr, $value:expr) => {
use $crate::tracy_client::{create_plot, Plot};
static PLOT: Plot = create_plot!($name);
PLOT.point($value);
};
}
@ -45,6 +46,7 @@ macro_rules! dev_panic {
}
// https://discordapp.com/channels/676678179678715904/676685797524766720/723358438943621151
#[cfg(not(feature = "tracy"))]
#[macro_export]
macro_rules! span {
($guard_name:tt, $level:ident, $name:expr, $($fields:tt)*) => {
@ -56,12 +58,27 @@ macro_rules! span {
let $guard_name = span.enter();
};
($guard_name:tt, $name:expr) => {
#[cfg(not(feature = "tracy"))]
let span = tracing::span!(tracing::Level::TRACE, $name);
#[cfg(not(feature = "tracy"))]
let $guard_name = span.enter();
};
($guard_name:tt, $no_tracy_name:expr, $tracy_name:expr) => {
$crate::span!($guard_name, $no_tracy_name);
};
}
#[cfg(feature = "tracy")]
#[macro_export]
macro_rules! span {
($guard_name:tt, $level:ident, $name:expr, $($fields:tt)*) => {
let span = tracing::span!(tracing::Level::$level, $name, $($fields)*);
let $guard_name = span.enter();
};
($guard_name:tt, $level:ident, $name:expr) => {
let span = tracing::span!(tracing::Level::$level, $name);
let $guard_name = span.enter();
};
($guard_name:tt, $name:expr) => {
// Directly use `tracy_client` to decrease overhead for better timing
#[cfg(feature = "tracy")]
let $guard_name = $crate::tracy_client::Span::new(
$name,
"",
@ -72,9 +89,6 @@ macro_rules! span {
);
};
($guard_name:tt, $no_tracy_name:expr, $tracy_name:expr) => {
#[cfg(not(feature = "tracy"))]
$crate::span!($guard_name, $no_tracy_name);
#[cfg(feature = "tracy")]
$crate::span!($guard_name, $tracy_name);
};
}
@ -87,9 +101,22 @@ pub struct ProfSpan;
/// Like the span macro but only used when profiling and not in regular tracing
/// operations
#[macro_export]
#[cfg(not(feature = "tracy"))]
macro_rules! prof_span {
($guard_name:tt, $name:expr) => {
let $guard_name = $crate::ProfSpan;
};
// Shorthand for when you want the guard to just be dropped at the end of the scope instead
// of controlling it manually
($name:expr) => {};
}
/// Like the span macro but only used when profiling and not in regular tracing
/// operations
#[macro_export]
#[cfg(feature = "tracy")]
macro_rules! prof_span {
($guard_name:tt, $name:expr) => {
#[cfg(feature = "tracy")]
let $guard_name = $crate::ProfSpan($crate::tracy_client::Span::new(
$name,
"",
@ -98,8 +125,11 @@ macro_rules! prof_span {
// No callstack since this has significant overhead
0,
));
#[cfg(not(feature = "tracy"))]
let $guard_name = $crate::ProfSpan;
};
// Shorthand for when you want the guard to just be dropped at the end of the scope instead
// of controlling it manually
($name:expr) => {
$crate::prof_span!(_guard, $name);
};
}

View File

@ -5,7 +5,6 @@ name = "veloren-common-ecs"
version = "0.10.0"
[features]
tracy = ["common-base/tracy"]
[dependencies]

View File

@ -19,4 +19,4 @@ tracing-log = "0.1.1"
tracing-subscriber = { version = "0.2.3", default-features = false, features = ["env-filter", "fmt", "chrono", "ansi", "smallvec", "tracing-log"]}
# Tracy
tracing-tracy = { version = "0.6.0", optional = true }
tracing-tracy = { version = "0.6.0", optional = true }

View File

@ -5,7 +5,6 @@ name = "veloren-common-net"
version = "0.10.0"
[features]
tracy = ["common/tracy"]
simd = ["vek/platform_intrinsics"]
default = ["simd"]

View File

@ -5,7 +5,6 @@ name = "veloren-common-state"
version = "0.10.0"
[features]
tracy = ["common/tracy"]
simd = ["vek/platform_intrinsics"]
plugins = ["toml", "tar", "wasmer", "bincode", "plugin-api", "serde"]

View File

@ -5,7 +5,6 @@ name = "veloren-common-systems"
version = "0.10.0"
[features]
tracy = ["common/tracy"]
simd = ["vek/platform_intrinsics"]
default = ["simd"]

View File

@ -17,7 +17,7 @@ This package includes the official server CLI.
[features]
worldgen = ["server/worldgen"]
default = ["worldgen"]
tracy = ["common/tracy", "server/tracy", "common-net/tracy", "common-frontend/tracy"]
tracy = ["common-frontend/tracy"]
plugins = ["server/plugins"]
[dependencies]

View File

@ -6,7 +6,6 @@ edition = "2018"
[features]
worldgen = []
tracy = ["common/tracy", "common-base/tracy", "common-ecs/tracy", "common-state/tracy", "common-net/tracy", "world/tracy"]
simd = ["vek/platform_intrinsics"]
plugins = ["common-state/plugins"]

View File

@ -25,7 +25,7 @@ buildInputs = ["xorg.libxcb"]
hot-anim = ["anim/use-dyn-lib"]
singleplayer = ["server"]
simd = ["vek/platform_intrinsics"]
tracy = ["profiling", "profiling/profile-with-tracy", "common/tracy", "common-ecs/tracy", "common-frontend/tracy", "common-net/tracy", "common-systems/tracy", "common-state/tracy", "client/tracy"]
tracy = ["profiling", "profiling/profile-with-tracy", "common-frontend/tracy"]
plugins = ["client/plugins"]
default = ["singleplayer", "native-dialog", "plugins", "simd"]

View File

@ -574,6 +574,7 @@ impl<'a> Widget for Bag<'a> {
#[allow(clippy::useless_format)] // TODO: Pending review in #587
fn update(self, args: widget::UpdateArgs<Self>) -> Self::Event {
common_base::prof_span!("Bag::update");
let widget::UpdateArgs { state, ui, .. } = args;
let i18n = &self.localized_strings;
let key_layout = &self.global_state.window.key_layout;

View File

@ -99,6 +99,7 @@ impl<'a> Widget for BuffsBar<'a> {
fn style(&self) -> Self::Style {}
fn update(self, args: widget::UpdateArgs<Self>) -> Self::Event {
common_base::prof_span!("BuffsBar::update");
let widget::UpdateArgs { state, ui, .. } = args;
let mut event = Vec::new();
let localized_strings = self.localized_strings;

View File

@ -123,6 +123,7 @@ impl<'a> Widget for Buttons<'a> {
fn style(&self) -> Self::Style { () }
fn update(self, args: widget::UpdateArgs<Self>) -> Self::Event {
common_base::prof_span!("Buttons::update");
let widget::UpdateArgs { state, ui, .. } = args;
let invs = self.client.inventories();
let inventory = match invs.get(self.client.entity()) {

View File

@ -203,6 +203,8 @@ impl<'a> Widget for Chat<'a> {
#[allow(clippy::redundant_clone)] // TODO: Pending review in #587
#[allow(clippy::single_match)] // TODO: Pending review in #587
fn update(self, args: widget::UpdateArgs<Self>) -> Self::Event {
common_base::prof_span!("Chat::update");
let widget::UpdateArgs { id, state, ui, .. } = args;
let mut events = Vec::new();

View File

@ -234,6 +234,7 @@ impl<'a> Widget for Crafting<'a> {
fn style(&self) -> Self::Style { () }
fn update(self, args: widget::UpdateArgs<Self>) -> Self::Event {
common_base::prof_span!("Crafting::update");
let widget::UpdateArgs { state, ui, .. } = args;
let mut events = Vec::new();

View File

@ -260,6 +260,7 @@ impl<'a> Widget for Diary<'a> {
fn style(&self) -> Self::Style { () }
fn update(mut self, args: widget::UpdateArgs<Self>) -> Self::Event {
common_base::prof_span!("Diary::update");
let widget::UpdateArgs {
id: _, state, ui, ..
} = args;

View File

@ -67,6 +67,7 @@ impl<'a> Widget for EscMenu<'a> {
fn style(&self) -> Self::Style { () }
fn update(self, args: widget::UpdateArgs<Self>) -> Self::Event {
common_base::prof_span!("EscMenu::update");
let widget::UpdateArgs { state, ui, .. } = args;
Image::new(self.imgs.esc_frame)

View File

@ -148,6 +148,7 @@ impl<'a> Widget for Group<'a> {
#[allow(clippy::unused_unit)] // TODO: Pending review in #587
#[allow(clippy::blocks_in_if_conditions)] // TODO: Pending review in #587
fn update(self, args: widget::UpdateArgs<Self>) -> Self::Event {
common_base::prof_span!("Group::update");
let widget::UpdateArgs { state, ui, .. } = args;
let mut events = Vec::new();
let localized_strings = self.localized_strings;

View File

@ -194,6 +194,7 @@ impl<'a> Widget for Map<'a> {
#[allow(clippy::useless_format)] // TODO: Pending review in #587
fn update(self, args: widget::UpdateArgs<Self>) -> Self::Event {
common_base::prof_span!("Map::update");
let widget::UpdateArgs { state, ui, .. } = args;
let zoom = self.global_state.settings.interface.map_zoom * 0.8;
let show_difficulty = self.global_state.settings.interface.map_show_difficulty;

View File

@ -437,6 +437,7 @@ impl<'a> Widget for MiniMap<'a> {
fn style(&self) -> Self::Style { () }
fn update(self, args: widget::UpdateArgs<Self>) -> Self::Event {
common_base::prof_span!("Minimap::update");
let mut events = Vec::new();
let widget::UpdateArgs { state, ui, .. } = args;

View File

@ -88,7 +88,7 @@ use common::{
util::srgba_to_linear,
vol::RectRasterableVol,
};
use common_base::span;
use common_base::{prof_span, span};
use common_net::{
msg::{world_msg::SiteId, Notification, PresenceKind},
sync::WorldSyncExt,
@ -977,6 +977,8 @@ impl Hud {
let key_layout = &global_state.window.key_layout;
if self.show.ingame {
prof_span!("ingame elements");
let ecs = client.state().ecs();
let pos = ecs.read_storage::<comp::Pos>();
let stats = ecs.read_storage::<comp::Stats>();
@ -1912,63 +1914,65 @@ impl Hud {
// Temporary Example Quest
let arrow_ani = (self.pulse * 4.0/* speed factor */).cos() * 0.5 + 0.8; //Animation timer
let show_intro = self.show.intro; // borrow check doesn't understand closures
if let Some(toggle_cursor_key) = global_state
.settings
.controls
.get_binding(GameInput::ToggleCursor)
.filter(|_| !show_intro)
{
if !self.show.intro {
match global_state.settings.interface.intro_show {
Intro::Show => {
if Button::image(self.imgs.button)
.w_h(150.0, 40.0)
.hover_image(self.imgs.button_hover)
.press_image(self.imgs.button_press)
.bottom_left_with_margins_on(ui_widgets.window, 200.0, 120.0)
.label(&i18n.get("hud.tutorial_btn"))
.label_font_id(self.fonts.cyri.conrod_id)
.label_font_size(self.fonts.cyri.scale(18))
.label_color(TEXT_COLOR)
.label_y(conrod_core::position::Relative::Scalar(2.0))
.image_color(ENEMY_HP_COLOR)
.set(self.ids.intro_button, ui_widgets)
.was_clicked()
{
self.show.intro = true;
self.show.want_grab = true;
}
Image::new(self.imgs.sp_indicator_arrow)
.w_h(20.0, 11.0)
.mid_top_with_margin_on(self.ids.intro_button, -20.0 + arrow_ani as f64)
.color(Some(QUALITY_LEGENDARY))
.set(self.ids.tut_arrow, ui_widgets);
Text::new(&i18n.get("hud.tutorial_click_here").replace(
"{key}",
toggle_cursor_key.display_string(key_layout).as_str(),
))
.mid_top_with_margin_on(self.ids.tut_arrow, -18.0)
.font_id(self.fonts.cyri.conrod_id)
.font_size(self.fonts.cyri.scale(14))
.color(BLACK)
.set(self.ids.tut_arrow_txt_bg, ui_widgets);
Text::new(&i18n.get("hud.tutorial_click_here").replace(
"{key}",
toggle_cursor_key.display_string(key_layout).as_str(),
))
.bottom_right_with_margins_on(self.ids.tut_arrow_txt_bg, 1.0, 1.0)
.font_id(self.fonts.cyri.conrod_id)
.font_size(self.fonts.cyri.scale(14))
.color(QUALITY_LEGENDARY)
.set(self.ids.tut_arrow_txt, ui_widgets);
},
Intro::Never => {
self.show.intro = false;
},
}
prof_span!("temporary example quest");
match global_state.settings.interface.intro_show {
Intro::Show => {
if Button::image(self.imgs.button)
.w_h(150.0, 40.0)
.hover_image(self.imgs.button_hover)
.press_image(self.imgs.button_press)
.bottom_left_with_margins_on(ui_widgets.window, 200.0, 120.0)
.label(&i18n.get("hud.tutorial_btn"))
.label_font_id(self.fonts.cyri.conrod_id)
.label_font_size(self.fonts.cyri.scale(18))
.label_color(TEXT_COLOR)
.label_y(conrod_core::position::Relative::Scalar(2.0))
.image_color(ENEMY_HP_COLOR)
.set(self.ids.intro_button, ui_widgets)
.was_clicked()
{
self.show.intro = true;
self.show.want_grab = true;
}
Image::new(self.imgs.sp_indicator_arrow)
.w_h(20.0, 11.0)
.mid_top_with_margin_on(self.ids.intro_button, -20.0 + arrow_ani as f64)
.color(Some(QUALITY_LEGENDARY))
.set(self.ids.tut_arrow, ui_widgets);
Text::new(&i18n.get("hud.tutorial_click_here").replace(
"{key}",
toggle_cursor_key.display_string(key_layout).as_str(),
))
.mid_top_with_margin_on(self.ids.tut_arrow, -18.0)
.font_id(self.fonts.cyri.conrod_id)
.font_size(self.fonts.cyri.scale(14))
.color(BLACK)
.set(self.ids.tut_arrow_txt_bg, ui_widgets);
Text::new(&i18n.get("hud.tutorial_click_here").replace(
"{key}",
toggle_cursor_key.display_string(key_layout).as_str(),
))
.bottom_right_with_margins_on(self.ids.tut_arrow_txt_bg, 1.0, 1.0)
.font_id(self.fonts.cyri.conrod_id)
.font_size(self.fonts.cyri.scale(14))
.color(QUALITY_LEGENDARY)
.set(self.ids.tut_arrow_txt, ui_widgets);
},
Intro::Never => {
self.show.intro = false;
},
}
}
// TODO: Add event/stat based tutorial system
if self.show.intro && !self.show.esc_menu {
prof_span!("intro show");
match global_state.settings.interface.intro_show {
Intro::Show => {
if self.show.intro {
@ -2062,6 +2066,7 @@ impl Hud {
// Display debug window.
if let Some(debug_info) = debug_info {
prof_span!("debug info");
// Alpha Version
Text::new(&version)
.top_left_with_margins_on(ui_widgets.window, 5.0, 5.0)
@ -2281,6 +2286,7 @@ impl Hud {
.set(self.ids.debug_info, ui_widgets);
}
} else {
prof_span!("help window");
// Help Window
if let Some(help_key) = global_state.settings.controls.get_binding(GameInput::Help) {
Text::new(

View File

@ -85,6 +85,7 @@ impl<'a> Widget for Popup<'a> {
#[allow(clippy::single_match)] // TODO: Pending review in #587
fn update(self, args: widget::UpdateArgs<Self>) -> Self::Event {
common_base::prof_span!("Popup::update");
let widget::UpdateArgs { state, ui, .. } = args;
const FADE_IN: f32 = 0.5;

View File

@ -83,6 +83,7 @@ impl<'a> Widget for PromptDialog<'a> {
fn style(&self) -> Self::Style { () }
fn update(self, args: widget::UpdateArgs<Self>) -> Self::Event {
common_base::prof_span!("PromptDialog::update");
let widget::UpdateArgs { state, ui, .. } = args;
let _localized_strings = &self.localized_strings;
let mut event: Option<DialogOutcomeEvent> = None;

View File

@ -122,6 +122,7 @@ impl<'a> Widget for Chat<'a> {
fn style(&self) -> Self::Style { () }
fn update(self, args: widget::UpdateArgs<Self>) -> Self::Event {
common_base::prof_span!("Chat::update");
let widget::UpdateArgs { state, ui, .. } = args;
let mut events = Vec::new();

View File

@ -72,6 +72,7 @@ impl<'a> Widget for Controls<'a> {
fn style(&self) -> Self::Style { () }
fn update(self, args: widget::UpdateArgs<Self>) -> Self::Event {
common_base::prof_span!("Controls::update");
let widget::UpdateArgs { state, ui, .. } = args;
let mut events = Vec::new();

View File

@ -98,6 +98,7 @@ impl<'a> Widget for Gameplay<'a> {
fn style(&self) -> Self::Style { () }
fn update(self, args: widget::UpdateArgs<Self>) -> Self::Event {
common_base::prof_span!("Gameplay::update");
let widget::UpdateArgs { state, ui, .. } = args;
let mut events = Vec::new();

View File

@ -137,6 +137,7 @@ impl<'a> Widget for Interface<'a> {
fn style(&self) -> Self::Style { () }
fn update(self, args: widget::UpdateArgs<Self>) -> Self::Event {
common_base::prof_span!("Interface::update");
let widget::UpdateArgs { state, ui, .. } = args;
let mut events = Vec::new();

View File

@ -67,6 +67,7 @@ impl<'a> Widget for Language<'a> {
fn style(&self) -> Self::Style { () }
fn update(self, args: widget::UpdateArgs<Self>) -> Self::Event {
common_base::prof_span!("Language::update");
let widget::UpdateArgs { state, ui, .. } = args;
let mut events = Vec::new();

View File

@ -148,6 +148,7 @@ impl<'a> Widget for SettingsWindow<'a> {
fn style(&self) -> Self::Style { () }
fn update(self, args: widget::UpdateArgs<Self>) -> Self::Event {
common_base::prof_span!("SettingsWindow::update");
let widget::UpdateArgs { state, ui, .. } = args;
let mut events = Vec::new();

View File

@ -80,6 +80,7 @@ impl<'a> Widget for Sound<'a> {
fn style(&self) -> Self::Style { () }
fn update(self, args: widget::UpdateArgs<Self>) -> Self::Event {
common_base::prof_span!("Sound::update");
let widget::UpdateArgs { state, ui, .. } = args;
let mut events = Vec::new();

View File

@ -177,6 +177,7 @@ impl<'a> Widget for Video<'a> {
fn style(&self) -> Self::Style { () }
fn update(self, args: widget::UpdateArgs<Self>) -> Self::Event {
common_base::prof_span!("Video::update");
let widget::UpdateArgs { state, ui, .. } = args;
let mut events = Vec::new();

View File

@ -226,6 +226,7 @@ impl<'a> Widget for Skillbar<'a> {
fn style(&self) -> Self::Style { () }
fn update(self, args: widget::UpdateArgs<Self>) -> Self::Event {
common_base::prof_span!("Skillbar::update");
let widget::UpdateArgs { state, ui, .. } = args;
let max_hp = self.health.base_max().max(self.health.maximum());

View File

@ -109,6 +109,7 @@ impl<'a> Widget for Social<'a> {
fn style(&self) -> Self::Style { () }
fn update(self, args: widget::UpdateArgs<Self>) -> Self::Event {
common_base::prof_span!("Social::update");
let widget::UpdateArgs { state, ui, .. } = args;
let mut events = Vec::new();
let button_tooltip = Tooltip::new({

View File

@ -522,6 +522,7 @@ impl<'a> Widget for Trade<'a> {
fn style(&self) -> Self::Style {}
fn update(mut self, args: widget::UpdateArgs<Self>) -> Self::Event {
common_base::prof_span!("Trade::update");
let widget::UpdateArgs { mut state, ui, .. } = args;
let mut event = None;

View File

@ -33,7 +33,7 @@ use common::{
terrain::{BlockKind, TerrainChunk},
vol::ReadVol,
};
use common_base::span;
use common_base::{prof_span, span};
use common_state::State;
use comp::item::Reagent;
use hashbrown::HashMap;
@ -1064,6 +1064,7 @@ impl Scene {
// would instead have this as an extension.
if drawer.render_mode().shadow.is_map() && (is_daylight || !self.light_data.is_empty()) {
if is_daylight {
prof_span!("directed shadows");
if let Some(mut shadow_pass) = drawer.shadow_pass() {
// Render terrain directed shadows.
self.terrain
@ -1080,12 +1081,16 @@ impl Scene {
}
// Render terrain point light shadows.
drawer.draw_point_shadows(
&self.data.point_light_matrices,
self.terrain.chunks_for_point_shadows(focus_pos),
)
{
prof_span!("point shadows");
drawer.draw_point_shadows(
&self.data.point_light_matrices,
self.terrain.chunks_for_point_shadows(focus_pos),
)
}
}
prof_span!(guard, "main pass");
if let Some(mut first_pass) = drawer.first_pass() {
self.figure_mgr.render_player(
&mut first_pass.draw_figures(),
@ -1125,6 +1130,7 @@ impl Scene {
// Render debug shapes
self.debug.render(&mut first_pass.draw_debug());
}
drop(guard);
}
pub fn maintain_debug_hitboxes(

View File

@ -27,7 +27,7 @@ use common::{
},
vol::ReadVol,
};
use common_base::span;
use common_base::{prof_span, span};
use common_net::{
msg::{server::InviteAnswer, PresenceKind},
sync::WorldSyncExt,
@ -1444,16 +1444,22 @@ impl PlayState for SessionState {
}
// Clouds
if let Some(mut second_pass) = drawer.second_pass() {
second_pass.draw_clouds();
{
prof_span!("clouds");
if let Some(mut second_pass) = drawer.second_pass() {
second_pass.draw_clouds();
}
}
// PostProcess and UI
let mut third_pass = drawer.third_pass();
third_pass.draw_postprocess();
// Draw the UI to the screen
if let Some(mut ui_drawer) = third_pass.draw_ui() {
self.hud.render(&mut ui_drawer);
}; // Note: this semicolon is needed for the third_pass borrow to be dropped before it's lifetime ends
{
prof_span!("post-process and ui");
let mut third_pass = drawer.third_pass();
third_pass.draw_postprocess();
// Draw the UI to the screen
if let Some(mut ui_drawer) = third_pass.draw_ui() {
self.hud.render(&mut ui_drawer);
}; // Note: this semicolon is needed for the third_pass borrow to be dropped before it's lifetime ends
}
}
}

View File

@ -5,7 +5,6 @@ authors = ["Joshua Barretto <joshua.s.barretto@gmail.com>"]
edition = "2018"
[features]
tracy = ["common/tracy", "common-net/tracy"]
simd = ["vek/platform_intrinsics"]
bin_compression = ["lz-fear", "deflate", "flate2", "image/jpeg", "num-traits"]