aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhnOsmium0001 <[email protected]>2022-04-25 22:17:42 -0700
committerhnOsmium0001 <[email protected]>2022-04-25 22:17:42 -0700
commita0b6646bbd601bfeaf0106cb4c22958c53085cac (patch)
treed806d5a9135feed65ca4d7ac0972e6e8fa109d28
parente826894632f59c214c309d934843c49d73103612 (diff)
Add tracy
-rw-r--r--.gitmodules3
-rw-r--r--3rdparty/tracy/CMakeLists.txt2
m---------3rdparty/tracy/tracy0
-rw-r--r--CMakeLists.txt10
-rw-r--r--source/main.cpp14
5 files changed, 28 insertions, 1 deletions
diff --git a/.gitmodules b/.gitmodules
index 7fe5977..2f4d246 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -7,3 +7,6 @@
[submodule "3rdparty/imguicolortextedit/source"]
path = 3rdparty/imguicolortextedit/source
url = https://github.com/BalazsJako/ImGuiColorTextEdit.git
+[submodule "3rdparty/tracy/source"]
+ path = 3rdparty/tracy/tracy
+ url = https://github.com/wolfpld/tracy.git
diff --git a/3rdparty/tracy/CMakeLists.txt b/3rdparty/tracy/CMakeLists.txt
new file mode 100644
index 0000000..84cc697
--- /dev/null
+++ b/3rdparty/tracy/CMakeLists.txt
@@ -0,0 +1,2 @@
+add_library(tracy INTERFACE)
+target_include_directories(tracy INTERFACE ${CMAKE_CURRENT_LIST_DIR})
diff --git a/3rdparty/tracy/tracy b/3rdparty/tracy/tracy
new file mode 160000
+Subproject 9ba7171c3dd6f728268a820ee268a62c75f2dfb
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 73e95cd..7ebe02f 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -10,6 +10,7 @@ add_subdirectory(3rdparty/glm)
add_subdirectory(3rdparty/imgui)
add_subdirectory(3rdparty/imguizmo)
add_subdirectory(3rdparty/imguicolortextedit)
+add_subdirectory(3rdparty/tracy)
# add_executable requires at least one source file
add_executable(${PROJECT_NAME} dummy.c)
@@ -44,8 +45,17 @@ target_link_libraries(${PROJECT_NAME} PRIVATE
imgui
ImGuizmo
ImGuiColorTextEdit
+ tracy
)
+option(BRUSSEL_ENABLE_PROFILING "Whether profiling support is enabled or not." OFF)
+if(BRUSSEL_ENABLE_PROFILING)
+ target_compile_definitions(${PROJECT_NAME}
+ PRIVATE
+ TRACY_ENABLE
+ )
+endif()
+
option(BRUSSEL_ENABLE_ASAN "Enable AddressSanitizer or not." OFF)
if(BRUSSEL_ENABLE_ASAN)
target_compile_options(${PROJECT_NAME}
diff --git a/source/main.cpp b/source/main.cpp
index 99a11c0..fe50b94 100644
--- a/source/main.cpp
+++ b/source/main.cpp
@@ -20,6 +20,9 @@
#include <filesystem>
#include <string>
+#include <tracy/Tracy.hpp>
+#include <tracy/TracyClient.cpp>
+
namespace fs = std::filesystem;
using namespace std::literals;
@@ -379,7 +382,10 @@ void main() {
double prevTime = glfwGetTime();
double accumulatedTime = 0.0;
while (!glfwWindowShouldClose(window)) {
- glfwPollEvents();
+ {
+ ZoneScopedN("GameInput");
+ glfwPollEvents();
+ }
double currTime = glfwGetTime();
double deltaTime = prevTime - currTime;
@@ -392,6 +398,7 @@ void main() {
while (accumulatedTime >= kSecondsPerUpdate) {
double beg = glfwGetTime();
{
+ ZoneScopedN("GameUpdate");
app.Update();
}
double end = glfwGetTime();
@@ -416,10 +423,12 @@ void main() {
glClear(GL_COLOR_BUFFER_BIT);
{ // Regular draw
+ ZoneScopedN("Render");
app.Draw(currTime, deltaTime);
}
{ // ImGui draw
+ ZoneScopedN("ImGui");
if (imguiUseOpenGL3) {
ImGui_ImplOpenGL3_NewFrame();
} else {
@@ -439,6 +448,9 @@ void main() {
}
glfwSwapBuffers(window);
+ FrameMark;
+
+ prevTime = currTime;
}
}