From 35426572cd9bf429a856d4ec532b03d5851cf166 Mon Sep 17 00:00:00 2001 From: Mikulas Florek Date: Fri, 27 Nov 2015 21:03:22 +0100 Subject: [PATCH] bgfx allocator using allocation with alignment; some more parts of code profiled --- src/engine/core/FS/tcp_file_server.cpp | 10 ++++++---- src/engine/core/MTJD/scheduler.cpp | 4 +++- src/engine/debug/pc/debug.cpp | 8 +++----- src/renderer/culling_system.cpp | 2 ++ src/renderer/render_scene.cpp | 1 + src/renderer/renderer.cpp | 8 ++++---- src/studio/pc/file_system_watcher.cpp | 2 ++ 7 files changed, 21 insertions(+), 14 deletions(-) diff --git a/src/engine/core/FS/tcp_file_server.cpp b/src/engine/core/FS/tcp_file_server.cpp index 857d6460f..c426f8347 100644 --- a/src/engine/core/FS/tcp_file_server.cpp +++ b/src/engine/core/FS/tcp_file_server.cpp @@ -2,13 +2,14 @@ #include "core/array.h" #include "core/free_list.h" -#include "core/path.h" -#include "core/stack_allocator.h" -#include "core/static_array.h" -#include "core/string.h" #include "core/fs/os_file.h" #include "core/fs/tcp_file_device.h" #include "core/mt/task.h" +#include "core/path.h" +#include "core/profiler.h" +#include "core/stack_allocator.h" +#include "core/static_array.h" +#include "core/string.h" #include "core/network.h" @@ -175,6 +176,7 @@ public: while (!quit) { + PROFILE_BLOCK("File server operation") int32 op = 0; stream->read(op); switch (op) diff --git a/src/engine/core/MTJD/scheduler.cpp b/src/engine/core/MTJD/scheduler.cpp index 2ba7b520b..4712c84e6 100644 --- a/src/engine/core/MTJD/scheduler.cpp +++ b/src/engine/core/MTJD/scheduler.cpp @@ -1,7 +1,8 @@ #include "lumix.h" #include "core/MTJD/scheduler.h" - #include "core/MTJD/manager.h" +#include "core/profiler.h" + namespace Lumix { @@ -25,6 +26,7 @@ namespace Lumix { m_data_event.wait(); + PROFILE_BLOCK("Schedule") m_manager.doScheduling(); } diff --git a/src/engine/debug/pc/debug.cpp b/src/engine/debug/pc/debug.cpp index 67beaa565..2c662d871 100644 --- a/src/engine/debug/pc/debug.cpp +++ b/src/engine/debug/pc/debug.cpp @@ -381,21 +381,19 @@ void* Allocator::reallocate(void* user_ptr, size_t size) void* Allocator::allocate_aligned(size_t size, size_t align) { - ASSERT(false); - return nullptr; + return m_source.allocate_aligned(size, align); } void Allocator::deallocate_aligned(void* ptr) { - ASSERT(false); + m_source.deallocate_aligned(ptr); } void* Allocator::reallocate_aligned(void* ptr, size_t size, size_t align) { - ASSERT(false); - return nullptr; + return m_source.reallocate_aligned(ptr, size, align); } diff --git a/src/renderer/culling_system.cpp b/src/renderer/culling_system.cpp index d05327510..ff3329831 100644 --- a/src/renderer/culling_system.cpp +++ b/src/renderer/culling_system.cpp @@ -5,6 +5,7 @@ #include "core/binary_array.h" #include "core/free_list.h" #include "core/frustum.h" +#include "core/profiler.h" #include "core/sphere.h" #include "core/mtjd/group.h" @@ -27,6 +28,7 @@ static void doCulling(int start_index, int64 layer_mask, CullingSystem::Subresults& results) { + PROFILE_FUNCTION(); int i = start_index; ASSERT(results.empty()); for (const Sphere *sphere = start; sphere <= end; sphere++, ++i) diff --git a/src/renderer/render_scene.cpp b/src/renderer/render_scene.cpp index cbb4c18c0..9d84486e9 100644 --- a/src/renderer/render_scene.cpp +++ b/src/renderer/render_scene.cpp @@ -1661,6 +1661,7 @@ public: MTJD::Job* job = MTJD::makeJob(m_engine.getMTJDManager(), [&subinfos, layer_mask, this, &results, subresult_index, &frustum]() { + PROFILE_BLOCK("Temporary Info Job"); Vec3 frustum_position = frustum.getPosition(); const CullingSystem::Subresults& subresults = results[subresult_index]; for (int i = 0, c = subresults.size(); i < c; ++i) diff --git a/src/renderer/renderer.cpp b/src/renderer/renderer.cpp index 384854e46..4e0270d26 100644 --- a/src/renderer/renderer.cpp +++ b/src/renderer/renderer.cpp @@ -89,17 +89,17 @@ struct BGFXAllocator : public bx::AllocatorI } - void* realloc(void* _ptr, size_t _size, size_t, const char*, uint32) override + void* realloc(void* _ptr, size_t _size, size_t _alignment, const char*, uint32) override { - if (!_ptr) return m_source.allocate(_size); + if (!_ptr) return m_source.allocate_aligned(_size, _alignment); if (_ptr && _size == 0) { - m_source.deallocate(_ptr); + m_source.deallocate_aligned(_ptr); return nullptr; } - return m_source.reallocate(_ptr, _size); + return m_source.reallocate_aligned(_ptr, _size, _alignment); } diff --git a/src/studio/pc/file_system_watcher.cpp b/src/studio/pc/file_system_watcher.cpp index b1ed31621..c6fb26090 100644 --- a/src/studio/pc/file_system_watcher.cpp +++ b/src/studio/pc/file_system_watcher.cpp @@ -1,5 +1,6 @@ #include "file_system_watcher.h" #include "core/MT/task.h" +#include "core/profiler.h" #include "core/string.h" #include "core/pc/simple_win.h" @@ -138,6 +139,7 @@ int FileSystemWatcherTask::task() bool finished = false; while (!finished) { + PROFILE_BLOCK("Change handling"); finished = ReadDirectoryChangesW(m_handle, m_info, sizeof(m_info),