Browse Source

Remove the allocator from Scne

Panagiotis Christopoulos Charitos 3 years ago
parent
commit
10ed61e0e2

+ 4 - 4
AnKi/Renderer/Common.h

@@ -101,7 +101,7 @@ public:
 class RenderingContext
 class RenderingContext
 {
 {
 public:
 public:
-	StackAllocator<U8> m_tempAllocator;
+	StackMemoryPool* m_tempPool = nullptr;
 	RenderQueue* m_renderQueue = nullptr;
 	RenderQueue* m_renderQueue = nullptr;
 
 
 	RenderGraphDescription m_renderGraphDescr;
 	RenderGraphDescription m_renderGraphDescr;
@@ -114,9 +114,9 @@ public:
 
 
 	ClusteredShadingContext m_clusteredShading;
 	ClusteredShadingContext m_clusteredShading;
 
 
-	RenderingContext(const StackAllocator<U8>& alloc)
-		: m_tempAllocator(alloc)
-		, m_renderGraphDescr(alloc)
+	RenderingContext(StackMemoryPool* pool)
+		: m_tempPool(pool)
+		, m_renderGraphDescr(pool)
 	{
 	{
 	}
 	}
 
 

+ 1 - 1
AnKi/Renderer/RenderQueue.h

@@ -42,7 +42,7 @@ public:
 	CommandBufferPtr m_commandBuffer;
 	CommandBufferPtr m_commandBuffer;
 	SamplerPtr m_sampler; ///< A trilinear sampler with anisotropy.
 	SamplerPtr m_sampler; ///< A trilinear sampler with anisotropy.
 	StagingGpuMemoryPool* m_stagingGpuAllocator ANKI_DEBUG_CODE(= nullptr);
 	StagingGpuMemoryPool* m_stagingGpuAllocator ANKI_DEBUG_CODE(= nullptr);
-	StackAllocator<U8> m_frameAllocator;
+	StackMemoryPool* m_framePool = nullptr;
 	Bool m_debugDraw; ///< If true the drawcall should be drawing some kind of debug mesh.
 	Bool m_debugDraw; ///< If true the drawcall should be drawing some kind of debug mesh.
 	BitSet<U(RenderQueueDebugDrawFlag::kCount), U32> m_debugDrawFlags = {false};
 	BitSet<U(RenderQueueDebugDrawFlag::kCount), U32> m_debugDrawFlags = {false};
 };
 };

+ 4 - 5
AnKi/Renderer/Renderer.h

@@ -73,8 +73,7 @@ public:
 
 
 	/// Init the renderer.
 	/// Init the renderer.
 	Error init(ThreadHive* hive, ResourceManager* resources, GrManager* gr, StagingGpuMemoryPool* stagingMem,
 	Error init(ThreadHive* hive, ResourceManager* resources, GrManager* gr, StagingGpuMemoryPool* stagingMem,
-			   UiManager* ui, HeapAllocator<U8> alloc, ConfigSet* config, Timestamp* globTimestamp,
-			   UVec2 swapchainSize);
+			   UiManager* ui, HeapMemoryPool* pool, ConfigSet* config, Timestamp* globTimestamp, UVec2 swapchainSize);
 
 
 	/// This function does all the rendering stages and produces a final result.
 	/// This function does all the rendering stages and produces a final result.
 	Error populateRenderGraph(RenderingContext& ctx);
 	Error populateRenderGraph(RenderingContext& ctx);
@@ -118,9 +117,9 @@ public:
 		return *m_gr;
 		return *m_gr;
 	}
 	}
 
 
-	HeapAllocator<U8> getAllocator() const
+	HeapMemoryPool& getMemoryPool() const
 	{
 	{
-		return m_alloc;
+		return *m_pool;
 	}
 	}
 
 
 	ResourceManager& getResourceManager()
 	ResourceManager& getResourceManager()
@@ -234,7 +233,7 @@ private:
 	UiManager* m_ui = nullptr;
 	UiManager* m_ui = nullptr;
 	Timestamp* m_globTimestamp = nullptr;
 	Timestamp* m_globTimestamp = nullptr;
 	ConfigSet* m_config = nullptr;
 	ConfigSet* m_config = nullptr;
-	HeapAllocator<U8> m_alloc;
+	mutable HeapMemoryPool* m_pool = nullptr;
 
 
 	/// @name Rendering stages
 	/// @name Rendering stages
 	/// @{
 	/// @{

+ 2 - 2
AnKi/Renderer/RendererObject.cpp

@@ -20,9 +20,9 @@ const GrManager& RendererObject::getGrManager() const
 	return m_r->getGrManager();
 	return m_r->getGrManager();
 }
 }
 
 
-HeapAllocator<U8> RendererObject::getAllocator() const
+HeapMemoryPool& RendererObject::getMemoryPool() const
 {
 {
-	return m_r->getAllocator();
+	return m_r->getMemoryPool();
 }
 }
 
 
 ResourceManager& RendererObject::getResourceManager()
 ResourceManager& RendererObject::getResourceManager()

+ 1 - 1
AnKi/Renderer/RendererObject.h

@@ -35,7 +35,7 @@ public:
 	{
 	{
 	}
 	}
 
 
-	HeapAllocator<U8> getAllocator() const;
+	HeapMemoryPool& getMemoryPool() const;
 
 
 	virtual void getDebugRenderTarget([[maybe_unused]] CString rtName,
 	virtual void getDebugRenderTarget([[maybe_unused]] CString rtName,
 									  [[maybe_unused]] Array<RenderTargetHandle, kMaxDebugRenderTargets>& handles,
 									  [[maybe_unused]] Array<RenderTargetHandle, kMaxDebugRenderTargets>& handles,

+ 0 - 8
AnKi/Scene/Common.h

@@ -18,14 +18,6 @@ namespace anki {
 #define ANKI_SCENE_LOGE(...) ANKI_LOG("SCEN", kError, __VA_ARGS__)
 #define ANKI_SCENE_LOGE(...) ANKI_LOG("SCEN", kError, __VA_ARGS__)
 #define ANKI_SCENE_LOGW(...) ANKI_LOG("SCEN", kWarning, __VA_ARGS__)
 #define ANKI_SCENE_LOGW(...) ANKI_LOG("SCEN", kWarning, __VA_ARGS__)
 #define ANKI_SCENE_LOGF(...) ANKI_LOG("SCEN", kFatal, __VA_ARGS__)
 #define ANKI_SCENE_LOGF(...) ANKI_LOG("SCEN", kFatal, __VA_ARGS__)
-
-/// The type of the scene's allocator
-template<typename T>
-using SceneAllocator = HeapAllocator<T>;
-
-/// The type of the scene's frame allocator
-template<typename T>
-using SceneFrameAllocator = StackAllocator<T>;
 /// @}
 /// @}
 
 
 } // end namespace anki
 } // end namespace anki

+ 3 - 3
AnKi/Scene/Components/FrustumComponent.cpp

@@ -27,7 +27,7 @@ FrustumComponent::FrustumComponent(SceneNode* node)
 
 
 FrustumComponent::~FrustumComponent()
 FrustumComponent::~FrustumComponent()
 {
 {
-	m_coverageBuff.m_depthMap.destroy(m_node->getAllocator());
+	m_coverageBuff.m_depthMap.destroy(m_node->getMemoryPool());
 }
 }
 
 
 Bool FrustumComponent::updateInternal()
 Bool FrustumComponent::updateInternal()
@@ -145,8 +145,8 @@ void FrustumComponent::fillCoverageBufferCallback(void* userData, F32* depthValu
 	ANKI_ASSERT(userData && depthValues && width > 0 && height > 0);
 	ANKI_ASSERT(userData && depthValues && width > 0 && height > 0);
 	FrustumComponent& self = *static_cast<FrustumComponent*>(userData);
 	FrustumComponent& self = *static_cast<FrustumComponent*>(userData);
 
 
-	self.m_coverageBuff.m_depthMap.destroy(self.m_node->getAllocator());
-	self.m_coverageBuff.m_depthMap.create(self.m_node->getAllocator(), width * height);
+	self.m_coverageBuff.m_depthMap.destroy(self.m_node->getMemoryPool());
+	self.m_coverageBuff.m_depthMap.create(self.m_node->getMemoryPool(), width * height);
 	memcpy(&self.m_coverageBuff.m_depthMap[0], depthValues, self.m_coverageBuff.m_depthMap.getSizeInBytes());
 	memcpy(&self.m_coverageBuff.m_depthMap[0], depthValues, self.m_coverageBuff.m_depthMap.getSizeInBytes());
 
 
 	self.m_coverageBuff.m_depthMapWidth = width;
 	self.m_coverageBuff.m_depthMapWidth = width;

+ 4 - 4
AnKi/Scene/Components/JointComponent.cpp

@@ -31,7 +31,7 @@ void JointComponent::removeAllJoints()
 		JointNode* node = &m_jointList.getFront();
 		JointNode* node = &m_jointList.getFront();
 		m_jointList.popFront();
 		m_jointList.popFront();
 
 
-		m_node->getAllocator().deleteInstance(node);
+		deleteInstance(m_node->getMemoryPool(), node);
 	}
 	}
 }
 }
 
 
@@ -69,7 +69,7 @@ void JointComponent::newJoint(const Vec3& relPosFactor, F32 breakingImpulse, TAr
 			bodyc->getPhysicsBody(), relPos, std::forward<TArgs>(args)...);
 			bodyc->getPhysicsBody(), relPos, std::forward<TArgs>(args)...);
 		joint->setBreakingImpulseThreshold(breakingImpulse);
 		joint->setBreakingImpulseThreshold(breakingImpulse);
 
 
-		JointNode* newNode = m_node->getAllocator().newInstance<JointNode>();
+		JointNode* newNode = newInstance<JointNode>(m_node->getMemoryPool());
 		newNode->m_joint = std::move(joint);
 		newNode->m_joint = std::move(joint);
 		m_jointList.pushBack(newNode);
 		m_jointList.pushBack(newNode);
 	}
 	}
@@ -102,7 +102,7 @@ void JointComponent::newPoint2PointJoint2(const Vec3& relPosFactorA, const Vec3&
 			bodycA->getPhysicsBody(), relPosA, bodycB->getPhysicsBody(), relPosB);
 			bodycA->getPhysicsBody(), relPosA, bodycB->getPhysicsBody(), relPosB);
 		joint->setBreakingImpulseThreshold(breakingImpulse);
 		joint->setBreakingImpulseThreshold(breakingImpulse);
 
 
-		JointNode* newNode = m_node->getAllocator().newInstance<JointNode>();
+		JointNode* newNode = newInstance<JointNode>(m_node->getMemoryPool());
 		newNode->m_joint = std::move(joint);
 		newNode->m_joint = std::move(joint);
 		newNode->m_parentNode = m_node->getParent();
 		newNode->m_parentNode = m_node->getParent();
 		m_jointList.pushBack(newNode);
 		m_jointList.pushBack(newNode);
@@ -131,7 +131,7 @@ Error JointComponent::update(SceneComponentUpdateInfo& info, Bool& updated)
 			if(otherNode.m_parentNode != info.m_node->getParent() || otherNode.m_joint->isBroken())
 			if(otherNode.m_parentNode != info.m_node->getParent() || otherNode.m_joint->isBroken())
 			{
 			{
 				m_jointList.erase(&otherNode);
 				m_jointList.erase(&otherNode);
-				info.m_node->getAllocator().deleteInstance(&otherNode);
+				deleteInstance(info.m_node->getMemoryPool(), &otherNode);
 				erasedOne = true;
 				erasedOne = true;
 				updated = true;
 				updated = true;
 				break;
 				break;

+ 3 - 3
AnKi/Scene/Components/ModelComponent.cpp

@@ -21,7 +21,7 @@ ModelComponent::ModelComponent(SceneNode* node)
 
 
 ModelComponent::~ModelComponent()
 ModelComponent::~ModelComponent()
 {
 {
-	m_modelPatchMergeKeys.destroy(m_node->getAllocator());
+	m_modelPatchMergeKeys.destroy(m_node->getMemoryPool());
 }
 }
 
 
 Error ModelComponent::loadModelResource(CString filename)
 Error ModelComponent::loadModelResource(CString filename)
@@ -32,8 +32,8 @@ Error ModelComponent::loadModelResource(CString filename)
 	ANKI_CHECK(m_node->getSceneGraph().getResourceManager().loadResource(filename, rsrc));
 	ANKI_CHECK(m_node->getSceneGraph().getResourceManager().loadResource(filename, rsrc));
 	m_model = std::move(rsrc);
 	m_model = std::move(rsrc);
 
 
-	m_modelPatchMergeKeys.destroy(m_node->getAllocator());
-	m_modelPatchMergeKeys.create(m_node->getAllocator(), m_model->getModelPatches().getSize());
+	m_modelPatchMergeKeys.destroy(m_node->getMemoryPool());
+	m_modelPatchMergeKeys.create(m_node->getMemoryPool(), m_model->getModelPatches().getSize());
 
 
 	for(U32 i = 0; i < m_model->getModelPatches().getSize(); ++i)
 	for(U32 i = 0; i < m_model->getModelPatches().getSize(); ++i)
 	{
 	{

+ 8 - 8
AnKi/Scene/Components/ParticleEmitterComponent.cpp

@@ -203,8 +203,8 @@ ParticleEmitterComponent::ParticleEmitterComponent(SceneNode* node)
 
 
 ParticleEmitterComponent::~ParticleEmitterComponent()
 ParticleEmitterComponent::~ParticleEmitterComponent()
 {
 {
-	m_simpleParticles.destroy(m_node->getAllocator());
-	m_physicsParticles.destroy(m_node->getAllocator());
+	m_simpleParticles.destroy(m_node->getMemoryPool());
+	m_physicsParticles.destroy(m_node->getMemoryPool());
 }
 }
 
 
 Error ParticleEmitterComponent::loadParticleEmitterResource(CString filename)
 Error ParticleEmitterComponent::loadParticleEmitterResource(CString filename)
@@ -221,8 +221,8 @@ Error ParticleEmitterComponent::loadParticleEmitterResource(CString filename)
 	m_props = m_particleEmitterResource->getProperties();
 	m_props = m_particleEmitterResource->getProperties();
 
 
 	// Cleanup
 	// Cleanup
-	m_simpleParticles.destroy(m_node->getAllocator());
-	m_physicsParticles.destroy(m_node->getAllocator());
+	m_simpleParticles.destroy(m_node->getMemoryPool());
+	m_physicsParticles.destroy(m_node->getMemoryPool());
 
 
 	// Init particles
 	// Init particles
 	m_simulationType = (m_props.m_usePhysicsEngine) ? SimulationType::kPhysicsEngine : SimulationType::kSimple;
 	m_simulationType = (m_props.m_usePhysicsEngine) ? SimulationType::kPhysicsEngine : SimulationType::kSimple;
@@ -234,16 +234,16 @@ Error ParticleEmitterComponent::loadParticleEmitterResource(CString filename)
 		PhysicsBodyInitInfo binit;
 		PhysicsBodyInitInfo binit;
 		binit.m_shape = std::move(collisionShape);
 		binit.m_shape = std::move(collisionShape);
 
 
-		m_physicsParticles.resizeStorage(m_node->getAllocator(), m_props.m_maxNumOfParticles);
+		m_physicsParticles.resizeStorage(m_node->getMemoryPool(), m_props.m_maxNumOfParticles);
 		for(U32 i = 0; i < m_props.m_maxNumOfParticles; i++)
 		for(U32 i = 0; i < m_props.m_maxNumOfParticles; i++)
 		{
 		{
 			binit.m_mass = getRandomRange(m_props.m_particle.m_minMass, m_props.m_particle.m_maxMass);
 			binit.m_mass = getRandomRange(m_props.m_particle.m_minMass, m_props.m_particle.m_maxMass);
-			m_physicsParticles.emplaceBack(m_node->getAllocator(), binit, m_node, this);
+			m_physicsParticles.emplaceBack(m_node->getMemoryPool(), binit, m_node, this);
 		}
 		}
 	}
 	}
 	else
 	else
 	{
 	{
-		m_simpleParticles.create(m_node->getAllocator(), m_props.m_maxNumOfParticles);
+		m_simpleParticles.create(m_node->getMemoryPool(), m_props.m_maxNumOfParticles);
 	}
 	}
 
 
 	m_vertBuffSize = m_props.m_maxNumOfParticles * kVertexSize;
 	m_vertBuffSize = m_props.m_maxNumOfParticles * kVertexSize;
@@ -285,7 +285,7 @@ void ParticleEmitterComponent::simulate(Second prevUpdateTime, Second crntTime,
 	Vec3 aabbMax(kMinF32);
 	Vec3 aabbMax(kMinF32);
 	m_aliveParticleCount = 0;
 	m_aliveParticleCount = 0;
 
 
-	F32* verts = reinterpret_cast<F32*>(m_node->getFrameAllocator().allocate(m_vertBuffSize));
+	F32* verts = static_cast<F32*>(m_node->getFrameMemoryPool().allocate(m_vertBuffSize, alignof(F32)));
 	m_verts = verts;
 	m_verts = verts;
 
 
 	F32 maxParticleSize = -1.0f;
 	F32 maxParticleSize = -1.0f;

+ 3 - 3
AnKi/Scene/Components/ScriptComponent.cpp

@@ -23,7 +23,7 @@ ScriptComponent::ScriptComponent(SceneNode* node)
 
 
 ScriptComponent::~ScriptComponent()
 ScriptComponent::~ScriptComponent()
 {
 {
-	m_node->getAllocator().deleteInstance(m_env);
+	deleteInstance(m_node->getMemoryPool(), m_env);
 }
 }
 
 
 Error ScriptComponent::loadScriptResource(CString fname)
 Error ScriptComponent::loadScriptResource(CString fname)
@@ -34,9 +34,9 @@ Error ScriptComponent::loadScriptResource(CString fname)
 	// Create the env
 	// Create the env
 	if(m_env)
 	if(m_env)
 	{
 	{
-		m_node->getAllocator().deleteInstance(m_env);
+		deleteInstance(m_node->getMemoryPool(), m_env);
 	}
 	}
-	m_env = m_node->getAllocator().newInstance<ScriptEnvironment>();
+	m_env = newInstance<ScriptEnvironment>(m_node->getMemoryPool());
 	ANKI_CHECK(m_env->init(&m_node->getSceneGraph().getScriptManager()));
 	ANKI_CHECK(m_env->init(&m_node->getSceneGraph().getScriptManager()));
 
 
 	// Exec the script
 	// Exec the script

+ 9 - 9
AnKi/Scene/Components/SkinComponent.cpp

@@ -23,22 +23,22 @@ SkinComponent::SkinComponent(SceneNode* node)
 
 
 SkinComponent::~SkinComponent()
 SkinComponent::~SkinComponent()
 {
 {
-	m_boneTrfs[0].destroy(m_node->getAllocator());
-	m_boneTrfs[1].destroy(m_node->getAllocator());
-	m_animationTrfs.destroy(m_node->getAllocator());
+	m_boneTrfs[0].destroy(m_node->getMemoryPool());
+	m_boneTrfs[1].destroy(m_node->getMemoryPool());
+	m_animationTrfs.destroy(m_node->getMemoryPool());
 }
 }
 
 
 Error SkinComponent::loadSkeletonResource(CString fname)
 Error SkinComponent::loadSkeletonResource(CString fname)
 {
 {
 	ANKI_CHECK(m_node->getSceneGraph().getResourceManager().loadResource(fname, m_skeleton));
 	ANKI_CHECK(m_node->getSceneGraph().getResourceManager().loadResource(fname, m_skeleton));
 
 
-	m_boneTrfs[0].destroy(m_node->getAllocator());
-	m_boneTrfs[1].destroy(m_node->getAllocator());
-	m_animationTrfs.destroy(m_node->getAllocator());
+	m_boneTrfs[0].destroy(m_node->getMemoryPool());
+	m_boneTrfs[1].destroy(m_node->getMemoryPool());
+	m_animationTrfs.destroy(m_node->getMemoryPool());
 
 
-	m_boneTrfs[0].create(m_node->getAllocator(), m_skeleton->getBones().getSize(), Mat4::getIdentity());
-	m_boneTrfs[1].create(m_node->getAllocator(), m_skeleton->getBones().getSize(), Mat4::getIdentity());
-	m_animationTrfs.create(m_node->getAllocator(), m_skeleton->getBones().getSize(),
+	m_boneTrfs[0].create(m_node->getMemoryPool(), m_skeleton->getBones().getSize(), Mat4::getIdentity());
+	m_boneTrfs[1].create(m_node->getMemoryPool(), m_skeleton->getBones().getSize(), Mat4::getIdentity());
+	m_animationTrfs.create(m_node->getMemoryPool(), m_skeleton->getBones().getSize(),
 						   {Vec3(0.0f), Quat::getIdentity(), 1.0f});
 						   {Vec3(0.0f), Quat::getIdentity(), 1.0f});
 
 
 	return Error::kNone;
 	return Error::kNone;

+ 2 - 2
AnKi/Scene/Components/SpatialComponent.cpp

@@ -31,7 +31,7 @@ SpatialComponent::~SpatialComponent()
 		m_node->getSceneGraph().getOctree().remove(m_octreeInfo);
 		m_node->getSceneGraph().getOctree().remove(m_octreeInfo);
 	}
 	}
 
 
-	m_convexHullPoints.destroy(m_node->getAllocator());
+	m_convexHullPoints.destroy(m_node->getMemoryPool());
 }
 }
 
 
 void SpatialComponent::setConvexHullWorldSpace(const ConvexHullShape& hull)
 void SpatialComponent::setConvexHullWorldSpace(const ConvexHullShape& hull)
@@ -40,7 +40,7 @@ void SpatialComponent::setConvexHullWorldSpace(const ConvexHullShape& hull)
 
 
 	if(m_convexHullPoints.getSize() != hull.getPoints().getSize())
 	if(m_convexHullPoints.getSize() != hull.getPoints().getSize())
 	{
 	{
-		m_convexHullPoints.resize(m_node->getAllocator(), hull.getPoints().getSize());
+		m_convexHullPoints.resize(m_node->getMemoryPool(), hull.getPoints().getSize());
 	}
 	}
 
 
 	memcpy(&m_convexHullPoints[0], &hull.getPoints()[0], hull.getPoints().getSizeInBytes());
 	memcpy(&m_convexHullPoints[0], &hull.getPoints()[0], hull.getPoints().getSizeInBytes());

+ 11 - 11
AnKi/Scene/Components/TriggerComponent.cpp

@@ -29,12 +29,12 @@ public:
 		if(!m_enterUpdated)
 		if(!m_enterUpdated)
 		{
 		{
 			m_enterUpdated = true;
 			m_enterUpdated = true;
-			m_comp->m_bodiesEnter.destroy(m_comp->m_node->getAllocator());
+			m_comp->m_bodiesEnter.destroy(m_comp->m_node->getMemoryPool());
 		}
 		}
 
 
 		m_updated = true;
 		m_updated = true;
 
 
-		m_comp->m_bodiesEnter.emplaceBack(m_comp->m_node->getAllocator(),
+		m_comp->m_bodiesEnter.emplaceBack(m_comp->m_node->getMemoryPool(),
 										  static_cast<BodyComponent*>(obj.getUserData()));
 										  static_cast<BodyComponent*>(obj.getUserData()));
 	}
 	}
 
 
@@ -44,12 +44,12 @@ public:
 		if(!m_insideUpdated)
 		if(!m_insideUpdated)
 		{
 		{
 			m_insideUpdated = true;
 			m_insideUpdated = true;
-			m_comp->m_bodiesInside.destroy(m_comp->m_node->getAllocator());
+			m_comp->m_bodiesInside.destroy(m_comp->m_node->getMemoryPool());
 		}
 		}
 
 
 		m_updated = true;
 		m_updated = true;
 
 
-		m_comp->m_bodiesInside.emplaceBack(m_comp->m_node->getAllocator(),
+		m_comp->m_bodiesInside.emplaceBack(m_comp->m_node->getMemoryPool(),
 										   static_cast<BodyComponent*>(obj.getUserData()));
 										   static_cast<BodyComponent*>(obj.getUserData()));
 	}
 	}
 
 
@@ -59,12 +59,12 @@ public:
 		if(!m_exitUpdated)
 		if(!m_exitUpdated)
 		{
 		{
 			m_exitUpdated = true;
 			m_exitUpdated = true;
-			m_comp->m_bodiesExit.destroy(m_comp->m_node->getAllocator());
+			m_comp->m_bodiesExit.destroy(m_comp->m_node->getMemoryPool());
 		}
 		}
 
 
 		m_updated = true;
 		m_updated = true;
 
 
-		m_comp->m_bodiesExit.emplaceBack(m_comp->m_node->getAllocator(),
+		m_comp->m_bodiesExit.emplaceBack(m_comp->m_node->getMemoryPool(),
 										 static_cast<BodyComponent*>(obj.getUserData()));
 										 static_cast<BodyComponent*>(obj.getUserData()));
 	}
 	}
 };
 };
@@ -74,16 +74,16 @@ TriggerComponent::TriggerComponent(SceneNode* node)
 	, m_node(node)
 	, m_node(node)
 {
 {
 	ANKI_ASSERT(node);
 	ANKI_ASSERT(node);
-	m_callbacks = m_node->getAllocator().newInstance<MyPhysicsTriggerProcessContactCallback>();
+	m_callbacks = newInstance<MyPhysicsTriggerProcessContactCallback>(m_node->getMemoryPool());
 	m_callbacks->m_comp = this;
 	m_callbacks->m_comp = this;
 }
 }
 
 
 TriggerComponent::~TriggerComponent()
 TriggerComponent::~TriggerComponent()
 {
 {
-	m_node->getAllocator().deleteInstance(m_callbacks);
-	m_bodiesEnter.destroy(m_node->getAllocator());
-	m_bodiesInside.destroy(m_node->getAllocator());
-	m_bodiesExit.destroy(m_node->getAllocator());
+	deleteInstance(m_node->getMemoryPool(), m_callbacks);
+	m_bodiesEnter.destroy(m_node->getMemoryPool());
+	m_bodiesInside.destroy(m_node->getMemoryPool());
+	m_bodiesExit.destroy(m_node->getMemoryPool());
 }
 }
 
 
 void TriggerComponent::setSphereVolumeRadius(F32 radius)
 void TriggerComponent::setSphereVolumeRadius(F32 radius)

+ 1 - 1
AnKi/Scene/Events/AnimationEvent.cpp

@@ -39,7 +39,7 @@ Error AnimationEvent::init(CString animationFilename, CString channelName, Scene
 
 
 	Event::init(m_anim->getStartingTime(), m_anim->getDuration());
 	Event::init(m_anim->getStartingTime(), m_anim->getDuration());
 	m_reanimate = true;
 	m_reanimate = true;
-	m_associatedNodes.emplaceBack(getAllocator(), movableSceneNode);
+	m_associatedNodes.emplaceBack(getMemoryPool(), movableSceneNode);
 
 
 	return Error::kNone;
 	return Error::kNone;
 }
 }

+ 3 - 3
AnKi/Scene/Events/Event.cpp

@@ -17,7 +17,7 @@ Event::Event(EventManager* manager)
 
 
 Event::~Event()
 Event::~Event()
 {
 {
-	m_associatedNodes.destroy(getAllocator());
+	m_associatedNodes.destroy(getMemoryPool());
 }
 }
 
 
 void Event::init(Second startTime, Second duration)
 void Event::init(Second startTime, Second duration)
@@ -31,9 +31,9 @@ void Event::init(Second startTime, Second duration)
 	}
 	}
 }
 }
 
 
-SceneAllocator<U8> Event::getAllocator() const
+HeapMemoryPool& Event::getMemoryPool() const
 {
 {
-	return m_manager->getSceneGraph().getAllocator();
+	return m_manager->getSceneGraph().getMemoryPool();
 }
 }
 
 
 void Event::setMarkedForDeletion()
 void Event::setMarkedForDeletion()

+ 2 - 2
AnKi/Scene/Events/Event.h

@@ -25,7 +25,7 @@ public:
 
 
 	virtual ~Event();
 	virtual ~Event();
 
 
-	SceneAllocator<U8> getAllocator() const;
+	HeapMemoryPool& getMemoryPool() const;
 
 
 	EventManager& getEventManager()
 	EventManager& getEventManager()
 	{
 	{
@@ -84,7 +84,7 @@ public:
 	void addAssociatedSceneNode(SceneNode* node)
 	void addAssociatedSceneNode(SceneNode* node)
 	{
 	{
 		ANKI_ASSERT(node);
 		ANKI_ASSERT(node);
-		m_associatedNodes.emplaceBack(getAllocator(), node);
+		m_associatedNodes.emplaceBack(getMemoryPool(), node);
 	}
 	}
 
 
 	/// This method should be implemented by the derived classes
 	/// This method should be implemented by the derived classes

+ 6 - 8
AnKi/Scene/Events/EventManager.cpp

@@ -31,14 +31,14 @@ Error EventManager::init(SceneGraph* scene)
 	return Error::kNone;
 	return Error::kNone;
 }
 }
 
 
-SceneAllocator<U8> EventManager::getAllocator() const
+HeapMemoryPool& EventManager::getMemoryPool() const
 {
 {
-	return m_scene->getAllocator();
+	return m_scene->getMemoryPool();
 }
 }
 
 
-SceneFrameAllocator<U8> EventManager::getFrameAllocator() const
+StackMemoryPool& EventManager::getFrameMemoryPool() const
 {
 {
-	return m_scene->getFrameAllocator();
+	return m_scene->getFrameMemoryPool();
 }
 }
 
 
 Error EventManager::updateAllEvents(Second prevUpdateTime, Second crntTime)
 Error EventManager::updateAllEvents(Second prevUpdateTime, Second crntTime)
@@ -124,13 +124,11 @@ void EventManager::markEventForDeletion(Event* event)
 
 
 void EventManager::deleteEventsMarkedForDeletion(Bool fullCleanup)
 void EventManager::deleteEventsMarkedForDeletion(Bool fullCleanup)
 {
 {
-	SceneAllocator<U8> alloc = getAllocator();
-
 	// Mark events with to-be-deleted nodes as also to be deleted
 	// Mark events with to-be-deleted nodes as also to be deleted
 	if(fullCleanup)
 	if(fullCleanup)
 	{
 	{
 		// Gather in an array because we can't call setMarkedForDeletion while iterating m_events
 		// Gather in an array because we can't call setMarkedForDeletion while iterating m_events
-		DynamicArrayRaii<Event*> markedForDeletion(getFrameAllocator());
+		DynamicArrayRaii<Event*> markedForDeletion(&getFrameMemoryPool());
 		for(Event& event : m_events)
 		for(Event& event : m_events)
 		{
 		{
 			for(SceneNode* node : event.m_associatedNodes)
 			for(SceneNode* node : event.m_associatedNodes)
@@ -155,7 +153,7 @@ void EventManager::deleteEventsMarkedForDeletion(Bool fullCleanup)
 		Event* event = &m_eventsMarkedForDeletion.getFront();
 		Event* event = &m_eventsMarkedForDeletion.getFront();
 		m_eventsMarkedForDeletion.popFront();
 		m_eventsMarkedForDeletion.popFront();
 
 
-		alloc.deleteInstance(event);
+		deleteInstance(getMemoryPool(), event);
 	}
 	}
 }
 }
 
 

+ 4 - 4
AnKi/Scene/Events/EventManager.h

@@ -33,19 +33,19 @@ public:
 		return *m_scene;
 		return *m_scene;
 	}
 	}
 
 
-	SceneAllocator<U8> getAllocator() const;
-	SceneFrameAllocator<U8> getFrameAllocator() const;
+	HeapMemoryPool& getMemoryPool() const;
+	StackMemoryPool& getFrameMemoryPool() const;
 
 
 	/// Create a new event
 	/// Create a new event
 	/// @note It's thread-safe against itself.
 	/// @note It's thread-safe against itself.
 	template<typename T, typename... Args>
 	template<typename T, typename... Args>
 	Error newEvent(T*& event, Args... args)
 	Error newEvent(T*& event, Args... args)
 	{
 	{
-		event = getAllocator().template newInstance<T>(this);
+		event = newInstance<T>(getMemoryPool(), this);
 		Error err = event->init(std::forward<Args>(args)...);
 		Error err = event->init(std::forward<Args>(args)...);
 		if(err)
 		if(err)
 		{
 		{
-			getAllocator().deleteInstance(event);
+			deleteInstance(getMemoryPool(), event);
 		}
 		}
 		else
 		else
 		{
 		{

+ 1 - 1
AnKi/Scene/Events/JitterMoveEvent.cpp

@@ -14,7 +14,7 @@ Error JitterMoveEvent::init(Second startTime, Second duration, SceneNode* node)
 {
 {
 	ANKI_ASSERT(node);
 	ANKI_ASSERT(node);
 	Event::init(startTime, duration);
 	Event::init(startTime, duration);
-	m_associatedNodes.emplaceBack(getAllocator(), node);
+	m_associatedNodes.emplaceBack(getMemoryPool(), node);
 
 
 	const MoveComponent& move = node->getFirstComponentOfType<MoveComponent>();
 	const MoveComponent& move = node->getFirstComponentOfType<MoveComponent>();
 
 

+ 1 - 1
AnKi/Scene/Events/LightEvent.cpp

@@ -12,7 +12,7 @@ namespace anki {
 Error LightEvent::init(Second startTime, Second duration, SceneNode* light)
 Error LightEvent::init(Second startTime, Second duration, SceneNode* light)
 {
 {
 	Event::init(startTime, duration);
 	Event::init(startTime, duration);
-	m_associatedNodes.emplaceBack(getAllocator(), light);
+	m_associatedNodes.emplaceBack(getMemoryPool(), light);
 
 
 	LightComponent& lightc = light->getFirstComponentOfType<LightComponent>();
 	LightComponent& lightc = light->getFirstComponentOfType<LightComponent>();
 
 

+ 3 - 3
AnKi/Scene/Events/ScriptEvent.cpp

@@ -20,7 +20,7 @@ ScriptEvent::ScriptEvent(EventManager* manager)
 
 
 ScriptEvent::~ScriptEvent()
 ScriptEvent::~ScriptEvent()
 {
 {
-	m_script.destroy(getAllocator());
+	m_script.destroy(getMemoryPool());
 }
 }
 
 
 Error ScriptEvent::init(Second startTime, Second duration, CString script)
 Error ScriptEvent::init(Second startTime, Second duration, CString script)
@@ -31,7 +31,7 @@ Error ScriptEvent::init(Second startTime, Second duration, CString script)
 	ANKI_CHECK(m_env.init(&getSceneGraph().getScriptManager()));
 	ANKI_CHECK(m_env.init(&getSceneGraph().getScriptManager()));
 
 
 	// Do the rest
 	// Do the rest
-	StringRaii extension(getAllocator());
+	StringRaii extension(&getMemoryPool());
 	getFilepathExtension(script, extension);
 	getFilepathExtension(script, extension);
 
 
 	if(!extension.isEmpty() && extension == "lua")
 	if(!extension.isEmpty() && extension == "lua")
@@ -45,7 +45,7 @@ Error ScriptEvent::init(Second startTime, Second duration, CString script)
 	else
 	else
 	{
 	{
 		// It's a string
 		// It's a string
-		m_script.create(getAllocator(), script);
+		m_script.create(getMemoryPool(), script);
 
 
 		// Exec the script
 		// Exec the script
 		ANKI_CHECK(m_env.evalString(m_script.toCString()));
 		ANKI_CHECK(m_env.evalString(m_script.toCString()));

+ 2 - 2
AnKi/Scene/LightNode.cpp

@@ -126,7 +126,7 @@ PointLightNode::PointLightNode(SceneGraph* scene, CString name)
 
 
 PointLightNode::~PointLightNode()
 PointLightNode::~PointLightNode()
 {
 {
-	m_shadowData.destroy(getAllocator());
+	m_shadowData.destroy(getMemoryPool());
 }
 }
 
 
 void PointLightNode::onMoved(const MoveComponent& move)
 void PointLightNode::onMoved(const MoveComponent& move)
@@ -160,7 +160,7 @@ Error PointLightNode::frameUpdate([[maybe_unused]] Second prevUpdateTime, [[mayb
 	const LightComponent& lightc = getFirstComponentOfType<LightComponent>();
 	const LightComponent& lightc = getFirstComponentOfType<LightComponent>();
 	if(lightc.getShadowEnabled() && m_shadowData.isEmpty())
 	if(lightc.getShadowEnabled() && m_shadowData.isEmpty())
 	{
 	{
-		m_shadowData.create(getAllocator(), 6);
+		m_shadowData.create(getMemoryPool(), 6);
 
 
 		const F32 ang = toRad(90.0f);
 		const F32 ang = toRad(90.0f);
 		const F32 dist = lightc.getRadius();
 		const F32 dist = lightc.getRadius();

+ 7 - 7
AnKi/Scene/ModelNode.cpp

@@ -54,12 +54,12 @@ ModelNode::ModelNode(SceneGraph* scene, CString name)
 	newComponent<FeedbackComponent>();
 	newComponent<FeedbackComponent>();
 	newComponent<SpatialComponent>();
 	newComponent<SpatialComponent>();
 	newComponent<RenderComponent>(); // One of many
 	newComponent<RenderComponent>(); // One of many
-	m_renderProxies.create(getAllocator(), 1);
+	m_renderProxies.create(getMemoryPool(), 1);
 }
 }
 
 
 ModelNode::~ModelNode()
 ModelNode::~ModelNode()
 {
 {
-	m_renderProxies.destroy(getAllocator());
+	m_renderProxies.destroy(getMemoryPool());
 }
 }
 
 
 void ModelNode::feedbackUpdate()
 void ModelNode::feedbackUpdate()
@@ -140,7 +140,7 @@ Error ModelNode::frameUpdate([[maybe_unused]] Second prevUpdateTime, [[maybe_unu
 			newComponent<RenderComponent>();
 			newComponent<RenderComponent>();
 		}
 		}
 
 
-		m_renderProxies.resize(getAllocator(), modelPatchCount);
+		m_renderProxies.resize(getMemoryPool(), modelPatchCount);
 	}
 	}
 	else
 	else
 	{
 	{
@@ -289,7 +289,7 @@ void ModelNode::draw(RenderQueueDrawContext& ctx, ConstWeakArray<void*> userData
 	{
 	{
 		// Draw the bounding volumes
 		// Draw the bounding volumes
 
 
-		Mat4* const mvps = ctx.m_frameAllocator.newArray<Mat4>(instanceCount);
+		Mat4* const mvps = newArray<Mat4>(*ctx.m_framePool, instanceCount);
 		for(U32 i = 0; i < instanceCount; ++i)
 		for(U32 i = 0; i < instanceCount; ++i)
 		{
 		{
 			const ModelNode& otherNode = *static_cast<const RenderProxy*>(userData[i])->m_node;
 			const ModelNode& otherNode = *static_cast<const RenderProxy*>(userData[i])->m_node;
@@ -322,7 +322,7 @@ void ModelNode::draw(RenderQueueDrawContext& ctx, ConstWeakArray<void*> userData
 			ctx.m_debugDrawFlags.get(RenderQueueDebugDrawFlag::kDitheredDepthTestOn), 2.0f, *ctx.m_stagingGpuAllocator,
 			ctx.m_debugDrawFlags.get(RenderQueueDebugDrawFlag::kDitheredDepthTestOn), 2.0f, *ctx.m_stagingGpuAllocator,
 			cmdb);
 			cmdb);
 
 
-		ctx.m_frameAllocator.deleteArray(mvps, instanceCount);
+		deleteArray(*ctx.m_framePool, mvps, instanceCount);
 
 
 		// Bones
 		// Bones
 		const SkinComponent& skinc = getFirstComponentOfType<SkinComponent>();
 		const SkinComponent& skinc = getFirstComponentOfType<SkinComponent>();
@@ -332,9 +332,9 @@ void ModelNode::draw(RenderQueueDrawContext& ctx, ConstWeakArray<void*> userData
 			SkeletonResourcePtr skeleton = skinc.getSkeleronResource();
 			SkeletonResourcePtr skeleton = skinc.getSkeleronResource();
 			const U32 boneCount = skinc.getBoneTransforms().getSize();
 			const U32 boneCount = skinc.getBoneTransforms().getSize();
 
 
-			DynamicArrayRaii<Vec3> lines(ctx.m_frameAllocator);
+			DynamicArrayRaii<Vec3> lines(ctx.m_framePool);
 			lines.resizeStorage(boneCount * 2);
 			lines.resizeStorage(boneCount * 2);
-			DynamicArrayRaii<Vec3> chidlessLines(ctx.m_frameAllocator);
+			DynamicArrayRaii<Vec3> chidlessLines(ctx.m_framePool);
 			for(U32 i = 0; i < boneCount; ++i)
 			for(U32 i = 0; i < boneCount; ++i)
 			{
 			{
 				const Bone& bone = skeleton->getBones()[i];
 				const Bone& bone = skeleton->getBones()[i];

+ 9 - 9
AnKi/Scene/Octree.h

@@ -40,8 +40,8 @@ class Octree
 	friend class OctreePlaceable;
 	friend class OctreePlaceable;
 
 
 public:
 public:
-	Octree(SceneAllocator<U8> alloc)
-		: m_alloc(alloc)
+	Octree(HeapMemoryPool* pool)
+		: m_pool(pool)
 	{
 	{
 	}
 	}
 
 
@@ -198,7 +198,7 @@ private:
 	};
 	};
 	ANKI_ENUM_ALLOW_NUMERIC_OPERATIONS_FRIEND(LeafMask)
 	ANKI_ENUM_ALLOW_NUMERIC_OPERATIONS_FRIEND(LeafMask)
 
 
-	SceneAllocator<U8> m_alloc;
+	HeapMemoryPool* m_pool;
 	U32 m_maxDepth = 0;
 	U32 m_maxDepth = 0;
 	Vec3 m_sceneAabbMin = Vec3(0.0f);
 	Vec3 m_sceneAabbMin = Vec3(0.0f);
 	Vec3 m_sceneAabbMax = Vec3(0.0f);
 	Vec3 m_sceneAabbMax = Vec3(0.0f);
@@ -217,38 +217,38 @@ private:
 
 
 	Leaf* newLeaf()
 	Leaf* newLeaf()
 	{
 	{
-		return m_leafAlloc.newInstance(m_alloc);
+		return m_leafAlloc.newInstance(*m_pool);
 	}
 	}
 
 
 	void releaseLeaf(Leaf* leaf)
 	void releaseLeaf(Leaf* leaf)
 	{
 	{
-		m_leafAlloc.deleteInstance(m_alloc, leaf);
+		m_leafAlloc.deleteInstance(*m_pool, leaf);
 	}
 	}
 
 
 	PlaceableNode* newPlaceableNode(OctreePlaceable* placeable)
 	PlaceableNode* newPlaceableNode(OctreePlaceable* placeable)
 	{
 	{
 		ANKI_ASSERT(placeable);
 		ANKI_ASSERT(placeable);
-		PlaceableNode* out = m_placeableNodeAlloc.newInstance(m_alloc);
+		PlaceableNode* out = m_placeableNodeAlloc.newInstance(*m_pool);
 		out->m_placeable = placeable;
 		out->m_placeable = placeable;
 		return out;
 		return out;
 	}
 	}
 
 
 	void releasePlaceableNode(PlaceableNode* placeable)
 	void releasePlaceableNode(PlaceableNode* placeable)
 	{
 	{
-		m_placeableNodeAlloc.deleteInstance(m_alloc, placeable);
+		m_placeableNodeAlloc.deleteInstance(*m_pool, placeable);
 	}
 	}
 
 
 	LeafNode* newLeafNode(Leaf* leaf)
 	LeafNode* newLeafNode(Leaf* leaf)
 	{
 	{
 		ANKI_ASSERT(leaf);
 		ANKI_ASSERT(leaf);
-		LeafNode* out = m_leafNodeAlloc.newInstance(m_alloc);
+		LeafNode* out = m_leafNodeAlloc.newInstance(*m_pool);
 		out->m_leaf = leaf;
 		out->m_leaf = leaf;
 		return out;
 		return out;
 	}
 	}
 
 
 	void releaseLeafNode(LeafNode* node)
 	void releaseLeafNode(LeafNode* node)
 	{
 	{
-		m_leafNodeAlloc.deleteInstance(m_alloc, node);
+		m_leafNodeAlloc.deleteInstance(*m_pool, node);
 	}
 	}
 
 
 	void placeRecursive(const Aabb& volume, OctreePlaceable* placeable, Leaf* parent, U32 depth);
 	void placeRecursive(const Aabb& volume, OctreePlaceable* placeable, Leaf* parent, U32 depth);

+ 8 - 8
AnKi/Scene/SceneGraph.cpp

@@ -48,7 +48,7 @@ SceneGraph::~SceneGraph()
 
 
 	if(m_octree)
 	if(m_octree)
 	{
 	{
-		m_alloc.deleteInstance(m_octree);
+		deleteInstance(m_pool, m_octree);
 	}
 	}
 }
 }
 
 
@@ -66,12 +66,12 @@ Error SceneGraph::init(AllocAlignedCallback allocCb, void* allocCbData, ThreadHi
 	m_uiManager = uiManager;
 	m_uiManager = uiManager;
 	m_config = config;
 	m_config = config;
 
 
-	m_alloc = SceneAllocator<U8>(allocCb, allocCbData);
-	m_frameAlloc = SceneFrameAllocator<U8>(allocCb, allocCbData, 1 * 1024 * 1024);
+	m_pool.init(allocCb, allocCbData);
+	m_framePool.init(allocCb, allocCbData, 1 * 1024 * 1024);
 
 
 	ANKI_CHECK(m_events.init(this));
 	ANKI_CHECK(m_events.init(this));
 
 
-	m_octree = m_alloc.newInstance<Octree>(m_alloc);
+	m_octree = newInstance<Octree>(m_pool, &m_pool);
 	m_octree->init(m_sceneMin, m_sceneMax, m_config->getSceneOctreeMaxDepth());
 	m_octree->init(m_sceneMin, m_sceneMax, m_config->getSceneOctreeMaxDepth());
 
 
 	// Init the default main camera
 	// Init the default main camera
@@ -103,7 +103,7 @@ Error SceneGraph::registerNode(SceneNode* node)
 			return Error::kUserData;
 			return Error::kUserData;
 		}
 		}
 
 
-		m_nodesDict.emplace(m_alloc, node->getName(), node);
+		m_nodesDict.emplace(m_pool, node->getName(), node);
 	}
 	}
 
 
 	// Add to vector
 	// Add to vector
@@ -129,7 +129,7 @@ void SceneGraph::unregisterNode(SceneNode* node)
 	{
 	{
 		auto it = m_nodesDict.find(node->getName());
 		auto it = m_nodesDict.find(node->getName());
 		ANKI_ASSERT(it != m_nodesDict.getEnd());
 		ANKI_ASSERT(it != m_nodesDict.getEnd());
-		m_nodesDict.erase(m_alloc, it);
+		m_nodesDict.erase(m_pool, it);
 	}
 	}
 }
 }
 
 
@@ -163,7 +163,7 @@ void SceneGraph::deleteNodesMarkedForDeletion()
 			{
 			{
 				// Delete node
 				// Delete node
 				unregisterNode(&node);
 				unregisterNode(&node);
-				m_alloc.deleteInstance(&node);
+				deleteInstance(m_pool, &node);
 				m_objectsMarkedForDeletionCount.fetchSub(1);
 				m_objectsMarkedForDeletionCount.fetchSub(1);
 				found = true;
 				found = true;
 				break;
 				break;
@@ -185,7 +185,7 @@ Error SceneGraph::update(Second prevUpdateTime, Second crntTime)
 	ANKI_ASSERT(m_timestamp > 0);
 	ANKI_ASSERT(m_timestamp > 0);
 
 
 	// Reset the framepool
 	// Reset the framepool
-	m_frameAlloc.getMemoryPool().reset();
+	m_framePool.reset();
 
 
 	// Delete stuff
 	// Delete stuff
 	{
 	{

+ 8 - 11
AnKi/Scene/SceneGraph.h

@@ -57,16 +57,14 @@ public:
 		return m_timestamp;
 		return m_timestamp;
 	}
 	}
 
 
-	/// @note Return a copy
-	SceneAllocator<U8> getAllocator() const
+	HeapMemoryPool& getMemoryPool() const
 	{
 	{
-		return m_alloc;
+		return m_pool;
 	}
 	}
 
 
-	/// @note Return a copy
-	SceneFrameAllocator<U8> getFrameAllocator() const
+	StackMemoryPool& getFrameMemoryPool() const
 	{
 	{
-		return m_frameAlloc;
+		return m_framePool;
 	}
 	}
 
 
 	SceneNode& getActiveCameraNode()
 	SceneNode& getActiveCameraNode()
@@ -239,8 +237,8 @@ private:
 	UiManager* m_uiManager = nullptr;
 	UiManager* m_uiManager = nullptr;
 	ConfigSet* m_config = nullptr;
 	ConfigSet* m_config = nullptr;
 
 
-	SceneAllocator<U8> m_alloc;
-	SceneFrameAllocator<U8> m_frameAlloc;
+	mutable HeapMemoryPool m_pool;
+	mutable StackMemoryPool m_framePool;
 
 
 	IntrusiveList<SceneNode> m_nodes;
 	IntrusiveList<SceneNode> m_nodes;
 	U32 m_nodesCount = 0;
 	U32 m_nodesCount = 0;
@@ -283,9 +281,8 @@ template<typename Node, typename... Args>
 inline Error SceneGraph::newSceneNode(const CString& name, Node*& node, Args&&... args)
 inline Error SceneGraph::newSceneNode(const CString& name, Node*& node, Args&&... args)
 {
 {
 	Error err = Error::kNone;
 	Error err = Error::kNone;
-	SceneAllocator<Node> al = m_alloc;
 
 
-	node = al.template newInstance<Node>(this, name);
+	node = newInstance<Node>(m_pool, this, name);
 	if(node)
 	if(node)
 	{
 	{
 		err = node->init(std::forward<Args>(args)...);
 		err = node->init(std::forward<Args>(args)...);
@@ -306,7 +303,7 @@ inline Error SceneGraph::newSceneNode(const CString& name, Node*& node, Args&&..
 
 
 		if(node)
 		if(node)
 		{
 		{
-			al.deleteInstance(node);
+			deleteInstance(m_pool, node);
 			node = nullptr;
 			node = nullptr;
 		}
 		}
 	}
 	}

+ 11 - 11
AnKi/Scene/SceneNode.cpp

@@ -14,25 +14,25 @@ SceneNode::SceneNode(SceneGraph* scene, CString name)
 {
 {
 	if(name)
 	if(name)
 	{
 	{
-		m_name.create(getAllocator(), name);
+		m_name.create(getMemoryPool(), name);
 	}
 	}
 }
 }
 
 
 SceneNode::~SceneNode()
 SceneNode::~SceneNode()
 {
 {
-	auto alloc = getAllocator();
+	HeapMemoryPool& pool = getMemoryPool();
 
 
 	auto it = m_components.getBegin();
 	auto it = m_components.getBegin();
 	auto end = m_components.getEnd();
 	auto end = m_components.getEnd();
 	for(; it != end; ++it)
 	for(; it != end; ++it)
 	{
 	{
-		alloc.deleteInstance(*it);
+		deleteInstance(pool, *it);
 	}
 	}
 
 
-	Base::destroy(alloc);
-	m_name.destroy(alloc);
-	m_components.destroy(alloc);
-	m_componentInfos.destroy(alloc);
+	Base::destroy(pool);
+	m_name.destroy(pool);
+	m_components.destroy(pool);
+	m_componentInfos.destroy(pool);
 }
 }
 
 
 void SceneNode::setMarkedForDeletion()
 void SceneNode::setMarkedForDeletion()
@@ -55,16 +55,16 @@ Timestamp SceneNode::getGlobalTimestamp() const
 	return m_scene->getGlobalTimestamp();
 	return m_scene->getGlobalTimestamp();
 }
 }
 
 
-SceneAllocator<U8> SceneNode::getAllocator() const
+HeapMemoryPool& SceneNode::getMemoryPool() const
 {
 {
 	ANKI_ASSERT(m_scene);
 	ANKI_ASSERT(m_scene);
-	return m_scene->getAllocator();
+	return m_scene->getMemoryPool();
 }
 }
 
 
-SceneFrameAllocator<U8> SceneNode::getFrameAllocator() const
+StackMemoryPool& SceneNode::getFrameMemoryPool() const
 {
 {
 	ANKI_ASSERT(m_scene);
 	ANKI_ASSERT(m_scene);
-	return m_scene->getFrameAllocator();
+	return m_scene->getFrameMemoryPool();
 }
 }
 
 
 ResourceManager& SceneNode::getResourceManager()
 ResourceManager& SceneNode::getResourceManager()

+ 6 - 6
AnKi/Scene/SceneNode.h

@@ -84,13 +84,13 @@ public:
 		m_maxComponentTimestamp = maxComponentTimestamp;
 		m_maxComponentTimestamp = maxComponentTimestamp;
 	}
 	}
 
 
-	SceneAllocator<U8> getAllocator() const;
+	HeapMemoryPool& getMemoryPool() const;
 
 
-	SceneFrameAllocator<U8> getFrameAllocator() const;
+	StackMemoryPool& getFrameMemoryPool() const;
 
 
 	void addChild(SceneNode* obj)
 	void addChild(SceneNode* obj)
 	{
 	{
-		Base::addChild(getAllocator(), obj);
+		Base::addChild(getMemoryPool(), obj);
 	}
 	}
 
 
 	/// This is called by the scenegraph every frame after all component updates. By default it does nothing.
 	/// This is called by the scenegraph every frame after all component updates. By default it does nothing.
@@ -265,9 +265,9 @@ protected:
 	template<typename TComponent>
 	template<typename TComponent>
 	TComponent* newComponent()
 	TComponent* newComponent()
 	{
 	{
-		TComponent* comp = getAllocator().newInstance<TComponent>(this);
-		m_components.emplaceBack(getAllocator(), comp);
-		m_componentInfos.emplaceBack(getAllocator(), *comp);
+		TComponent* comp = newInstance<TComponent>(getMemoryPool(), this);
+		m_components.emplaceBack(getMemoryPool(), comp);
+		m_componentInfos.emplaceBack(getMemoryPool(), *comp);
 		return comp;
 		return comp;
 	}
 	}
 
 

+ 2 - 2
AnKi/Scene/SoftwareRasterizer.cpp

@@ -26,8 +26,8 @@ void SoftwareRasterizer::prepare(const Mat4& mv, const Mat4& p, U32 width, U32 h
 	U32 size = width * height;
 	U32 size = width * height;
 	if(m_zbuffer.getSize() < size)
 	if(m_zbuffer.getSize() < size)
 	{
 	{
-		m_zbuffer.destroy(m_alloc);
-		m_zbuffer.create(m_alloc, size);
+		m_zbuffer.destroy(*m_pool);
+		m_zbuffer.create(*m_pool, size);
 	}
 	}
 	memset(&m_zbuffer[0], 0xFF, sizeof(m_zbuffer[0]) * size);
 	memset(&m_zbuffer[0], 0xFF, sizeof(m_zbuffer[0]) * size);
 }
 }

+ 5 - 4
AnKi/Scene/SoftwareRasterizer.h

@@ -25,13 +25,14 @@ public:
 
 
 	~SoftwareRasterizer()
 	~SoftwareRasterizer()
 	{
 	{
-		m_zbuffer.destroy(m_alloc);
+		m_zbuffer.destroy(*m_pool);
 	}
 	}
 
 
 	/// Initialize.
 	/// Initialize.
-	void init(const GenericMemoryPoolAllocator<U8>& alloc)
+	void init(BaseMemoryPool* pool)
 	{
 	{
-		m_alloc = alloc;
+		ANKI_ASSERT(pool);
+		m_pool = pool;
 	}
 	}
 
 
 	/// Prepare for rendering. Call it before every draw.
 	/// Prepare for rendering. Call it before every draw.
@@ -54,7 +55,7 @@ public:
 	Bool visibilityTest(const Aabb& aabb) const;
 	Bool visibilityTest(const Aabb& aabb) const;
 
 
 private:
 private:
-	GenericMemoryPoolAllocator<U8> m_alloc;
+	BaseMemoryPool* m_pool = nullptr;
 	Mat4 m_mv; ///< ModelView.
 	Mat4 m_mv; ///< ModelView.
 	Mat4 m_p; ///< Projection.
 	Mat4 m_p; ///< Projection.
 	Mat4 m_mvp;
 	Mat4 m_mvp;

+ 38 - 38
AnKi/Scene/Visibility.cpp

@@ -109,7 +109,7 @@ void VisibilityContext::submitNewWork(const FrustumComponent& frc, const Frustum
 	}
 	}
 	rqueue.m_effectiveShadowDistance = frc.getEffectiveShadowDistance();
 	rqueue.m_effectiveShadowDistance = frc.getEffectiveShadowDistance();
 
 
-	auto alloc = m_scene->getFrameAllocator();
+	StackMemoryPool& pool = m_scene->getFrameMemoryPool();
 
 
 	// Check if this frc was tested before
 	// Check if this frc was tested before
 	{
 	{
@@ -125,15 +125,15 @@ void VisibilityContext::submitNewWork(const FrustumComponent& frc, const Frustum
 		}
 		}
 
 
 		// Not there, push it
 		// Not there, push it
-		m_testedFrcs.pushBack(alloc, &frc);
+		m_testedFrcs.pushBack(pool, &frc);
 	}
 	}
 
 
 	// Prepare the ctx
 	// Prepare the ctx
-	FrustumVisibilityContext* frcCtx = alloc.newInstance<FrustumVisibilityContext>();
+	FrustumVisibilityContext* frcCtx = newInstance<FrustumVisibilityContext>(pool);
 	frcCtx->m_visCtx = this;
 	frcCtx->m_visCtx = this;
 	frcCtx->m_frc = &frc;
 	frcCtx->m_frc = &frc;
 	frcCtx->m_primaryFrustum = &primaryFrustum;
 	frcCtx->m_primaryFrustum = &primaryFrustum;
-	frcCtx->m_queueViews.create(alloc, hive.getThreadCount());
+	frcCtx->m_queueViews.create(pool, hive.getThreadCount());
 	frcCtx->m_visTestsSignalSem = hive.newSemaphore(1);
 	frcCtx->m_visTestsSignalSem = hive.newSemaphore(1);
 	frcCtx->m_renderQueue = &rqueue;
 	frcCtx->m_renderQueue = &rqueue;
 
 
@@ -146,7 +146,7 @@ void VisibilityContext::submitNewWork(const FrustumComponent& frc, const Frustum
 	{
 	{
 		// Gather triangles task
 		// Gather triangles task
 		ThreadHiveTask fillDepthTask =
 		ThreadHiveTask fillDepthTask =
-			ANKI_THREAD_HIVE_TASK({ self->fill(); }, alloc.newInstance<FillRasterizerWithCoverageTask>(frcCtx), nullptr,
+			ANKI_THREAD_HIVE_TASK({ self->fill(); }, newInstance<FillRasterizerWithCoverageTask>(pool, frcCtx), nullptr,
 								  hive.newSemaphore(1));
 								  hive.newSemaphore(1));
 
 
 		hive.submitTasks(&fillDepthTask, 1);
 		hive.submitTasks(&fillDepthTask, 1);
@@ -162,14 +162,14 @@ void VisibilityContext::submitNewWork(const FrustumComponent& frc, const Frustum
 
 
 	// Gather visibles from the octree. No need to signal anything because it will spawn new tasks
 	// Gather visibles from the octree. No need to signal anything because it will spawn new tasks
 	ThreadHiveTask gatherTask =
 	ThreadHiveTask gatherTask =
-		ANKI_THREAD_HIVE_TASK({ self->gather(hive); }, alloc.newInstance<GatherVisiblesFromOctreeTask>(frcCtx),
+		ANKI_THREAD_HIVE_TASK({ self->gather(hive); }, newInstance<GatherVisiblesFromOctreeTask>(pool, frcCtx),
 							  prepareRasterizerSem, nullptr);
 							  prepareRasterizerSem, nullptr);
 	hive.submitTasks(&gatherTask, 1);
 	hive.submitTasks(&gatherTask, 1);
 
 
 	// Combind results task
 	// Combind results task
 	ANKI_ASSERT(frcCtx->m_visTestsSignalSem);
 	ANKI_ASSERT(frcCtx->m_visTestsSignalSem);
 	ThreadHiveTask combineTask = ANKI_THREAD_HIVE_TASK(
 	ThreadHiveTask combineTask = ANKI_THREAD_HIVE_TASK(
-		{ self->combine(); }, alloc.newInstance<CombineResultsTask>(frcCtx), frcCtx->m_visTestsSignalSem, nullptr);
+		{ self->combine(); }, newInstance<CombineResultsTask>(pool, frcCtx), frcCtx->m_visTestsSignalSem, nullptr);
 	hive.submitTasks(&combineTask, 1);
 	hive.submitTasks(&combineTask, 1);
 }
 }
 
 
@@ -177,7 +177,7 @@ void FillRasterizerWithCoverageTask::fill()
 {
 {
 	ANKI_TRACE_SCOPED_EVENT(SCENE_VIS_FILL_DEPTH);
 	ANKI_TRACE_SCOPED_EVENT(SCENE_VIS_FILL_DEPTH);
 
 
-	auto alloc = m_frcCtx->m_visCtx->m_scene->getFrameAllocator();
+	StackMemoryPool& pool = m_frcCtx->m_visCtx->m_scene->getFrameMemoryPool();
 
 
 	// Get the C-Buffer
 	// Get the C-Buffer
 	ConstWeakArray<F32> depthBuff;
 	ConstWeakArray<F32> depthBuff;
@@ -189,8 +189,8 @@ void FillRasterizerWithCoverageTask::fill()
 	// Init the rasterizer
 	// Init the rasterizer
 	if(true)
 	if(true)
 	{
 	{
-		m_frcCtx->m_r = alloc.newInstance<SoftwareRasterizer>();
-		m_frcCtx->m_r->init(alloc);
+		m_frcCtx->m_r = newInstance<SoftwareRasterizer>(pool);
+		m_frcCtx->m_r->init(&pool);
 		m_frcCtx->m_r->prepare(Mat4(m_frcCtx->m_frc->getPreviousViewMatrix(1), Vec4(0.0f, 0.0f, 0.0f, 1.0f)),
 		m_frcCtx->m_r->prepare(Mat4(m_frcCtx->m_frc->getPreviousViewMatrix(1), Vec4(0.0f, 0.0f, 0.0f, 1.0f)),
 							   m_frcCtx->m_frc->getPreviousProjectionMatrix(1), width, height);
 							   m_frcCtx->m_frc->getPreviousProjectionMatrix(1), width, height);
 
 
@@ -246,7 +246,7 @@ void GatherVisiblesFromOctreeTask::flush(ThreadHive& hive)
 	{
 	{
 		// Create the task
 		// Create the task
 		VisibilityTestTask* vis =
 		VisibilityTestTask* vis =
-			m_frcCtx->m_visCtx->m_scene->getFrameAllocator().newInstance<VisibilityTestTask>(m_frcCtx);
+			newInstance<VisibilityTestTask>(m_frcCtx->m_visCtx->m_scene->getFrameMemoryPool(), m_frcCtx);
 		memcpy(&vis->m_spatialsToTest[0], &m_spatials[0], sizeof(m_spatials[0]) * m_spatialCount);
 		memcpy(&vis->m_spatialsToTest[0], &m_spatials[0], sizeof(m_spatials[0]) * m_spatialCount);
 		vis->m_spatialToTestCount = m_spatialCount;
 		vis->m_spatialToTestCount = m_spatialCount;
 
 
@@ -274,7 +274,7 @@ void VisibilityTestTask::test(ThreadHive& hive, U32 taskId)
 	const FrustumComponent& primaryFrc = *m_frcCtx->m_primaryFrustum;
 	const FrustumComponent& primaryFrc = *m_frcCtx->m_primaryFrustum;
 
 
 	const SceneNode& testedNode = testedFrc.getSceneNode();
 	const SceneNode& testedNode = testedFrc.getSceneNode();
-	auto alloc = m_frcCtx->m_visCtx->m_scene->getFrameAllocator();
+	StackMemoryPool& pool = m_frcCtx->m_visCtx->m_scene->getFrameMemoryPool();
 
 
 	Timestamp& timestamp = m_frcCtx->m_queueViews[taskId].m_timestamp;
 	Timestamp& timestamp = m_frcCtx->m_queueViews[taskId].m_timestamp;
 	timestamp = testedNode.getComponentMaxTimestamp();
 	timestamp = testedNode.getComponentMaxTimestamp();
@@ -365,11 +365,11 @@ void VisibilityTestTask::test(ThreadHive& hive, U32 taskId)
 			RenderableQueueElement* el;
 			RenderableQueueElement* el;
 			if(!!(rc.getFlags() & RenderComponentFlag::kForwardShading))
 			if(!!(rc.getFlags() & RenderComponentFlag::kForwardShading))
 			{
 			{
-				el = result.m_forwardShadingRenderables.newElement(alloc);
+				el = result.m_forwardShadingRenderables.newElement(pool);
 			}
 			}
 			else
 			else
 			{
 			{
-				el = result.m_renderables.newElement(alloc);
+				el = result.m_renderables.newElement(pool);
 			}
 			}
 
 
 			rc.setupRenderableQueueElement(*el);
 			rc.setupRenderableQueueElement(*el);
@@ -386,14 +386,14 @@ void VisibilityTestTask::test(ThreadHive& hive, U32 taskId)
 			if(wantsEarlyZ && el->m_distanceFromCamera < m_frcCtx->m_visCtx->m_earlyZDist
 			if(wantsEarlyZ && el->m_distanceFromCamera < m_frcCtx->m_visCtx->m_earlyZDist
 			   && !(rc.getFlags() & RenderComponentFlag::kForwardShading))
 			   && !(rc.getFlags() & RenderComponentFlag::kForwardShading))
 			{
 			{
-				RenderableQueueElement* el2 = result.m_earlyZRenderables.newElement(alloc);
+				RenderableQueueElement* el2 = result.m_earlyZRenderables.newElement(pool);
 				*el2 = *el;
 				*el2 = *el;
 			}
 			}
 
 
 			// Add to RT
 			// Add to RT
 			if(rtRc)
 			if(rtRc)
 			{
 			{
-				RayTracingInstanceQueueElement* el = result.m_rayTracingInstances.newElement(alloc);
+				RayTracingInstanceQueueElement* el = result.m_rayTracingInstances.newElement(pool);
 
 
 				// Compute the LOD
 				// Compute the LOD
 				const Plane& nearPlane = primaryFrc.getViewPlanes()[FrustumPlaneType::kNear];
 				const Plane& nearPlane = primaryFrc.getViewPlanes()[FrustumPlaneType::kNear];
@@ -421,12 +421,12 @@ void VisibilityTestTask::test(ThreadHive& hive, U32 taskId)
 			{
 			{
 			case LightComponentType::kPoint:
 			case LightComponentType::kPoint:
 			{
 			{
-				PointLightQueueElement* el = result.m_pointLights.newElement(alloc);
+				PointLightQueueElement* el = result.m_pointLights.newElement(pool);
 				lc->setupPointLightQueueElement(*el);
 				lc->setupPointLightQueueElement(*el);
 
 
 				if(castsShadow && !!(frustumFlags & FrustumComponentVisibilityTestFlag::kPointLightShadowsEnabled))
 				if(castsShadow && !!(frustumFlags & FrustumComponentVisibilityTestFlag::kPointLightShadowsEnabled))
 				{
 				{
-					RenderQueue* a = alloc.newArray<RenderQueue>(6);
+					RenderQueue* a = newArray<RenderQueue>(pool, 6);
 					nextQueues = WeakArray<RenderQueue>(a, 6);
 					nextQueues = WeakArray<RenderQueue>(a, 6);
 
 
 					el->m_shadowRenderQueues[0] = &nextQueues[0];
 					el->m_shadowRenderQueues[0] = &nextQueues[0];
@@ -445,12 +445,12 @@ void VisibilityTestTask::test(ThreadHive& hive, U32 taskId)
 			}
 			}
 			case LightComponentType::kSpot:
 			case LightComponentType::kSpot:
 			{
 			{
-				SpotLightQueueElement* el = result.m_spotLights.newElement(alloc);
+				SpotLightQueueElement* el = result.m_spotLights.newElement(pool);
 				lc->setupSpotLightQueueElement(*el);
 				lc->setupSpotLightQueueElement(*el);
 
 
 				if(castsShadow && !!(frustumFlags & FrustumComponentVisibilityTestFlag::kSpotLightShadowsEnabled))
 				if(castsShadow && !!(frustumFlags & FrustumComponentVisibilityTestFlag::kSpotLightShadowsEnabled))
 				{
 				{
-					RenderQueue* a = alloc.newInstance<RenderQueue>();
+					RenderQueue* a = newInstance<RenderQueue>(pool);
 					nextQueues = WeakArray<RenderQueue>(a, 1);
 					nextQueues = WeakArray<RenderQueue>(a, 1);
 					el->m_shadowRenderQueue = a;
 					el->m_shadowRenderQueue = a;
 				}
 				}
@@ -479,7 +479,7 @@ void VisibilityTestTask::test(ThreadHive& hive, U32 taskId)
 				// Create some dummy frustum components and initialize them
 				// Create some dummy frustum components and initialize them
 				WeakArray<FrustumComponent> cascadeFrustumComponents(
 				WeakArray<FrustumComponent> cascadeFrustumComponents(
 					(cascadeCount) ? reinterpret_cast<FrustumComponent*>(
 					(cascadeCount) ? reinterpret_cast<FrustumComponent*>(
-						alloc.allocate(cascadeCount * sizeof(FrustumComponent), alignof(FrustumComponent)))
+						pool.allocate(cascadeCount * sizeof(FrustumComponent), alignof(FrustumComponent)))
 								   : nullptr,
 								   : nullptr,
 					cascadeCount);
 					cascadeCount);
 				for(U32 i = 0; i < cascadeCount; ++i)
 				for(U32 i = 0; i < cascadeCount; ++i)
@@ -491,7 +491,7 @@ void VisibilityTestTask::test(ThreadHive& hive, U32 taskId)
 				lc->setupDirectionalLightQueueElement(testedFrc, result.m_directionalLight, cascadeFrustumComponents);
 				lc->setupDirectionalLightQueueElement(testedFrc, result.m_directionalLight, cascadeFrustumComponents);
 
 
 				nextQueues = WeakArray<RenderQueue>(
 				nextQueues = WeakArray<RenderQueue>(
-					(cascadeCount) ? alloc.newArray<RenderQueue>(cascadeCount) : nullptr, cascadeCount);
+					(cascadeCount) ? newArray<RenderQueue>(pool, cascadeCount) : nullptr, cascadeCount);
 				for(U32 i = 0; i < cascadeCount; ++i)
 				for(U32 i = 0; i < cascadeCount; ++i)
 				{
 				{
 					result.m_directionalLight.m_shadowRenderQueues[i] = &nextQueues[i];
 					result.m_directionalLight.m_shadowRenderQueues[i] = &nextQueues[i];
@@ -525,18 +525,18 @@ void VisibilityTestTask::test(ThreadHive& hive, U32 taskId)
 
 
 		if(lfc && lfc->isLoaded())
 		if(lfc && lfc->isLoaded())
 		{
 		{
-			LensFlareQueueElement* el = result.m_lensFlares.newElement(alloc);
+			LensFlareQueueElement* el = result.m_lensFlares.newElement(pool);
 			lfc->setupLensFlareQueueElement(*el);
 			lfc->setupLensFlareQueueElement(*el);
 		}
 		}
 
 
 		if(reflc)
 		if(reflc)
 		{
 		{
-			ReflectionProbeQueueElement* el = result.m_reflectionProbes.newElement(alloc);
+			ReflectionProbeQueueElement* el = result.m_reflectionProbes.newElement(pool);
 			reflc->setupReflectionProbeQueueElement(*el);
 			reflc->setupReflectionProbeQueueElement(*el);
 
 
 			if(reflc->getMarkedForRendering())
 			if(reflc->getMarkedForRendering())
 			{
 			{
-				RenderQueue* a = alloc.newArray<RenderQueue>(6);
+				RenderQueue* a = newArray<RenderQueue>(pool, 6);
 				nextQueues = WeakArray<RenderQueue>(a, 6);
 				nextQueues = WeakArray<RenderQueue>(a, 6);
 
 
 				el->m_renderQueues[0] = &nextQueues[0];
 				el->m_renderQueues[0] = &nextQueues[0];
@@ -554,24 +554,24 @@ void VisibilityTestTask::test(ThreadHive& hive, U32 taskId)
 
 
 		if(decalc)
 		if(decalc)
 		{
 		{
-			DecalQueueElement* el = result.m_decals.newElement(alloc);
+			DecalQueueElement* el = result.m_decals.newElement(pool);
 			decalc->setupDecalQueueElement(*el);
 			decalc->setupDecalQueueElement(*el);
 		}
 		}
 
 
 		if(fogc)
 		if(fogc)
 		{
 		{
-			FogDensityQueueElement* el = result.m_fogDensityVolumes.newElement(alloc);
+			FogDensityQueueElement* el = result.m_fogDensityVolumes.newElement(pool);
 			fogc->setupFogDensityQueueElement(*el);
 			fogc->setupFogDensityQueueElement(*el);
 		}
 		}
 
 
 		if(giprobec)
 		if(giprobec)
 		{
 		{
-			GlobalIlluminationProbeQueueElement* el = result.m_giProbes.newElement(alloc);
+			GlobalIlluminationProbeQueueElement* el = result.m_giProbes.newElement(pool);
 			giprobec->setupGlobalIlluminationProbeQueueElement(*el);
 			giprobec->setupGlobalIlluminationProbeQueueElement(*el);
 
 
 			if(giprobec->getMarkedForRendering())
 			if(giprobec->getMarkedForRendering())
 			{
 			{
-				RenderQueue* a = alloc.newArray<RenderQueue>(6);
+				RenderQueue* a = newArray<RenderQueue>(pool, 6);
 				nextQueues = WeakArray<RenderQueue>(a, 6);
 				nextQueues = WeakArray<RenderQueue>(a, 6);
 
 
 				el->m_renderQueues[0] = &nextQueues[0];
 				el->m_renderQueues[0] = &nextQueues[0];
@@ -589,13 +589,13 @@ void VisibilityTestTask::test(ThreadHive& hive, U32 taskId)
 
 
 		if(computec)
 		if(computec)
 		{
 		{
-			GenericGpuComputeJobQueueElement* el = result.m_genericGpuComputeJobs.newElement(alloc);
+			GenericGpuComputeJobQueueElement* el = result.m_genericGpuComputeJobs.newElement(pool);
 			computec->setupGenericGpuComputeJobQueueElement(*el);
 			computec->setupGenericGpuComputeJobQueueElement(*el);
 		}
 		}
 
 
 		if(uic)
 		if(uic)
 		{
 		{
-			UiQueueElement* el = result.m_uis.newElement(alloc);
+			UiQueueElement* el = result.m_uis.newElement(pool);
 			uic->setupUiQueueElement(*el);
 			uic->setupUiQueueElement(*el);
 		}
 		}
 
 
@@ -634,7 +634,7 @@ void CombineResultsTask::combine()
 {
 {
 	ANKI_TRACE_SCOPED_EVENT(SCENE_VIS_COMBINE_RESULTS);
 	ANKI_TRACE_SCOPED_EVENT(SCENE_VIS_COMBINE_RESULTS);
 
 
-	auto alloc = m_frcCtx->m_visCtx->m_scene->getFrameAllocator();
+	StackMemoryPool& pool = m_frcCtx->m_visCtx->m_scene->getFrameMemoryPool();
 	RenderQueue& results = *m_frcCtx->m_renderQueue;
 	RenderQueue& results = *m_frcCtx->m_renderQueue;
 
 
 	// Compute the timestamp
 	// Compute the timestamp
@@ -654,7 +654,7 @@ void CombineResultsTask::combine()
 		{ \
 		{ \
 			subStorages[i] = m_frcCtx->m_queueViews[i].member_; \
 			subStorages[i] = m_frcCtx->m_queueViews[i].member_; \
 		} \
 		} \
-		combineQueueElements<t_>(alloc, WeakArray<TRenderQueueElementStorage<t_>>(&subStorages[0], threadCount), \
+		combineQueueElements<t_>(pool, WeakArray<TRenderQueueElementStorage<t_>>(&subStorages[0], threadCount), \
 								 nullptr, results.member_, nullptr); \
 								 nullptr, results.member_, nullptr); \
 	}
 	}
 
 
@@ -737,7 +737,7 @@ void CombineResultsTask::combine()
 }
 }
 
 
 template<typename T>
 template<typename T>
-void CombineResultsTask::combineQueueElements(SceneFrameAllocator<U8>& alloc,
+void CombineResultsTask::combineQueueElements(StackMemoryPool& pool,
 											  WeakArray<TRenderQueueElementStorage<T>> subStorages,
 											  WeakArray<TRenderQueueElementStorage<T>> subStorages,
 											  WeakArray<TRenderQueueElementStorage<U32>>* ptrSubStorages,
 											  WeakArray<TRenderQueueElementStorage<U32>>* ptrSubStorages,
 											  WeakArray<T>& combined, WeakArray<T*>* ptrCombined)
 											  WeakArray<T>& combined, WeakArray<T*>* ptrCombined)
@@ -774,7 +774,7 @@ void CombineResultsTask::combineQueueElements(SceneFrameAllocator<U8>& alloc,
 		// Create the new storage
 		// Create the new storage
 		if(ptrTotalElCount > 0)
 		if(ptrTotalElCount > 0)
 		{
 		{
-			ptrIt = alloc.newArray<T*>(ptrTotalElCount);
+			ptrIt = newArray<T*>(pool, ptrTotalElCount);
 			*ptrCombined = WeakArray<T*>(ptrIt, ptrTotalElCount);
 			*ptrCombined = WeakArray<T*>(ptrIt, ptrTotalElCount);
 		}
 		}
 	}
 	}
@@ -784,7 +784,7 @@ void CombineResultsTask::combineQueueElements(SceneFrameAllocator<U8>& alloc,
 	{
 	{
 		// Can't reuse any of the existing storage, will allocate a brand new one
 		// Can't reuse any of the existing storage, will allocate a brand new one
 
 
-		it = alloc.newArray<T>(totalElCount);
+		it = newArray<T>(pool, totalElCount);
 		biggestSubStorageIdx = kMaxU32;
 		biggestSubStorageIdx = kMaxU32;
 
 
 		combined = WeakArray<T>(it, totalElCount);
 		combined = WeakArray<T>(it, totalElCount);
@@ -850,12 +850,12 @@ void SceneGraph::doVisibilityTests(SceneNode& fsn, SceneGraph& scene, RenderQueu
 		ANKI_ASSERT(
 		ANKI_ASSERT(
 			!(extendedFrustum->getEnabledVisibilityTests() & ~FrustumComponentVisibilityTestFlag::kAllRayTracing));
 			!(extendedFrustum->getEnabledVisibilityTests() & ~FrustumComponentVisibilityTestFlag::kAllRayTracing));
 
 
-		rqueue.m_rayTracingQueue = scene.getFrameAllocator().newInstance<RenderQueue>();
+		rqueue.m_rayTracingQueue = newInstance<RenderQueue>(scene.getFrameMemoryPool());
 		ctx.submitNewWork(*extendedFrustum, mainFrustum, *rqueue.m_rayTracingQueue, hive);
 		ctx.submitNewWork(*extendedFrustum, mainFrustum, *rqueue.m_rayTracingQueue, hive);
 	}
 	}
 
 
 	hive.waitAllTasks();
 	hive.waitAllTasks();
-	ctx.m_testedFrcs.destroy(scene.getFrameAllocator());
+	ctx.m_testedFrcs.destroy(scene.getFrameMemoryPool());
 }
 }
 
 
 } // end namespace anki
 } // end namespace anki

+ 3 - 4
AnKi/Scene/VisibilityInternal.h

@@ -67,14 +67,14 @@ public:
 	U32 m_elementCount = 0;
 	U32 m_elementCount = 0;
 	U32 m_elementStorage = 0;
 	U32 m_elementStorage = 0;
 
 
-	T* newElement(SceneFrameAllocator<T> alloc)
+	T* newElement(StackMemoryPool& pool)
 	{
 	{
 		if(ANKI_UNLIKELY(m_elementCount + 1 > m_elementStorage))
 		if(ANKI_UNLIKELY(m_elementCount + 1 > m_elementStorage))
 		{
 		{
 			m_elementStorage = max(kInitialStorage, m_elementStorage * kStorageGrowRate);
 			m_elementStorage = max(kInitialStorage, m_elementStorage * kStorageGrowRate);
 
 
 			const T* oldElements = m_elements;
 			const T* oldElements = m_elements;
-			m_elements = alloc.allocate(m_elementStorage);
+			m_elements = static_cast<T*>(pool.allocate(m_elementStorage, alignof(T)));
 
 
 			if(oldElements)
 			if(oldElements)
 			{
 			{
@@ -238,8 +238,7 @@ public:
 
 
 private:
 private:
 	template<typename T>
 	template<typename T>
-	static void combineQueueElements(SceneFrameAllocator<U8>& alloc,
-									 WeakArray<TRenderQueueElementStorage<T>> subStorages,
+	static void combineQueueElements(StackMemoryPool& pool, WeakArray<TRenderQueueElementStorage<T>> subStorages,
 									 WeakArray<TRenderQueueElementStorage<U32>>* ptrSubStorage, WeakArray<T>& combined,
 									 WeakArray<TRenderQueueElementStorage<U32>>* ptrSubStorage, WeakArray<T>& combined,
 									 WeakArray<T*>* ptrCombined);
 									 WeakArray<T*>* ptrCombined);
 };
 };

+ 10 - 10
AnKi/Util/ObjectAllocator.h

@@ -36,13 +36,13 @@ public:
 
 
 	/// Allocate and construct a new object instance.
 	/// Allocate and construct a new object instance.
 	/// @note Not thread-safe.
 	/// @note Not thread-safe.
-	template<typename T, typename TAlloc, typename... TArgs>
-	T* newInstance(TAlloc& alloc, TArgs&&... args);
+	template<typename T, typename TMemPool, typename... TArgs>
+	T* newInstance(TMemPool& pool, TArgs&&... args);
 
 
 	/// Delete an object.
 	/// Delete an object.
 	/// @note Not thread-safe.
 	/// @note Not thread-safe.
-	template<typename T, typename TAlloc>
-	void deleteInstance(TAlloc& alloc, T* obj);
+	template<typename T, typename TMemPool>
+	void deleteInstance(TMemPool& pool, T* obj);
 
 
 private:
 private:
 	/// Storage with equal properties as the object.
 	/// Storage with equal properties as the object.
@@ -76,18 +76,18 @@ public:
 
 
 	/// Allocate and construct a new object instance.
 	/// Allocate and construct a new object instance.
 	/// @note Not thread-safe.
 	/// @note Not thread-safe.
-	template<typename TAlloc, typename... TArgs>
-	T* newInstance(TAlloc& alloc, TArgs&&... args)
+	template<typename TMemPool, typename... TArgs>
+	T* newInstance(TMemPool& pool, TArgs&&... args)
 	{
 	{
-		return Base::template newInstance<T>(alloc, std::forward(args)...);
+		return Base::template newInstance<T>(pool, std::forward(args)...);
 	}
 	}
 
 
 	/// Delete an object.
 	/// Delete an object.
 	/// @note Not thread-safe.
 	/// @note Not thread-safe.
-	template<typename TAlloc>
-	void deleteInstance(TAlloc& alloc, T* obj)
+	template<typename TMemPool>
+	void deleteInstance(TMemPool& pool, T* obj)
 	{
 	{
-		Base::deleteInstance(alloc, obj);
+		Base::deleteInstance(pool, obj);
 	}
 	}
 };
 };
 /// @}
 /// @}

+ 8 - 8
AnKi/Util/ObjectAllocator.inl.h

@@ -8,8 +8,8 @@
 namespace anki {
 namespace anki {
 
 
 template<PtrSize kTObjectSize, U32 kTObjectAlignment, U32 kTObjectsPerChunk, typename TIndexType>
 template<PtrSize kTObjectSize, U32 kTObjectAlignment, U32 kTObjectsPerChunk, typename TIndexType>
-template<typename T, typename TAlloc, typename... TArgs>
-T* ObjectAllocator<kTObjectSize, kTObjectAlignment, kTObjectsPerChunk, TIndexType>::newInstance(TAlloc& alloc,
+template<typename T, typename TMemPool, typename... TArgs>
+T* ObjectAllocator<kTObjectSize, kTObjectAlignment, kTObjectsPerChunk, TIndexType>::newInstance(TMemPool& pool,
 																								TArgs&&... args)
 																								TArgs&&... args)
 {
 {
 	static_assert(alignof(T) <= kObjectAlignment, "Wrong object alignment");
 	static_assert(alignof(T) <= kObjectAlignment, "Wrong object alignment");
@@ -37,7 +37,7 @@ T* ObjectAllocator<kTObjectSize, kTObjectAlignment, kTObjectsPerChunk, TIndexTyp
 		// Need to create a new chunk
 		// Need to create a new chunk
 
 
 		// Create the chunk
 		// Create the chunk
-		chunk = alloc.template newInstance<Chunk>();
+		chunk = anki::newInstance<Chunk>(pool);
 		chunk->m_unusedCount = kObjectsPerChunk;
 		chunk->m_unusedCount = kObjectsPerChunk;
 
 
 		for(U32 i = 0; i < kObjectsPerChunk; ++i)
 		for(U32 i = 0; i < kObjectsPerChunk; ++i)
@@ -65,14 +65,14 @@ T* ObjectAllocator<kTObjectSize, kTObjectAlignment, kTObjectsPerChunk, TIndexTyp
 	ANKI_ASSERT(out);
 	ANKI_ASSERT(out);
 
 
 	// Construct it
 	// Construct it
-	alloc.construct(out, std::forward<TArgs>(args)...);
+	callConstructor(*out, std::forward<TArgs>(args)...);
 
 
 	return out;
 	return out;
 }
 }
 
 
 template<PtrSize kTObjectSize, U32 kTObjectAlignment, U32 kTObjectsPerChunk, typename TIndexType>
 template<PtrSize kTObjectSize, U32 kTObjectAlignment, U32 kTObjectsPerChunk, typename TIndexType>
-template<typename T, typename TAlloc>
-void ObjectAllocator<kTObjectSize, kTObjectAlignment, kTObjectsPerChunk, TIndexType>::deleteInstance(TAlloc& alloc,
+template<typename T, typename TMemPool>
+void ObjectAllocator<kTObjectSize, kTObjectAlignment, kTObjectsPerChunk, TIndexType>::deleteInstance(TMemPool& pool,
 																									 T* obj)
 																									 T* obj)
 {
 {
 	static_assert(alignof(T) <= kObjectAlignment, "Wrong object alignment");
 	static_assert(alignof(T) <= kObjectAlignment, "Wrong object alignment");
@@ -95,7 +95,7 @@ void ObjectAllocator<kTObjectSize, kTObjectAlignment, kTObjectsPerChunk, TIndexT
 			const U32 idx = U32(mem - begin);
 			const U32 idx = U32(mem - begin);
 
 
 			// Destroy the object
 			// Destroy the object
-			obj->~T();
+			callDestructor(*obj);
 
 
 			// Remove from the chunk
 			// Remove from the chunk
 			chunk->m_unusedStack[chunk->m_unusedCount] = idx;
 			chunk->m_unusedStack[chunk->m_unusedCount] = idx;
@@ -126,7 +126,7 @@ void ObjectAllocator<kTObjectSize, kTObjectAlignment, kTObjectsPerChunk, TIndexT
 					chunk->m_next->m_prev = chunk->m_prev;
 					chunk->m_next->m_prev = chunk->m_prev;
 				}
 				}
 
 
-				alloc.deleteInstance(chunk);
+				anki::deleteInstance(pool, chunk);
 			}
 			}
 
 
 			break;
 			break;