add flag to toggle tracy (disabled for now)

This commit is contained in:
2026-02-24 20:39:48 +01:00
parent d88b66c058
commit 349d614611
20 changed files with 153 additions and 24 deletions

View File

@ -1,14 +1,17 @@
#include <mutex>
#include <raylib.h>
#include <raymath.h>
#include <tracy/Tracy.hpp>
#include "config.hpp"
#include "input.hpp"
#include "physics.hpp"
#include "renderer.hpp"
#include "state.hpp"
#ifdef TRACY
#include "tracy.hpp"
#include <tracy/Tracy.hpp>
#endif
// TODO: Klotski state file loading
// - File should contain a single state per line, multiple lines possible
@ -20,8 +23,6 @@
// - Click states to display them in the board
// - Find shortest path to any winning state and mark it in the graph
// - Also mark the next move along the path on the board
// TODO: Do I have a huge memory leak or is the memory just not reclaimed from
// the C++ runtime?
auto main(int argc, char *argv[]) -> int {
// if (argc < 2) {
@ -50,7 +51,9 @@ auto main(int argc, char *argv[]) -> int {
// Game loop
while (!WindowShouldClose()) {
#ifdef TRACY
FrameMarkStart("MainThread");
#endif
// Input update
state.previous_state = state.current_state;
@ -58,9 +61,15 @@ auto main(int argc, char *argv[]) -> int {
state.UpdateGraph(); // Add state added after user input
// Read positions from physics thread
#ifdef TRACY
FrameMarkStart("MainThreadConsumeLock");
#endif
{
#ifdef TRACY
std::unique_lock<LockableBase(std::mutex)> lock(physics.state.data_mtx);
#else
std::unique_lock<std::mutex> lock(physics.state.data_mtx);
#endif
ups = physics.state.ups;
@ -77,7 +86,9 @@ auto main(int argc, char *argv[]) -> int {
physics.state.data_consumed_cnd.notify_all();
}
}
#ifdef TRACY
FrameMarkEnd("MainThreadConsumeLock");
#endif
// Update the camera after the physics, so target lock is smooth
std::size_t current_index = state.CurrentMassIndex();
@ -92,7 +103,10 @@ auto main(int argc, char *argv[]) -> int {
renderer.DrawKlotski();
renderer.DrawMenu(masses, springs);
renderer.DrawTextures(ups);
#ifdef TRACY
FrameMark;
FrameMarkEnd("MainThread");
#endif
}
CloseWindow();