starting to work on headless support

This commit is contained in:
Kbz-8
2025-06-24 07:10:02 +02:00
parent ea9bd71245
commit 26eab93f9f
4 changed files with 38 additions and 19 deletions

View File

@@ -22,7 +22,7 @@ namespace mlx
MLX_PROFILE_FUNCTION();
s_instance = this;
m_drop_sdl_responsability = SDL_WasInit(SDL_INIT_VIDEO);
m_drop_sdl_responsability = SDL_WasInit(SDL_INIT_VIDEO) || std::getenv("MLX_HEADLESS_MODE") != nullptr;
if(m_drop_sdl_responsability) // is case the mlx is running in a sandbox like MacroUnitTester where SDL is already init
return;
SDL_SetMemoryFunctions(MemManager::Get().Malloc, MemManager::Get().Calloc, MemManager::Get().Realloc, MemManager::Get().Free);

View File

@@ -7,7 +7,14 @@ namespace mlx
static std::random_device random_device;
static std::mt19937_64 engine(random_device());
static std::uniform_int_distribution<std::uint64_t> uniform_distribution;
static std::unordered_set<std::uint64_t> registry;
UUID::UUID() : m_uuid(uniform_distribution(engine)) {}
UUID::UUID(std::uint64_t uuid) : m_uuid(uuid) {}
UUID::UUID()
{
do
{
m_uuid = uniform_distribution(engine);
} while(registry.contains(m_uuid));
registry.emplace(m_uuid);
}
}