From 49cfa0b8000a78eb41306eb457096b7ad8e83bed Mon Sep 17 00:00:00 2001 From: BlackMATov Date: Sun, 1 Dec 2019 18:16:42 +0700 Subject: [PATCH 01/19] dummy profiler module --- headers/enduro2d/core/_all.hpp | 1 + headers/enduro2d/core/_core.hpp | 1 + headers/enduro2d/core/profiler.hpp | 21 +++++++++++++++++++++ sources/enduro2d/core/engine.cpp | 6 ++++++ sources/enduro2d/core/profiler.cpp | 20 ++++++++++++++++++++ 5 files changed, 49 insertions(+) create mode 100644 headers/enduro2d/core/profiler.hpp create mode 100644 sources/enduro2d/core/profiler.cpp diff --git a/headers/enduro2d/core/_all.hpp b/headers/enduro2d/core/_all.hpp index af113a40..2b0721a7 100644 --- a/headers/enduro2d/core/_all.hpp +++ b/headers/enduro2d/core/_all.hpp @@ -16,6 +16,7 @@ #include "input.hpp" #include "network.hpp" #include "platform.hpp" +#include "profiler.hpp" #include "render.hpp" #include "render.inl" #include "vfs.hpp" diff --git a/headers/enduro2d/core/_core.hpp b/headers/enduro2d/core/_core.hpp index a993592d..be0a4675 100644 --- a/headers/enduro2d/core/_core.hpp +++ b/headers/enduro2d/core/_core.hpp @@ -44,6 +44,7 @@ namespace e2d class input; class network; class platform; + class profiler; class render; class shader; class texture; diff --git a/headers/enduro2d/core/profiler.hpp b/headers/enduro2d/core/profiler.hpp new file mode 100644 index 00000000..1579a564 --- /dev/null +++ b/headers/enduro2d/core/profiler.hpp @@ -0,0 +1,21 @@ +/******************************************************************************* + * This file is part of the "Enduro2D" + * For conditions of distribution and use, see copyright notice in LICENSE.md + * Copyright (C) 2018-2019, by Matvey Cherevko (blackmatov@gmail.com) + ******************************************************************************/ + +#pragma once + +#include "_core.hpp" + +namespace e2d +{ + class profiler final : public module { + public: + profiler(); + ~profiler() noexcept final; + private: + class internal_state; + std::unique_ptr state_; + }; +} diff --git a/sources/enduro2d/core/engine.cpp b/sources/enduro2d/core/engine.cpp index 3b9833fc..6522d475 100644 --- a/sources/enduro2d/core/engine.cpp +++ b/sources/enduro2d/core/engine.cpp @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -374,6 +375,10 @@ namespace e2d engine::engine(int argc, char *argv[], const parameters& params) : state_(new internal_state(params)) { + // setup profiler + + safe_module_initialize(); + // setup platform safe_module_initialize(argc, argv); @@ -479,6 +484,7 @@ namespace e2d modules::shutdown(); modules::shutdown(); modules::shutdown(); + modules::shutdown(); } bool engine::start(application_uptr app) { diff --git a/sources/enduro2d/core/profiler.cpp b/sources/enduro2d/core/profiler.cpp new file mode 100644 index 00000000..f2d83ec6 --- /dev/null +++ b/sources/enduro2d/core/profiler.cpp @@ -0,0 +1,20 @@ +/******************************************************************************* + * This file is part of the "Enduro2D" + * For conditions of distribution and use, see copyright notice in LICENSE.md + * Copyright (C) 2018-2019, by Matvey Cherevko (blackmatov@gmail.com) + ******************************************************************************/ + +#include + +namespace e2d +{ + class profiler::internal_state final : private e2d::noncopyable { + public: + internal_state() = default; + ~internal_state() noexcept = default; + }; + + profiler::profiler() + : state_(new internal_state()) {} + profiler::~profiler() noexcept = default; +} From 199768ddf54f7e98cbd54f7a288fad2f801aaeb8 Mon Sep 17 00:00:00 2001 From: BlackMATov Date: Mon, 2 Dec 2019 01:32:47 +0700 Subject: [PATCH 02/19] utils: little defer refactoring --- headers/enduro2d/utils/defer.hpp | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/headers/enduro2d/utils/defer.hpp b/headers/enduro2d/utils/defer.hpp index 0993630b..e569ffe9 100644 --- a/headers/enduro2d/utils/defer.hpp +++ b/headers/enduro2d/utils/defer.hpp @@ -13,12 +13,8 @@ namespace e2d namespace impl { template < typename F > - class defer_impl { + class defer_impl final : noncopyable { public: - defer_impl() = delete; - defer_impl(const defer_impl&) = delete; - defer_impl& operator=(const defer_impl&) = delete; - explicit defer_impl(F f) : f_(std::move(f)) {} @@ -44,4 +40,4 @@ namespace e2d } #define E2D_DEFER(lambda)\ - auto E2D_PP_CAT(e2d_defer_, __LINE__) = ::e2d::make_defer(lambda) + auto E2D_PP_CAT(e2d_generated_defer_, __LINE__) = ::e2d::make_defer(lambda) From be7114f4b28662834319e16abea11b3424108b47 Mon Sep 17 00:00:00 2001 From: BlackMATov Date: Mon, 2 Dec 2019 10:08:27 +0700 Subject: [PATCH 03/19] some str_view vs buffer_view improvements --- headers/enduro2d/high/luasol.hpp | 1 + headers/enduro2d/utils/buffer_view.hpp | 8 -------- headers/enduro2d/utils/filesystem.hpp | 1 + headers/enduro2d/utils/streams.hpp | 5 +++++ sources/enduro2d/high/luasol.cpp | 13 ++++++++++--- sources/enduro2d/utils/filesystem.cpp | 5 +++++ sources/enduro2d/utils/streams.cpp | 14 ++++++++++++++ 7 files changed, 36 insertions(+), 11 deletions(-) diff --git a/headers/enduro2d/high/luasol.hpp b/headers/enduro2d/high/luasol.hpp index f06883b7..a030f176 100644 --- a/headers/enduro2d/high/luasol.hpp +++ b/headers/enduro2d/high/luasol.hpp @@ -24,6 +24,7 @@ namespace e2d template < typename F > decltype(auto) with_state(F&& f) const; + std::optional