6#include <Common/assertion.h>
7#include <Common/primitive_type.h>
13namespace ph {
class EngineInitSettings; }
30 static uint32 nextUInt32Number();
32 static std::atomic<uint32> s_numberSource;
39 static_assert(CHAR_BIT == 8);
46 const auto number = nextUInt32Number();
47 if constexpr(std::is_same_v<T, uint32>)
51 else if constexpr(std::is_same_v<T, uint64>)
53 const auto lower32 = uint64(
murmur3_32(number, 2237617));
54 const auto upper32 = uint64(
murmur3_32(number, 3237557)) << 32;
55 return upper32 | lower32;
59 PH_STATIC_ASSERT_DEPENDENT_FALSE(T,
60 "Unsupported seed type `T`. You can provide your own implementation.");
64inline uint32 DeterministicSeeder::nextUInt32Number()
66 PH_ASSERT_NE(s_step, 0);
68 return s_numberSource.fetch_add(s_step, std::memory_order_relaxed);
Options for initializing core engine. These settings are loaded on engine startup and remains constan...
Definition EngineInitSettings.h:20
Convenient thread-safe seed provider for RNGs. Do not use this for cryptography.
Definition DeterministicSeeder.h:22
static void init(const EngineInitSettings &settings)
Definition DeterministicSeeder.cpp:20
static T nextSeed()
Definition DeterministicSeeder.h:37
Math functions and utilities.
Definition TransformInfo.h:10
uint32 murmur3_32(const T &data, uint32 seed)
Generate 32-bit hash values using MurmurHash3. Note that there are no collisions when T has <= 32 bit...
Definition hash.ipp:119
The root for all renderer implementations.
Definition EEngineProject.h:6