|
| 1 | +#ifndef _TRACY_H |
| 2 | +#define _TRACY_H |
| 3 | + |
| 4 | +#ifdef TRACY_ENABLE |
| 5 | + #include "fmt/format.h" |
| 6 | + #include "Tracy.hpp" |
| 7 | + |
| 8 | + #define TracyFrameMark FrameMark |
| 9 | + #define TracyZoneScoped ZoneScoped |
| 10 | + #define TracyZoneScopedN(n) ZoneScopedN(n) |
| 11 | + #define TracyZoneText(n, l) ZoneText(n, l) |
| 12 | + #define TracyZoneScopedC(c) ZoneScopedC(c) |
| 13 | + #define TracyZoneString(str) ZoneText(str.c_str(), str.size()) |
| 14 | + #define TracyZoneCString(cstr) ZoneText(cstr, std::strlen(cstr)) |
| 15 | + #define TracyZoneIString(istr) TracyZoneCString(reinterpret_cast<const char*>(istr)) |
| 16 | + |
| 17 | + inline std::string Hex8ToString(uint8 hex) |
| 18 | + { |
| 19 | + return fmt::format("0x{:2X}", hex); |
| 20 | + } |
| 21 | + |
| 22 | + inline std::string Hex16ToString(uint16 hex) |
| 23 | + { |
| 24 | + return fmt::format("0x{:4X}", hex); |
| 25 | + } |
| 26 | + |
| 27 | + #define TracyZoneHex8(num) auto str = Hex8ToString(num); TracyZoneText(str.c_str(), str.size()); |
| 28 | + #define TracyZoneHex16(num) auto str = Hex16ToString(num); TracyZoneText(str.c_str(), str.size()); |
| 29 | + |
| 30 | + #define TracyReportLuaMemory(L) TracyPlotConfig("Lua Memory Usage", tracy::PlotFormatType::Memory); TracyPlot("Lua Memory Usage", static_cast<double>(lua_gc(L, LUA_GCCOUNT, 0)) * 1024.0); |
| 31 | + |
| 32 | +#else // Empty stubs for regular builds |
| 33 | + #define TracyFrameMark |
| 34 | + #define TracyZoneScoped |
| 35 | + #define TracyZoneScopedN(n) |
| 36 | + #define TracyZoneText(n, l) |
| 37 | + #define TracyZoneScopedC(c) |
| 38 | + #define TracyZoneString(str) |
| 39 | + #define TracyZoneCString(cstr) |
| 40 | + #define TracyZoneIString(istr) |
| 41 | + #define TracyZoneHex8(num) |
| 42 | + #define TracyZoneHex16(num) |
| 43 | + #define TracyReportLuaMemory(L) |
| 44 | +#endif |
| 45 | + |
| 46 | +#endif // _TRACY_H |
0 commit comments