diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..adcdb55 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "tracy"] + path = tracy + url = https://github.com/wolfpld/tracy.git diff --git a/CMakeLists.txt b/CMakeLists.txt index 4cec5e2..8a4adfc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,7 +2,7 @@ set(PROJECT_NAME HATPC_remake) set(CMAKE_C_COMPILER clang) set(CMAKE_C_FLAGS "-Wall -Wextra") cmake_minimum_required(VERSION 3.22.1) -project(${PROJECT_NAME} C) +project(${PROJECT_NAME} C CXX) set(CMAKE_C_STANDARD 99) set(RAYLIB_DIR /usr/local/lib CACHE FILEPATH "directory to Raylib") set(LIBZSTD_DIR /usr/local/lib CACHE FILEPATH "directory to zstd") @@ -45,6 +45,30 @@ target_include_directories(${PROJECT_NAME} target_link_libraries(${PROJECT_NAME} ${GAME_LIBS} ) + +add_executable(sandbox_trace + scene_test.c + tracy/public/TracyClient.cpp +) +target_compile_definitions(sandbox_trace + PUBLIC + TRACY_ENABLE + TRACY_ON_DEMAND +) +target_include_directories(sandbox_trace + PRIVATE + ${CMAKE_CURRENT_LIST_DIR} + PUBLIC + tracy/public/ +) + +target_link_libraries(sandbox_trace + PUBLIC + ${GAME_LIBS} + pthread + dl +) + add_executable(scene_test scene_test.c ) @@ -54,6 +78,7 @@ target_include_directories(scene_test ${CMAKE_CURRENT_LIST_DIR} ) + if (NOT EMSCRIPTEN) target_compile_options(scene_test PRIVATE -fsanitize=address -gdwarf-4) target_link_options(scene_test PRIVATE -fsanitize=address -gdwarf-4) diff --git a/scene_test.c b/scene_test.c index 48a84ca..d7df555 100644 --- a/scene_test.c +++ b/scene_test.c @@ -1,3 +1,6 @@ +#ifdef TRACY_ENABLE +#include "tracy/TracyC.h" +#endif #include "scene_impl.h" #include "ent_impl.h" #include "assets_loader.h" @@ -89,10 +92,22 @@ int main(void) float frame_time = GetFrameTime(); float delta_time = fminf(frame_time, DT); + #ifdef TRACY_ENABLE + TracyCZoneN(ctx, "Overall", true) + #endif + #ifdef TRACY_ENABLE + TracyCZoneN(ctx1, "Update", true) + #endif update_scene(&scene.scene, delta_time); update_entity_manager(&scene.scene.ent_manager); + #ifdef TRACY_ENABLE + TracyCZoneEnd(ctx1) + #endif // This is needed to advance time delta render_scene(&scene.scene); + #ifdef TRACY_ENABLE + TracyCZoneEnd(ctx) + #endif update_sfx_list(&engine); if (WindowShouldClose()) break; } diff --git a/tracy b/tracy new file mode 160000 index 0000000..5d542dc --- /dev/null +++ b/tracy @@ -0,0 +1 @@ +Subproject commit 5d542dc09f3d9378d005092a4ad446bd405f819a