diff --git a/Cargo.lock b/Cargo.lock index 4a55a6ba37..43527b3c08 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5718,7 +5718,6 @@ dependencies = [ "authc", "byteorder", "clap", - "futures-util", "hashbrown 0.11.2", "image", "num 0.4.0", diff --git a/client/Cargo.toml b/client/Cargo.toml index 449b18ba21..7e3877a9e8 100644 --- a/client/Cargo.toml +++ b/client/Cargo.toml @@ -5,7 +5,6 @@ authors = ["Joshua Barretto "] 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"] } diff --git a/client/src/lib.rs b/client/src/lib.rs index de2f3d56b4..66fb721872 100644 --- a/client/src/lib.rs +++ b/client/src/lib.rs @@ -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, { + 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 comps update"); let ecs = self.state.ecs(); - for (entity, _) in (&ecs.entities(), &ecs.read_storage::()).join() { - let mut last_character_states = - ecs.write_storage::>(); - if let Some(client_character_state) = - ecs.read_storage::().get(entity) + let mut last_character_states = ecs.write_storage::>(); + for (entity, _, character_state) in ( + &ecs.entities(), + &ecs.read_storage::(), + &ecs.read_storage::(), + ) + .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, 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, 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, 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, - cnt: &mut u64, - ) -> Result<(), Error> { + fn handle_messages(&mut self, frontend_events: &mut Vec) -> Result { + 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, 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); diff --git a/common/Cargo.toml b/common/Cargo.toml index ebc46b92bd..ab7811d778 100644 --- a/common/Cargo.toml +++ b/common/Cargo.toml @@ -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"] diff --git a/common/base/src/lib.rs b/common/base/src/lib.rs index d05b952127..800869cf01 100644 --- a/common/base/src/lib.rs +++ b/common/base/src/lib.rs @@ -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); }; } diff --git a/common/ecs/Cargo.toml b/common/ecs/Cargo.toml index 687949a9df..17d39592ac 100644 --- a/common/ecs/Cargo.toml +++ b/common/ecs/Cargo.toml @@ -5,7 +5,6 @@ name = "veloren-common-ecs" version = "0.10.0" [features] -tracy = ["common-base/tracy"] [dependencies] diff --git a/common/frontend/Cargo.toml b/common/frontend/Cargo.toml index fcde12a404..c3091bf29e 100644 --- a/common/frontend/Cargo.toml +++ b/common/frontend/Cargo.toml @@ -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 } \ No newline at end of file +tracing-tracy = { version = "0.6.0", optional = true } diff --git a/common/net/Cargo.toml b/common/net/Cargo.toml index 5700672819..74ae0304d4 100644 --- a/common/net/Cargo.toml +++ b/common/net/Cargo.toml @@ -5,7 +5,6 @@ name = "veloren-common-net" version = "0.10.0" [features] -tracy = ["common/tracy"] simd = ["vek/platform_intrinsics"] default = ["simd"] diff --git a/common/state/Cargo.toml b/common/state/Cargo.toml index f613bb9a3c..de24d09f7a 100644 --- a/common/state/Cargo.toml +++ b/common/state/Cargo.toml @@ -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"] diff --git a/common/systems/Cargo.toml b/common/systems/Cargo.toml index 8f1bacdf86..23cc60178e 100644 --- a/common/systems/Cargo.toml +++ b/common/systems/Cargo.toml @@ -5,7 +5,6 @@ name = "veloren-common-systems" version = "0.10.0" [features] -tracy = ["common/tracy"] simd = ["vek/platform_intrinsics"] default = ["simd"] diff --git a/server-cli/Cargo.toml b/server-cli/Cargo.toml index 193fe74446..10636a8ad0 100644 --- a/server-cli/Cargo.toml +++ b/server-cli/Cargo.toml @@ -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] diff --git a/server/Cargo.toml b/server/Cargo.toml index 455a38147e..4236c3d887 100644 --- a/server/Cargo.toml +++ b/server/Cargo.toml @@ -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"] diff --git a/voxygen/Cargo.toml b/voxygen/Cargo.toml index 70cb8f3b90..dfc7fcb121 100644 --- a/voxygen/Cargo.toml +++ b/voxygen/Cargo.toml @@ -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"] diff --git a/voxygen/src/hud/bag.rs b/voxygen/src/hud/bag.rs index 7a1027da61..ee8e47d735 100644 --- a/voxygen/src/hud/bag.rs +++ b/voxygen/src/hud/bag.rs @@ -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::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; diff --git a/voxygen/src/hud/buffs.rs b/voxygen/src/hud/buffs.rs index 12cff265e7..5fc82242df 100644 --- a/voxygen/src/hud/buffs.rs +++ b/voxygen/src/hud/buffs.rs @@ -99,6 +99,7 @@ impl<'a> Widget for BuffsBar<'a> { fn style(&self) -> Self::Style {} fn update(self, args: widget::UpdateArgs) -> 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; diff --git a/voxygen/src/hud/buttons.rs b/voxygen/src/hud/buttons.rs index dce7b90060..71b591d1b1 100644 --- a/voxygen/src/hud/buttons.rs +++ b/voxygen/src/hud/buttons.rs @@ -123,6 +123,7 @@ impl<'a> Widget for Buttons<'a> { fn style(&self) -> Self::Style { () } fn update(self, args: widget::UpdateArgs) -> 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()) { diff --git a/voxygen/src/hud/chat.rs b/voxygen/src/hud/chat.rs index 43283d68a0..2b4c70081a 100644 --- a/voxygen/src/hud/chat.rs +++ b/voxygen/src/hud/chat.rs @@ -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::Event { + common_base::prof_span!("Chat::update"); + let widget::UpdateArgs { id, state, ui, .. } = args; let mut events = Vec::new(); diff --git a/voxygen/src/hud/crafting.rs b/voxygen/src/hud/crafting.rs index d2d34f96e5..2013b20ab8 100644 --- a/voxygen/src/hud/crafting.rs +++ b/voxygen/src/hud/crafting.rs @@ -234,6 +234,7 @@ impl<'a> Widget for Crafting<'a> { fn style(&self) -> Self::Style { () } fn update(self, args: widget::UpdateArgs) -> Self::Event { + common_base::prof_span!("Crafting::update"); let widget::UpdateArgs { state, ui, .. } = args; let mut events = Vec::new(); diff --git a/voxygen/src/hud/diary.rs b/voxygen/src/hud/diary.rs index 96a0cb6fc7..96479dfb46 100644 --- a/voxygen/src/hud/diary.rs +++ b/voxygen/src/hud/diary.rs @@ -260,6 +260,7 @@ impl<'a> Widget for Diary<'a> { fn style(&self) -> Self::Style { () } fn update(mut self, args: widget::UpdateArgs) -> Self::Event { + common_base::prof_span!("Diary::update"); let widget::UpdateArgs { id: _, state, ui, .. } = args; diff --git a/voxygen/src/hud/esc_menu.rs b/voxygen/src/hud/esc_menu.rs index fb949a249f..a85bde4861 100644 --- a/voxygen/src/hud/esc_menu.rs +++ b/voxygen/src/hud/esc_menu.rs @@ -67,6 +67,7 @@ impl<'a> Widget for EscMenu<'a> { fn style(&self) -> Self::Style { () } fn update(self, args: widget::UpdateArgs) -> Self::Event { + common_base::prof_span!("EscMenu::update"); let widget::UpdateArgs { state, ui, .. } = args; Image::new(self.imgs.esc_frame) diff --git a/voxygen/src/hud/group.rs b/voxygen/src/hud/group.rs index 4145e072f9..fa5c31621e 100644 --- a/voxygen/src/hud/group.rs +++ b/voxygen/src/hud/group.rs @@ -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::Event { + common_base::prof_span!("Group::update"); let widget::UpdateArgs { state, ui, .. } = args; let mut events = Vec::new(); let localized_strings = self.localized_strings; diff --git a/voxygen/src/hud/map.rs b/voxygen/src/hud/map.rs index 7ea03cf1b8..5e5634d82d 100644 --- a/voxygen/src/hud/map.rs +++ b/voxygen/src/hud/map.rs @@ -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::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; diff --git a/voxygen/src/hud/minimap.rs b/voxygen/src/hud/minimap.rs index 6eabfb7275..4519e87edc 100644 --- a/voxygen/src/hud/minimap.rs +++ b/voxygen/src/hud/minimap.rs @@ -437,6 +437,7 @@ impl<'a> Widget for MiniMap<'a> { fn style(&self) -> Self::Style { () } fn update(self, args: widget::UpdateArgs) -> Self::Event { + common_base::prof_span!("Minimap::update"); let mut events = Vec::new(); let widget::UpdateArgs { state, ui, .. } = args; diff --git a/voxygen/src/hud/mod.rs b/voxygen/src/hud/mod.rs index a61df245bc..d409045156 100644 --- a/voxygen/src/hud/mod.rs +++ b/voxygen/src/hud/mod.rs @@ -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::(); let stats = ecs.read_storage::(); @@ -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( diff --git a/voxygen/src/hud/popup.rs b/voxygen/src/hud/popup.rs index 78c44bc085..f1e8ef2f97 100644 --- a/voxygen/src/hud/popup.rs +++ b/voxygen/src/hud/popup.rs @@ -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::Event { + common_base::prof_span!("Popup::update"); let widget::UpdateArgs { state, ui, .. } = args; const FADE_IN: f32 = 0.5; diff --git a/voxygen/src/hud/prompt_dialog.rs b/voxygen/src/hud/prompt_dialog.rs index 409495d53d..eea312fb6b 100644 --- a/voxygen/src/hud/prompt_dialog.rs +++ b/voxygen/src/hud/prompt_dialog.rs @@ -83,6 +83,7 @@ impl<'a> Widget for PromptDialog<'a> { fn style(&self) -> Self::Style { () } fn update(self, args: widget::UpdateArgs) -> Self::Event { + common_base::prof_span!("PromptDialog::update"); let widget::UpdateArgs { state, ui, .. } = args; let _localized_strings = &self.localized_strings; let mut event: Option = None; diff --git a/voxygen/src/hud/settings_window/chat.rs b/voxygen/src/hud/settings_window/chat.rs index 12b5f9b22f..3db6833f0d 100644 --- a/voxygen/src/hud/settings_window/chat.rs +++ b/voxygen/src/hud/settings_window/chat.rs @@ -122,6 +122,7 @@ impl<'a> Widget for Chat<'a> { fn style(&self) -> Self::Style { () } fn update(self, args: widget::UpdateArgs) -> Self::Event { + common_base::prof_span!("Chat::update"); let widget::UpdateArgs { state, ui, .. } = args; let mut events = Vec::new(); diff --git a/voxygen/src/hud/settings_window/controls.rs b/voxygen/src/hud/settings_window/controls.rs index 42daae7175..42fe82d28f 100644 --- a/voxygen/src/hud/settings_window/controls.rs +++ b/voxygen/src/hud/settings_window/controls.rs @@ -72,6 +72,7 @@ impl<'a> Widget for Controls<'a> { fn style(&self) -> Self::Style { () } fn update(self, args: widget::UpdateArgs) -> Self::Event { + common_base::prof_span!("Controls::update"); let widget::UpdateArgs { state, ui, .. } = args; let mut events = Vec::new(); diff --git a/voxygen/src/hud/settings_window/gameplay.rs b/voxygen/src/hud/settings_window/gameplay.rs index 5b08fac973..8797769007 100644 --- a/voxygen/src/hud/settings_window/gameplay.rs +++ b/voxygen/src/hud/settings_window/gameplay.rs @@ -98,6 +98,7 @@ impl<'a> Widget for Gameplay<'a> { fn style(&self) -> Self::Style { () } fn update(self, args: widget::UpdateArgs) -> Self::Event { + common_base::prof_span!("Gameplay::update"); let widget::UpdateArgs { state, ui, .. } = args; let mut events = Vec::new(); diff --git a/voxygen/src/hud/settings_window/interface.rs b/voxygen/src/hud/settings_window/interface.rs index 4a4c5cb32f..30478a2e20 100644 --- a/voxygen/src/hud/settings_window/interface.rs +++ b/voxygen/src/hud/settings_window/interface.rs @@ -137,6 +137,7 @@ impl<'a> Widget for Interface<'a> { fn style(&self) -> Self::Style { () } fn update(self, args: widget::UpdateArgs) -> Self::Event { + common_base::prof_span!("Interface::update"); let widget::UpdateArgs { state, ui, .. } = args; let mut events = Vec::new(); diff --git a/voxygen/src/hud/settings_window/language.rs b/voxygen/src/hud/settings_window/language.rs index 285a70df19..c317247d34 100644 --- a/voxygen/src/hud/settings_window/language.rs +++ b/voxygen/src/hud/settings_window/language.rs @@ -67,6 +67,7 @@ impl<'a> Widget for Language<'a> { fn style(&self) -> Self::Style { () } fn update(self, args: widget::UpdateArgs) -> Self::Event { + common_base::prof_span!("Language::update"); let widget::UpdateArgs { state, ui, .. } = args; let mut events = Vec::new(); diff --git a/voxygen/src/hud/settings_window/mod.rs b/voxygen/src/hud/settings_window/mod.rs index 8ef0a31c3e..874ae01bad 100644 --- a/voxygen/src/hud/settings_window/mod.rs +++ b/voxygen/src/hud/settings_window/mod.rs @@ -148,6 +148,7 @@ impl<'a> Widget for SettingsWindow<'a> { fn style(&self) -> Self::Style { () } fn update(self, args: widget::UpdateArgs) -> Self::Event { + common_base::prof_span!("SettingsWindow::update"); let widget::UpdateArgs { state, ui, .. } = args; let mut events = Vec::new(); diff --git a/voxygen/src/hud/settings_window/sound.rs b/voxygen/src/hud/settings_window/sound.rs index eb3c4972e0..a60d0f5b15 100644 --- a/voxygen/src/hud/settings_window/sound.rs +++ b/voxygen/src/hud/settings_window/sound.rs @@ -80,6 +80,7 @@ impl<'a> Widget for Sound<'a> { fn style(&self) -> Self::Style { () } fn update(self, args: widget::UpdateArgs) -> Self::Event { + common_base::prof_span!("Sound::update"); let widget::UpdateArgs { state, ui, .. } = args; let mut events = Vec::new(); diff --git a/voxygen/src/hud/settings_window/video.rs b/voxygen/src/hud/settings_window/video.rs index 0ce0cc2b0e..d4b58bf0dd 100644 --- a/voxygen/src/hud/settings_window/video.rs +++ b/voxygen/src/hud/settings_window/video.rs @@ -177,6 +177,7 @@ impl<'a> Widget for Video<'a> { fn style(&self) -> Self::Style { () } fn update(self, args: widget::UpdateArgs) -> Self::Event { + common_base::prof_span!("Video::update"); let widget::UpdateArgs { state, ui, .. } = args; let mut events = Vec::new(); diff --git a/voxygen/src/hud/skillbar.rs b/voxygen/src/hud/skillbar.rs index f48eb11aa9..9956ab55d8 100644 --- a/voxygen/src/hud/skillbar.rs +++ b/voxygen/src/hud/skillbar.rs @@ -226,6 +226,7 @@ impl<'a> Widget for Skillbar<'a> { fn style(&self) -> Self::Style { () } fn update(self, args: widget::UpdateArgs) -> 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()); diff --git a/voxygen/src/hud/social.rs b/voxygen/src/hud/social.rs index 6e90ee40ee..2d428f3e60 100644 --- a/voxygen/src/hud/social.rs +++ b/voxygen/src/hud/social.rs @@ -109,6 +109,7 @@ impl<'a> Widget for Social<'a> { fn style(&self) -> Self::Style { () } fn update(self, args: widget::UpdateArgs) -> Self::Event { + common_base::prof_span!("Social::update"); let widget::UpdateArgs { state, ui, .. } = args; let mut events = Vec::new(); let button_tooltip = Tooltip::new({ diff --git a/voxygen/src/hud/trade.rs b/voxygen/src/hud/trade.rs index 7dbdc061a7..3d48fdf92e 100644 --- a/voxygen/src/hud/trade.rs +++ b/voxygen/src/hud/trade.rs @@ -522,6 +522,7 @@ impl<'a> Widget for Trade<'a> { fn style(&self) -> Self::Style {} fn update(mut self, args: widget::UpdateArgs) -> Self::Event { + common_base::prof_span!("Trade::update"); let widget::UpdateArgs { mut state, ui, .. } = args; let mut event = None; diff --git a/voxygen/src/scene/mod.rs b/voxygen/src/scene/mod.rs index 50ef89f52f..365c5a0490 100644 --- a/voxygen/src/scene/mod.rs +++ b/voxygen/src/scene/mod.rs @@ -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( diff --git a/voxygen/src/session/mod.rs b/voxygen/src/session/mod.rs index d4e2e4cb39..2e7464f658 100644 --- a/voxygen/src/session/mod.rs +++ b/voxygen/src/session/mod.rs @@ -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 + } } } diff --git a/world/Cargo.toml b/world/Cargo.toml index 07b4084e78..4beef26bd3 100644 --- a/world/Cargo.toml +++ b/world/Cargo.toml @@ -5,7 +5,6 @@ authors = ["Joshua Barretto "] edition = "2018" [features] -tracy = ["common/tracy", "common-net/tracy"] simd = ["vek/platform_intrinsics"] bin_compression = ["lz-fear", "deflate", "flate2", "image/jpeg", "num-traits"]