diff options
-rw-r--r-- | .gitmodules | 3 | ||||
-rw-r--r-- | 3rdparty/tracy/CMakeLists.txt | 2 | ||||
-rw-r--r-- | 3rdparty/tracy/tracy | 0 | ||||
-rw-r--r-- | CMakeLists.txt | 10 | ||||
-rw-r--r-- | source/main.cpp | 14 |
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 100644 index 0000000..e69de29 --- /dev/null +++ b/3rdparty/tracy/tracy 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; } } |