/*********************************************************************
 * \file   Profiler.hpp
 *
 * \author Romain BOULLARD
 * \date   October 2025
 *********************************************************************/
#ifndef BIGFOOT_UTILS_PROFILER_HPP
#define BIGFOOT_UTILS_PROFILER_HPP

#ifdef TRACY
#include <tracy/Tracy.hpp>
#define BIGFOOT_PROFILER_THREADNAME(p_name) tracy::SetThreadName(p_name)

#define BIGFOOT_PROFILER_FRAME()             FrameMark
#define BIGFOOT_PROFILER_FRAME_START(p_name) FrameMarkStart(p_name)
#define BIGFOOT_PROFILER_FRAME_STOP(p_name)  FrameMarkEnd(p_name)

#define BIGFOOT_PROFILER_PROFILE_FUNCTION() ZoneScoped
#define BIGFOOT_PROFILER_PROFILE(p_name)    ZoneScopedN(p_name)

#define BIGFOOT_PROFILER_TEXT(p_text, p_size) ZoneText(p_text, p_size)

#define BIGFOOT_PROFILER_MEMORY_ALLOC(p_ptr, p_size) TracyAlloc(p_ptr, p_size)
#define BIGFOOT_PROFILER_MEMORY_FREE(p_ptr)          TracyFree(p_ptr)

#define BIGFOOT_PROFILER_LOCKABLE(p_type, p_name) TracyLockable(p_type, p_name)
#define BIGFOOT_PROFILER_LOCK(p_name)             LockMark(p_name)

#define BIGFOOT_PROFILER_APPINFO(p_text, p_size) TracyAppInfo(p_text, p_size)

#define BIGFOOT_PROFILER_ATTACH_FRAME_IMAGE(p_imageData, p_width, p_height, p_offset)                                  \
    FrameImage(p_imageData, p_width, p_height, p_offset, false)

#define BIGFOOT_PROFILER

#define BIGFOOT_PROFILER_ONLY(...) __VA_ARGS__
// TODO: profile GPU
#else
#define BIGFOOT_PROFILER_THREADNAME(p_name)

#define BIGFOOT_PROFILER_FRAME()
#define BIGFOOT_PROFILER_FRAME_START(p_name)
#define BIGFOOT_PROFILER_FRAME_STOP(p_name)

#define BIGFOOT_PROFILER_PROFILE_FUNCTION()
#define BIGFOOT_PROFILER_PROFILE(p_name)

#define BIGFOOT_PROFILER_TEXT_FUNCTION(p_text, p_size)
#define BIGFOOT_PROFILER_TEXT(p_text, p_size)

#define BIGFOOT_PROFILER_MEMORY_ALLOC(p_ptr, p_size)
#define BIGFOOT_PROFILER_MEMORY_FREE(p_ptr)

#define BIGFOOT_PROFILER_LOCKABLE(p_type, p_name) p_type p_name
#define BIGFOOT_PROFILER_LOCK(p_name)

#define BIGFOOT_PROFILER_APPINFO(p_text, p_size)

#define BIGFOOT_PROFILER_ATTACH_FRAME_IMAGE(p_imageData, p_width, p_height, p_offset)

#define BIGFOOT_PROFILER_ONLY(...)
// TODO: profile GPU
#endif
#endif
