Experiment with Tracy profiler
parent
ef04e4ce42
commit
b2beaea248
|
@ -0,0 +1,3 @@
|
||||||
|
[submodule "tracy"]
|
||||||
|
path = tracy
|
||||||
|
url = https://github.com/wolfpld/tracy.git
|
|
@ -2,7 +2,7 @@ set(PROJECT_NAME HATPC_remake)
|
||||||
set(CMAKE_C_COMPILER clang)
|
set(CMAKE_C_COMPILER clang)
|
||||||
set(CMAKE_C_FLAGS "-Wall -Wextra")
|
set(CMAKE_C_FLAGS "-Wall -Wextra")
|
||||||
cmake_minimum_required(VERSION 3.22.1)
|
cmake_minimum_required(VERSION 3.22.1)
|
||||||
project(${PROJECT_NAME} C)
|
project(${PROJECT_NAME} C CXX)
|
||||||
set(CMAKE_C_STANDARD 99)
|
set(CMAKE_C_STANDARD 99)
|
||||||
set(RAYLIB_DIR /usr/local/lib CACHE FILEPATH "directory to Raylib")
|
set(RAYLIB_DIR /usr/local/lib CACHE FILEPATH "directory to Raylib")
|
||||||
set(LIBZSTD_DIR /usr/local/lib CACHE FILEPATH "directory to zstd")
|
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}
|
target_link_libraries(${PROJECT_NAME}
|
||||||
${GAME_LIBS}
|
${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
|
add_executable(scene_test
|
||||||
scene_test.c
|
scene_test.c
|
||||||
)
|
)
|
||||||
|
@ -54,6 +78,7 @@ target_include_directories(scene_test
|
||||||
${CMAKE_CURRENT_LIST_DIR}
|
${CMAKE_CURRENT_LIST_DIR}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
if (NOT EMSCRIPTEN)
|
if (NOT EMSCRIPTEN)
|
||||||
target_compile_options(scene_test PRIVATE -fsanitize=address -gdwarf-4)
|
target_compile_options(scene_test PRIVATE -fsanitize=address -gdwarf-4)
|
||||||
target_link_options(scene_test PRIVATE -fsanitize=address -gdwarf-4)
|
target_link_options(scene_test PRIVATE -fsanitize=address -gdwarf-4)
|
||||||
|
|
15
scene_test.c
15
scene_test.c
|
@ -1,3 +1,6 @@
|
||||||
|
#ifdef TRACY_ENABLE
|
||||||
|
#include "tracy/TracyC.h"
|
||||||
|
#endif
|
||||||
#include "scene_impl.h"
|
#include "scene_impl.h"
|
||||||
#include "ent_impl.h"
|
#include "ent_impl.h"
|
||||||
#include "assets_loader.h"
|
#include "assets_loader.h"
|
||||||
|
@ -89,10 +92,22 @@ int main(void)
|
||||||
float frame_time = GetFrameTime();
|
float frame_time = GetFrameTime();
|
||||||
float delta_time = fminf(frame_time, DT);
|
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_scene(&scene.scene, delta_time);
|
||||||
update_entity_manager(&scene.scene.ent_manager);
|
update_entity_manager(&scene.scene.ent_manager);
|
||||||
|
#ifdef TRACY_ENABLE
|
||||||
|
TracyCZoneEnd(ctx1)
|
||||||
|
#endif
|
||||||
// This is needed to advance time delta
|
// This is needed to advance time delta
|
||||||
render_scene(&scene.scene);
|
render_scene(&scene.scene);
|
||||||
|
#ifdef TRACY_ENABLE
|
||||||
|
TracyCZoneEnd(ctx)
|
||||||
|
#endif
|
||||||
update_sfx_list(&engine);
|
update_sfx_list(&engine);
|
||||||
if (WindowShouldClose()) break;
|
if (WindowShouldClose()) break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
Subproject commit 5d542dc09f3d9378d005092a4ad446bd405f819a
|
Loading…
Reference in New Issue