SlotMaps
Bigfoot / Build & Test Debug with ./ConanProfiles/clang (Unity Build: OFF) (push) Successful in 5m26s
Bigfoot / Build & Test Debug with ./ConanProfiles/clang (Unity Build: ON) (push) Successful in 5m20s
Bigfoot / Build & Test Debug with ./ConanProfiles/clang_asan (Unity Build: OFF) (push) Successful in 5m42s
Bigfoot / Build & Test Debug with ./ConanProfiles/clang_asan (Unity Build: ON) (push) Successful in 5m37s
Bigfoot / Build & Test RelWithDebInfo with ./ConanProfiles/clang (Unity Build: OFF) (push) Successful in 5m45s
Bigfoot / Build & Test RelWithDebInfo with ./ConanProfiles/clang (Unity Build: ON) (push) Successful in 5m48s
Bigfoot / Build & Test RelWithDebInfo with ./ConanProfiles/clang_asan (Unity Build: OFF) (push) Successful in 7m0s
Bigfoot / Build & Test RelWithDebInfo with ./ConanProfiles/clang_asan (Unity Build: ON) (push) Successful in 6m56s
Bigfoot / Build & Test Release with ./ConanProfiles/clang (Unity Build: OFF) (push) Successful in 6m2s
Bigfoot / Build & Test Release with ./ConanProfiles/clang (Unity Build: ON) (push) Successful in 5m51s
Bigfoot / Build & Test Release with ./ConanProfiles/clang_asan (Unity Build: OFF) (push) Successful in 6m29s
Bigfoot / Build & Test Release with ./ConanProfiles/clang_asan (Unity Build: ON) (push) Successful in 6m31s
Bigfoot / Clang Format Checks (push) Successful in 10s

This commit is contained in:
2026-05-14 01:54:38 +02:00
parent f314ffc2f7
commit b867701d2a
24 changed files with 361 additions and 54 deletions
+11 -1
View File
@@ -2,6 +2,8 @@ get_filename_component(PackageName ${CMAKE_CURRENT_SOURCE_DIR} NAME)
project(${PackageName})
set(PublicDependencies
$<$<CONFIG:Debug,RelWithDebInfo>:quill::quill>
$<IF:$<BOOL:${ASAN}>,mimalloc-asan,mimalloc-static>
unordered_dense::unordered_dense)
set(PrivateDependencies)
set(BigfootPublicDependencies)
@@ -12,4 +14,12 @@ bigfoot_create_package_lib(
"${PrivateLibraries}"
"${BigfootPublicDependencies}"
"${BigfootPrivateDependencies}"
"")
"")
set_source_files_properties(../Utils/MimallocImpl.cpp PROPERTIES SKIP_UNITY_BUILD_INCLUSION ON)
bigfoot_create_logger()
target_compile_definitions(${PROJECT_NAME}
PUBLIC
$<$<CONFIG:Debug,RelWithDebInfo>:QUILL_NO_EXCEPTIONS>
$<$<CONFIG:Debug,RelWithDebInfo>:QUILL_DISABLE_NON_PREFIXED_MACROS>)
@@ -6,7 +6,7 @@
*********************************************************************/
#ifndef BIGFOOT_UTILS_ASSERT_HPP
#define BIGFOOT_UTILS_ASSERT_HPP
#include <System/Log/Log.hpp>
#include <Utils/Log/Log.hpp>
#if defined BIGFOOT_NOT_OPTIMIZED
@@ -6,5 +6,217 @@
*********************************************************************/
#ifndef BIGFOOT_UTILS_CONTAINERS_SLOTMAP_HPP
#define BIGFOOT_UTILS_CONTAINERS_SLOTMAP_HPP
#include <Utils/UtilsAssertHandler.hpp>
#include <EASTL/vector.h>
#include <cstdint>
namespace Bigfoot
{
template<class TYPE>
class SlotMap
{
private:
using IndexType = std::uint32_t;
using VersionType = std::uint32_t;
public:
struct SlotKey
{
VersionType m_version = 0;
IndexType m_index = 0;
bool Invalid() const
{
return m_version == 0;
}
bool operator==(const SlotKey p_key) const
{
return m_version == p_key.m_version && m_index == p_key.m_index;
}
};
SlotMap():
m_freeSlotHead(std::numeric_limits<IndexType>::max())
{
}
SlotMap(const SlotMap& p_slotMap) = default;
SlotMap(SlotMap&& p_slotMap) = default;
template<class... ARGS>
SlotKey Insert(ARGS&&... p_args)
{
ASSERT(UtilsAssertHandler,
m_data.size() < std::numeric_limits<IndexType>::max(),
"Too many elements for SlotMap!");
m_data.emplace_back(std::forward<ARGS>(p_args)...);
if (m_freeSlotHead != std::numeric_limits<IndexType>::max())
{
const IndexType freeSlotIndex = m_freeSlotHead;
m_freeSlotHead = m_slots[freeSlotIndex].m_index;
const VersionType version = m_slots[freeSlotIndex].m_version;
m_slots[freeSlotIndex] = {.m_version = version, .m_index = static_cast<IndexType>(m_data.size()) - 1};
m_dataToSlots.push_back(freeSlotIndex);
return {.m_version = version, .m_index = freeSlotIndex};
}
const IndexType newSlotIndex = m_slots.size();
m_slots.push_back({.m_version = 1, .m_index = static_cast<IndexType>(m_data.size()) - 1});
m_dataToSlots.push_back(newSlotIndex);
return {.m_version = 1, .m_index = newSlotIndex};
}
void Remove(const SlotKey p_key)
{
const IndexType slotIndex = p_key.m_index;
if (slotIndex >= m_slots.size())
{
return;
}
if (p_key.m_version != m_slots[slotIndex].m_version)
{
return;
}
const IndexType dataIndex = m_slots[slotIndex].m_index;
m_data.erase_unsorted(m_data.begin() + dataIndex);
m_dataToSlots.erase_unsorted(m_dataToSlots.begin() + dataIndex);
if (dataIndex < m_data.size())
{
const IndexType movedSlotIndex = m_dataToSlots[dataIndex];
m_slots[movedSlotIndex].m_index = dataIndex;
}
m_slots[slotIndex] = {.m_version = p_key.m_version + 1, .m_index = m_freeSlotHead};
m_freeSlotHead = slotIndex;
}
TYPE* Get(const SlotKey p_key)
{
const IndexType slotIndex = p_key.m_index;
if (slotIndex >= m_slots.size())
{
return nullptr;
}
if (p_key.m_version != m_slots[slotIndex].m_version)
{
return nullptr;
}
return &m_data[m_slots[slotIndex].m_index];
}
const TYPE* Get(const SlotKey p_key) const
{
const IndexType slotIndex = p_key.m_index;
if (slotIndex >= m_slots.size())
{
return nullptr;
}
if (p_key.m_version != m_slots[slotIndex].m_version)
{
return nullptr;
}
return &m_data[m_slots[slotIndex].m_index];
}
void Reserve(const std::uint32_t p_size)
{
m_data.reserve(p_size);
m_slots.reserve(p_size);
m_dataToSlots.reserve(p_size);
}
typename eastl::vector<TYPE>::size_type Size() const
{
return m_data.size();
}
typename eastl::vector<TYPE>::size_type Capacity() const
{
return m_data.capacity();
}
bool Empty() const
{
return m_data.empty();
}
void Clear()
{
m_data.clear();
m_dataToSlots.clear();
for (IndexType i = 0; i < m_slots.size(); ++i)
{
const VersionType newVersion = m_slots[i].m_version + 1;
const IndexType nextFree = i + 1 < static_cast<IndexType>(m_slots.size())
? i + 1
: std::numeric_limits<IndexType>::max();
m_slots[i] = {.m_version = newVersion, .m_index = nextFree};
}
m_freeSlotHead = m_slots.empty() ? std::numeric_limits<IndexType>::max() : 0;
}
void Reset()
{
m_data.clear();
m_slots.clear();
m_dataToSlots.clear();
m_freeSlotHead = std::numeric_limits<IndexType>::max();
}
typename eastl::vector<TYPE>::iterator begin()
{
return m_data.begin();
}
typename eastl::vector<TYPE>::iterator end()
{
return m_data.end();
}
typename eastl::vector<TYPE>::const_iterator begin() const
{
return m_data.begin();
}
typename eastl::vector<TYPE>::const_iterator end() const
{
return m_data.end();
}
typename eastl::vector<TYPE>::const_iterator cbegin() const
{
return m_data.cbegin();
}
typename eastl::vector<TYPE>::const_iterator cend() const
{
return m_data.cend();
}
~SlotMap() = default;
SlotMap& operator=(const SlotMap& p_slotMap) = default;
SlotMap& operator=(SlotMap&& p_slotMap) = default;
private:
eastl::vector<TYPE> m_data;
eastl::vector<IndexType> m_dataToSlots;
eastl::vector<SlotKey> m_slots;
IndexType m_freeSlotHead;
};
} // namespace Bigfoot
#endif
@@ -0,0 +1,95 @@
/*********************************************************************
* \file EASTLFormatters.hpp
*
* \author Romain BOULLARD
* \date December 2025
*********************************************************************/
#ifndef BIGFOOT_SYSTEM_EASTLFORMATTERS_HPP
#define BIGFOOT_SYSTEM_EASTLFORMATTERS_HPP
#include <Utils/TargetMacros.h>
#if defined(BIGFOOT_NOT_OPTIMIZED)
#include <quill/DeferredFormatCodec.h>
#endif
#include <format>
#include <EASTL/string.h>
#include <EASTL/string_view.h>
// STRING
template<>
struct std::formatter<eastl::string>
{
constexpr auto parse(std::format_parse_context& ctx)
{
return ctx.begin();
}
template<typename FormatContext>
auto format(const eastl::string& p_string, FormatContext& ctx) const
{
return std::format_to(ctx.out(), "{}", p_string.c_str());
}
};
#if defined BIGFOOT_NOT_OPTIMIZED
template<>
struct fmtquill::formatter<eastl::string>
{
constexpr auto parse(format_parse_context& ctx)
{
return ctx.begin();
}
auto format(const eastl::string& p_string, format_context& ctx) const
{
return fmtquill::format_to(ctx.out(), "{}", p_string.c_str());
}
};
template<>
struct quill::Codec<eastl::string>: quill::DeferredFormatCodec<eastl::string>
{
};
#endif
// STRING_VIEW
template<>
struct std::formatter<eastl::string_view>
{
constexpr auto parse(std::format_parse_context& ctx)
{
return ctx.begin();
}
template<typename FormatContext>
auto format(const eastl::string_view& p_stringView, FormatContext& ctx) const
{
return std::format_to(ctx.out(), "{}", p_stringView.data());
}
};
#if defined BIGFOOT_NOT_OPTIMIZED
template<>
struct fmtquill::formatter<eastl::string_view>
{
constexpr auto parse(format_parse_context& ctx)
{
return ctx.begin();
}
auto format(const eastl::string_view& p_stringView, format_context& ctx) const
{
return fmtquill::format_to(ctx.out(), "{}", p_stringView.data());
}
};
template<>
struct quill::Codec<eastl::string_view>: quill::DeferredFormatCodec<eastl::string_view>
{
};
#endif
#endif
@@ -0,0 +1,16 @@
namespace Bigfoot.Flat;
enum LogSinkType: byte
{
Console
}
enum LogLevel: byte
{
Debug,
Trace,
Info,
Warn,
Error,
Critical
}
@@ -0,0 +1,187 @@
/*********************************************************************
* \file Log.hpp
*
* \author Romain BOULLARD
* \date October 2025
*********************************************************************/
#ifndef BIGFOOT_UTILS_LOG_HPP
#define BIGFOOT_UTILS_LOG_HPP
#include <Utils/Log/EASTLFormatters.hpp>
#if defined BIGFOOT_NOT_OPTIMIZED
#include <Utils/Log/Log_generated.hpp>
#include <Utils/Singleton.hpp>
#include <EASTL/array.h>
#ifdef BIGFOOT_WINDOWS
#pragma warning(disable: 4702)
#endif
#include <quill/Backend.h>
#include <quill/Frontend.h>
#include <quill/LogMacros.h>
#include <quill/Logger.h>
#include <quill/sinks/ConsoleSink.h>
#if defined BIGFOOT_WINDOWS
#pragma warning(default: 4702)
#endif
namespace Bigfoot
{
class Log
{
public:
struct LoggerInfo
{
std::string m_name;
Flat::LogLevel m_level;
};
Log();
Log(const Log& p_logger) = delete;
Log(Log&& p_logger) = delete;
/**
* Register a logger.
*
* \param p_loggerInfo The logger to register
*/
[[nodiscard]]
quill::Logger* RegisterLogger(const LoggerInfo& p_loggerInfo);
/**
* Register a logger.
*
* \param p_loggerInfo The logger to get
* \return The logger, nullptr if it does not exist
*/
[[nodiscard]]
quill::Logger* GetLogger(const LoggerInfo& p_loggerInfo);
/**
* Changes the loglevel of a Logger.
*
* \param p_loggerInfo The logger to change
* \param p_level The new level
*/
void ChangeLoggerLogLevel(LoggerInfo& p_loggerInfo, const Flat::LogLevel p_level);
/*
* Flush all the loggers
*
*/
void Flush();
~Log();
Log& operator=(const Log& p_logger) = delete;
Log& operator=(Log&& p_logger) = delete;
private:
/**
* Set the LogLevel of a logger
*
* \param p_loggerInfo The logger to set
*/
void SetLoggerLevel(const LoggerInfo& p_loggerInfo);
/*
* The sinks
*/
eastl::array<std::shared_ptr<quill::Sink>, 1> m_sinks;
};
} // namespace Bigfoot
#define BIGFOOT_LOG_DEBUG(loggerName, fmt, ...) \
do \
{ \
if (quill::Logger* logger = Bigfoot::Singleton<Bigfoot::Log>::Instance().GetLogger(loggerName)) \
{ \
QUILL_LOG_DEBUG(logger, fmt __VA_OPT__(, ) __VA_ARGS__); \
} \
else \
{ \
QUILL_LOG_DEBUG(Bigfoot::Singleton<Bigfoot::Log>::Instance().RegisterLogger(loggerName), \
fmt __VA_OPT__(, ) __VA_ARGS__); \
} \
} while (0)
#define BIGFOOT_LOG_TRACE(loggerName, fmt, ...) \
do \
{ \
if (quill::Logger* logger = Bigfoot::Singleton<Bigfoot::Log>::Instance().GetLogger(loggerName)) \
{ \
QUILL_LOG_TRACE_L3(logger, fmt __VA_OPT__(, ) __VA_ARGS__); \
} \
else \
{ \
QUILL_LOG_TRACE_L3(Bigfoot::Singleton<Bigfoot::Log>::Instance().RegisterLogger(loggerName), \
fmt __VA_OPT__(, ) __VA_ARGS__); \
} \
} while (0)
#define BIGFOOT_LOG_INFO(loggerName, fmt, ...) \
do \
{ \
if (quill::Logger* logger = Bigfoot::Singleton<Bigfoot::Log>::Instance().GetLogger(loggerName)) \
{ \
QUILL_LOG_INFO(logger, fmt __VA_OPT__(, ) __VA_ARGS__); \
} \
else \
{ \
QUILL_LOG_INFO(Bigfoot::Singleton<Bigfoot::Log>::Instance().RegisterLogger(loggerName), \
fmt __VA_OPT__(, ) __VA_ARGS__); \
} \
} while (0)
#define BIGFOOT_LOG_WARN(loggerName, fmt, ...) \
do \
{ \
if (quill::Logger* logger = Bigfoot::Singleton<Bigfoot::Log>::Instance().GetLogger(loggerName)) \
{ \
QUILL_LOG_WARNING(logger, fmt __VA_OPT__(, ) __VA_ARGS__); \
} \
else \
{ \
QUILL_LOG_WARNING(Bigfoot::Singleton<Bigfoot::Log>::Instance().RegisterLogger(loggerName), \
fmt __VA_OPT__(, ) __VA_ARGS__); \
} \
} while (0)
#define BIGFOOT_LOG_ERROR(loggerName, fmt, ...) \
do \
{ \
if (quill::Logger* logger = Bigfoot::Singleton<Bigfoot::Log>::Instance().GetLogger(loggerName)) \
{ \
QUILL_LOG_ERROR(logger, fmt __VA_OPT__(, ) __VA_ARGS__); \
} \
else \
{ \
QUILL_LOG_ERROR(Bigfoot::Singleton<Bigfoot::Log>::Instance().RegisterLogger(loggerName), \
fmt __VA_OPT__(, ) __VA_ARGS__); \
} \
} while (0)
#define BIGFOOT_LOG_FATAL(loggerName, fmt, ...) \
do \
{ \
if (quill::Logger* logger = Bigfoot::Singleton<Bigfoot::Log>::Instance().GetLogger(loggerName)) \
{ \
QUILL_LOG_CRITICAL(logger, fmt __VA_OPT__(, ) __VA_ARGS__); \
} \
else \
{ \
QUILL_LOG_CRITICAL(Bigfoot::Singleton<Bigfoot::Log>::Instance().RegisterLogger(loggerName), \
fmt __VA_OPT__(, ) __VA_ARGS__); \
} \
} while (0)
#else
#define BIGFOOT_LOG_DEBUG(loggerName, fmt, ...)
#define BIGFOOT_LOG_TRACE(loggerName, fmt, ...)
#define BIGFOOT_LOG_INFO(loggerName, fmt, ...)
#define BIGFOOT_LOG_WARN(loggerName, fmt, ...)
#define BIGFOOT_LOG_ERROR(loggerName, fmt, ...)
#define BIGFOOT_LOG_FATAL(loggerName, fmt, ...)
#endif
#endif
@@ -0,0 +1,126 @@
// automatically generated by the FlatBuffers compiler, do not modify
#ifndef FLATBUFFERS_GENERATED_LOG_BIGFOOT_FLAT_H_
#define FLATBUFFERS_GENERATED_LOG_BIGFOOT_FLAT_H_
#include "flatbuffers/flatbuffers.h"
// Ensure the included flatbuffers.h is the same version as when this file was
// generated, otherwise it may not be compatible.
static_assert(FLATBUFFERS_VERSION_MAJOR == 25 &&
FLATBUFFERS_VERSION_MINOR == 12 &&
FLATBUFFERS_VERSION_REVISION == 19,
"Non-compatible flatbuffers version included");
#include "EASTL/unique_ptr.h"
#include "EASTL/string.h"
#include "EASTL/vector.h"
namespace Bigfoot {
namespace Flat {
enum class LogSinkType : int8_t {
Console = 0,
MIN = Console,
MAX = Console
};
inline const LogSinkType (&EnumValuesLogSinkType())[1] {
static const LogSinkType values[] = {
LogSinkType::Console
};
return values;
}
inline const char * const *EnumNamesLogSinkType() {
static const char * const names[2] = {
"Console",
nullptr
};
return names;
}
inline const char *EnumNameLogSinkType(LogSinkType e) {
if (::flatbuffers::IsOutRange(e, LogSinkType::Console, LogSinkType::Console)) return "";
const size_t index = static_cast<size_t>(e);
return EnumNamesLogSinkType()[index];
}
enum class LogLevel : int8_t {
Debug = 0,
Trace = 1,
Info = 2,
Warn = 3,
Error = 4,
Critical = 5,
MIN = Debug,
MAX = Critical
};
inline const LogLevel (&EnumValuesLogLevel())[6] {
static const LogLevel values[] = {
LogLevel::Debug,
LogLevel::Trace,
LogLevel::Info,
LogLevel::Warn,
LogLevel::Error,
LogLevel::Critical
};
return values;
}
inline const char * const *EnumNamesLogLevel() {
static const char * const names[7] = {
"Debug",
"Trace",
"Info",
"Warn",
"Error",
"Critical",
nullptr
};
return names;
}
inline const char *EnumNameLogLevel(LogLevel e) {
if (::flatbuffers::IsOutRange(e, LogLevel::Debug, LogLevel::Critical)) return "";
const size_t index = static_cast<size_t>(e);
return EnumNamesLogLevel()[index];
}
inline const ::flatbuffers::TypeTable *LogSinkTypeTypeTable() {
static const ::flatbuffers::TypeCode type_codes[] = {
{ ::flatbuffers::ET_CHAR, 0, 0 }
};
static const ::flatbuffers::TypeFunction type_refs[] = {
Bigfoot::Flat::LogSinkTypeTypeTable
};
static const ::flatbuffers::TypeTable tt = {
::flatbuffers::ST_ENUM, 1, type_codes, type_refs, nullptr, nullptr, nullptr
};
return &tt;
}
inline const ::flatbuffers::TypeTable *LogLevelTypeTable() {
static const ::flatbuffers::TypeCode type_codes[] = {
{ ::flatbuffers::ET_CHAR, 0, 0 },
{ ::flatbuffers::ET_CHAR, 0, 0 },
{ ::flatbuffers::ET_CHAR, 0, 0 },
{ ::flatbuffers::ET_CHAR, 0, 0 },
{ ::flatbuffers::ET_CHAR, 0, 0 },
{ ::flatbuffers::ET_CHAR, 0, 0 }
};
static const ::flatbuffers::TypeFunction type_refs[] = {
Bigfoot::Flat::LogLevelTypeTable
};
static const ::flatbuffers::TypeTable tt = {
::flatbuffers::ST_ENUM, 6, type_codes, type_refs, nullptr, nullptr, nullptr
};
return &tt;
}
} // namespace Flat
} // namespace Bigfoot
#endif // FLATBUFFERS_GENERATED_LOG_BIGFOOT_FLAT_H_
@@ -0,0 +1,21 @@
@AUTO_GENERATED_COMMENT@
/*********************************************************************
* \file @LOGGER_FILENAME@.generated.hpp
*
*********************************************************************/
#ifndef BIGFOOT_@LOGGER_FILENAME_UPPER@_GENERATED_HPP
#define BIGFOOT_@LOGGER_FILENAME_UPPER@_GENERATED_HPP
#include <Utils/Log/Log.hpp>
#if defined BIGFOOT_NOT_OPTIMIZED
namespace Bigfoot
{
/*
* Logger
*/
inline Log::LoggerInfo @LOGGER_NAME@ {"@LOGGER_NAME@", Flat::LogLevel::Trace};
} // namespace Bigfoot
#endif
#endif
@@ -0,0 +1,64 @@
/*********************************************************************
* \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
@@ -0,0 +1,56 @@
/*********************************************************************
* \file UtilsAssertHandler.hpp
*
* \author Romain BOULLARD
* \date May 2026
*********************************************************************/
#ifndef BIGFOOT_UTILS_UTILSASSERTHANDLER_HPP
#define BIGFOOT_UTILS_UTILSASSERTHANDLER_HPP
#include <Utils/Assert.hpp>
#include <Utils/Log/Log.hpp>
#include <Utils/UtilsLogger_generated.hpp>
#if defined BIGFOOT_NOT_OPTIMIZED
#include <EASTL/utility.h>
#include <format>
#include <source_location>
#include <string_view>
namespace Bigfoot
{
class UtilsAssertHandler
{
public:
UtilsAssertHandler() = delete;
UtilsAssertHandler(const UtilsAssertHandler& p_handler) = delete;
UtilsAssertHandler(UtilsAssertHandler&& p_handler) = delete;
~UtilsAssertHandler() = delete;
/**
* Handle an assertion.
*
* \param p_location Location of the assertion.
* \param p_format Format string for the assertion message.
* \param p_args Arguments for the format string.
*/
template<typename... ARGS>
static void Handle(const std::source_location& p_location, std::format_string<ARGS...> p_format, ARGS&&... p_args)
{
BIGFOOT_LOG_FATAL(UTILS_LOGGER,
"Assert: {} (File:{}, Line:{}, Function:{}\n",
std::format(p_format, std::forward<ARGS>(p_args)...),
p_location.file_name(),
p_location.line(),
p_location.function_name());
}
UtilsAssertHandler& operator=(const UtilsAssertHandler& p_handler) = delete;
UtilsAssertHandler& operator=(UtilsAssertHandler&& p_handler) = delete;
};
} // namespace Bigfoot
#endif
#endif
@@ -0,0 +1,21 @@
// AUTO-GENERATED DO NOT TOUCH
/*********************************************************************
* \file UtilsLogger.generated.hpp
*
*********************************************************************/
#ifndef BIGFOOT_UTILSLOGGER_GENERATED_HPP
#define BIGFOOT_UTILSLOGGER_GENERATED_HPP
#include <Utils/Log/Log.hpp>
#if defined BIGFOOT_NOT_OPTIMIZED
namespace Bigfoot
{
/*
* Logger
*/
inline Log::LoggerInfo UTILS_LOGGER {"UTILS_LOGGER", Flat::LogLevel::Trace};
} // namespace Bigfoot
#endif
#endif
+104
View File
@@ -0,0 +1,104 @@
/*******************************************************************
* \file Log.cpp
*
* \author Romain BOULLARD
* \date October 2025
*********************************************************************/
#include <Utils/Log/Log.hpp>
#if defined BIGFOOT_NOT_OPTIMIZED
namespace Bigfoot
{
Log::Log()
{
quill::Backend::start();
m_sinks[static_cast<std::size_t>(Flat::LogSinkType::Console)] =
quill::Frontend::create_or_get_sink<quill::ConsoleSink>(
std::string {Flat::EnumNameLogSinkType(Flat::LogSinkType::Console)});
}
/****************************************************************************************/
quill::Logger* Log::RegisterLogger(const LoggerInfo& p_loggerInfo)
{
quill::Logger* logger = quill::Frontend::create_or_get_logger(
p_loggerInfo.m_name,
m_sinks[static_cast<std::size_t>(Flat::LogSinkType::Console)]);
SetLoggerLevel(p_loggerInfo);
return logger;
}
/****************************************************************************************/
quill::Logger* Log::GetLogger(const LoggerInfo& p_loggerInfo)
{
return quill::Frontend::get_logger(p_loggerInfo.m_name);
}
/****************************************************************************************/
void Log::ChangeLoggerLogLevel(LoggerInfo& p_loggerInfo, const Flat::LogLevel p_level)
{
p_loggerInfo.m_level = p_level;
SetLoggerLevel(p_loggerInfo);
}
/****************************************************************************************/
void Log::SetLoggerLevel(const LoggerInfo& p_loggerInfo)
{
constexpr auto logLevelToQuillLogLevel = [](const Flat::LogLevel p_level) constexpr -> quill::LogLevel
{
switch (p_level)
{
case Flat::LogLevel::Debug:
return quill::LogLevel::Debug;
case Flat::LogLevel::Trace:
return quill::LogLevel::TraceL3;
case Flat::LogLevel::Info:
return quill::LogLevel::Info;
case Flat::LogLevel::Warn:
return quill::LogLevel::Warning;
case Flat::LogLevel::Error:
return quill::LogLevel::Error;
case Flat::LogLevel::Critical:
return quill::LogLevel::Critical;
}
return quill::LogLevel::TraceL3;
};
if (quill::Logger* logger = GetLogger(p_loggerInfo))
{
logger->set_log_level(logLevelToQuillLogLevel(p_loggerInfo.m_level));
}
}
/****************************************************************************************/
void Log::Flush()
{
for (quill::Logger* logger: quill::Frontend::get_all_loggers())
{
logger->flush_log();
}
}
/****************************************************************************************/
Log::~Log()
{
Flush();
for (quill::Logger* logger: quill::Frontend::get_all_loggers())
{
quill::Frontend::remove_logger(logger);
}
quill::Backend::stop();
}
} // namespace Bigfoot
#endif
+98
View File
@@ -0,0 +1,98 @@
/*********************************************************************
* \file MimallocImpl.cpp
*
* \author Romain BOULLARD
* \date October 2025
*********************************************************************/
#include <Utils/Profiler.hpp>
#if defined BIGFOOT_WINDOWS
#pragma comment(linker, "/include:mi_version")
#pragma warning(disable: 4100 4559)
#elif defined BIGFOOT_LINUX
#if defined(__GNUC__) && !defined(__llvm__) && !defined(__INTEL_COMPILER)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-parameter"
#else
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunused-parameter"
#endif
#endif
// Taken from mimalloc-new-delete.h
// clang-format off
// ----------------------------------------------------------------------------
// This header provides convenient overrides for the new and
// delete operations in C++.
//
// This header should be included in only one source file!
//
// On Windows, or when linking dynamically with mimalloc, these
// can be more performant than the standard new-delete operations.
// See <https://en.cppreference.com/w/cpp/memory/new/operator_new>
// ---------------------------------------------------------------------------
#if defined(__cplusplus)
#include <new>
#include <mimalloc.h>
#if defined(_MSC_VER) && defined(_Ret_notnull_) && defined(_Post_writable_byte_size_)
// stay consistent with VCRT definitions
#define mi_decl_new(n) mi_decl_nodiscard mi_decl_restrict _Ret_notnull_ _Post_writable_byte_size_(n)
#define mi_decl_new_nothrow(n) mi_decl_nodiscard mi_decl_restrict _Ret_maybenull_ _Success_(return != NULL) _Post_writable_byte_size_(n)
#else
#define mi_decl_new(n) mi_decl_nodiscard mi_decl_restrict
#define mi_decl_new_nothrow(n) mi_decl_nodiscard mi_decl_restrict
#endif
void operator delete(void* p) noexcept { mi_free(p); BIGFOOT_PROFILER_MEMORY_FREE(p); };
void operator delete[](void* p) noexcept { mi_free(p); BIGFOOT_PROFILER_MEMORY_FREE(p); };
void operator delete (void* p, const std::nothrow_t&) noexcept { mi_free(p); BIGFOOT_PROFILER_MEMORY_FREE(p); }
void operator delete[](void* p, const std::nothrow_t&) noexcept { mi_free(p); BIGFOOT_PROFILER_MEMORY_FREE(p); }
mi_decl_new(n) void* operator new(std::size_t n) noexcept(false) { void* p = mi_new(n); BIGFOOT_PROFILER_MEMORY_ALLOC(p, n); return p; }
mi_decl_new(n) void* operator new[](std::size_t n) noexcept(false) { void* p = mi_new(n); BIGFOOT_PROFILER_MEMORY_ALLOC(p, n); return p; }
mi_decl_new_nothrow(n) void* operator new (std::size_t n, const std::nothrow_t& tag) noexcept { (void)(tag); void* p = mi_new_nothrow(n); BIGFOOT_PROFILER_MEMORY_ALLOC(p, n); return p; }
mi_decl_new_nothrow(n) void* operator new[](std::size_t n, const std::nothrow_t& tag) noexcept { (void)(tag); void* p = mi_new_nothrow(n); BIGFOOT_PROFILER_MEMORY_ALLOC(p, n); return p; }
// Not from mimalloc-new-delete.h, but necessary for EASTL
void* operator new[](size_t size, const char* name, int flags, unsigned debugFlags, const char* file, int line) noexcept(false) { void* p = mi_new(size); BIGFOOT_PROFILER_MEMORY_ALLOC(p, size); return p; }
#if (__cplusplus >= 201402L || _MSC_VER >= 1916)
void operator delete (void* p, std::size_t n) noexcept { mi_free_size(p,n); BIGFOOT_PROFILER_MEMORY_FREE(p); };
void operator delete[](void* p, std::size_t n) noexcept { mi_free_size(p,n); BIGFOOT_PROFILER_MEMORY_FREE(p); };
#endif
#if (__cplusplus > 201402L || defined(__cpp_aligned_new))
void operator delete (void* p, std::align_val_t al) noexcept { mi_free_aligned(p, static_cast<size_t>(al)); BIGFOOT_PROFILER_MEMORY_FREE(p); }
void operator delete[](void* p, std::align_val_t al) noexcept { mi_free_aligned(p, static_cast<size_t>(al)); BIGFOOT_PROFILER_MEMORY_FREE(p); }
void operator delete (void* p, std::size_t n, std::align_val_t al) noexcept { mi_free_size_aligned(p, n, static_cast<size_t>(al)); BIGFOOT_PROFILER_MEMORY_FREE(p); };
void operator delete[](void* p, std::size_t n, std::align_val_t al) noexcept { mi_free_size_aligned(p, n, static_cast<size_t>(al)); BIGFOOT_PROFILER_MEMORY_FREE(p); };
void operator delete (void* p, std::align_val_t al, const std::nothrow_t&) noexcept { mi_free_aligned(p, static_cast<size_t>(al)); BIGFOOT_PROFILER_MEMORY_FREE(p); }
void operator delete[](void* p, std::align_val_t al, const std::nothrow_t&) noexcept { mi_free_aligned(p, static_cast<size_t>(al)); BIGFOOT_PROFILER_MEMORY_FREE(p); }
void* operator new (std::size_t n, std::align_val_t al) noexcept(false) { void* p = mi_new_aligned(n, static_cast<size_t>(al)); BIGFOOT_PROFILER_MEMORY_ALLOC(p, n); return p; }
void* operator new[](std::size_t n, std::align_val_t al) noexcept(false) { void* p = mi_new_aligned(n, static_cast<size_t>(al)); BIGFOOT_PROFILER_MEMORY_ALLOC(p, n); return p; }
void* operator new (std::size_t n, std::align_val_t al, const std::nothrow_t&) noexcept { void* p = mi_new_aligned_nothrow(n, static_cast<size_t>(al)); BIGFOOT_PROFILER_MEMORY_ALLOC(p, n); return p; }
void* operator new[](std::size_t n, std::align_val_t al, const std::nothrow_t&) noexcept { void* p = mi_new_aligned_nothrow(n, static_cast<size_t>(al)); BIGFOOT_PROFILER_MEMORY_ALLOC(p, n); return p; }
// Not from mimalloc-new-delete.h, but necessary for EASTL
void* operator new[](size_t size, size_t alignment, size_t alignmentOffset, const char* pName, int flags, unsigned debugFlags, const char* file, int line) noexcept(false) { void* p = mi_new_aligned(size, alignment); BIGFOOT_PROFILER_MEMORY_ALLOC(p, size); return p; }
#endif
#endif
// clang-format on
#if defined BIGFOOT_WINDOWS
#pragma warning(default: 4100 4559)
#elif defined BIGFOOT_LINUX
#if defined(__GNUC__) && !defined(__llvm__) && !defined(__INTEL_COMPILER)
#pragma GCC diagnostic pop
#else
#pragma clang diagnostic pop
#endif
#endif