Browse Source

Remove the allocator from the renderer

Panagiotis Christopoulos Charitos 3 years ago
parent
commit
4e4413115a

+ 1 - 1
AnKi/Gr/RenderGraph.h

@@ -332,7 +332,7 @@ public:
 	void setWork(U32 secondLeveCmdbCount, TFunc func)
 	{
 		ANKI_ASSERT(m_type == Type::kGraphics || secondLeveCmdbCount == 0);
-		m_callback.init(m_pool, func);
+		m_callback.init(*m_pool, func);
 		m_secondLevelCmdbsCount = secondLeveCmdbCount;
 	}
 

+ 2 - 2
AnKi/Renderer/AccelerationStructureBuilder.cpp

@@ -22,8 +22,8 @@ void AccelerationStructureBuilder::populateRenderGraph(RenderingContext& ctx)
 	ANKI_ASSERT(instanceCount > 0);
 
 	// Create the instances. Allocate but not construct to save some CPU time
-	void* instancesMem = ctx.m_tempAllocator.getMemoryPool().allocate(
-		sizeof(AccelerationStructureInstance) * instanceCount, alignof(AccelerationStructureInstance));
+	void* instancesMem = ctx.m_tempPool->allocate(sizeof(AccelerationStructureInstance) * instanceCount,
+												  alignof(AccelerationStructureInstance));
 	WeakArray<AccelerationStructureInstance> instances(static_cast<AccelerationStructureInstance*>(instancesMem),
 													   instanceCount);
 

+ 4 - 3
AnKi/Renderer/Common.h

@@ -126,8 +126,9 @@ public:
 };
 
 /// A convenience function to find empty cache entries. Used for various probes.
-template<typename THashMap, typename TCacheEntryArray, typename TAlloc>
-U32 findBestCacheEntry(U64 uuid, Timestamp crntTimestamp, const TCacheEntryArray& entries, THashMap& map, TAlloc alloc)
+template<typename THashMap, typename TCacheEntryArray, typename TMemPool>
+U32 findBestCacheEntry(U64 uuid, Timestamp crntTimestamp, const TCacheEntryArray& entries, THashMap& map,
+					   TMemPool& pool)
 {
 	ANKI_ASSERT(uuid > 0);
 
@@ -144,7 +145,7 @@ U32 findBestCacheEntry(U64 uuid, Timestamp crntTimestamp, const TCacheEntryArray
 		else
 		{
 			// Cache entry is wrong, remove it
-			map.erase(alloc, it);
+			map.erase(pool, it);
 		}
 	}
 

+ 1 - 1
AnKi/Renderer/Dbg.cpp

@@ -69,7 +69,7 @@ void Dbg::run(RenderPassWorkContext& rgraphCtx, const RenderingContext& ctx)
 	dctx.m_projectionMatrix = ctx.m_renderQueue->m_projectionMatrix;
 	dctx.m_cameraTransform = ctx.m_renderQueue->m_cameraTransform;
 	dctx.m_stagingGpuAllocator = &m_r->getStagingGpuMemory();
-	dctx.m_frameAllocator = ctx.m_tempAllocator;
+	dctx.m_framePool = ctx.m_tempPool;
 	dctx.m_commandBuffer = cmdb;
 	dctx.m_sampler = m_r->getSamplers().m_trilinearRepeatAniso;
 	dctx.m_key = RenderingKey(RenderingTechnique::FORWARD, 0, 1, false, false);

+ 2 - 2
AnKi/Renderer/DepthDownscale.cpp

@@ -34,7 +34,7 @@ DepthDownscale::~DepthDownscale()
 		m_clientBuffer->unmap();
 	}
 
-	m_fbDescrs.destroy(getAllocator());
+	m_fbDescrs.destroy(getMemoryPool());
 }
 
 Error DepthDownscale::initInternal()
@@ -138,7 +138,7 @@ Error DepthDownscale::initInternal()
 
 	if(!preferCompute)
 	{
-		m_fbDescrs.create(getAllocator(), m_mipCount);
+		m_fbDescrs.create(getMemoryPool(), m_mipCount);
 		for(U32 mip = 0; mip < m_mipCount; ++mip)
 		{
 			FramebufferDescription& fbDescr = m_fbDescrs[mip];

+ 2 - 2
AnKi/Renderer/DownscaleBlur.cpp

@@ -13,7 +13,7 @@ namespace anki {
 
 DownscaleBlur::~DownscaleBlur()
 {
-	m_fbDescrs.destroy(getAllocator());
+	m_fbDescrs.destroy(getMemoryPool());
 }
 
 Error DownscaleBlur::init()
@@ -56,7 +56,7 @@ Error DownscaleBlur::initInternal()
 	// FB descr
 	if(!preferCompute)
 	{
-		m_fbDescrs.create(getAllocator(), m_passCount);
+		m_fbDescrs.create(getMemoryPool(), m_passCount);
 		for(U32 pass = 0; pass < m_passCount; ++pass)
 		{
 			m_fbDescrs[pass].m_colorAttachmentCount = 1;

+ 12 - 11
AnKi/Renderer/IndirectDiffuseProbes.cpp

@@ -56,8 +56,8 @@ public:
 
 IndirectDiffuseProbes::~IndirectDiffuseProbes()
 {
-	m_cacheEntries.destroy(getAllocator());
-	m_probeUuidToCacheEntryIdx.destroy(getAllocator());
+	m_cacheEntries.destroy(getMemoryPool());
+	m_probeUuidToCacheEntryIdx.destroy(getMemoryPool());
 }
 
 const RenderTargetHandle&
@@ -109,7 +109,7 @@ Error IndirectDiffuseProbes::init()
 Error IndirectDiffuseProbes::initInternal()
 {
 	m_tileSize = getConfig().getRIndirectDiffuseProbeTileResolution();
-	m_cacheEntries.create(getAllocator(), getConfig().getRIndirectDiffuseProbeMaxCachedProbes());
+	m_cacheEntries.create(getMemoryPool(), getConfig().getRIndirectDiffuseProbeMaxCachedProbes());
 	m_maxVisibleProbes = getConfig().getRIndirectDiffuseProbeMaxVisibleProbes();
 	ANKI_ASSERT(m_maxVisibleProbes <= MAX_VISIBLE_GLOBAL_ILLUMINATION_PROBES);
 	ANKI_ASSERT(m_cacheEntries.getSize() >= m_maxVisibleProbes);
@@ -134,7 +134,8 @@ Error IndirectDiffuseProbes::initGBuffer()
 		{
 			texinit.m_format = kGBufferColorRenderTargetFormats[i];
 			m_gbuffer.m_colorRtDescrs[i] = texinit;
-			m_gbuffer.m_colorRtDescrs[i].setName(StringRaii(getAllocator()).sprintf("GI GBuff Col #%u", i).toCString());
+			m_gbuffer.m_colorRtDescrs[i].setName(
+				StringRaii(&getMemoryPool()).sprintf("GI GBuff Col #%u", i).toCString());
 			m_gbuffer.m_colorRtDescrs[i].bake();
 		}
 
@@ -228,7 +229,7 @@ void IndirectDiffuseProbes::populateRenderGraph(RenderingContext& rctx)
 {
 	ANKI_TRACE_SCOPED_EVENT(R_GI);
 
-	InternalContext* giCtx = rctx.m_tempAllocator.newInstance<InternalContext>();
+	InternalContext* giCtx = newInstance<InternalContext>(*rctx.m_tempPool);
 	m_giCtx = giCtx;
 	giCtx->m_gi = this;
 	giCtx->m_ctx = &rctx;
@@ -391,9 +392,9 @@ void IndirectDiffuseProbes::prepareProbes(InternalContext& giCtx)
 	// - Find a probe to update next frame
 	// - Find the cache entries for each probe
 	DynamicArray<GlobalIlluminationProbeQueueElement> newListOfProbes;
-	newListOfProbes.create(ctx.m_tempAllocator, ctx.m_renderQueue->m_giProbes.getSize());
+	newListOfProbes.create(*ctx.m_tempPool, ctx.m_renderQueue->m_giProbes.getSize());
 	DynamicArray<RenderTargetHandle> volumeRts;
-	volumeRts.create(ctx.m_tempAllocator, ctx.m_renderQueue->m_giProbes.getSize());
+	volumeRts.create(*ctx.m_tempPool, ctx.m_renderQueue->m_giProbes.getSize());
 	U32 newListOfProbeCount = 0;
 	Bool foundProbeToUpdateNextFrame = false;
 	for(U32 probeIdx = 0; probeIdx < ctx.m_renderQueue->m_giProbes.getSize(); ++probeIdx)
@@ -410,7 +411,7 @@ void IndirectDiffuseProbes::prepareProbes(InternalContext& giCtx)
 
 		// Find cache entry
 		const U32 cacheEntryIdx = findBestCacheEntry(probe.m_uuid, m_r->getGlobalTimestamp(), m_cacheEntries,
-													 m_probeUuidToCacheEntryIdx, getAllocator());
+													 m_probeUuidToCacheEntryIdx, getMemoryPool());
 		if(ANKI_UNLIKELY(cacheEntryIdx == kMaxU32))
 		{
 			// Failed
@@ -468,7 +469,7 @@ void IndirectDiffuseProbes::prepareProbes(InternalContext& giCtx)
 			entry.m_probeAabbMin = probe.m_aabbMin;
 			entry.m_probeAabbMax = probe.m_aabbMax;
 			entry.m_volumeSize = probe.m_cellCounts;
-			m_probeUuidToCacheEntryIdx.emplace(getAllocator(), probe.m_uuid, cacheEntryIdx);
+			m_probeUuidToCacheEntryIdx.emplace(getMemoryPool(), probe.m_uuid, cacheEntryIdx);
 		}
 
 		// Update the cache entry
@@ -533,8 +534,8 @@ void IndirectDiffuseProbes::prepareProbes(InternalContext& giCtx)
 	else
 	{
 		ctx.m_renderQueue->m_giProbes = WeakArray<GlobalIlluminationProbeQueueElement>();
-		newListOfProbes.destroy(ctx.m_tempAllocator);
-		volumeRts.destroy(ctx.m_tempAllocator);
+		newListOfProbes.destroy(*ctx.m_tempPool);
+		volumeRts.destroy(*ctx.m_tempPool);
 	}
 }
 

+ 7 - 7
AnKi/Renderer/MainRenderer.cpp

@@ -30,8 +30,8 @@ MainRenderer::~MainRenderer()
 
 Error MainRenderer::init(const MainRendererInitInfo& inf)
 {
-	m_alloc = HeapAllocator<U8>(inf.m_allocCallback, inf.m_allocCallbackUserData, "MainRenderer");
-	m_frameAlloc = StackAllocator<U8>(inf.m_allocCallback, inf.m_allocCallbackUserData, 10_MB, 1.0f);
+	m_pool.init(inf.m_allocCallback, inf.m_allocCallbackUserData, "MainRenderer");
+	m_framePool.init(inf.m_allocCallback, inf.m_allocCallbackUserData, 10_MB, 1.0f);
 
 	// Init renderer and manipulate the width/height
 	m_swapchainResolution = inf.m_swapchainSize;
@@ -40,8 +40,8 @@ Error MainRenderer::init(const MainRendererInitInfo& inf)
 	ANKI_R_LOGI("Initializing main renderer. Swapchain resolution %ux%u", m_swapchainResolution.x(),
 				m_swapchainResolution.y());
 
-	m_r.reset(m_alloc.newInstance<Renderer>());
-	ANKI_CHECK(m_r->init(inf.m_threadHive, inf.m_resourceManager, inf.m_gr, inf.m_stagingMemory, inf.m_ui, m_alloc,
+	m_r.reset(newInstance<Renderer>(m_pool));
+	ANKI_CHECK(m_r->init(inf.m_threadHive, inf.m_resourceManager, inf.m_gr, inf.m_stagingMemory, inf.m_ui, &m_pool,
 						 inf.m_config, inf.m_globTimestamp, m_swapchainResolution));
 
 	// Init other
@@ -82,10 +82,10 @@ Error MainRenderer::render(RenderQueue& rqueue, TexturePtr presentTex)
 	m_stats.m_renderingCpuTime = (m_statsEnabled) ? HighRezTimer::getCurrentTime() : -1.0;
 
 	// First thing, reset the temp mem pool
-	m_frameAlloc.getMemoryPool().reset();
+	m_framePool.reset();
 
 	// Run renderer
-	RenderingContext ctx(m_frameAlloc);
+	RenderingContext ctx(&m_framePool);
 	m_runCtx.m_ctx = &ctx;
 	m_runCtx.m_secondaryTaskId.setNonAtomically(0);
 	ctx.m_renderGraphDescr.setStatisticsEnabled(m_statsEnabled);
@@ -138,7 +138,7 @@ Error MainRenderer::render(RenderQueue& rqueue, TexturePtr presentTex)
 	}
 
 	// Bake the render graph
-	m_rgraph->compileNewGraph(ctx.m_renderGraphDescr, m_frameAlloc);
+	m_rgraph->compileNewGraph(ctx.m_renderGraphDescr, m_framePool);
 
 	// Populate the 2nd level command buffers
 	Array<ThreadHiveTask, ThreadHive::kMaxThreads> tasks;

+ 2 - 2
AnKi/Renderer/MainRenderer.h

@@ -83,8 +83,8 @@ public:
 	}
 
 private:
-	HeapAllocator<U8> m_alloc;
-	StackAllocator<U8> m_frameAlloc;
+	HeapMemoryPool m_pool;
+	StackMemoryPool m_framePool;
 
 	UniquePtr<Renderer> m_r;
 	Bool m_rDrawToDefaultFb = false;

+ 8 - 8
AnKi/Renderer/ProbeReflections.cpp

@@ -23,8 +23,8 @@ ProbeReflections::ProbeReflections(Renderer* r)
 
 ProbeReflections::~ProbeReflections()
 {
-	m_cacheEntries.destroy(getAllocator());
-	m_probeUuidToCacheEntryIdx.destroy(getAllocator());
+	m_cacheEntries.destroy(getMemoryPool());
+	m_probeUuidToCacheEntryIdx.destroy(getMemoryPool());
 }
 
 Error ProbeReflections::init()
@@ -41,7 +41,7 @@ Error ProbeReflections::init()
 Error ProbeReflections::initInternal()
 {
 	// Init cache entries
-	m_cacheEntries.create(getAllocator(), getConfig().getRProbeRefectionMaxCachedProbes());
+	m_cacheEntries.create(getMemoryPool(), getConfig().getRProbeRefectionMaxCachedProbes());
 
 	ANKI_CHECK(initGBuffer());
 	ANKI_CHECK(initLightShading());
@@ -78,7 +78,7 @@ Error ProbeReflections::initGBuffer()
 			texinit.m_format = kGBufferColorRenderTargetFormats[i];
 			m_gbuffer.m_colorRtDescrs[i] = texinit;
 			m_gbuffer.m_colorRtDescrs[i].setName(
-				StringRaii(getAllocator()).sprintf("CubeRefl GBuff Col #%u", i).toCString());
+				StringRaii(&getMemoryPool()).sprintf("CubeRefl GBuff Col #%u", i).toCString());
 			m_gbuffer.m_colorRtDescrs[i].bake();
 		}
 
@@ -233,7 +233,7 @@ void ProbeReflections::prepareProbes(RenderingContext& ctx, ReflectionProbeQueue
 	// - Find a probe to update next frame
 	// - Find the cache entries for each probe
 	DynamicArray<ReflectionProbeQueueElement> newListOfProbes;
-	newListOfProbes.create(ctx.m_tempAllocator, ctx.m_renderQueue->m_reflectionProbes.getSize());
+	newListOfProbes.create(*ctx.m_tempPool, ctx.m_renderQueue->m_reflectionProbes.getSize());
 	U32 newListOfProbeCount = 0;
 	Bool foundProbeToUpdateNextFrame = false;
 	for(U32 probeIdx = 0; probeIdx < ctx.m_renderQueue->m_reflectionProbes.getSize(); ++probeIdx)
@@ -242,7 +242,7 @@ void ProbeReflections::prepareProbes(RenderingContext& ctx, ReflectionProbeQueue
 
 		// Find cache entry
 		const U32 cacheEntryIdx = findBestCacheEntry(probe.m_uuid, m_r->getGlobalTimestamp(), m_cacheEntries,
-													 m_probeUuidToCacheEntryIdx, getAllocator());
+													 m_probeUuidToCacheEntryIdx, getMemoryPool());
 		if(ANKI_UNLIKELY(cacheEntryIdx == kMaxU32))
 		{
 			// Failed
@@ -295,7 +295,7 @@ void ProbeReflections::prepareProbes(RenderingContext& ctx, ReflectionProbeQueue
 		// Update cache map
 		if(!probeFoundInCache)
 		{
-			m_probeUuidToCacheEntryIdx.emplace(getAllocator(), probe.m_uuid, cacheEntryIdx);
+			m_probeUuidToCacheEntryIdx.emplace(getMemoryPool(), probe.m_uuid, cacheEntryIdx);
 		}
 
 		// Don't gather renderables next frame
@@ -316,7 +316,7 @@ void ProbeReflections::prepareProbes(RenderingContext& ctx, ReflectionProbeQueue
 	else
 	{
 		ctx.m_renderQueue->m_reflectionProbes = WeakArray<ReflectionProbeQueueElement>();
-		newListOfProbes.destroy(ctx.m_tempAllocator);
+		newListOfProbes.destroy(*ctx.m_tempPool);
 	}
 }
 

+ 37 - 37
AnKi/Renderer/Renderer.cpp

@@ -87,14 +87,14 @@ Renderer::~Renderer()
 {
 	for(DebugRtInfo& info : m_debugRts)
 	{
-		info.m_rtName.destroy(getAllocator());
+		info.m_rtName.destroy(getMemoryPool());
 	}
-	m_debugRts.destroy(getAllocator());
-	m_currentDebugRtName.destroy(getAllocator());
+	m_debugRts.destroy(getMemoryPool());
+	m_currentDebugRtName.destroy(getMemoryPool());
 }
 
 Error Renderer::init(ThreadHive* hive, ResourceManager* resources, GrManager* gl, StagingGpuMemoryPool* stagingMem,
-					 UiManager* ui, HeapAllocator<U8> alloc, ConfigSet* config, Timestamp* globTimestamp,
+					 UiManager* ui, HeapMemoryPool* pool, ConfigSet* config, Timestamp* globTimestamp,
 					 UVec2 swapchainSize)
 {
 	ANKI_TRACE_SCOPED_EVENT(R_INIT);
@@ -105,7 +105,7 @@ Error Renderer::init(ThreadHive* hive, ResourceManager* resources, GrManager* gl
 	m_gr = gl;
 	m_stagingMem = stagingMem;
 	m_ui = ui;
-	m_alloc = std::move(alloc);
+	m_pool = pool;
 	m_config = config;
 
 	const Error err = initInternal(swapchainSize);
@@ -170,93 +170,93 @@ Error Renderer::initInternal(UVec2 swapchainResolution)
 	}
 
 	// Init the stages. Careful with the order!!!!!!!!!!
-	m_genericCompute.reset(m_alloc.newInstance<GenericCompute>(this));
+	m_genericCompute.reset(newInstance<GenericCompute>(*m_pool, this));
 	ANKI_CHECK(m_genericCompute->init());
 
-	m_volumetricLightingAccumulation.reset(m_alloc.newInstance<VolumetricLightingAccumulation>(this));
+	m_volumetricLightingAccumulation.reset(newInstance<VolumetricLightingAccumulation>(*m_pool, this));
 	ANKI_CHECK(m_volumetricLightingAccumulation->init());
 
-	m_indirectDiffuseProbes.reset(m_alloc.newInstance<IndirectDiffuseProbes>(this));
+	m_indirectDiffuseProbes.reset(newInstance<IndirectDiffuseProbes>(*m_pool, this));
 	ANKI_CHECK(m_indirectDiffuseProbes->init());
 
-	m_probeReflections.reset(m_alloc.newInstance<ProbeReflections>(this));
+	m_probeReflections.reset(newInstance<ProbeReflections>(*m_pool, this));
 	ANKI_CHECK(m_probeReflections->init());
 
-	m_vrsSriGeneration.reset(m_alloc.newInstance<VrsSriGeneration>(this));
+	m_vrsSriGeneration.reset(newInstance<VrsSriGeneration>(*m_pool, this));
 	ANKI_CHECK(m_vrsSriGeneration->init());
 
-	m_scale.reset(m_alloc.newInstance<Scale>(this));
+	m_scale.reset(newInstance<Scale>(*m_pool, this));
 	ANKI_CHECK(m_scale->init());
 
-	m_gbuffer.reset(m_alloc.newInstance<GBuffer>(this));
+	m_gbuffer.reset(newInstance<GBuffer>(*m_pool, this));
 	ANKI_CHECK(m_gbuffer->init());
 
-	m_gbufferPost.reset(m_alloc.newInstance<GBufferPost>(this));
+	m_gbufferPost.reset(newInstance<GBufferPost>(*m_pool, this));
 	ANKI_CHECK(m_gbufferPost->init());
 
-	m_shadowMapping.reset(m_alloc.newInstance<ShadowMapping>(this));
+	m_shadowMapping.reset(newInstance<ShadowMapping>(*m_pool, this));
 	ANKI_CHECK(m_shadowMapping->init());
 
-	m_volumetricFog.reset(m_alloc.newInstance<VolumetricFog>(this));
+	m_volumetricFog.reset(newInstance<VolumetricFog>(*m_pool, this));
 	ANKI_CHECK(m_volumetricFog->init());
 
-	m_lightShading.reset(m_alloc.newInstance<LightShading>(this));
+	m_lightShading.reset(newInstance<LightShading>(*m_pool, this));
 	ANKI_CHECK(m_lightShading->init());
 
-	m_depthDownscale.reset(m_alloc.newInstance<DepthDownscale>(this));
+	m_depthDownscale.reset(newInstance<DepthDownscale>(*m_pool, this));
 	ANKI_CHECK(m_depthDownscale->init());
 
-	m_forwardShading.reset(m_alloc.newInstance<ForwardShading>(this));
+	m_forwardShading.reset(newInstance<ForwardShading>(*m_pool, this));
 	ANKI_CHECK(m_forwardShading->init());
 
-	m_lensFlare.reset(m_alloc.newInstance<LensFlare>(this));
+	m_lensFlare.reset(newInstance<LensFlare>(*m_pool, this));
 	ANKI_CHECK(m_lensFlare->init());
 
-	m_downscaleBlur.reset(getAllocator().newInstance<DownscaleBlur>(this));
+	m_downscaleBlur.reset(newInstance<DownscaleBlur>(*m_pool, this));
 	ANKI_CHECK(m_downscaleBlur->init());
 
-	m_indirectSpecular.reset(m_alloc.newInstance<IndirectSpecular>(this));
+	m_indirectSpecular.reset(newInstance<IndirectSpecular>(*m_pool, this));
 	ANKI_CHECK(m_indirectSpecular->init());
 
-	m_tonemapping.reset(getAllocator().newInstance<Tonemapping>(this));
+	m_tonemapping.reset(newInstance<Tonemapping>(*m_pool, this));
 	ANKI_CHECK(m_tonemapping->init());
 
-	m_temporalAA.reset(getAllocator().newInstance<TemporalAA>(this));
+	m_temporalAA.reset(newInstance<TemporalAA>(*m_pool, this));
 	ANKI_CHECK(m_temporalAA->init());
 
-	m_bloom.reset(m_alloc.newInstance<Bloom>(this));
+	m_bloom.reset(newInstance<Bloom>(*m_pool, this));
 	ANKI_CHECK(m_bloom->init());
 
-	m_finalComposite.reset(m_alloc.newInstance<FinalComposite>(this));
+	m_finalComposite.reset(newInstance<FinalComposite>(*m_pool, this));
 	ANKI_CHECK(m_finalComposite->init());
 
-	m_dbg.reset(m_alloc.newInstance<Dbg>(this));
+	m_dbg.reset(newInstance<Dbg>(*m_pool, this));
 	ANKI_CHECK(m_dbg->init());
 
-	m_uiStage.reset(m_alloc.newInstance<UiStage>(this));
+	m_uiStage.reset(newInstance<UiStage>(*m_pool, this));
 	ANKI_CHECK(m_uiStage->init());
 
-	m_indirectDiffuse.reset(m_alloc.newInstance<IndirectDiffuse>(this));
+	m_indirectDiffuse.reset(newInstance<IndirectDiffuse>(*m_pool, this));
 	ANKI_CHECK(m_indirectDiffuse->init());
 
 	if(getGrManager().getDeviceCapabilities().m_rayTracingEnabled && getConfig().getSceneRayTracedShadows())
 	{
-		m_accelerationStructureBuilder.reset(m_alloc.newInstance<AccelerationStructureBuilder>(this));
+		m_accelerationStructureBuilder.reset(newInstance<AccelerationStructureBuilder>(*m_pool, this));
 		ANKI_CHECK(m_accelerationStructureBuilder->init());
 
-		m_rtShadows.reset(m_alloc.newInstance<RtShadows>(this));
+		m_rtShadows.reset(newInstance<RtShadows>(*m_pool, this));
 		ANKI_CHECK(m_rtShadows->init());
 	}
 	else
 	{
-		m_shadowmapsResolve.reset(m_alloc.newInstance<ShadowmapsResolve>(this));
+		m_shadowmapsResolve.reset(newInstance<ShadowmapsResolve>(*m_pool, this));
 		ANKI_CHECK(m_shadowmapsResolve->init());
 	}
 
-	m_motionVectors.reset(m_alloc.newInstance<MotionVectors>(this));
+	m_motionVectors.reset(newInstance<MotionVectors>(*m_pool, this));
 	ANKI_CHECK(m_motionVectors->init());
 
-	m_clusterBinning.reset(m_alloc.newInstance<ClusterBinning>(this));
+	m_clusterBinning.reset(newInstance<ClusterBinning>(*m_pool, this));
 	ANKI_CHECK(m_clusterBinning->init());
 
 	// Init samplers
@@ -612,9 +612,9 @@ void Renderer::registerDebugRenderTarget(RendererObject* obj, CString rtName)
 	ANKI_ASSERT(obj);
 	DebugRtInfo inf;
 	inf.m_obj = obj;
-	inf.m_rtName.create(getAllocator(), rtName);
+	inf.m_rtName.create(getMemoryPool(), rtName);
 
-	m_debugRts.emplaceBack(getAllocator(), std::move(inf));
+	m_debugRts.emplaceBack(getMemoryPool(), std::move(inf));
 }
 
 Bool Renderer::getCurrentDebugRenderTarget(Array<RenderTargetHandle, kMaxDebugRenderTargets>& handles,
@@ -641,11 +641,11 @@ Bool Renderer::getCurrentDebugRenderTarget(Array<RenderTargetHandle, kMaxDebugRe
 
 void Renderer::setCurrentDebugRenderTarget(CString rtName)
 {
-	m_currentDebugRtName.destroy(getAllocator());
+	m_currentDebugRtName.destroy(getMemoryPool());
 
 	if(!rtName.isEmpty() && rtName.getLength() > 0)
 	{
-		m_currentDebugRtName.create(getAllocator(), rtName);
+		m_currentDebugRtName.create(getMemoryPool(), rtName);
 	}
 }
 

+ 5 - 5
AnKi/Renderer/ShadowMapping.cpp

@@ -87,7 +87,7 @@ Error ShadowMapping::initScratch()
 		m_scratch.m_fbDescr.bake();
 	}
 
-	m_scratch.m_tileAlloc.init(getAllocator(), m_scratch.m_tileCountX, m_scratch.m_tileCountY, MAX_LOD_COUNT, false);
+	m_scratch.m_tileAlloc.init(&getMemoryPool(), m_scratch.m_tileCountX, m_scratch.m_tileCountY, MAX_LOD_COUNT, false);
 
 	return Error::kNone;
 }
@@ -114,7 +114,7 @@ Error ShadowMapping::initAtlas()
 	}
 
 	// Tiles
-	m_atlas.m_tileAlloc.init(getAllocator(), m_atlas.m_tileCountBothAxis, m_atlas.m_tileCountBothAxis, MAX_LOD_COUNT,
+	m_atlas.m_tileAlloc.init(&getMemoryPool(), m_atlas.m_tileCountBothAxis, m_atlas.m_tileCountBothAxis, MAX_LOD_COUNT,
 							 true);
 
 	// Programs and shaders
@@ -491,9 +491,9 @@ void ShadowMapping::processLights(RenderingContext& ctx, U32& threadCountForScra
 
 	// Vars
 	const Vec4 cameraOrigin = ctx.m_renderQueue->m_cameraTransform.getTranslationPart().xyz0();
-	DynamicArrayRaii<Scratch::LightToRenderToScratchInfo> lightsToRender(ctx.m_tempAllocator);
+	DynamicArrayRaii<Scratch::LightToRenderToScratchInfo> lightsToRender(ctx.m_tempPool);
 	U32 drawcallCount = 0;
-	DynamicArrayRaii<Atlas::ResolveWorkItem> atlasWorkItems(ctx.m_tempAllocator);
+	DynamicArrayRaii<Atlas::ResolveWorkItem> atlasWorkItems(ctx.m_tempPool);
 
 	// First thing, allocate an empty tile for empty faces of point lights
 	UVec4 emptyTileViewport;
@@ -752,7 +752,7 @@ void ShadowMapping::processLights(RenderingContext& ctx, U32& threadCountForScra
 	// Split the work that will happen in the scratch buffer
 	if(lightsToRender.getSize())
 	{
-		DynamicArrayRaii<Scratch::WorkItem> workItems(ctx.m_tempAllocator);
+		DynamicArrayRaii<Scratch::WorkItem> workItems(ctx.m_tempPool);
 		Scratch::LightToRenderToScratchInfo* lightToRender = lightsToRender.getBegin();
 		U32 lightToRenderDrawcallCount = lightToRender->m_drawcallCount;
 		const Scratch::LightToRenderToScratchInfo* lightToRenderEnd = lightsToRender.getEnd();

+ 10 - 10
AnKi/Renderer/TileAllocator.cpp

@@ -35,12 +35,12 @@ public:
 
 TileAllocator::~TileAllocator()
 {
-	m_lightInfoToTileIdx.destroy(m_alloc);
-	m_allTiles.destroy(m_alloc);
-	m_lodFirstTileIndex.destroy(m_alloc);
+	m_lightInfoToTileIdx.destroy(*m_pool);
+	m_allTiles.destroy(*m_pool);
+	m_lodFirstTileIndex.destroy(*m_pool);
 }
 
-void TileAllocator::init(HeapAllocator<U8> alloc, U32 tileCountX, U32 tileCountY, U32 lodCount, Bool enableCaching)
+void TileAllocator::init(HeapMemoryPool* pool, U32 tileCountX, U32 tileCountY, U32 lodCount, Bool enableCaching)
 {
 	// Preconditions
 	ANKI_ASSERT(tileCountX > 0);
@@ -51,9 +51,9 @@ void TileAllocator::init(HeapAllocator<U8> alloc, U32 tileCountX, U32 tileCountY
 	m_tileCountX = U16(tileCountX);
 	m_tileCountY = U16(tileCountY);
 	m_lodCount = U8(lodCount);
-	m_alloc = std::move(alloc);
+	m_pool = pool;
 	m_cachingEnabled = enableCaching;
-	m_lodFirstTileIndex.create(m_alloc, lodCount + 1);
+	m_lodFirstTileIndex.create(*m_pool, lodCount + 1);
 
 	// Create the tile array & index ranges
 	U32 tileCount = 0;
@@ -69,7 +69,7 @@ void TileAllocator::init(HeapAllocator<U8> alloc, U32 tileCountX, U32 tileCountY
 		tileCount += lodTileCountX * lodTileCountY;
 	}
 	ANKI_ASSERT(tileCount >= tileCountX * tileCountY);
-	m_allTiles.create(m_alloc, tileCount);
+	m_allTiles.create(*m_pool, tileCount);
 	m_lodFirstTileIndex[lodCount] = tileCount - 1;
 
 	// Init the tiles
@@ -242,7 +242,7 @@ TileAllocatorResult TileAllocator::allocate(Timestamp crntTimestamp, Timestamp l
 			if(tile.m_lightUuid != lightUuid || tile.m_lightLod != lod || tile.m_lightFace != lightFace)
 			{
 				// Cache entry is wrong, remove it
-				m_lightInfoToTileIdx.erase(m_alloc, it);
+				m_lightInfoToTileIdx.erase(*m_pool, it);
 			}
 			else
 			{
@@ -337,7 +337,7 @@ TileAllocatorResult TileAllocator::allocate(Timestamp crntTimestamp, Timestamp l
 	// Update the cache
 	if(m_cachingEnabled)
 	{
-		m_lightInfoToTileIdx.emplace(m_alloc, key, allocatedTileIdx);
+		m_lightInfoToTileIdx.emplace(*m_pool, key, allocatedTileIdx);
 	}
 
 	// Return
@@ -359,7 +359,7 @@ void TileAllocator::invalidateCache(U64 lightUuid, U32 lightFace)
 	auto it = m_lightInfoToTileIdx.find(key);
 	if(it != m_lightInfoToTileIdx.getEnd())
 	{
-		m_lightInfoToTileIdx.erase(m_alloc, it);
+		m_lightInfoToTileIdx.erase(*m_pool, it);
 	}
 }
 

+ 2 - 2
AnKi/Renderer/TileAllocator.h

@@ -33,7 +33,7 @@ public:
 	TileAllocator& operator=(const TileAllocator&) = delete; // Non-copyable
 
 	/// Initialize the allocator.
-	void init(HeapAllocator<U8> alloc, U32 tileCountX, U32 tileCountY, U32 lodCount, Bool enableCaching);
+	void init(HeapMemoryPool* pool, U32 tileCountX, U32 tileCountY, U32 lodCount, Bool enableCaching);
 
 	/// Allocate some tiles.
 	[[nodiscard]] TileAllocatorResult allocate(Timestamp crntTimestamp, Timestamp lightTimestamp, U64 lightUuid,
@@ -48,7 +48,7 @@ private:
 	/// A HashMap key.
 	class HashMapKey;
 
-	HeapAllocator<U8> m_alloc;
+	HeapMemoryPool* m_pool = nullptr;
 	DynamicArray<Tile> m_allTiles;
 	DynamicArray<U32> m_lodFirstTileIndex;