From 2d9531d3d70bb938e9b7fd5d21a1860e230c34ec Mon Sep 17 00:00:00 2001 From: Webster Sheets Date: Mon, 31 Aug 2020 21:06:04 -0400 Subject: [PATCH] Add more profiling points Better profile the startup phase, add profiling to Sound.cpp --- CMakeLists.txt | 15 +++++++++------ src/BaseSphere.cpp | 1 + src/NavLights.cpp | 1 + src/Sfx.cpp | 1 + src/Shields.cpp | 1 + src/galaxy/GalaxyGenerator.cpp | 1 + src/graphics/TextureBuilder.cpp | 7 ++++++- src/gui/Gui.cpp | 1 + src/sound/Sound.cpp | 3 +++ 9 files changed, 24 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1ddaf93bed3..4b4a6c06b7d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -53,14 +53,17 @@ if (CMAKE_COMPILER_IS_GNUCXX) if (NOT IS_TRAVIS) add_compile_options( -fdiagnostics-color - -Wall - -Wextra - -Wno-unused-parameter - -Wno-unused-but-set-parameter - -Wno-implicit-fallthrough ) - endif() + endif() + add_compile_options( + -Wall + -Wextra + -Wno-unused-parameter + -Wno-unused-but-set-parameter + -Wno-implicit-fallthrough + ) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fpermissive") + set(CMAKE_CXX_FLAGS_DEBUG "-g -Og") endif (CMAKE_COMPILER_IS_GNUCXX) include(CheckSymbolExists) diff --git a/src/BaseSphere.cpp b/src/BaseSphere.cpp index 8ba2f53dd25..46d626fea80 100644 --- a/src/BaseSphere.cpp +++ b/src/BaseSphere.cpp @@ -18,6 +18,7 @@ BaseSphere::~BaseSphere() {} //static void BaseSphere::Init() { + PROFILE_SCOPED() GeoSphere::Init(); GasGiant::Init(); } diff --git a/src/NavLights.cpp b/src/NavLights.cpp index b3f405b20e4..f0225517824 100644 --- a/src/NavLights.cpp +++ b/src/NavLights.cpp @@ -48,6 +48,7 @@ NavLights::LightBulb::LightBulb(Uint8 _group, Uint8 _mask, Uint8 _color, SceneGr void NavLights::Init(Graphics::Renderer *renderer) { + PROFILE_SCOPED() assert(!g_initted); IniConfig cfg; diff --git a/src/Sfx.cpp b/src/Sfx.cpp index d5f1556091d..34416433d2d 100644 --- a/src/Sfx.cpp +++ b/src/Sfx.cpp @@ -360,6 +360,7 @@ bool SfxManager::SplitMaterialData(const std::string &spec, MaterialData &output void SfxManager::Init(Graphics::Renderer *r) { + PROFILE_SCOPED() IniConfig cfg; // set defaults in case they're missing from the file cfg.SetString("damageFile", "textures/smoke.png"); diff --git a/src/Shields.cpp b/src/Shields.cpp index 4585fa4ed45..4baf85c7464 100644 --- a/src/Shields.cpp +++ b/src/Shields.cpp @@ -73,6 +73,7 @@ Shields::Hits::Hits(const vector3d &_pos, const Uint32 _start, const Uint32 _end void Shields::Init(Graphics::Renderer *renderer) { + PROFILE_SCOPED() assert(!s_initialised); // create our global shield material diff --git a/src/galaxy/GalaxyGenerator.cpp b/src/galaxy/GalaxyGenerator.cpp index 4f57b68472b..be13d522e95 100644 --- a/src/galaxy/GalaxyGenerator.cpp +++ b/src/galaxy/GalaxyGenerator.cpp @@ -19,6 +19,7 @@ RefCountedPtr GalaxyGenerator::s_galaxy; //static void GalaxyGenerator::Init(const std::string &name, Version version) { + PROFILE_SCOPED() s_defaultGenerator = name; s_defaultVersion = (version == LAST_VERSION) ? GetLastVersion(name) : version; GalaxyGenerator::Create(); // This will set s_galaxy diff --git a/src/graphics/TextureBuilder.cpp b/src/graphics/TextureBuilder.cpp index 93e38ed81f4..3bd6ae56e43 100644 --- a/src/graphics/TextureBuilder.cpp +++ b/src/graphics/TextureBuilder.cpp @@ -3,6 +3,7 @@ #include "TextureBuilder.h" #include "FileSystem.h" +#include "profiler/Profiler.h" #include "utils.h" #include #include @@ -140,7 +141,9 @@ namespace Graphics { } TextureFormat targetTextureFormat; - unsigned int virtualWidth, actualWidth, virtualHeight, actualHeight, numberOfMipMaps = 0, numberOfImages = 1; + // initialize actualWidth to 1 to avoid divide-by-zero in case we fail to set the values somehow + uint32_t virtualWidth = 0, actualWidth = 1, virtualHeight = 0, actualHeight = 1; + uint32_t numberOfMipMaps = 0, numberOfImages = 1; if (m_surface) { SDL_PixelFormat *targetPixelFormat; bool needConvert = !GetTargetFormat(m_surface->format, &targetTextureFormat, &targetPixelFormat, m_forceRGBA); @@ -265,6 +268,7 @@ namespace Graphics { void TextureBuilder::LoadSurface() { + PROFILE_SCOPED() assert(!m_surface); SDLSurfacePtr s; @@ -286,6 +290,7 @@ namespace Graphics { void TextureBuilder::LoadDDS() { + PROFILE_SCOPED() assert(!m_surface); assert(!m_dds.headerdone_); if(m_textureType != TEXTURE_2D_ARRAY) diff --git a/src/gui/Gui.cpp b/src/gui/Gui.cpp index 96699546722..996eecbe8d5 100644 --- a/src/gui/Gui.cpp +++ b/src/gui/Gui.cpp @@ -115,6 +115,7 @@ namespace Gui { void Init(Graphics::Renderer *renderer, int screen_width, int screen_height, int ui_width, int ui_height) { + PROFILE_SCOPED() Screen::Init(renderer, screen_width, screen_height, ui_width, ui_height); } diff --git a/src/sound/Sound.cpp b/src/sound/Sound.cpp index 7321cb39f7d..1e16de6b285 100644 --- a/src/sound/Sound.cpp +++ b/src/sound/Sound.cpp @@ -470,6 +470,7 @@ namespace Sound { static void load_sound(const std::string &basename, const std::string &path, bool is_music) { + PROFILE_SCOPED() if (!ends_with_ci(basename, ".ogg")) return; Sample sample; @@ -538,6 +539,7 @@ namespace Sound { bool Init(bool automaticallyOpenDevice) { + PROFILE_SCOPED() if (m_audioDevice) { DestroyAllEvents(); return true; @@ -633,6 +635,7 @@ namespace Sound { void UpdateAudioDevices() { + PROFILE_SCOPED() audioDeviceNames.clear(); for (int idx = 0; idx < SDL_GetNumAudioDevices(0); idx++) { const char *name = SDL_GetAudioDeviceName(idx, 0);