Skip to content

Commit

Permalink
gh-76: support gpu profiling time events
Browse files Browse the repository at this point in the history
  • Loading branch information
EgorOrachyov committed Oct 10, 2024
1 parent 5dd6390 commit e94d178
Show file tree
Hide file tree
Showing 101 changed files with 1,273 additions and 886 deletions.
4 changes: 2 additions & 2 deletions engine/plugins/assimp/assimp_asset_loader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
#include "mesh/mesh_builder.hpp"
#include "mesh/mesh_manager.hpp"
#include "platform/file_system.hpp"
#include "profiler/profiler.hpp"
#include "profiler/profiler_cpu.hpp"

#include <cassert>
#include <cstring>
Expand All @@ -59,7 +59,7 @@ namespace wmoge {
}

Status AssimpMeshAssetLoader::load_typed(AssetLoadContext& context, const AssetId& asset_id, const AssetLoadResult& result, Ref<Mesh>& asset) {
WG_AUTO_PROFILE_ASSET("AssimpMeshAssetLoader::load_typed");
WG_PROFILE_CPU_ASSET("AssimpMeshAssetLoader::load_typed");

Ref<AssimpMeshImportData> import_data = context.asset_meta.import_data.cast<AssimpMeshImportData>();
assert(import_data);
Expand Down
8 changes: 4 additions & 4 deletions engine/plugins/assimp/assimp_importer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
#include "core/data.hpp"
#include "core/log.hpp"
#include "math/math_utils3d.hpp"
#include "profiler/profiler.hpp"
#include "profiler/profiler_cpu.hpp"

#include <cassert>
#include <cstring>
Expand All @@ -39,7 +39,7 @@
namespace wmoge {

Status AssimpImporter::read(std::string file_name, array_view<const std::uint8_t> data, const AssimpProcess& flags) {
WG_AUTO_PROFILE_ASSET("AssimpImporter::read");
WG_PROFILE_CPU_ASSET("AssimpImporter::read");

if (flags.triangulate) m_options |= aiProcess_Triangulate;
if (flags.tangent_space) m_options |= aiProcess_CalcTangentSpace;
Expand Down Expand Up @@ -75,7 +75,7 @@ namespace wmoge {
}

Status AssimpImporter::process_node(aiNode* node, const Mat4x4f& parent_transform, const Mat4x4f& inv_parent_transform, std::optional<int> parent) {
WG_AUTO_PROFILE_ASSET("AssimpImporter::process_node");
WG_PROFILE_CPU_ASSET("AssimpImporter::process_node");

Mat4x4f local_transform;
Mat4x4f inv_local_transform;
Expand Down Expand Up @@ -115,7 +115,7 @@ namespace wmoge {
}

Status AssimpMeshImporter::process_mesh(aiMesh* mesh, const Mat4x4f& transform, const Mat4x4f& inv_transform, std::optional<int> parent) {
WG_AUTO_PROFILE_ASSET("AssimpMeshImporter::process_mesh");
WG_PROFILE_CPU_ASSET("AssimpMeshImporter::process_mesh");

const Vec3f aabb_min = Vec3f(mesh->mAABB.mMin.x, mesh->mAABB.mMin.y, mesh->mAABB.mMin.z);
const Vec3f aabb_max = Vec3f(mesh->mAABB.mMax.x, mesh->mAABB.mMax.y, mesh->mAABB.mMax.z);
Expand Down
4 changes: 2 additions & 2 deletions engine/plugins/freetype/freetype_asset_loader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
#include "core/ioc_container.hpp"
#include "freetype_font.hpp"
#include "freetype_import_data.hpp"
#include "profiler/profiler.hpp"
#include "profiler/profiler_cpu.hpp"

namespace wmoge {

Expand All @@ -49,7 +49,7 @@ namespace wmoge {
}

Status FreetypeAssetLoader::load_typed(AssetLoadContext& context, const AssetId& asset_id, const AssetLoadResult& result, Ref<Font>& asset) {
WG_AUTO_PROFILE_ASSET("FreetypeAssetLoader::load_typed");
WG_PROFILE_CPU_ASSET("FreetypeAssetLoader::load_typed");

Ref<FreetypeImportData> import_data = context.asset_meta.import_data.cast<FreetypeImportData>();
assert(import_data);
Expand Down
4 changes: 2 additions & 2 deletions engine/plugins/freetype/freetype_font.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
#include "grc/image.hpp"
#include "grc/texture.hpp"
#include "platform/file_system.hpp"
#include "profiler/profiler.hpp"
#include "profiler/profiler_cpu.hpp"

#include <freetype/freetype.h>

Expand All @@ -45,7 +45,7 @@ namespace wmoge {
}

Status FreetypeFont::load(const Ref<Font>& font, array_view<const std::uint8_t> ttf_data, int height, int glyphs_in_row) {
WG_AUTO_PROFILE_ASSET("FreetypeFont::load");
WG_PROFILE_CPU_ASSET("FreetypeFont::load");

static const int GLYPHS_SIZE_SHIFT = 6;
static const int GLYPHS_BITMAP_OFFSET = 2;
Expand Down
4 changes: 2 additions & 2 deletions engine/plugins/runtime/asset/default_asset_loader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

#include "core/ioc_container.hpp"
#include "io/tree_yaml.hpp"
#include "profiler/profiler.hpp"
#include "profiler/profiler_cpu.hpp"
#include "rtti/type_storage.hpp"

namespace wmoge {
Expand All @@ -50,7 +50,7 @@ namespace wmoge {
}

Status DefaultAssetLoader::load_typed(AssetLoadContext& context, const AssetId& asset_id, const AssetLoadResult& result, Ref<Asset>& asset) {
WG_AUTO_PROFILE_ASSET("DefaultAssetLoader::load_typed");
WG_PROFILE_CPU_ASSET("DefaultAssetLoader::load_typed");

Ref<AssetImportData> import_data = context.asset_meta.import_data.cast<AssetImportData>();
assert(import_data);
Expand Down
4 changes: 2 additions & 2 deletions engine/plugins/runtime/asset/image_asset_loader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
#include "image_asset_loader.hpp"

#include "image_import_data.hpp"
#include "profiler/profiler.hpp"
#include "profiler/profiler_cpu.hpp"

namespace wmoge {

Expand All @@ -47,7 +47,7 @@ namespace wmoge {
}

Status ImageAssetLoader::load_typed(AssetLoadContext& context, const AssetId& asset_id, const AssetLoadResult& result, Ref<Image>& asset) {
WG_AUTO_PROFILE_ASSET("ImageAssetLoader::load_typed");
WG_PROFILE_CPU_ASSET("ImageAssetLoader::load_typed");

Ref<ImageImportData> import_data = context.asset_meta.import_data.cast<ImageImportData>();
assert(import_data);
Expand Down
4 changes: 2 additions & 2 deletions engine/plugins/runtime/asset/shader_asset_loader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
#include "grc/shader_file.hpp"
#include "grc/shader_manager.hpp"
#include "io/tree_yaml.hpp"
#include "profiler/profiler.hpp"
#include "profiler/profiler_cpu.hpp"

namespace wmoge {

Expand All @@ -51,7 +51,7 @@ namespace wmoge {
}

Status ShaderAssetLoader::load_typed(AssetLoadContext& context, const AssetId& asset_id, const AssetLoadResult& result, Ref<Shader>& asset) {
WG_AUTO_PROFILE_ASSET("ShaderAssetLoader::load_typed");
WG_PROFILE_CPU_ASSET("ShaderAssetLoader::load_typed");

Ref<AssetImportData> import_data = context.asset_meta.import_data.cast<AssetImportData>();
assert(import_data);
Expand Down
6 changes: 3 additions & 3 deletions engine/plugins/runtime/asset/texture_asset_loader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
#include "grc/texture.hpp"
#include "grc/texture_manager.hpp"
#include "grc/texture_resize.hpp"
#include "profiler/profiler.hpp"
#include "profiler/profiler_cpu.hpp"

namespace wmoge {

Expand All @@ -54,7 +54,7 @@ namespace wmoge {
}

Status Texture2dAssetLoader::load_typed(AssetLoadContext& context, const AssetId& asset_id, const AssetLoadResult& result, Ref<Texture2d>& asset) {
WG_AUTO_PROFILE_ASSET("Texture2dAssetLoader::load_typed");
WG_PROFILE_CPU_ASSET("Texture2dAssetLoader::load_typed");

Ref<Texture2dImportData> import_data = context.asset_meta.import_data.cast<Texture2dImportData>();
assert(import_data);
Expand Down Expand Up @@ -140,7 +140,7 @@ namespace wmoge {
}

Status TextureCubeAssetLoader::load_typed(AssetLoadContext& context, const AssetId& asset_id, const AssetLoadResult& result, Ref<TextureCube>& asset) {
WG_AUTO_PROFILE_ASSET("TextureCubeAssetLoader::load_typed");
WG_PROFILE_CPU_ASSET("TextureCubeAssetLoader::load_typed");

Ref<TextureCubeImportData> import_data = context.asset_meta.import_data.cast<TextureCubeImportData>();
assert(import_data);
Expand Down
4 changes: 2 additions & 2 deletions engine/plugins/runtime/asset/wav_asset_loader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
#include "wav_asset_loader.hpp"

#include "asset/wav_import_data.hpp"
#include "profiler/profiler.hpp"
#include "profiler/profiler_cpu.hpp"

namespace wmoge {

Expand All @@ -47,7 +47,7 @@ namespace wmoge {
}

Status WavAssetLoader::load_typed(AssetLoadContext& context, const AssetId& asset_id, const AssetLoadResult& result, Ref<AudioStreamWav>& asset) {
WG_AUTO_PROFILE_ASSET("WavAssetLoader::load_typed");
WG_PROFILE_CPU_ASSET("WavAssetLoader::load_typed");

Ref<WavImportData> import_data = context.asset_meta.import_data.cast<WavImportData>();
assert(import_data);
Expand Down
10 changes: 5 additions & 5 deletions engine/runtime/asset/asset_library_fs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
#include "io/tree.hpp"
#include "io/tree_yaml.hpp"
#include "platform/file_system.hpp"
#include "profiler/profiler.hpp"
#include "profiler/profiler_cpu.hpp"
#include "rtti/type_storage.hpp"

namespace wmoge {
Expand All @@ -55,12 +55,12 @@ namespace wmoge {
}

bool AssetLibraryFileSystem::has_asset(const AssetId& name) {
WG_AUTO_PROFILE_ASSET("AssetLibraryFileSystem::has_asset");
WG_PROFILE_CPU_ASSET("AssetLibraryFileSystem::has_asset");
return m_file_system->exists(make_asset_meta_path(m_directory, name, m_asset_ext));
}

Status AssetLibraryFileSystem::find_asset_meta(const AssetId& name, AssetMeta& meta) {
WG_AUTO_PROFILE_ASSET("AssetLibraryFileSystem::find_asset_meta");
WG_PROFILE_CPU_ASSET("AssetLibraryFileSystem::find_asset_meta");

IoContext context;
context.add(m_file_system);
Expand All @@ -78,7 +78,7 @@ namespace wmoge {
}

Status AssetLibraryFileSystem::find_asset_data_meta(const Strid& name, AssetDataMeta& meta) {
WG_AUTO_PROFILE_ASSET("AssetLibraryFileSystem::find_asset_data_meta");
WG_PROFILE_CPU_ASSET("AssetLibraryFileSystem::find_asset_data_meta");

WG_CHECKED(m_file_system->get_file_size(make_asset_data_path(m_directory, name), meta.size));
meta.size_compressed = 0;
Expand All @@ -89,7 +89,7 @@ namespace wmoge {
}

Async AssetLibraryFileSystem::read_data(const Strid& name, array_view<std::uint8_t> data) {
WG_AUTO_PROFILE_ASSET("AssetLibraryFileSystem::read_data");
WG_PROFILE_CPU_ASSET("AssetLibraryFileSystem::read_data");
return m_async_file_system->read_file(make_asset_data_path(m_directory, name), data).as_async();
}

Expand Down
12 changes: 6 additions & 6 deletions engine/runtime/asset/asset_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
#include "core/ioc_container.hpp"
#include "core/timer.hpp"
#include "platform/file_system.hpp"
#include "profiler/profiler.hpp"
#include "profiler/profiler_cpu.hpp"
#include "rtti/type_storage.hpp"

#include <chrono>
Expand All @@ -55,7 +55,7 @@ namespace wmoge {
}

AsyncResult<Ref<Asset>> AssetManager::load_async(const AssetId& name) {
WG_AUTO_PROFILE_ASSET("AssetManager::load_async");
WG_PROFILE_CPU_ASSET("AssetManager::load_async");

std::lock_guard guard(m_mutex);

Expand Down Expand Up @@ -177,7 +177,7 @@ namespace wmoge {
}

Ref<Asset> AssetManager::load(const AssetId& name) {
WG_AUTO_PROFILE_ASSET("AssetManager::load");
WG_PROFILE_CPU_ASSET("AssetManager::load");

Ref<Asset> fast_look_up = find(name);
if (fast_look_up) {
Expand All @@ -190,7 +190,7 @@ namespace wmoge {
}

Ref<Asset> AssetManager::find(const AssetId& name) {
WG_AUTO_PROFILE_ASSET("AssetManager::find");
WG_PROFILE_CPU_ASSET("AssetManager::find");

std::lock_guard guard(m_mutex);

Expand Down Expand Up @@ -237,14 +237,14 @@ namespace wmoge {
}

void AssetManager::clear() {
WG_AUTO_PROFILE_ASSET("AssetManager::clear");
WG_PROFILE_CPU_ASSET("AssetManager::clear");

std::lock_guard guard(m_mutex);
m_assets.clear();
}

void AssetManager::load_loaders() {
WG_AUTO_PROFILE_ASSET("AssetManager::load_loaders");
WG_PROFILE_CPU_ASSET("AssetManager::load_loaders");

std::vector<RttiClass*> loaders = m_type_storage->find_classes([](const Ref<RttiClass>& type) {
return type->is_subtype_of(AssetLoader::get_class_static()) && type->can_instantiate();
Expand Down
4 changes: 2 additions & 2 deletions engine/runtime/audio/audio_stream_wav.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

#include "audio_stream_wav.hpp"

#include "profiler/profiler.hpp"
#include "profiler/profiler_cpu.hpp"

#include <AudioFile.h>

Expand All @@ -36,7 +36,7 @@
namespace wmoge {

Status AudioStreamWav::load(array_view<const std::uint8_t> file_data) {
WG_AUTO_PROFILE_ASSET("AudioStreamWav::load");
WG_PROFILE_CPU_ASSET("AudioStreamWav::load");

std::vector<std::uint8_t> data;
data.resize(file_data.size());
Expand Down
8 changes: 4 additions & 4 deletions engine/runtime/audio/openal/al_bus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
#include "al_bus.hpp"

#include "audio/openal/al_engine.hpp"
#include "profiler/profiler.hpp"
#include "profiler/profiler_cpu.hpp"

namespace wmoge {

Expand Down Expand Up @@ -60,7 +60,7 @@ namespace wmoge {
m_playbacks.erase(playback);
}
void ALAudioBus::make_active() {
WG_AUTO_PROFILE_OPENAL("ALAudioBus::make_active");
WG_PROFILE_CPU_OPENAL("ALAudioBus::make_active");

std::lock_guard guard(m_engine.get_mutex());

Expand All @@ -72,7 +72,7 @@ namespace wmoge {
}
}
void ALAudioBus::make_inactive() {
WG_AUTO_PROFILE_OPENAL("ALAudioBus::make_inactive");
WG_PROFILE_CPU_OPENAL("ALAudioBus::make_inactive");

std::lock_guard guard(m_engine.get_mutex());

Expand All @@ -98,7 +98,7 @@ namespace wmoge {
}
}
void ALAudioBus::get_playbacks(std::vector<Ref<AudioPlayback>>& playbacks) {
WG_AUTO_PROFILE_OPENAL("ALAudioBus::get_playbacks");
WG_PROFILE_CPU_OPENAL("ALAudioBus::get_playbacks");

std::lock_guard guard(m_engine.get_mutex());

Expand Down
Loading

0 comments on commit e94d178

Please sign in to comment.