Skip to content

Commit

Permalink
adding tracy and BS::thread_pool
Browse files Browse the repository at this point in the history
  • Loading branch information
beaumanvienna committed Aug 30, 2024
1 parent 9d6a89f commit 2f50bd3
Show file tree
Hide file tree
Showing 88 changed files with 48,649 additions and 12 deletions.
7 changes: 3 additions & 4 deletions .vscode_Linux/c_cpp_properties.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
{
"configurations":
[
"configurations": [
{
"name": "Linux",
"includePath":
[
"includePath": [
"application",
"application/lucre",
"engine",
Expand All @@ -27,6 +25,7 @@
"vendor/stb",
"vendor/pamanager/libpamanager/src",
"vendor/sdl/include",
"vendor/thread-pool/include",
"resources/atlas",
"/usr/include/glib-2.0",
"/usr/lib/x86_64-linux-gnu/glib-2.0/include"
Expand Down
19 changes: 15 additions & 4 deletions engine.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ project "engine"

defines
{
"ENGINE_VERSION=\"0.8.8\"",
"PROFILING"
"ENGINE_VERSION=\"0.9.0\""
}

files
Expand Down Expand Up @@ -55,6 +54,8 @@ project "engine"
"vendor/json",
"vendor/sdl/include",
"vendor/sdl_mixer/include",
"vendor/thread-pool/include",
"vendor/tracy/include"
}

libdirs
Expand Down Expand Up @@ -159,11 +160,21 @@ project "engine"
buildoptions { "-Wall -Wextra -Wpedantic -Wshadow -Wno-unused-parameter -Wno-reorder -Wno-expansion-to-defined" }

filter { "configurations:Debug" }
defines { "DEBUG" }
defines
{
"DEBUG",
"PROFILING",
"TRACY_ENABLE"
}
symbols "On"

filter { "configurations:Release" }
defines { "NDEBUG" }
defines
{
"NDEBUG",
"PROFILING",
"TRACY_ENABLE"
}
optimize "On"

filter { "configurations:Dist" }
Expand Down
61 changes: 61 additions & 0 deletions engine/auxiliary/TracyClient.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
//
// Tracy profiler
// ----------------
//
// For fast integration, compile and
// link with this source file (and none
// other) in your executable (or in the
// main DLL / shared object on multi-DLL
// projects).
//

// Define TRACY_ENABLE to enable profiler.

#include "common/TracySystem.cpp"

#ifdef TRACY_ENABLE

#ifdef _MSC_VER
# pragma warning(push, 0)
#endif

#include "common/tracy_lz4.cpp"
#include "client/TracyProfiler.cpp"
#include "client/TracyCallstack.cpp"
#include "client/TracySysPower.cpp"
#include "client/TracySysTime.cpp"
#include "client/TracySysTrace.cpp"
#include "common/TracySocket.cpp"
#include "client/tracy_rpmalloc.cpp"
#include "client/TracyDxt1.cpp"
#include "client/TracyAlloc.cpp"
#include "client/TracyOverride.cpp"
#include "client/TracyKCore.cpp"

#if defined(TRACY_HAS_CALLSTACK)
# if TRACY_HAS_CALLSTACK == 2 || TRACY_HAS_CALLSTACK == 3 || TRACY_HAS_CALLSTACK == 4 || TRACY_HAS_CALLSTACK == 6
# include "libbacktrace/alloc.cpp"
# include "libbacktrace/dwarf.cpp"
# include "libbacktrace/fileline.cpp"
# include "libbacktrace/mmapio.cpp"
# include "libbacktrace/posix.cpp"
# include "libbacktrace/sort.cpp"
# include "libbacktrace/state.cpp"
# if TRACY_HAS_CALLSTACK == 4
# include "libbacktrace/macho.cpp"
# else
# include "libbacktrace/elf.cpp"
# endif
# include "common/TracyStackFrames.cpp"
# endif
#endif

#ifdef _MSC_VER
# pragma comment(lib, "ws2_32.lib")
# pragma comment(lib, "dbghelp.lib")
# pragma comment(lib, "advapi32.lib")
# pragma comment(lib, "user32.lib")
# pragma warning(pop)
#endif

#endif
2 changes: 2 additions & 0 deletions engine/core.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
#include "platform/window.h"
#include "layer/layerStack.h"
#include "renderer/graphicsContext.h"
#include "BS_thread_pool/BS_thread_pool.hpp"
#include "renderer/renderer.h"
#include "renderer/model.h"
#include "audio/audio.h"
Expand Down Expand Up @@ -121,6 +122,7 @@ namespace GfxRenderEngine
static Engine* m_Engine;
static SettingsManager m_SettingsManager;
CoreSettings m_CoreSettings{&m_SettingsManager};
BS::thread_pool m_Pool;

private:
static void SignalHandler(int signal);
Expand Down
2 changes: 2 additions & 0 deletions engine/engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ int engine(int argc, char* argv[])
{
{
PROFILE_SCOPE("application->OnUpdate()");
ZoneScopedN("application->OnUpdate");
application->OnUpdate(engine->GetTimestep());
engine->RunScripts(application.get());
}
Expand All @@ -92,6 +93,7 @@ int engine(int argc, char* argv[])
std::this_thread::sleep_for(16ms);
}
}
FrameMark;
}

application->Shutdown();
Expand Down
4 changes: 4 additions & 0 deletions engine/engine.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@
#define GLM_ENABLE_EXPERIMENTAL
#include "gtx/hash.hpp"

#ifdef TRACY_ENABLE
#include "tracy/Tracy.hpp"
#endif

typedef uint8_t uchar;
typedef uint16_t uint16;
typedef uint32_t uint;
Expand Down
2 changes: 2 additions & 0 deletions engine/platform/Vulkan/VKrenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,7 @@ namespace GfxRenderEngine

VkCommandBuffer VK_Renderer::BeginFrame()
{
ZoneScopedN("VK_Renderer::BeginFrame()");
ASSERT(!m_FrameInProgress);

auto result = m_SwapChain->AcquireNextImage(&m_CurrentImageIndex);
Expand Down Expand Up @@ -508,6 +509,7 @@ namespace GfxRenderEngine

void VK_Renderer::EndFrame()
{
ZoneScopedN("VK_Renderer::EndFrame()");
ASSERT(m_FrameInProgress);

auto commandBuffer = GetCurrentCommandBuffer();
Expand Down
23 changes: 19 additions & 4 deletions premake5.lua
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ project "lucre"

defines
{
"LUCRE_VERSION=\"0.4.2\"",
"PROFILING"
"LUCRE_VERSION=\"0.4.2\""
}

files
Expand Down Expand Up @@ -47,6 +46,8 @@ project "lucre"
"vendor/json",
"vendor/glm",
"vendor/stb",
"vendor/thread-pool/include",
"vendor/tracy/include"
}

libdirs
Expand Down Expand Up @@ -216,7 +217,12 @@ project "lucre"
}

filter { "configurations:Debug" }
defines { "DEBUG" }
defines
{
"DEBUG",
"PROFILING",
"TRACY_ENABLE"
}
symbols "On"
kind "ConsoleApp"

Expand All @@ -230,7 +236,12 @@ project "lucre"
buildoptions { "-Wall -Wextra -Wpedantic -Wshadow -Wno-unused-parameter -Wno-reorder -Wno-expansion-to-defined" }

filter { "configurations:Release" }
defines { "NDEBUG" }
defines
{
"NDEBUG",
"PROFILING",
"TRACY_ENABLE"
}
optimize "On"
kind "ConsoleApp"

Expand Down Expand Up @@ -262,6 +273,10 @@ project "lucre"
os.remove("./vendor/atlas/Makefile")
os.rmdir("./vendor/box2d/bin")
os.rmdir("./vendor/box2d/bin-int")
os.rmdir("./vendor/fastgltf/bin")
os.rmdir("./vendor/fastgltf/bin-int")
os.rmdir("./vendor/ufbx/bin")
os.rmdir("./vendor/ufbx/bin-int")
os.rmdir("./vendor/assetImporter/bin")
os.rmdir("./vendor/assetImporter/bin-int")
os.remove("./vendor/assetImporter/Makefile")
Expand Down
21 changes: 21 additions & 0 deletions vendor/thread-pool/LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2024 Barak Shoshany

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Loading

0 comments on commit 2f50bd3

Please sign in to comment.