소스 검색

Make tests compile

Panagiotis Christopoulos Charitos 3 년 전
부모
커밋
d5f3165482

+ 3 - 2
AnKi/Core/App.cpp

@@ -304,8 +304,9 @@ Error App::initInternal(AllocAlignedCallback allocCb, void* allocCbUserData)
 	m_config->setRsrcDataPaths(shadersPath);
 #endif
 
-	m_resourceFs = newInstance<ResourceFilesystem>(m_mainPool, &m_mainPool);
-	ANKI_CHECK(m_resourceFs->init(*m_config));
+	m_resourceFs = newInstance<ResourceFilesystem>(m_mainPool);
+	ANKI_CHECK(
+		m_resourceFs->init(*m_config, m_mainPool.getAllocationCallback(), m_mainPool.getAllocationCallbackUserData()));
 
 	//
 	// Resources

+ 1 - 1
AnKi/Importer/GltfImporter.cpp

@@ -1167,7 +1167,7 @@ StringRaii GltfImporter::computeModelResourceFilename(const cgltf_mesh& mesh) co
 
 	const U64 hash = computeHash(joined.getBegin(), joined.getLength());
 
-	StringRaii out(m_alloc);
+	StringRaii out(m_pool);
 	out.sprintf("%.64s_%" PRIx64 ".ankimdl", joined.cstr(), hash); // Limit the filename size
 
 	return out;

+ 1 - 1
AnKi/Importer/GltfImporterAnimation.cpp

@@ -49,7 +49,7 @@ static void optimizeChannel(DynamicArrayRaii<GltfAnimKey<T>>& arr, const T& iden
 			break;
 		}
 
-		DynamicArrayRaii<GltfAnimKey<T>> newArr(arr.getAllocator());
+		DynamicArrayRaii<GltfAnimKey<T>> newArr(&arr.getMemoryPool());
 		for(U32 i = 0; i < arr.getSize() - 2; i += 2)
 		{
 			const GltfAnimKey<T>& left = arr[i];

+ 2 - 2
AnKi/Importer/ImageImporter.cpp

@@ -423,7 +423,7 @@ static Error loadFirstMipmap(const ImageImporterConfig& config, ImageImporterCon
 {
 	BaseMemoryPool& pool = ctx.getMemoryPool();
 
-	ctx.m_mipmaps.emplaceBack(pool);
+	ctx.m_mipmaps.emplaceBack(&pool);
 	Mipmap& mip0 = ctx.m_mipmaps[0];
 
 	if(ctx.m_depth > 1)
@@ -962,7 +962,7 @@ static Error importImageInternal(const ImageImporterConfig& configOriginal)
 								   newFilenames[i]));
 
 			newFilenamesCString[i] = newFilenames[i];
-			resizedImagesCleanup.emplaceBack(pool, newFilenames[i]);
+			resizedImagesCleanup.emplaceBack(&pool, newFilenames[i]);
 		}
 
 		// Override config

+ 19 - 18
AnKi/Resource/ResourceFilesystem.cpp

@@ -199,25 +199,26 @@ ResourceFilesystem::~ResourceFilesystem()
 {
 	for(Path& p : m_paths)
 	{
-		p.m_files.destroy(*m_pool);
-		p.m_path.destroy(*m_pool);
+		p.m_files.destroy(m_pool);
+		p.m_path.destroy(m_pool);
 	}
 
-	m_paths.destroy(*m_pool);
-	m_cacheDir.destroy(*m_pool);
+	m_paths.destroy(m_pool);
+	m_cacheDir.destroy(m_pool);
 }
 
-Error ResourceFilesystem::init(const ConfigSet& config)
+Error ResourceFilesystem::init(const ConfigSet& config, AllocAlignedCallback allocCallback, void* allocCallbackUserData)
 {
-	StringListRaii paths(m_pool);
+	m_pool.init(allocCallback, allocCallbackUserData);
+	StringListRaii paths(&m_pool);
 	paths.splitString(config.getRsrcDataPaths(), ':');
 
-	StringListRaii excludedStrings(m_pool);
+	StringListRaii excludedStrings(&m_pool);
 	excludedStrings.splitString(config.getRsrcDataPathExcludedStrings(), ':');
 
 	// Workaround the fact that : is used in drives in Windows
 #if ANKI_OS_WINDOWS
-	StringListRaii paths2(m_pool);
+	StringListRaii paths2(&m_pool);
 	StringListRaii::Iterator it = paths.getBegin();
 	while(it != paths.getEnd())
 	{
@@ -315,7 +316,7 @@ Error ResourceFilesystem::addNewPath(const CString& filepath, const StringListRa
 			const Bool itsADir = info.uncompressed_size == 0;
 			if(!itsADir && !rejectPath(&filename[0]))
 			{
-				path.m_files.pushBackSprintf(*m_pool, "%s", &filename[0]);
+				path.m_files.pushBackSprintf(m_pool, "%s", &filename[0]);
 				++fileCount;
 			}
 		} while(unzGoToNextFile(zfile) == UNZ_OK);
@@ -328,10 +329,10 @@ Error ResourceFilesystem::addNewPath(const CString& filepath, const StringListRa
 	{
 		// It's simple directory
 
-		ANKI_CHECK(walkDirectoryTree(filepath, *m_pool, [&, this](const CString& fname, Bool isDir) -> Error {
+		ANKI_CHECK(walkDirectoryTree(filepath, m_pool, [&, this](const CString& fname, Bool isDir) -> Error {
 			if(!isDir && !rejectPath(fname))
 			{
-				path.m_files.pushBackSprintf(*m_pool, "%s", fname.cstr());
+				path.m_files.pushBackSprintf(m_pool, "%s", fname.cstr());
 				++fileCount;
 			}
 
@@ -346,8 +347,8 @@ Error ResourceFilesystem::addNewPath(const CString& filepath, const StringListRa
 	}
 	else
 	{
-		path.m_path.sprintf(*m_pool, "%s", &filepath[0]);
-		m_paths.emplaceFront(*m_pool, std::move(path));
+		path.m_path.sprintf(m_pool, "%s", &filepath[0]);
+		m_paths.emplaceFront(m_pool, std::move(path));
 
 		ANKI_RESOURCE_LOGI("Added new data path \"%s\" that contains %u files", &filepath[0], fileCount);
 	}
@@ -371,7 +372,7 @@ Error ResourceFilesystem::openFile(const ResourceFilename& filename, ResourceFil
 	if(err)
 	{
 		ANKI_RESOURCE_LOGE("Resource file not found: %s", filename.cstr());
-		deleteInstance(*m_pool, rfile);
+		deleteInstance(m_pool, rfile);
 	}
 	else
 	{
@@ -399,17 +400,17 @@ Error ResourceFilesystem::openFileInternal(const ResourceFilename& filename, Res
 			// Found
 			if(p.m_isArchive)
 			{
-				ZipResourceFile* file = newInstance<ZipResourceFile>(*m_pool, m_pool);
+				ZipResourceFile* file = newInstance<ZipResourceFile>(m_pool, &m_pool);
 				rfile = file;
 
 				ANKI_CHECK(file->open(p.m_path.toCString(), filename));
 			}
 			else
 			{
-				StringRaii newFname(m_pool);
+				StringRaii newFname(&m_pool);
 				newFname.sprintf("%s/%s", &p.m_path[0], &filename[0]);
 
-				CResourceFile* file = newInstance<CResourceFile>(*m_pool, m_pool);
+				CResourceFile* file = newInstance<CResourceFile>(m_pool, &m_pool);
 				rfile = file;
 				ANKI_CHECK(file->m_file.open(newFname, FileOpenFlag::kRead));
 
@@ -428,7 +429,7 @@ Error ResourceFilesystem::openFileInternal(const ResourceFilename& filename, Res
 	// File not found? On Win/Linux try to find it outside the resource dirs. On Android try the archive
 	if(!rfile)
 	{
-		CResourceFile* file = newInstance<CResourceFile>(*m_pool, m_pool);
+		CResourceFile* file = newInstance<CResourceFile>(m_pool, &m_pool);
 		rfile = file;
 
 		FileOpenFlag openFlags = FileOpenFlag::kRead;

+ 3 - 7
AnKi/Resource/ResourceFilesystem.h

@@ -84,11 +84,7 @@ using ResourceFilePtr = IntrusivePtr<ResourceFile>;
 class ResourceFilesystem
 {
 public:
-	ResourceFilesystem(HeapMemoryPool* pool)
-		: m_pool(pool)
-	{
-		ANKI_ASSERT(pool);
-	}
+	ResourceFilesystem() = default;
 
 	ResourceFilesystem(const ResourceFilesystem&) = delete; // Non-copyable
 
@@ -96,7 +92,7 @@ public:
 
 	ResourceFilesystem& operator=(const ResourceFilesystem&) = delete; // Non-copyable
 
-	Error init(const ConfigSet& config);
+	Error init(const ConfigSet& config, AllocAlignedCallback allocCallback, void* allocCallbackUserData);
 
 	/// Search the path list to find the file. Then open the file for reading. It's thread-safe.
 	Error openFile(const ResourceFilename& filename, ResourceFilePtr& file);
@@ -145,7 +141,7 @@ private:
 		}
 	};
 
-	HeapMemoryPool* m_pool = nullptr;
+	HeapMemoryPool m_pool;
 	List<Path> m_paths;
 	String m_cacheDir;
 

+ 1 - 1
AnKi/Util/HashMap.h

@@ -297,7 +297,7 @@ private:
 	{
 		destroy();
 		m_pool = b.m_pool;
-		b.m_sparseArr.clone(*m_pool, Base::m_sparseArr);
+		b.m_sparseArr.clone(m_pool, Base::m_sparseArr);
 	}
 };
 /// @}

+ 4 - 5
AnKi/Util/SegregatedListsAllocatorBuilder.h

@@ -30,14 +30,14 @@ public:
 
 /// The base class for all user memory chunks of SegregatedListsAllocatorBuilder.
 /// @memberof SegregatedListsAllocatorBuilder
-template<typename TChunk, U32 T_CLASS_COUNT>
+template<typename TChunk, U32 kClassCount>
 class SegregatedListsAllocatorBuilderChunkBase
 {
 	template<typename TChunk_, typename TInterface, typename TLock>
 	friend class SegregatedListsAllocatorBuilder;
 
 private:
-	Array<DynamicArray<detail::SegregatedListsAllocatorBuilderFreeBlock>, T_CLASS_COUNT> m_freeLists;
+	Array<DynamicArray<detail::SegregatedListsAllocatorBuilderFreeBlock>, kClassCount> m_freeLists;
 	PtrSize m_totalSize = 0;
 	PtrSize m_freeSize = 0;
 };
@@ -56,8 +56,7 @@ private:
 ///                    /// Deletes a chunk.
 ///                    void deleteChunk(TChunk* chunk);
 ///                    /// Get an allocator for internal allocations of the builder.
-///                    SomeAllocator& getAllocator();
-///                    const SomeAllocator getAllocator() const;
+///                    SomeMemoryPool& getMemoryPool() const;
 ///                    @endcode
 /// @tparam TLock User defined lock (eg Mutex).
 template<typename TChunk, typename TInterface, typename TLock>
@@ -101,7 +100,7 @@ private:
 	using FreeBlock = detail::SegregatedListsAllocatorBuilderFreeBlock;
 	using ChunksIterator = typename DynamicArray<TChunk*>::Iterator;
 
-	TInterface m_interface; ///< XXX
+	TInterface m_interface; ///< The interface.
 
 	DynamicArray<TChunk*> m_chunks;
 

+ 7 - 7
AnKi/Util/SegregatedListsAllocatorBuilder.inl.h

@@ -201,7 +201,7 @@ void SegregatedListsAllocatorBuilder<TChunk, TInterface, TLock>::placeFreeBlock(
 		newBlock.m_address = lblock.m_address;
 		newBlock.m_size += lblock.m_size;
 
-		chunk.m_freeLists[leftClass].erase(m_interface.getAllocator(),
+		chunk.m_freeLists[leftClass].erase(m_interface.getMemoryPool(),
 										   chunk.m_freeLists[leftClass].getBegin() + leftBlock);
 
 		if(rightBlock != kMaxU32 && rightClass == leftClass)
@@ -219,13 +219,13 @@ void SegregatedListsAllocatorBuilder<TChunk, TInterface, TLock>::placeFreeBlock(
 
 		newBlock.m_size += rblock.m_size;
 
-		chunk.m_freeLists[rightClass].erase(m_interface.getAllocator(),
+		chunk.m_freeLists[rightClass].erase(m_interface.getMemoryPool(),
 											chunk.m_freeLists[rightClass].getBegin() + rightBlock);
 	}
 
 	// Store the new block
 	const U32 newClassIdx = findClass(newBlock.m_size, 1);
-	chunk.m_freeLists[newClassIdx].emplaceBack(m_interface.getAllocator(), newBlock);
+	chunk.m_freeLists[newClassIdx].emplaceBack(m_interface.getMemoryPool(), newBlock);
 
 	std::sort(chunk.m_freeLists[newClassIdx].getBegin(), chunk.m_freeLists[newClassIdx].getEnd(),
 			  [](const FreeBlock& a, const FreeBlock& b) {
@@ -243,12 +243,12 @@ void SegregatedListsAllocatorBuilder<TChunk, TInterface, TLock>::placeFreeBlock(
 		for(U32 classIdx = 0; classIdx < TInterface::getClassCount(); ++classIdx)
 		{
 			blockCount += chunk.m_freeLists[classIdx].getSize();
-			chunk.m_freeLists[classIdx].destroy(m_interface.getAllocator());
+			chunk.m_freeLists[classIdx].destroy(m_interface.getMemoryPool());
 		}
 
 		ANKI_ASSERT(blockCount == 1);
 
-		m_chunks.erase(m_interface.getAllocator(), chunkIt);
+		m_chunks.erase(m_interface.getMemoryPool(), chunkIt);
 		m_interface.deleteChunk(&chunk);
 	}
 }
@@ -332,7 +332,7 @@ Error SegregatedListsAllocatorBuilder<TChunk, TInterface, TLock>::allocate(PtrSi
 
 		chunk->m_totalSize = chunkSize;
 		chunk->m_freeSize = 0;
-		m_chunks.emplaceBack(m_interface.getAllocator(), chunk);
+		m_chunks.emplaceBack(m_interface.getMemoryPool(), chunk);
 
 		placeFreeBlock(size, chunkSize - size, m_chunks.getBegin() + m_chunks.getSize() - 1);
 
@@ -349,7 +349,7 @@ Error SegregatedListsAllocatorBuilder<TChunk, TInterface, TLock>::allocate(PtrSi
 		TChunk& chunk = *(*chunkIt);
 
 		const FreeBlock fBlock = *freeBlock;
-		chunk.m_freeLists[classIdx].erase(m_interface.getAllocator(), freeBlock);
+		chunk.m_freeLists[classIdx].erase(m_interface.getMemoryPool(), freeBlock);
 		freeBlock = nullptr;
 
 		ANKI_ASSERT(chunk.m_freeSize >= fBlock.m_size);

+ 4 - 5
Tests/Framework/Framework.cpp

@@ -263,7 +263,8 @@ GrManager* createGrManager(ConfigSet* cfg, NativeWindow* win)
 {
 	GrManagerInitInfo inf;
 	inf.m_allocCallback = allocAligned;
-	StringRaii home(HeapAllocator<U8>(allocAligned, nullptr));
+	HeapMemoryPool pool(allocAligned, nullptr);
+	StringRaii home(&pool);
 	const Error err = getTempDirectory(home);
 	if(err)
 	{
@@ -281,14 +282,12 @@ GrManager* createGrManager(ConfigSet* cfg, NativeWindow* win)
 ResourceManager* createResourceManager(ConfigSet* cfg, GrManager* gr, PhysicsWorld*& physics,
 									   ResourceFilesystem*& resourceFs)
 {
-	HeapAllocator<U8> alloc(allocAligned, nullptr);
-
 	physics = new PhysicsWorld();
 
 	ANKI_TEST_EXPECT_NO_ERR(physics->init(allocAligned, nullptr));
 
-	resourceFs = new ResourceFilesystem(alloc);
-	ANKI_TEST_EXPECT_NO_ERR(resourceFs->init(*cfg));
+	resourceFs = new ResourceFilesystem();
+	ANKI_TEST_EXPECT_NO_ERR(resourceFs->init(*cfg, allocAligned, nullptr));
 
 	ResourceManagerInitInfo rinit;
 	rinit.m_gr = gr;

+ 21 - 19
Tests/Gr/Gr.cpp

@@ -269,7 +269,7 @@ static Input* input = nullptr;
 	gr = createGrManager(&cfg, win); \
 	ANKI_TEST_EXPECT_NO_ERR(stagingMem->init(gr, cfg)); \
 	TransferGpuAllocator* transfAlloc = new TransferGpuAllocator(); \
-	ANKI_TEST_EXPECT_NO_ERR(transfAlloc->init(128_MB, gr, gr->getAllocator())); \
+	ANKI_TEST_EXPECT_NO_ERR(transfAlloc->init(128_MB, gr, &gr->getMemoryPool())); \
 	while(true) \
 	{
 
@@ -1521,8 +1521,8 @@ ANKI_TEST(Gr, RenderGraph)
 {
 	COMMON_BEGIN()
 
-	StackAllocator<U8> alloc(allocAligned, nullptr, 2_MB);
-	RenderGraphDescription descr(alloc);
+	StackMemoryPool pool(allocAligned, nullptr, 2_MB);
+	RenderGraphDescription descr(&pool);
 	RenderGraphPtr rgraph = gr->newRenderGraph();
 
 	const U GI_MIP_COUNT = 4;
@@ -1566,7 +1566,7 @@ ANKI_TEST(Gr, RenderGraph)
 		TextureSubresourceInfo subresource(TextureSurfaceInfo(0, 0, faceIdx, 0));
 
 		GraphicsRenderPassDescription& pass =
-			descr.newGraphicsRenderPass(StringRaii(alloc).sprintf("GI lp%u", faceIdx).toCString());
+			descr.newGraphicsRenderPass(StringRaii(&pool).sprintf("GI lp%u", faceIdx).toCString());
 		pass.newDependency({giGiLightRt, TextureUsageBit::kFramebufferWrite, subresource});
 		pass.newDependency({giGbuffNormRt, TextureUsageBit::kSampledFragment});
 		pass.newDependency({giGbuffDepthRt, TextureUsageBit::kSampledFragment});
@@ -1578,7 +1578,7 @@ ANKI_TEST(Gr, RenderGraph)
 		for(U32 faceIdx = 0; faceIdx < 6; ++faceIdx)
 		{
 			GraphicsRenderPassDescription& pass =
-				descr.newGraphicsRenderPass(StringRaii(alloc).sprintf("GI mip%u", faceIdx).toCString());
+				descr.newGraphicsRenderPass(StringRaii(&pool).sprintf("GI mip%u", faceIdx).toCString());
 
 			for(U32 mip = 0; mip < GI_MIP_COUNT; ++mip)
 			{
@@ -1688,7 +1688,7 @@ ANKI_TEST(Gr, RenderGraph)
 		pass.newDependency({taaHistoryRt, TextureUsageBit::kSampledFragment});
 	}
 
-	rgraph->compileNewGraph(descr, alloc);
+	rgraph->compileNewGraph(descr, pool);
 	COMMON_END()
 }
 
@@ -2531,7 +2531,8 @@ void main()
 }
 		)";
 
-		StringRaii fragSrc(HeapAllocator<U8>(allocAligned, nullptr));
+		HeapMemoryPool pool(allocAligned, nullptr);
+		StringRaii fragSrc(&pool);
 		if(useRayTracing)
 		{
 			fragSrc.append("#define USE_RAY_TRACING 1\n");
@@ -2747,7 +2748,7 @@ ANKI_TEST(Gr, RayGen)
 #include <Tests/Gr/RtTypes.h>
 #undef MAGIC_MACRO
 
-	HeapAllocator<U8> alloc(allocAligned, nullptr);
+	HeapMemoryPool pool(allocAligned, nullptr);
 
 	// Create the offscreen RTs
 	Array<TexturePtr, 2> offscreenRts;
@@ -3048,7 +3049,7 @@ F32 scatteringPdfLambertian(Vec3 normal, Vec3 scatteredDir)
 			;
 #undef MAGIC_MACRO
 
-		StringRaii commonSrc(alloc);
+		StringRaii commonSrc(&pool);
 		commonSrc.sprintf(commonSrcPart.cstr(), rtTypesStr.cstr());
 
 		const CString lambertianSrc = R"(
@@ -3258,24 +3259,24 @@ void main()
 })";
 
 		ShaderPtr lambertianShader = createShader(
-			StringRaii(alloc).sprintf("%s\n%s", commonSrc.cstr(), lambertianSrc.cstr()), ShaderType::kClosestHit, *gr);
+			StringRaii(&pool).sprintf("%s\n%s", commonSrc.cstr(), lambertianSrc.cstr()), ShaderType::kClosestHit, *gr);
 		ShaderPtr lambertianRoomShader =
-			createShader(StringRaii(alloc).sprintf("%s\n%s", commonSrc.cstr(), lambertianRoomSrc.cstr()),
+			createShader(StringRaii(&pool).sprintf("%s\n%s", commonSrc.cstr(), lambertianRoomSrc.cstr()),
 						 ShaderType::kClosestHit, *gr);
 		ShaderPtr emissiveShader = createShader(
-			StringRaii(alloc).sprintf("%s\n%s", commonSrc.cstr(), emissiveSrc.cstr()), ShaderType::kClosestHit, *gr);
+			StringRaii(&pool).sprintf("%s\n%s", commonSrc.cstr(), emissiveSrc.cstr()), ShaderType::kClosestHit, *gr);
 
 		ShaderPtr shadowAhitShader = createShader(
-			StringRaii(alloc).sprintf("%s\n%s", commonSrc.cstr(), shadowAhitSrc.cstr()), ShaderType::kAnyHit, *gr);
+			StringRaii(&pool).sprintf("%s\n%s", commonSrc.cstr(), shadowAhitSrc.cstr()), ShaderType::kAnyHit, *gr);
 		ShaderPtr shadowChitShader = createShader(
-			StringRaii(alloc).sprintf("%s\n%s", commonSrc.cstr(), shadowChitSrc.cstr()), ShaderType::kClosestHit, *gr);
+			StringRaii(&pool).sprintf("%s\n%s", commonSrc.cstr(), shadowChitSrc.cstr()), ShaderType::kClosestHit, *gr);
 		ShaderPtr missShader =
-			createShader(StringRaii(alloc).sprintf("%s\n%s", commonSrc.cstr(), missSrc.cstr()), ShaderType::kMiss, *gr);
+			createShader(StringRaii(&pool).sprintf("%s\n%s", commonSrc.cstr(), missSrc.cstr()), ShaderType::kMiss, *gr);
 
 		ShaderPtr shadowMissShader = createShader(
-			StringRaii(alloc).sprintf("%s\n%s", commonSrc.cstr(), shadowMissSrc.cstr()), ShaderType::kMiss, *gr);
+			StringRaii(&pool).sprintf("%s\n%s", commonSrc.cstr(), shadowMissSrc.cstr()), ShaderType::kMiss, *gr);
 
-		ShaderPtr rayGenShader = createShader(StringRaii(alloc).sprintf("%s\n%s", commonSrc.cstr(), rayGenSrc.cstr()),
+		ShaderPtr rayGenShader = createShader(StringRaii(&pool).sprintf("%s\n%s", commonSrc.cstr(), rayGenSrc.cstr()),
 											  ShaderType::kRayGen, *gr);
 
 		Array<RayTracingHitGroup, 4> hitGroups;
@@ -3571,9 +3572,10 @@ void main()
 	memset(values, 0, info.m_size);
 
 	// Pre-create some CPU result buffers
-	DynamicArrayRaii<U32> atomicsBufferCpu(HeapAllocator<U8>(allocAligned, nullptr));
+	HeapMemoryPool pool(allocAligned, nullptr);
+	DynamicArrayRaii<U32> atomicsBufferCpu(&pool);
 	atomicsBufferCpu.create(ARRAY_SIZE);
-	DynamicArrayRaii<U32> expectedResultsBufferCpu(HeapAllocator<U8>(allocAligned, nullptr));
+	DynamicArrayRaii<U32> expectedResultsBufferCpu(&pool);
 	expectedResultsBufferCpu.create(ARRAY_SIZE);
 	for(U32 i = 0; i < ARRAY_SIZE; ++i)
 	{

+ 5 - 5
Tests/Gr/GrCommon.h

@@ -14,14 +14,14 @@ namespace anki {
 inline ShaderPtr createShader(CString src, ShaderType type, GrManager& gr,
 							  ConstWeakArray<ShaderSpecializationConstValue> specVals = {})
 {
-	HeapAllocator<U8> alloc(allocAligned, nullptr);
-	StringRaii header(alloc);
+	HeapMemoryPool pool(allocAligned, nullptr);
+	StringRaii header(&pool);
 	ShaderCompilerOptions compilerOptions;
 	ShaderProgramParser::generateAnkiShaderHeader(type, compilerOptions, header);
 	header.append(src);
-	DynamicArrayRaii<U8> spirv(alloc);
-	StringRaii errorLog(alloc);
-	ANKI_TEST_EXPECT_NO_ERR(compilerGlslToSpirv(header, type, alloc, spirv, errorLog));
+	DynamicArrayRaii<U8> spirv(&pool);
+	StringRaii errorLog(&pool);
+	ANKI_TEST_EXPECT_NO_ERR(compilerGlslToSpirv(header, type, pool, spirv, errorLog));
 
 	ShaderInitInfo initInf(type, spirv);
 	initInf.m_constValues = specVals;

+ 2 - 2
Tests/Renderer/TileAllocator.cpp

@@ -8,10 +8,10 @@
 
 ANKI_TEST(Renderer, TileAllocator)
 {
-	HeapAllocator<U8> alloc(allocAligned, nullptr);
+	HeapMemoryPool pool(allocAligned, nullptr);
 
 	TileAllocator talloc;
-	talloc.init(alloc, 8, 8, 3, true);
+	talloc.init(&pool, 8, 8, 3, true);
 
 	Array<U32, 4> viewport;
 	TileAllocatorResult res;

+ 17 - 17
Tests/Resource/AsyncLoader.cpp

@@ -70,24 +70,24 @@ public:
 class MemTask : public AsyncLoaderTask
 {
 public:
-	HeapAllocator<U8> m_alloc;
+	HeapMemoryPool* m_pool;
 	Barrier* m_barrier = nullptr;
 
-	MemTask(HeapAllocator<U8> alloc, Barrier* barrier)
-		: m_alloc(alloc)
+	MemTask(HeapMemoryPool* pool, Barrier* barrier)
+		: m_pool(pool)
 		, m_barrier(barrier)
 	{
 	}
 
 	Error operator()([[maybe_unused]] AsyncLoaderTaskContext& ctx)
 	{
-		void* mem = m_alloc.allocate(10);
+		void* mem = m_pool->allocate(10, 16);
 		if(!mem)
 			return Error::kFunctionFailed;
 
 		HighRezTimer::sleep(0.1);
 
-		m_alloc.deallocate(mem, 10);
+		m_pool->free(mem);
 
 		if(m_barrier)
 		{
@@ -102,18 +102,18 @@ public:
 
 ANKI_TEST(Resource, AsyncLoader)
 {
-	HeapAllocator<U8> alloc(allocAligned, nullptr);
+	HeapMemoryPool pool(allocAligned, nullptr);
 
 	// Simple create destroy
 	{
 		AsyncLoader a;
-		a.init(alloc);
+		a.init(&pool);
 	}
 
 	// Simple task that will finish
 	{
 		AsyncLoader a;
-		a.init(alloc);
+		a.init(&pool);
 		Barrier barrier(2);
 
 		a.submitNewTask<Task>(0.0f, &barrier, nullptr);
@@ -123,7 +123,7 @@ ANKI_TEST(Resource, AsyncLoader)
 	// Many tasks that will finish
 	{
 		AsyncLoader a;
-		a.init(alloc);
+		a.init(&pool);
 		Barrier barrier(2);
 		Atomic<U32> counter = {0};
 		const U COUNT = 100;
@@ -148,7 +148,7 @@ ANKI_TEST(Resource, AsyncLoader)
 	// Many tasks that will _not_ finish
 	{
 		AsyncLoader a;
-		a.init(alloc);
+		a.init(&pool);
 
 		for(U i = 0; i < 100; i++)
 		{
@@ -159,7 +159,7 @@ ANKI_TEST(Resource, AsyncLoader)
 	// Tasks that allocate
 	{
 		AsyncLoader a;
-		a.init(alloc);
+		a.init(&pool);
 		Barrier barrier(2);
 
 		for(U i = 0; i < 10; i++)
@@ -171,7 +171,7 @@ ANKI_TEST(Resource, AsyncLoader)
 				pbarrier = &barrier;
 			}
 
-			a.submitNewTask<MemTask>(alloc, pbarrier);
+			a.submitNewTask<MemTask>(&pool, pbarrier);
 		}
 
 		barrier.wait();
@@ -180,18 +180,18 @@ ANKI_TEST(Resource, AsyncLoader)
 	// Tasks that allocate and never finished
 	{
 		AsyncLoader a;
-		a.init(alloc);
+		a.init(&pool);
 
 		for(U i = 0; i < 10; i++)
 		{
-			a.submitNewTask<MemTask>(alloc, nullptr);
+			a.submitNewTask<MemTask>(&pool, nullptr);
 		}
 	}
 
 	// Pause/resume
 	{
 		AsyncLoader a;
-		a.init(alloc);
+		a.init(&pool);
 		Atomic<U32> counter(0);
 		Barrier barrier(2);
 
@@ -217,7 +217,7 @@ ANKI_TEST(Resource, AsyncLoader)
 	// Pause/resume
 	{
 		AsyncLoader a;
-		a.init(alloc);
+		a.init(&pool);
 		Atomic<U32> counter(0);
 		Barrier barrier(2);
 
@@ -252,7 +252,7 @@ ANKI_TEST(Resource, AsyncLoader)
 	// Fuzzy test
 	{
 		AsyncLoader a;
-		a.init(alloc);
+		a.init(&pool);
 		Barrier barrier(2);
 		Atomic<U32> counter = {0};
 

+ 9 - 6
Tests/Resource/ResourceFilesystem.cpp

@@ -10,23 +10,26 @@ ANKI_TEST(Resource, ResourceFilesystem)
 {
 	printf("Test requires the Data dir\n");
 
-	HeapAllocator<U8> alloc(allocAligned, nullptr);
-	ResourceFilesystem fs(alloc);
+	ConfigSet config(allocAligned, nullptr);
+
+	HeapMemoryPool pool(allocAligned, nullptr);
+	ResourceFilesystem fs;
+	ANKI_TEST_EXPECT_NO_ERR(fs.init(config, allocAligned, nullptr));
 
 	{
-		ANKI_TEST_EXPECT_NO_ERR(fs.addNewPath("Tests/Data/Dir/../Dir/", StringListRaii(alloc)));
+		ANKI_TEST_EXPECT_NO_ERR(fs.addNewPath("Tests/Data/Dir/../Dir/", StringListRaii(&pool)));
 		ResourceFilePtr file;
 		ANKI_TEST_EXPECT_NO_ERR(fs.openFile("subdir0/hello.txt", file));
-		StringRaii txt(alloc);
+		StringRaii txt(&pool);
 		ANKI_TEST_EXPECT_NO_ERR(file->readAllText(txt));
 		ANKI_TEST_EXPECT_EQ(txt, "hello\n");
 	}
 
 	{
-		ANKI_TEST_EXPECT_NO_ERR(fs.addNewPath("./Tests/Data/Dir.AnKiZLibip", StringListRaii(alloc)));
+		ANKI_TEST_EXPECT_NO_ERR(fs.addNewPath("./Tests/Data/Dir.AnKiZLibip", StringListRaii(&pool)));
 		ResourceFilePtr file;
 		ANKI_TEST_EXPECT_NO_ERR(fs.openFile("subdir0/hello.txt", file));
-		StringRaii txt(alloc);
+		StringRaii txt(&pool);
 		ANKI_TEST_EXPECT_NO_ERR(file->readAllText(txt));
 		ANKI_TEST_EXPECT_EQ(txt, "hell\n");
 	}

+ 22 - 24
Tests/ShaderCompiler/ShaderProgramCompiler.cpp

@@ -93,16 +93,16 @@ void main()
 		}
 	} fsystem;
 
-	HeapAllocator<U8> alloc(allocAligned, nullptr);
+	HeapMemoryPool pool(allocAligned, nullptr);
 
 	const U32 threadCount = 8;
-	ThreadHive hive(threadCount, alloc);
+	ThreadHive hive(threadCount, &pool);
 
 	class TaskManager : public ShaderProgramAsyncTaskInterface
 	{
 	public:
 		ThreadHive* m_hive = nullptr;
-		HeapAllocator<U8> m_alloc;
+		HeapMemoryPool* m_pool;
 
 		void enqueueTask(void (*callback)(void* userData), void* userData)
 		{
@@ -110,20 +110,19 @@ void main()
 			{
 				void (*m_callback)(void* userData);
 				void* m_userData;
-				HeapAllocator<U8> m_alloc;
+				HeapMemoryPool* m_pool;
 			};
-			Ctx* ctx = m_alloc.newInstance<Ctx>();
+			Ctx* ctx = newInstance<Ctx>(*m_pool);
 			ctx->m_callback = callback;
 			ctx->m_userData = userData;
-			ctx->m_alloc = m_alloc;
+			ctx->m_pool = m_pool;
 
 			m_hive->submitTask(
 				[](void* userData, [[maybe_unused]] U32 threadId, [[maybe_unused]] ThreadHive& hive,
 				   [[maybe_unused]] ThreadHiveSemaphore* signalSemaphore) {
 					Ctx* ctx = static_cast<Ctx*>(userData);
 					ctx->m_callback(ctx->m_userData);
-					auto alloc = ctx->m_alloc;
-					alloc.deleteInstance(ctx);
+					deleteInstance(*ctx->m_pool, ctx);
 				},
 				ctx);
 		}
@@ -135,15 +134,15 @@ void main()
 		}
 	} taskManager;
 	taskManager.m_hive = &hive;
-	taskManager.m_alloc = alloc;
+	taskManager.m_pool = &pool;
 
-	ShaderProgramBinaryWrapper binary(alloc);
+	ShaderProgramBinaryWrapper binary(&pool);
 	ShaderCompilerOptions compilerOptions;
 	ANKI_TEST_EXPECT_NO_ERR(
-		compileShaderProgram("test.glslp", fsystem, nullptr, &taskManager, alloc, compilerOptions, binary));
+		compileShaderProgram("test.glslp", fsystem, nullptr, &taskManager, pool, compilerOptions, binary));
 
 #if 1
-	StringRaii dis(alloc);
+	StringRaii dis(&pool);
 	dumpShaderProgramBinary(binary.getBinary(), dis);
 	ANKI_LOGI("Binary disassembly:\n%s\n", dis.cstr());
 #endif
@@ -290,16 +289,16 @@ void main()
 		}
 	} fsystem;
 
-	HeapAllocator<U8> alloc(allocAligned, nullptr);
+	HeapMemoryPool pool(allocAligned, nullptr);
 
 	const U32 threadCount = 24;
-	ThreadHive hive(threadCount, alloc);
+	ThreadHive hive(threadCount, &pool);
 
 	class TaskManager : public ShaderProgramAsyncTaskInterface
 	{
 	public:
 		ThreadHive* m_hive = nullptr;
-		HeapAllocator<U8> m_alloc;
+		HeapMemoryPool* m_pool = nullptr;
 
 		void enqueueTask(void (*callback)(void* userData), void* userData)
 		{
@@ -307,20 +306,19 @@ void main()
 			{
 				void (*m_callback)(void* userData);
 				void* m_userData;
-				HeapAllocator<U8> m_alloc;
+				HeapMemoryPool* m_pool;
 			};
-			Ctx* ctx = m_alloc.newInstance<Ctx>();
+			Ctx* ctx = newInstance<Ctx>(*m_pool);
 			ctx->m_callback = callback;
 			ctx->m_userData = userData;
-			ctx->m_alloc = m_alloc;
+			ctx->m_pool = m_pool;
 
 			m_hive->submitTask(
 				[](void* userData, [[maybe_unused]] U32 threadId, [[maybe_unused]] ThreadHive& hive,
 				   [[maybe_unused]] ThreadHiveSemaphore* signalSemaphore) {
 					Ctx* ctx = static_cast<Ctx*>(userData);
 					ctx->m_callback(ctx->m_userData);
-					auto alloc = ctx->m_alloc;
-					alloc.deleteInstance(ctx);
+					deleteInstance(*ctx->m_pool, ctx);
 				},
 				ctx);
 		}
@@ -332,14 +330,14 @@ void main()
 		}
 	} taskManager;
 	taskManager.m_hive = &hive;
-	taskManager.m_alloc = alloc;
+	taskManager.m_pool = &pool;
 
-	ShaderProgramBinaryWrapper binary(alloc);
+	ShaderProgramBinaryWrapper binary(&pool);
 	ANKI_TEST_EXPECT_NO_ERR(
-		compileShaderProgram("test.glslp", fsystem, nullptr, &taskManager, alloc, ShaderCompilerOptions(), binary));
+		compileShaderProgram("test.glslp", fsystem, nullptr, &taskManager, pool, ShaderCompilerOptions(), binary));
 
 #if 1
-	StringRaii dis(alloc);
+	StringRaii dis(&pool);
 	dumpShaderProgramBinary(binary.getBinary(), dis);
 	ANKI_LOGI("Binary disassembly:\n%s\n", dis.cstr());
 #endif

+ 2 - 2
Tests/ShaderCompiler/ShaderProgramParser.cpp

@@ -8,7 +8,7 @@
 
 ANKI_TEST(ShaderCompiler, ShaderCompilerParser)
 {
-	HeapAllocator<U8> alloc(allocAligned, nullptr);
+	HeapMemoryPool pool(allocAligned, nullptr);
 
 	class FilesystemInterface : public ShaderProgramFilesystemInterface
 	{
@@ -43,7 +43,7 @@ ANKI_TEST(ShaderCompiler, ShaderCompilerParser)
 		}
 	} interface;
 
-	ShaderProgramParser parser("filename0", &interface, alloc, ShaderCompilerOptions());
+	ShaderProgramParser parser("filename0", &interface, &pool, ShaderCompilerOptions());
 	ANKI_TEST_EXPECT_NO_ERR(parser.parse());
 
 	// Test a variant

+ 3 - 3
Tests/Util/BuddyAllocatorBuilder.cpp

@@ -18,11 +18,11 @@ static int memvcmp(const void* memory, U8 val, PtrSize size)
 
 ANKI_TEST(Util, BuddyAllocatorBuilder)
 {
-	HeapAllocator<U8> alloc(allocAligned, nullptr);
+	HeapMemoryPool pool(allocAligned, nullptr);
 
 	// Simple
 	{
-		BuddyAllocatorBuilder<32, Mutex> buddy(alloc, 32);
+		BuddyAllocatorBuilder<32, Mutex> buddy(&pool, 32);
 
 		Array<U32, 2> addr;
 		const Array<U32, 2> sizes = {58, 198010775};
@@ -43,7 +43,7 @@ ANKI_TEST(Util, BuddyAllocatorBuilder)
 
 	// Fuzzy with alignment
 	{
-		BuddyAllocatorBuilder<32, Mutex> buddy(alloc, 32);
+		BuddyAllocatorBuilder<32, Mutex> buddy(&pool, 32);
 		std::vector<std::tuple<U32, U32, U32, U8>> allocations;
 
 		U8* backingMemory = static_cast<U8*>(malloc(kMaxU32));

+ 2 - 2
Tests/Util/ClassAllocatorBuilder.cpp

@@ -107,9 +107,9 @@ static inline U32 floorPow2(U32 v)
 
 ANKI_TEST(Util, ClassAllocatorBuilder)
 {
-	HeapAllocator<U8> alloc(allocAligned, nullptr);
+	HeapMemoryPool pool(allocAligned, nullptr);
 	ClassAllocatorBuilder<Chunk, Interface, Mutex> calloc;
-	calloc.init(alloc);
+	calloc.init(&pool);
 
 	std::mt19937 gen(0);
 

+ 23 - 23
Tests/Util/DynamicArray.cpp

@@ -21,7 +21,7 @@ static I64 g_moveCount = 0;
 class DynamicArrayFoo
 {
 public:
-	static constexpr I32 WRONG_NUMBER = -1234;
+	static constexpr I32 kWrongNumber = -1234;
 
 	int m_x;
 
@@ -35,7 +35,7 @@ public:
 		: m_x(x)
 	{
 		++g_constructor1Count;
-		if(m_x == WRONG_NUMBER)
+		if(m_x == kWrongNumber)
 		{
 			++m_x;
 		}
@@ -44,29 +44,29 @@ public:
 	DynamicArrayFoo(const DynamicArrayFoo& b)
 		: m_x(b.m_x)
 	{
-		ANKI_TEST_EXPECT_NEQ(b.m_x, WRONG_NUMBER);
+		ANKI_TEST_EXPECT_NEQ(b.m_x, kWrongNumber);
 		++g_constructor2Count;
 	}
 
 	DynamicArrayFoo(DynamicArrayFoo&& b)
 		: m_x(b.m_x)
 	{
-		ANKI_TEST_EXPECT_NEQ(b.m_x, WRONG_NUMBER);
+		ANKI_TEST_EXPECT_NEQ(b.m_x, kWrongNumber);
 		b.m_x = 0;
 		++g_constructor3Count;
 	}
 
 	~DynamicArrayFoo()
 	{
-		ANKI_TEST_EXPECT_NEQ(m_x, WRONG_NUMBER);
-		m_x = WRONG_NUMBER;
+		ANKI_TEST_EXPECT_NEQ(m_x, kWrongNumber);
+		m_x = kWrongNumber;
 		++g_destructorCount;
 	}
 
 	DynamicArrayFoo& operator=(const DynamicArrayFoo& b)
 	{
-		ANKI_TEST_EXPECT_NEQ(m_x, WRONG_NUMBER);
-		ANKI_TEST_EXPECT_NEQ(b.m_x, WRONG_NUMBER);
+		ANKI_TEST_EXPECT_NEQ(m_x, kWrongNumber);
+		ANKI_TEST_EXPECT_NEQ(b.m_x, kWrongNumber);
 		m_x = b.m_x;
 		++g_copyCount;
 		return *this;
@@ -74,8 +74,8 @@ public:
 
 	DynamicArrayFoo& operator=(DynamicArrayFoo&& b)
 	{
-		ANKI_TEST_EXPECT_NEQ(m_x, WRONG_NUMBER);
-		ANKI_TEST_EXPECT_NEQ(b.m_x, WRONG_NUMBER);
+		ANKI_TEST_EXPECT_NEQ(m_x, kWrongNumber);
+		ANKI_TEST_EXPECT_NEQ(b.m_x, kWrongNumber);
 		m_x = b.m_x;
 		b.m_x = 0;
 		++g_moveCount;
@@ -88,8 +88,8 @@ public:
 ANKI_TEST(Util, DynamicArray)
 {
 	{
-		HeapAllocator<U8> alloc(allocAligned, nullptr);
-		DynamicArrayRaii<DynamicArrayFoo> arr(alloc);
+		HeapMemoryPool pool(allocAligned, nullptr);
+		DynamicArrayRaii<DynamicArrayFoo> arr(&pool);
 
 		arr.resize(0);
 		arr.resize(2, 1);
@@ -113,8 +113,8 @@ ANKI_TEST(Util, DynamicArray)
 	// Fuzzy
 	{
 		srand(U32(time(nullptr)));
-		HeapAllocator<U8> alloc(allocAligned, nullptr);
-		DynamicArrayRaii<DynamicArrayFoo> arr(alloc);
+		HeapMemoryPool pool(allocAligned, nullptr);
+		DynamicArrayRaii<DynamicArrayFoo> arr(&pool);
 
 		std::vector<DynamicArrayFoo> vec;
 
@@ -147,7 +147,7 @@ ANKI_TEST(Util, DynamicArray)
 			arr.validate();
 		}
 
-		arr = DynamicArrayRaii<DynamicArrayFoo>(alloc);
+		arr = DynamicArrayRaii<DynamicArrayFoo>(&pool);
 		vec = std::vector<DynamicArrayFoo>();
 		ANKI_TEST_EXPECT_GT(g_destructorCount, 0);
 		ANKI_TEST_EXPECT_EQ(g_constructor0Count + g_constructor1Count + g_constructor2Count + g_constructor3Count,
@@ -157,11 +157,11 @@ ANKI_TEST(Util, DynamicArray)
 
 ANKI_TEST(Util, DynamicArrayEmplaceAt)
 {
-	HeapAllocator<U8> alloc(allocAligned, nullptr);
+	HeapMemoryPool pool(allocAligned, nullptr);
 
 	// Empty & add to the end
 	{
-		DynamicArrayRaii<DynamicArrayFoo> arr(alloc);
+		DynamicArrayRaii<DynamicArrayFoo> arr(&pool);
 
 		arr.emplaceAt(arr.getEnd(), 12);
 		ANKI_TEST_EXPECT_EQ(arr[0].m_x, 12);
@@ -169,7 +169,7 @@ ANKI_TEST(Util, DynamicArrayEmplaceAt)
 
 	// 1 element & add to he end
 	{
-		DynamicArrayRaii<DynamicArrayFoo> arr(alloc);
+		DynamicArrayRaii<DynamicArrayFoo> arr(&pool);
 		arr.emplaceBack(12);
 
 		arr.emplaceAt(arr.getEnd(), 34);
@@ -180,7 +180,7 @@ ANKI_TEST(Util, DynamicArrayEmplaceAt)
 
 	// 1 element & add to 0
 	{
-		DynamicArrayRaii<DynamicArrayFoo> arr(alloc);
+		DynamicArrayRaii<DynamicArrayFoo> arr(&pool);
 		arr.emplaceBack(12);
 
 		arr.emplaceAt(arr.getBegin(), 34);
@@ -191,7 +191,7 @@ ANKI_TEST(Util, DynamicArrayEmplaceAt)
 
 	// A bit more complex
 	{
-		DynamicArrayRaii<DynamicArrayFoo> arr(alloc);
+		DynamicArrayRaii<DynamicArrayFoo> arr(&pool);
 
 		for(I32 i = 0; i < 10; ++i)
 		{
@@ -221,7 +221,7 @@ ANKI_TEST(Util, DynamicArrayEmplaceAt)
 	{
 		srand(U32(time(nullptr)));
 
-		DynamicArrayRaii<DynamicArrayFoo> arr(alloc);
+		DynamicArrayRaii<DynamicArrayFoo> arr(&pool);
 		std::vector<DynamicArrayFoo> vec;
 
 		const I ITERATIONS = 10000;
@@ -271,13 +271,13 @@ ANKI_TEST(Util, DynamicArrayEmplaceAt)
 
 ANKI_TEST(Util, DynamicArrayErase)
 {
-	HeapAllocator<U8> alloc(allocAligned, nullptr);
+	HeapMemoryPool pool(allocAligned, nullptr);
 
 	// Fuzzy
 	{
 		srand(U32(time(nullptr)));
 
-		DynamicArrayRaii<DynamicArrayFoo> arr(alloc);
+		DynamicArrayRaii<DynamicArrayFoo> arr(&pool);
 		std::vector<DynamicArrayFoo> vec;
 
 		const I ITERATIONS = 10000;

+ 13 - 13
Tests/Util/Filesystem.cpp

@@ -20,12 +20,12 @@ ANKI_TEST(Util, FileExists)
 
 ANKI_TEST(Util, Directory)
 {
-	HeapAllocator<U8> alloc(allocAligned, nullptr);
+	HeapMemoryPool pool(allocAligned, nullptr);
 
 	// Destroy previous
 	if(directoryExists("./dir"))
 	{
-		ANKI_TEST_EXPECT_NO_ERR(removeDirectory("./dir", alloc));
+		ANKI_TEST_EXPECT_NO_ERR(removeDirectory("./dir", pool));
 	}
 
 	// Create simple directory
@@ -35,7 +35,7 @@ ANKI_TEST(Util, Directory)
 	file.close();
 	ANKI_TEST_EXPECT_EQ(fileExists("./dir/tmp"), true);
 
-	ANKI_TEST_EXPECT_NO_ERR(removeDirectory("./dir", alloc));
+	ANKI_TEST_EXPECT_NO_ERR(removeDirectory("./dir", pool));
 	ANKI_TEST_EXPECT_EQ(fileExists("./dir/tmp"), false);
 	ANKI_TEST_EXPECT_EQ(directoryExists("./dir"), false);
 
@@ -46,7 +46,7 @@ ANKI_TEST(Util, Directory)
 	file.close();
 	ANKI_TEST_EXPECT_EQ(fileExists("./dir/rid/tmp"), true);
 
-	ANKI_TEST_EXPECT_NO_ERR(removeDirectory("./dir", alloc));
+	ANKI_TEST_EXPECT_NO_ERR(removeDirectory("./dir", pool));
 	ANKI_TEST_EXPECT_EQ(fileExists("./dir/rid/tmp"), false);
 	ANKI_TEST_EXPECT_EQ(directoryExists("./dir/rid"), false);
 	ANKI_TEST_EXPECT_EQ(directoryExists("./dir"), false);
@@ -54,8 +54,8 @@ ANKI_TEST(Util, Directory)
 
 ANKI_TEST(Util, HomeDir)
 {
-	HeapAllocator<char> alloc(allocAligned, nullptr);
-	StringRaii out(alloc);
+	HeapMemoryPool pool(allocAligned, nullptr);
+	StringRaii out(&pool);
 
 	ANKI_TEST_EXPECT_NO_ERR(getHomeDirectory(out));
 	printf("home dir %s\n", &out[0]);
@@ -64,7 +64,7 @@ ANKI_TEST(Util, HomeDir)
 
 ANKI_TEST(Util, WalkDir)
 {
-	HeapAllocator<char> alloc(allocAligned, nullptr);
+	HeapMemoryPool pool(allocAligned, nullptr);
 
 	class Path
 	{
@@ -79,11 +79,11 @@ ANKI_TEST(Util, WalkDir)
 		Array<Path, 4> m_paths = {
 			{{"./data", true}, {"./data/dir", true}, {"./data/file1", false}, {"./data/dir/file2", false}}};
 		U32 m_foundMask = 0;
-		HeapAllocator<char> m_alloc;
+		HeapMemoryPool* m_pool;
 	} ctx;
-	ctx.m_alloc = alloc;
+	ctx.m_pool = &pool;
 
-	[[maybe_unused]] const Error err = removeDirectory("./data", alloc);
+	[[maybe_unused]] const Error err = removeDirectory("./data", pool);
 
 	// Create some dirs and some files
 	for(U32 i = 0; i < ctx.m_paths.getSize(); ++i)
@@ -100,10 +100,10 @@ ANKI_TEST(Util, WalkDir)
 	}
 
 	// Walk crnt dir
-	ANKI_TEST_EXPECT_NO_ERR(walkDirectoryTree("./data", alloc, [&](const CString& fname, Bool isDir) -> Error {
+	ANKI_TEST_EXPECT_NO_ERR(walkDirectoryTree("./data", pool, [&](const CString& fname, Bool isDir) -> Error {
 		for(U32 i = 0; i < ctx.m_paths.getSize(); ++i)
 		{
-			StringRaii p(ctx.m_alloc);
+			StringRaii p(ctx.m_pool);
 			p.sprintf("./data/%s", fname.cstr());
 			if(ctx.m_paths[i].m_path == p)
 			{
@@ -120,7 +120,7 @@ ANKI_TEST(Util, WalkDir)
 	// Test error
 	U32 count = 0;
 	ANKI_TEST_EXPECT_ERR(
-		walkDirectoryTree("./data///dir////", alloc,
+		walkDirectoryTree("./data///dir////", pool,
 						  [&count]([[maybe_unused]] const CString& fname, [[maybe_unused]] Bool isDir) -> Error {
 							  ++count;
 							  return Error::kFunctionFailed;

+ 13 - 13
Tests/Util/Function.cpp

@@ -18,14 +18,14 @@ static I32 functionAcceptingFunction(const Function<I32(F32)>& f)
 
 ANKI_TEST(Util, Function)
 {
-	HeapAllocator<U8> alloc(allocAligned, nullptr);
+	HeapMemoryPool pool(allocAligned, nullptr);
 
 	// Simple
 	{
 		Function<I32(I32, F32), 8> f;
 
 		I32 i = 0;
-		f.init(alloc, [&i](U32 a, F32 b) -> I32 {
+		f.init(pool, [&i](U32 a, F32 b) -> I32 {
 			i += I32(a) + I32(b);
 			return i;
 		});
@@ -35,20 +35,20 @@ ANKI_TEST(Util, Function)
 		f(2, 10.0f);
 		ANKI_TEST_EXPECT_EQ(i, 13);
 
-		f.destroy(alloc);
+		f.destroy(pool);
 	}
 
 	// No templates
 	{
 		F32 f = 1.1f;
 
-		Function<I32(F32)> func(alloc, [&f](F32 ff) {
+		Function<I32(F32)> func(pool, [&f](F32 ff) {
 			f += 2.0f;
 			return I32(f) + I32(ff);
 		});
 
 		const I32 o = functionAcceptingFunction(func);
-		func.destroy(alloc);
+		func.destroy(pool);
 
 		ANKI_TEST_EXPECT_EQ(o, 11);
 	}
@@ -57,21 +57,21 @@ ANKI_TEST(Util, Function)
 	{
 		const Vec4 a(1.9f);
 		const Vec4 b(2.2f);
-		Function<Vec4(Vec4, Vec4), 8> f(alloc, [a, b](Vec4 c, Vec4 d) mutable -> Vec4 {
+		Function<Vec4(Vec4, Vec4), 8> f(pool, [a, b](Vec4 c, Vec4 d) mutable -> Vec4 {
 			return a + c * 2.0f + b * d;
 		});
 
 		const Vec4 r = f(Vec4(10.0f), Vec4(20.8f));
 		ANKI_TEST_EXPECT_EQ(r, a + Vec4(10.0f) * 2.0f + b * Vec4(20.8f));
 
-		f.destroy(alloc);
+		f.destroy(pool);
 	}
 
 	// Complex
 	{
 		{
 			Foo foo, bar;
-			Function<void(Foo&)> f(alloc, [foo](Foo& r) {
+			Function<void(Foo&)> f(pool, [foo](Foo& r) {
 				r.x += foo.x;
 			});
 
@@ -81,7 +81,7 @@ ANKI_TEST(Util, Function)
 			ff(bar);
 
 			ANKI_TEST_EXPECT_EQ(bar.x, 666 * 2);
-			ff.destroy(alloc);
+			ff.destroy(pool);
 		}
 
 		ANKI_TEST_EXPECT_EQ(Foo::constructorCallCount, Foo::destructorCallCount);
@@ -92,18 +92,18 @@ ANKI_TEST(Util, Function)
 	{
 		{
 			Foo foo, bar;
-			Function<void(Foo&)> f(alloc, [foo](Foo& r) {
+			Function<void(Foo&)> f(pool, [foo](Foo& r) {
 				r.x += foo.x;
 			});
 
 			Function<void(Foo&)> ff;
-			ff.copy(f, alloc);
+			ff.copy(f, pool);
 
 			ff(bar);
 
 			ANKI_TEST_EXPECT_EQ(bar.x, 666 * 2);
-			ff.destroy(alloc);
-			f.destroy(alloc);
+			ff.destroy(pool);
+			f.destroy(pool);
 		}
 
 		ANKI_TEST_EXPECT_EQ(Foo::constructorCallCount, Foo::destructorCallCount);

+ 21 - 22
Tests/Util/HashMap.cpp

@@ -24,16 +24,16 @@ public:
 
 ANKI_TEST(Util, HashMap)
 {
-	HeapAllocator<U8> alloc(allocAligned, nullptr);
+	HeapMemoryPool pool(allocAligned, nullptr);
 	int vals[] = {20, 15, 5, 1, 10, 0, 18, 6, 7, 11, 13, 3};
 	U valsSize = sizeof(vals) / sizeof(vals[0]);
 
 	// Simple
 	{
 		HashMap<int, int, Hasher> map;
-		map.emplace(alloc, 20, 1);
-		map.emplace(alloc, 21, 1);
-		map.destroy(alloc);
+		map.emplace(pool, 20, 1);
+		map.emplace(pool, 21, 1);
+		map.destroy(pool);
 	}
 
 	// Add more and iterate
@@ -42,7 +42,7 @@ ANKI_TEST(Util, HashMap)
 
 		for(U i = 0; i < valsSize; ++i)
 		{
-			map.emplace(alloc, vals[i], vals[i] * 10);
+			map.emplace(pool, vals[i], vals[i] * 10);
 		}
 
 		U count = 0;
@@ -53,7 +53,7 @@ ANKI_TEST(Util, HashMap)
 		}
 		ANKI_TEST_EXPECT_EQ(count, valsSize);
 
-		map.destroy(alloc);
+		map.destroy(pool);
 	}
 
 	// Erase
@@ -62,7 +62,7 @@ ANKI_TEST(Util, HashMap)
 
 		for(U i = 0; i < valsSize; ++i)
 		{
-			map.emplace(alloc, vals[i], vals[i] * 10);
+			map.emplace(pool, vals[i], vals[i] * 10);
 		}
 
 		for(U i = valsSize - 1; i != 0; --i)
@@ -70,11 +70,11 @@ ANKI_TEST(Util, HashMap)
 			HashMap<int, int, Hasher>::Iterator it = map.find(vals[i]);
 			ANKI_TEST_EXPECT_NEQ(it, map.getEnd());
 
-			map.erase(alloc, it);
-			map.emplace(alloc, vals[i], vals[i] * 10);
+			map.erase(pool, it);
+			map.emplace(pool, vals[i], vals[i] * 10);
 		}
 
-		map.destroy(alloc);
+		map.destroy(pool);
 	}
 
 	// Find
@@ -83,7 +83,7 @@ ANKI_TEST(Util, HashMap)
 
 		for(U i = 0; i < valsSize; ++i)
 		{
-			map.emplace(alloc, vals[i], vals[i] * 10);
+			map.emplace(pool, vals[i], vals[i] * 10);
 		}
 
 		for(U i = valsSize - 1; i != 0; --i)
@@ -93,7 +93,7 @@ ANKI_TEST(Util, HashMap)
 			ANKI_TEST_EXPECT_EQ(*it, vals[i] * 10);
 		}
 
-		map.destroy(alloc);
+		map.destroy(pool);
 	}
 
 	// Fuzzy test
@@ -113,7 +113,7 @@ ANKI_TEST(Util, HashMap)
 				{
 					// Not found
 					ANKI_TEST_EXPECT_EQ(akMap.find(num), akMap.getEnd());
-					akMap.emplace(alloc, num, num);
+					akMap.emplace(pool, num, num);
 					numbers.push_back(num);
 					break;
 				}
@@ -134,10 +134,10 @@ ANKI_TEST(Util, HashMap)
 			numbers.erase(numbers.begin() + idx);
 
 			auto it = akMap.find(num);
-			akMap.erase(alloc, it);
+			akMap.erase(pool, it);
 		}
 
-		akMap.destroy(alloc);
+		akMap.destroy(pool);
 	}
 
 	// Bench it
@@ -166,9 +166,8 @@ ANKI_TEST(Util, HashMap)
 		using AkMap = HashMap<int, int, Hasher, Config>;
 
 		AkMap akMap;
-		using StlMap =
-			std::unordered_map<int, int, std::hash<int>, std::equal_to<int>, HeapAllocator<std::pair<const int, int>>>;
-		StlMap stdMap(10, std::hash<int>(), std::equal_to<int>(), alloc);
+		using StlMap = std::unordered_map<int, int, std::hash<int>, std::equal_to<int>>;
+		StlMap stdMap(10, std::hash<int>(), std::equal_to<int>());
 
 		std::unordered_map<int, int> tmpMap;
 
@@ -176,7 +175,7 @@ ANKI_TEST(Util, HashMap)
 
 		// Create a huge set
 		const U32 COUNT = 1024 * 1024 * 10;
-		DynamicArrayRaii<int> vals(alloc);
+		DynamicArrayRaii<int> vals(&pool);
 		vals.create(COUNT);
 
 		for(U32 i = 0; i < COUNT; ++i)
@@ -198,7 +197,7 @@ ANKI_TEST(Util, HashMap)
 			timer.start();
 			for(U32 i = 0; i < COUNT; ++i)
 			{
-				akMap.emplace(alloc, vals[i], vals[i]);
+				akMap.emplace(pool, vals[i], vals[i]);
 			}
 			timer.stop();
 			Second akTime = timer.getElapsedTime();
@@ -253,7 +252,7 @@ ANKI_TEST(Util, HashMap)
 				auto it = akMap.find(vals[i]);
 
 				timer.start();
-				akMap.erase(alloc, it);
+				akMap.erase(pool, it);
 				timer.stop();
 				akTime += timer.getElapsedTime();
 			}
@@ -273,6 +272,6 @@ ANKI_TEST(Util, HashMap)
 			ANKI_TEST_LOGI("Deleting bench: STL %f AnKi %f | %f%%", stlTime, akTime, stlTime / akTime * 100.0);
 		}
 
-		akMap.destroy(alloc);
+		akMap.destroy(pool);
 	}
 }

+ 4 - 4
Tests/Util/INotify.cpp

@@ -9,7 +9,7 @@
 
 ANKI_TEST(Util, INotify)
 {
-	HeapAllocator<U8> alloc(allocAligned, nullptr);
+	HeapMemoryPool pool(allocAligned, nullptr);
 
 	// Monitor a dir
 	{
@@ -19,7 +19,7 @@ ANKI_TEST(Util, INotify)
 
 		{
 			INotify in;
-			ANKI_TEST_EXPECT_NO_ERR(in.init(alloc, dir));
+			ANKI_TEST_EXPECT_NO_ERR(in.init(&pool, dir));
 
 			Bool modified;
 			ANKI_TEST_EXPECT_NO_ERR(in.pollEvents(modified));
@@ -27,13 +27,13 @@ ANKI_TEST(Util, INotify)
 
 			File file;
 			ANKI_TEST_EXPECT_NO_ERR(
-				file.open(StringRaii(alloc).sprintf("%s/file.txt", dir.cstr()).toCString(), FileOpenFlag::kWrite));
+				file.open(StringRaii(&pool).sprintf("%s/file.txt", dir.cstr()).toCString(), FileOpenFlag::kWrite));
 			file.close();
 
 			ANKI_TEST_EXPECT_NO_ERR(in.pollEvents(modified));
 			ANKI_TEST_EXPECT_EQ(modified, true);
 		}
 
-		ANKI_TEST_EXPECT_NO_ERR(removeDirectory(dir, alloc));
+		ANKI_TEST_EXPECT_NO_ERR(removeDirectory(dir, pool));
 	}
 }

+ 26 - 26
Tests/Util/List.cpp

@@ -11,15 +11,15 @@
 
 ANKI_TEST(Util, List)
 {
-	HeapAllocator<U8> alloc(allocAligned, nullptr);
+	HeapMemoryPool pool(allocAligned, nullptr);
 
 	// Simple
 	{
 		List<Foo> a;
 		Error err = Error::kNone;
 
-		a.emplaceBack(alloc, 10);
-		a.emplaceBack(alloc, 11);
+		a.emplaceBack(pool, 10);
+		a.emplaceBack(pool, 11);
 
 		U sum = 0;
 
@@ -31,7 +31,7 @@ ANKI_TEST(Util, List)
 		ANKI_TEST_EXPECT_EQ(err, Error::kNone);
 		ANKI_TEST_EXPECT_EQ(sum, 21);
 
-		a.destroy(alloc);
+		a.destroy(pool);
 	}
 
 	// Sort
@@ -39,10 +39,10 @@ ANKI_TEST(Util, List)
 		List<I> a;
 		Error err = Error::kNone;
 
-		a.emplaceBack(alloc, 10);
-		a.emplaceBack(alloc, 9);
-		a.emplaceBack(alloc, 11);
-		a.emplaceBack(alloc, 2);
+		a.emplaceBack(pool, 10);
+		a.emplaceBack(pool, 9);
+		a.emplaceBack(pool, 11);
+		a.emplaceBack(pool, 2);
 
 		a.sort();
 
@@ -82,7 +82,7 @@ ANKI_TEST(Util, List)
 
 		ANKI_TEST_EXPECT_EQ(err, Error::kNone);
 
-		a.destroy(alloc);
+		a.destroy(pool);
 	}
 
 	// Extreme sort
@@ -96,7 +96,7 @@ ANKI_TEST(Util, List)
 			I32 randVal = rand();
 			Foo f(randVal);
 
-			a.pushBack(alloc, f);
+			a.pushBack(pool, f);
 			b.push_back(f);
 		}
 
@@ -129,7 +129,7 @@ ANKI_TEST(Util, List)
 
 		ANKI_TEST_EXPECT_EQ(ait, aend);
 		ANKI_TEST_EXPECT_EQ(bit, bend);
-		a.destroy(alloc);
+		a.destroy(pool);
 	}
 
 	// Iterate
@@ -137,10 +137,10 @@ ANKI_TEST(Util, List)
 		List<I> a;
 		Error err = Error::kNone;
 
-		a.emplaceBack(alloc, 10);
-		a.emplaceBack(alloc, 9);
-		a.emplaceBack(alloc, 11);
-		a.emplaceBack(alloc, 2);
+		a.emplaceBack(pool, 10);
+		a.emplaceBack(pool, 9);
+		a.emplaceBack(pool, 11);
+		a.emplaceBack(pool, 2);
 
 		Array<I, 4> arr = {{10, 9, 11, 2}};
 		U count = 0;
@@ -169,36 +169,36 @@ ANKI_TEST(Util, List)
 
 		ANKI_TEST_EXPECT_EQ(err, Error::kNone);
 
-		a.destroy(alloc);
+		a.destroy(pool);
 	}
 
 	// Erase
 	{
 		List<I> a;
 
-		a.emplaceBack(alloc, 10);
+		a.emplaceBack(pool, 10);
 
-		a.erase(alloc, a.getBegin());
+		a.erase(pool, a.getBegin());
 		ANKI_TEST_EXPECT_EQ(a.isEmpty(), true);
 
-		a.emplaceBack(alloc, 10);
-		a.emplaceBack(alloc, 20);
+		a.emplaceBack(pool, 10);
+		a.emplaceBack(pool, 20);
 
-		a.erase(alloc, a.getBegin() + 1);
+		a.erase(pool, a.getBegin() + 1);
 		ANKI_TEST_EXPECT_EQ(10, *a.getBegin());
 
-		a.emplaceFront(alloc, 5);
-		a.emplaceBack(alloc, 30);
+		a.emplaceFront(pool, 5);
+		a.emplaceBack(pool, 30);
 
 		ANKI_TEST_EXPECT_EQ(5, *(a.getBegin()));
 		ANKI_TEST_EXPECT_EQ(10, *(a.getEnd() - 2));
 		ANKI_TEST_EXPECT_EQ(30, *(a.getEnd() - 1));
 
-		a.erase(alloc, a.getEnd() - 2);
+		a.erase(pool, a.getEnd() - 2);
 		ANKI_TEST_EXPECT_EQ(5, *(a.getBegin()));
 		ANKI_TEST_EXPECT_EQ(30, *(a.getEnd() - 1));
 
-		a.erase(alloc, a.getBegin());
-		a.erase(alloc, a.getBegin());
+		a.erase(pool, a.getBegin());
+		a.erase(pool, a.getBegin());
 	}
 }

+ 7 - 5
Tests/Util/Process.cpp

@@ -46,7 +46,8 @@ exit 6
 		ANKI_TEST_EXPECT_EQ(status, ProcessStatus::kNotRunning);
 		ANKI_TEST_EXPECT_EQ(exitCode, 6);
 
-		StringRaii stdOut(HeapAllocator<U8>(allocAligned, nullptr));
+		HeapMemoryPool pool(allocAligned, nullptr);
+		StringRaii stdOut(&pool);
 		ANKI_TEST_EXPECT_NO_ERR(proc.readFromStdout(stdOut));
 		ANKI_TEST_EXPECT_EQ(stdOut, "Hello from script\n");
 	}
@@ -80,15 +81,15 @@ done
 				break;
 			}
 
-			HeapAllocator<U8> alloc(allocAligned, nullptr);
-			StringRaii stdOut(alloc);
+			HeapMemoryPool pool(allocAligned, nullptr);
+			StringRaii stdOut(&pool);
 			ANKI_TEST_EXPECT_NO_ERR(proc.readFromStdout(stdOut));
 			if(stdOut.getLength())
 			{
 				ANKI_TEST_LOGI("%s", stdOut.cstr());
 			}
 
-			StringRaii stderrStr(alloc);
+			StringRaii stderrStr(&pool);
 			ANKI_TEST_EXPECT_NO_ERR(proc.readFromStderr(stderrStr));
 			if(stderrStr.getLength())
 			{
@@ -115,7 +116,8 @@ sleep 1
 
 		HighRezTimer::sleep(0.5_sec); // Wait a bit more for good measure
 
-		StringRaii stdOut(HeapAllocator<U8>(allocAligned, nullptr));
+		HeapMemoryPool pool(allocAligned, nullptr);
+		StringRaii stdOut(&pool);
 		ANKI_TEST_EXPECT_NO_ERR(proc.readFromStdout(stdOut));
 		ANKI_TEST_EXPECT_EQ(stdOut, "Lala\n");
 	}

+ 11 - 16
Tests/Util/SegregatedListsAllocatorBuilder.cpp

@@ -9,40 +9,40 @@
 
 using namespace anki;
 
-static constexpr U32 CLASS_COUNT = 6;
+static constexpr U32 kClassCount = 6;
 
 class SegregatedListsAllocatorBuilderChunk :
-	public SegregatedListsAllocatorBuilderChunkBase<SegregatedListsAllocatorBuilderChunk, CLASS_COUNT>
+	public SegregatedListsAllocatorBuilderChunkBase<SegregatedListsAllocatorBuilderChunk, kClassCount>
 {
 };
 
 class SegregatedListsAllocatorBuilderInterface
 {
 public:
-	HeapAllocator<U8> m_alloc = {allocAligned, nullptr};
-	static constexpr PtrSize m_chunkSize = 100_MB;
+	HeapMemoryPool m_pool = {allocAligned, nullptr};
+	static constexpr PtrSize kChunkSize = 100_MB;
 
 	static constexpr U32 getClassCount()
 	{
-		return CLASS_COUNT;
+		return kClassCount;
 	}
 
 	void getClassInfo(U32 idx, PtrSize& size) const
 	{
-		static const Array<PtrSize, getClassCount()> classes = {512_KB, 1_MB, 5_MB, 10_MB, 30_MB, m_chunkSize};
+		static const Array<PtrSize, getClassCount()> classes = {512_KB, 1_MB, 5_MB, 10_MB, 30_MB, kChunkSize};
 		size = classes[idx];
 	}
 
 	Error allocateChunk(SegregatedListsAllocatorBuilderChunk*& newChunk, PtrSize& chunkSize)
 	{
-		newChunk = m_alloc.newInstance<SegregatedListsAllocatorBuilderChunk>();
-		chunkSize = m_chunkSize;
+		newChunk = newInstance<SegregatedListsAllocatorBuilderChunk>(m_pool);
+		chunkSize = kChunkSize;
 		return Error::kNone;
 	}
 
 	void deleteChunk(SegregatedListsAllocatorBuilderChunk* chunk)
 	{
-		m_alloc.deleteInstance(chunk);
+		deleteInstance(m_pool, chunk);
 	}
 
 	static constexpr PtrSize getMinSizeAlignment()
@@ -50,14 +50,9 @@ public:
 		return 4;
 	}
 
-	HeapAllocator<U8>& getAllocator()
+	HeapMemoryPool& getMemoryPool()
 	{
-		return m_alloc;
-	}
-
-	HeapAllocator<U8> getAllocator() const
-	{
-		return m_alloc;
+		return m_pool;
 	}
 };
 

+ 4 - 4
Tests/Util/Serializer.cpp

@@ -30,7 +30,7 @@ ANKI_TEST(Util, BinarySerializer)
 	a.m_u64 = 0x123456789ABCDEFF;
 	a.m_darray = b;
 
-	HeapAllocator<U8> alloc(allocAligned, nullptr);
+	HeapMemoryPool pool(allocAligned, nullptr);
 
 	// Serialize
 	{
@@ -38,7 +38,7 @@ ANKI_TEST(Util, BinarySerializer)
 		ANKI_TEST_EXPECT_NO_ERR(file.open("serialized.bin", FileOpenFlag::kWrite | FileOpenFlag::kBinary));
 		BinarySerializer serializer;
 
-		ANKI_TEST_EXPECT_NO_ERR(serializer.serialize(a, alloc, file));
+		ANKI_TEST_EXPECT_NO_ERR(serializer.serialize(a, pool, file));
 	}
 
 	// Deserialize
@@ -48,7 +48,7 @@ ANKI_TEST(Util, BinarySerializer)
 
 		BinaryDeserializer deserializer;
 		ClassA* pa;
-		ANKI_TEST_EXPECT_NO_ERR(deserializer.deserialize(pa, alloc, file));
+		ANKI_TEST_EXPECT_NO_ERR(deserializer.deserialize(pa, pool, file));
 
 		ANKI_TEST_EXPECT_EQ(pa->m_array[0], a.m_array[0]);
 		ANKI_TEST_EXPECT_EQ(pa->m_u32, a.m_u32);
@@ -64,6 +64,6 @@ ANKI_TEST(Util, BinarySerializer)
 			}
 		}
 
-		alloc.deleteInstance(pa);
+		deleteInstance(pool, pa);
 	}
 }

+ 31 - 33
Tests/Util/SparseArray.cpp

@@ -118,26 +118,26 @@ public:
 
 ANKI_TEST(Util, SparseArray)
 {
-	HeapAllocator<U8> alloc(allocAligned, nullptr);
+	HeapMemoryPool pool(allocAligned, nullptr);
 
 	// Set same key
 	{
 		SparseArray<PtrSize> arr;
 
-		arr.emplace(alloc, 1000, 123);
-		arr.emplace(alloc, 1000, 124);
+		arr.emplace(pool, 1000, 123);
+		arr.emplace(pool, 1000, 124);
 		auto it = arr.find(1000);
 		ANKI_TEST_EXPECT_EQ(*it, 124);
-		arr.erase(alloc, it);
+		arr.erase(pool, it);
 	}
 
 	// Check destroy and grow
 	{
 		SparseArray<SAFoo, Config<U32>> arr(Config<U32>{64, 2, 0.8f});
 
-		arr.emplace(alloc, 64 * 1, 123);
-		arr.emplace(alloc, 64 * 2, 124);
-		arr.emplace(alloc, 64 * 3, 125);
+		arr.emplace(pool, 64 * 1, 123);
+		arr.emplace(pool, 64 * 2, 124);
+		arr.emplace(pool, 64 * 3, 125);
 
 		ANKI_TEST_EXPECT_EQ(arr.find(64 * 1)->m_x, 123);
 		ANKI_TEST_EXPECT_EQ(arr.find(64 * 2)->m_x, 124);
@@ -145,7 +145,7 @@ ANKI_TEST(Util, SparseArray)
 
 		SparseArray<SAFoo, Config<U32>> arr2(std::move(arr));
 
-		arr2.destroy(alloc);
+		arr2.destroy(pool);
 		SAFoo::checkCalls();
 	}
 
@@ -153,19 +153,19 @@ ANKI_TEST(Util, SparseArray)
 	{
 		SparseArray<SAFoo, Config<U32>> arr(Config<U32>{64, 3, 0.8f});
 
-		arr.emplace(alloc, 64u * 0 - 1, 1);
+		arr.emplace(pool, 64u * 0 - 1, 1);
 		// Linear probing to 0
-		arr.emplace(alloc, 64 * 1 - 1, 2);
+		arr.emplace(pool, 64 * 1 - 1, 2);
 		// Linear probing to 1
-		arr.emplace(alloc, 64 * 2 - 1, 3);
+		arr.emplace(pool, 64 * 2 - 1, 3);
 		// Linear probing to 2
-		arr.emplace(alloc, 1, 3);
+		arr.emplace(pool, 1, 3);
 		// Swap
-		arr.emplace(alloc, 64 * 1, 3);
+		arr.emplace(pool, 64 * 1, 3);
 
 		ANKI_TEST_EXPECT_EQ(arr.getSize(), 5);
 
-		arr.destroy(alloc);
+		arr.destroy(pool);
 		SAFoo::checkCalls();
 	}
 
@@ -188,7 +188,7 @@ ANKI_TEST(Util, SparseArray)
 				{
 					// Not found
 					ANKI_TEST_EXPECT_EQ(arr.find(num), arr.getEnd());
-					arr.emplace(alloc, num, num);
+					arr.emplace(pool, num, num);
 					ANKI_TEST_EXPECT_EQ(arr.getSize(), i + 1);
 
 					numbers.push_back(num);
@@ -217,7 +217,7 @@ ANKI_TEST(Util, SparseArray)
 			auto it = arr.find(num);
 			ANKI_TEST_EXPECT_NEQ(it, arr.getEnd());
 			ANKI_TEST_EXPECT_EQ(it->m_x, num);
-			arr.erase(alloc, it);
+			arr.erase(pool, it);
 
 			arr.validate();
 		}
@@ -227,9 +227,8 @@ ANKI_TEST(Util, SparseArray)
 	{
 		constexpr U kMax = 10000;
 		SparseArray<SAFoo, Config<U64>> arr(Config<U64>{64, 8, 0.8f});
-		using StlMap =
-			std::unordered_map<int, int, std::hash<int>, std::equal_to<int>, HeapAllocator<std::pair<const int, int>>>;
-		StlMap map(10, std::hash<int>(), std::equal_to<int>(), alloc);
+		using StlMap = std::unordered_map<int, int, std::hash<int>, std::equal_to<int>>;
+		StlMap map(10, std::hash<int>(), std::equal_to<int>());
 
 		for(U i = 0; i < kMax; ++i)
 		{
@@ -244,7 +243,7 @@ ANKI_TEST(Util, SparseArray)
 					continue;
 				}
 
-				arr.emplace(alloc, idx, idx + 1);
+				arr.emplace(pool, idx, idx + 1);
 				map[idx] = idx + 1;
 
 				arr.validate();
@@ -261,7 +260,7 @@ ANKI_TEST(Util, SparseArray)
 				ANKI_TEST_EXPECT_EQ(it->second, it2->m_x);
 
 				map.erase(it);
-				arr.erase(alloc, it2);
+				arr.erase(pool, it2);
 
 				ANKI_TEST_EXPECT_EQ(arr.find(key), arr.getEnd());
 
@@ -287,7 +286,7 @@ ANKI_TEST(Util, SparseArray)
 			}
 		}
 
-		arr.destroy(alloc);
+		arr.destroy(pool);
 
 		// Check what the SparseArray have called
 		SAFoo::checkCalls();
@@ -344,9 +343,8 @@ static ANKI_DONT_INLINE void* allocAlignedStl([[maybe_unused]] void* userData, v
 
 ANKI_TEST(Util, SparseArrayBench)
 {
-	HeapAllocator<U8> allocAk(allocAlignedAk, nullptr);
+	HeapMemoryPool pool(allocAlignedAk, nullptr);
 	HeapAllocator<U8> allocStl(allocAlignedStl, nullptr);
-	HeapAllocator<U8> allocTml(allocAligned, nullptr);
 
 	using StlMap =
 		std::unordered_map<int, int, std::hash<int>, std::equal_to<int>, HeapAllocator<std::pair<const int, int>>>;
@@ -357,7 +355,7 @@ ANKI_TEST(Util, SparseArrayBench)
 
 	HighRezTimer timer;
 
-	const U COUNT = 1024 * 1024 * 6;
+	constexpr U kCount = 1024 * 1024 * 6;
 
 	// Create a huge set
 	std::vector<int> vals;
@@ -365,7 +363,7 @@ ANKI_TEST(Util, SparseArrayBench)
 	{
 		std::unordered_map<int, int> tmpMap;
 
-		for(U i = 0; i < COUNT; ++i)
+		for(U i = 0; i < kCount; ++i)
 		{
 			// Put unique keys
 			int v;
@@ -383,16 +381,16 @@ ANKI_TEST(Util, SparseArrayBench)
 	{
 		// AnkI
 		timer.start();
-		for(U i = 0; i < COUNT; ++i)
+		for(U i = 0; i < kCount; ++i)
 		{
-			akMap.emplace(allocAk, vals[i], vals[i]);
+			akMap.emplace(pool, vals[i], vals[i]);
 		}
 		timer.stop();
 		Second akTime = timer.getElapsedTime();
 
 		// STL
 		timer.start();
-		for(U i = 0; i < COUNT; ++i)
+		for(U i = 0; i < kCount; ++i)
 		{
 			stdMap[vals[i]] = vals[i];
 		}
@@ -411,7 +409,7 @@ ANKI_TEST(Util, SparseArrayBench)
 
 		// Find values AnKi
 		timer.start();
-		for(U i = 0; i < COUNT; ++i)
+		for(U i = 0; i < kCount; ++i)
 		{
 			auto it = akMap.find(vals[i]);
 			count += *it;
@@ -421,7 +419,7 @@ ANKI_TEST(Util, SparseArrayBench)
 
 		// Find values STL
 		timer.start();
-		for(U i = 0; i < COUNT; ++i)
+		for(U i = 0; i < kCount; ++i)
 		{
 			count += stdMap[vals[i]];
 		}
@@ -450,7 +448,7 @@ ANKI_TEST(Util, SparseArrayBench)
 			auto it = akMap.find(vals[i]);
 
 			timer.start();
-			akMap.erase(allocAk, it);
+			akMap.erase(pool, it);
 			timer.stop();
 			akTime += timer.getElapsedTime();
 		}
@@ -470,5 +468,5 @@ ANKI_TEST(Util, SparseArrayBench)
 		ANKI_TEST_LOGI("Deleting bench: STL %f AnKi %f | %f%%", stlTime, akTime, stlTime / akTime * 100.0);
 	}
 
-	akMap.destroy(allocAk);
+	akMap.destroy(pool);
 }

+ 65 - 65
Tests/Util/String.cpp

@@ -9,49 +9,49 @@
 
 ANKI_TEST(Util, String)
 {
-	HeapAllocator<U8> alloc(allocAligned, nullptr);
+	HeapMemoryPool pool(allocAligned, nullptr);
 
 	// Copy
 	{
 		String a, b;
-		a.create(alloc, "123");
-		b.create(alloc, a);
+		a.create(pool, "123");
+		b.create(pool, a);
 
 		ANKI_TEST_EXPECT_EQ(a, b);
 		ANKI_TEST_EXPECT_EQ(b, "123");
 
-		b.destroy(alloc);
-		a.destroy(alloc);
-		b.create(alloc, "321");
-		a.create(alloc, b);
+		b.destroy(pool);
+		a.destroy(pool);
+		b.create(pool, "321");
+		a.create(pool, b);
 		ANKI_TEST_EXPECT_EQ(a, b);
 		ANKI_TEST_EXPECT_EQ(a, "321");
 
-		b.destroy(alloc);
-		a.destroy(alloc);
+		b.destroy(pool);
+		a.destroy(pool);
 	}
 
 	// Move
 	{
 		String a;
-		a.create(alloc, "123");
+		a.create(pool, "123");
 		String b(std::move(a));
 		ANKI_TEST_EXPECT_EQ(a.isEmpty(), true);
 		ANKI_TEST_EXPECT_EQ(b, "123");
 
-		b.destroy(alloc);
-		b.create(alloc, "321");
+		b.destroy(pool);
+		b.create(pool, "321");
 		a = std::move(b);
 		ANKI_TEST_EXPECT_EQ(a, "321");
 		ANKI_TEST_EXPECT_EQ(b.isEmpty(), true);
-		a.destroy(alloc);
+		a.destroy(pool);
 	}
 
 	// Accessors
 	{
 		const char* s = "123";
 		String a;
-		a.create(alloc, s);
+		a.create(pool, s);
 		ANKI_TEST_EXPECT_EQ(a[0], '1');
 		ANKI_TEST_EXPECT_EQ(a[1], '2');
 		ANKI_TEST_EXPECT_EQ(a[2], '3');
@@ -68,35 +68,35 @@ ANKI_TEST(Util, String)
 
 		ANKI_TEST_EXPECT_EQ(a.begin(), &a[0]);
 		ANKI_TEST_EXPECT_EQ(a.end(), &a[0] + 3);
-		a.destroy(alloc);
+		a.destroy(pool);
 	}
 
 	// Append
 	{
 		String a, b;
 
-		b.create(alloc, "123");
+		b.create(pool, "123");
 
-		a.append(alloc, b);
+		a.append(pool, b);
 		ANKI_TEST_EXPECT_EQ(a, "123");
 
-		a.append(alloc, "456789");
-		a.append(alloc, String());
-		a.append(alloc, "");
-		a.append(alloc, "0");
+		a.append(pool, "456789");
+		a.append(pool, String());
+		a.append(pool, "");
+		a.append(pool, "0");
 		ANKI_TEST_EXPECT_EQ(a, "1234567890");
-		a.destroy(alloc);
-		b.destroy(alloc);
+		a.destroy(pool);
+		b.destroy(pool);
 	}
 
 	// Compare
 	{
 #define COMPARE(x_, y_, op_) \
-	a.append(alloc, x_); \
-	b.append(alloc, y_); \
+	a.append(pool, x_); \
+	b.append(pool, y_); \
 	ANKI_TEST_EXPECT_EQ(a op_ b, std::string(x_) op_ std::string(y_)) \
-	a.destroy(alloc); \
-	b.destroy(alloc);
+	a.destroy(pool); \
+	b.destroy(pool);
 
 		String a, b;
 		COMPARE("123", "1233", <);
@@ -112,26 +112,26 @@ ANKI_TEST(Util, String)
 		String a;
 
 		// Simple
-		a.sprintf(alloc, "12%c  %d", '3', 123);
+		a.sprintf(pool, "12%c  %d", '3', 123);
 		ANKI_TEST_EXPECT_EQ(a, "123  123");
-		a.destroy(alloc);
+		a.destroy(pool);
 
 		// Extreme
 		const char* s = "1234567890ABCDEF!@#$%^&*()_+asfghjkl:,.;ljk\"><{}[]/";
-		a.sprintf(alloc, "%s%s%s%s%s%s%s%s%s%s%s %d", s, s, s, s, s, s, s, s, s, s, s, 88);
+		a.sprintf(pool, "%s%s%s%s%s%s%s%s%s%s%s %d", s, s, s, s, s, s, s, s, s, s, s, 88);
 
 		String b;
 		for(U i = 0; i < 11; i++)
 		{
-			b.append(alloc, s);
+			b.append(pool, s);
 		}
-		b.append(alloc, " 88");
+		b.append(pool, " 88");
 
 		ANKI_TEST_EXPECT_EQ(a, b);
 		ANKI_TEST_EXPECT_EQ(a.getLength(), b.getLength());
 
-		a.destroy(alloc);
-		b.destroy(alloc);
+		a.destroy(pool);
+		b.destroy(pool);
 	}
 
 	// sprintf #2: Smaller result (will trigger another path)
@@ -139,92 +139,92 @@ ANKI_TEST(Util, String)
 		String a;
 
 		// Simple
-		a.sprintf(alloc, "12%c  %d", '3', 123);
+		a.sprintf(pool, "12%c  %d", '3', 123);
 		ANKI_TEST_EXPECT_EQ(a, "123  123");
-		a.destroy(alloc);
+		a.destroy(pool);
 
 		// Extreme
 		const char* s = "12345";
-		a.sprintf(alloc, "%s%s %d", s, s, 88);
+		a.sprintf(pool, "%s%s %d", s, s, 88);
 
 		String b;
 		for(U i = 0; i < 2; i++)
 		{
-			b.append(alloc, s);
+			b.append(pool, s);
 		}
-		b.append(alloc, " 88");
+		b.append(pool, " 88");
 
 		ANKI_TEST_EXPECT_EQ(a, b);
 		ANKI_TEST_EXPECT_EQ(a.getLength(), b.getLength());
 
-		a.destroy(alloc);
-		b.destroy(alloc);
+		a.destroy(pool);
+		b.destroy(pool);
 	}
 
 	// Other create
 	{
 		String a;
 
-		a.create(alloc, '1', 3);
+		a.create(pool, '1', 3);
 		ANKI_TEST_EXPECT_EQ(a, "111");
 		ANKI_TEST_EXPECT_EQ(a.getLength(), 3);
 
-		a.destroy(alloc);
+		a.destroy(pool);
 	}
 
 	// toString
 	{
 		String a;
-		a.toString(alloc, 123);
+		a.toString(pool, 123);
 		ANKI_TEST_EXPECT_EQ(a, "123");
-		a.destroy(alloc);
+		a.destroy(pool);
 
-		a.toString(alloc, 123.123);
+		a.toString(pool, 123.123);
 		ANKI_TEST_EXPECT_EQ(a, "123.123000");
-		a.destroy(alloc);
+		a.destroy(pool);
 	}
 
 	// To number
 	{
 		I64 i;
 		String a;
-		a.create(alloc, "123456789");
+		a.create(pool, "123456789");
 		ANKI_TEST_EXPECT_NO_ERR(a.toNumber(i));
 		ANKI_TEST_EXPECT_EQ(i, 123456789);
-		a.destroy(alloc);
+		a.destroy(pool);
 
-		a.create(alloc, "-9223372036854775807");
+		a.create(pool, "-9223372036854775807");
 		ANKI_TEST_EXPECT_NO_ERR(a.toNumber(i));
 		ANKI_TEST_EXPECT_EQ(i, -9223372036854775807);
-		a.destroy(alloc);
+		a.destroy(pool);
 
 		F64 f;
-		a.create(alloc, "123456789.145");
+		a.create(pool, "123456789.145");
 		ANKI_TEST_EXPECT_NO_ERR(a.toNumber(f));
 		ANKI_TEST_EXPECT_EQ(f, 123456789.145);
-		a.destroy(alloc);
+		a.destroy(pool);
 	}
 
 	// replaceAll
 	{
-		String a = {alloc, "foo"};
-		a.replaceAll(alloc, "foo", "bar");
+		String a = {pool, "foo"};
+		a.replaceAll(pool, "foo", "bar");
 		ANKI_TEST_EXPECT_EQ(a, "bar");
-		a.destroy(alloc);
+		a.destroy(pool);
 
-		a.create(alloc, "lafooha");
-		a.replaceAll(alloc, "foo", "bar");
+		a.create(pool, "lafooha");
+		a.replaceAll(pool, "foo", "bar");
 		ANKI_TEST_EXPECT_EQ(a, "labarha");
-		a.destroy(alloc);
+		a.destroy(pool);
 
-		a.create(alloc, "jjhfalkakljla");
-		a.replaceAll(alloc, "a", "b");
+		a.create(pool, "jjhfalkakljla");
+		a.replaceAll(pool, "a", "b");
 		ANKI_TEST_EXPECT_EQ(a, "jjhfblkbkljlb");
-		a.destroy(alloc);
+		a.destroy(pool);
 
-		a.create(alloc, "%foo%ajlkadsf%foo%");
-		a.replaceAll(alloc, "%foo%", "");
+		a.create(pool, "%foo%ajlkadsf%foo%");
+		a.replaceAll(pool, "%foo%", "");
 		ANKI_TEST_EXPECT_EQ(a, "ajlkadsf");
-		a.destroy(alloc);
+		a.destroy(pool);
 	}
 }

+ 2 - 2
Tests/Util/StringList.cpp

@@ -8,13 +8,13 @@
 
 ANKI_TEST(Util, StringList)
 {
-	HeapAllocator<U8> alloc(allocAligned, nullptr);
+	HeapMemoryPool pool(allocAligned, nullptr);
 
 	// Test splitString
 	{
 		CString toSplit = "foo\n\nboo\n";
 
-		StringListRaii list(alloc);
+		StringListRaii list(&pool);
 		list.splitString(toSplit, '\n');
 
 		ANKI_TEST_EXPECT_EQ(list.getSize(), 2);

+ 4 - 4
Tests/Util/ThreadHive.cpp

@@ -68,8 +68,8 @@ static void taskToWait(void* arg, [[maybe_unused]] U32 threadId, [[maybe_unused]
 ANKI_TEST(Util, ThreadHive)
 {
 	const U32 threadCount = 32;
-	HeapAllocator<U8> alloc(allocAligned, nullptr);
-	ThreadHive hive(threadCount, alloc);
+	HeapMemoryPool pool(allocAligned, nullptr);
+	ThreadHive hive(threadCount, &pool);
 
 	// Simple test
 	if(1)
@@ -238,8 +238,8 @@ ANKI_TEST(Util, ThreadHiveBench)
 	static const U FIB_N = 32;
 
 	const U32 threadCount = getCpuCoresCount();
-	HeapAllocator<U8> alloc(allocAligned, nullptr);
-	ThreadHive hive(threadCount, alloc, true);
+	HeapMemoryPool pool(allocAligned, nullptr);
+	ThreadHive hive(threadCount, &pool, true);
 
 	StackAllocator<U8> salloc(allocAligned, nullptr, 1024);
 	Atomic<U64> sum = {0};