Skip to content

Commit

Permalink
Add more profiling points
Browse files Browse the repository at this point in the history
Better profile the startup phase, add profiling to Sound.cpp
  • Loading branch information
sturnclaw committed Sep 1, 2020
1 parent f059d5a commit 2d9531d
Show file tree
Hide file tree
Showing 9 changed files with 24 additions and 7 deletions.
15 changes: 9 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions src/BaseSphere.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ BaseSphere::~BaseSphere() {}
//static
void BaseSphere::Init()
{
PROFILE_SCOPED()
GeoSphere::Init();
GasGiant::Init();
}
Expand Down
1 change: 1 addition & 0 deletions src/NavLights.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions src/Sfx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
1 change: 1 addition & 0 deletions src/Shields.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions src/galaxy/GalaxyGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ RefCountedPtr<Galaxy> 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
Expand Down
7 changes: 6 additions & 1 deletion src/graphics/TextureBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#include "TextureBuilder.h"
#include "FileSystem.h"
#include "profiler/Profiler.h"
#include "utils.h"
#include <SDL_image.h>
#include <SDL_rwops.h>
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -265,6 +268,7 @@ namespace Graphics {

void TextureBuilder::LoadSurface()
{
PROFILE_SCOPED()
assert(!m_surface);

SDLSurfacePtr s;
Expand All @@ -286,6 +290,7 @@ namespace Graphics {

void TextureBuilder::LoadDDS()
{
PROFILE_SCOPED()
assert(!m_surface);
assert(!m_dds.headerdone_);
if(m_textureType != TEXTURE_2D_ARRAY)
Expand Down
1 change: 1 addition & 0 deletions src/gui/Gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
3 changes: 3 additions & 0 deletions src/sound/Sound.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -538,6 +539,7 @@ namespace Sound {

bool Init(bool automaticallyOpenDevice)
{
PROFILE_SCOPED()
if (m_audioDevice) {
DestroyAllEvents();
return true;
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 2d9531d

Please sign in to comment.