Browse Source

Everything builds on windows

Panagiotis Christopoulos Charitos 3 years ago
parent
commit
8b7eeeba67

+ 7 - 7
Samples/PhysicsPlayground/Main.cpp

@@ -157,7 +157,7 @@ Error MyApp::sampleExtraInit()
 		{
 			ModelNode* monkey;
 			ANKI_CHECK(getSceneGraph().newSceneNode<ModelNode>(
-				StringRaii(getAllocator()).sprintf("monkey_chain%u", i).toCString(), monkey));
+				StringRaii(&getMemoryPool()).sprintf("monkey_chain%u", i).toCString(), monkey));
 			ANKI_CHECK(monkey->getFirstComponentOfType<ModelComponent>().loadModelResource(
 				"Assets/Suzanne_dynamic_36043dae41fe12d5.ankimdl"));
 
@@ -169,7 +169,7 @@ Error MyApp::sampleExtraInit()
 
 			BodyNode* body;
 			ANKI_CHECK(getSceneGraph().newSceneNode<BodyNode>(
-				StringRaii(getAllocator()).sprintf("bmonkey_chain%u", i).toCString(), body));
+				StringRaii(&getMemoryPool()).sprintf("bmonkey_chain%u", i).toCString(), body));
 			ANKI_CHECK(body->getFirstComponentOfType<BodyComponent>().loadMeshResource(
 				"Assets/Suzanne_lod0_e3526e1428c0763c.ankimesh"));
 			body->getFirstComponentOfType<BodyComponent>().setWorldTransform(trf);
@@ -296,14 +296,14 @@ Error MyApp::userMainLoop(Bool& quit, [[maybe_unused]] Second elapsedTime)
 
 		ModelNode* monkey;
 		ANKI_CHECK(getSceneGraph().newSceneNode<ModelNode>(
-			StringRaii(getAllocator()).sprintf("monkey%u", instance++).toCString(), monkey));
+			StringRaii(&getMemoryPool()).sprintf("monkey%u", instance++).toCString(), monkey));
 		ANKI_CHECK(monkey->getFirstComponentOfType<ModelComponent>().loadModelResource(
 			"Assets/Suzanne_dynamic_36043dae41fe12d5.ankimdl"));
 		// monkey->getFirstComponentOfType<MoveComponent>().setLocalTransform(camTrf);
 
 		BodyNode* body;
 		ANKI_CHECK(getSceneGraph().newSceneNode<BodyNode>(
-			StringRaii(getAllocator()).sprintf("bmonkey%u", instance++).toCString(), body));
+			StringRaii(&getMemoryPool()).sprintf("bmonkey%u", instance++).toCString(), body));
 		ANKI_CHECK(body->getFirstComponentOfType<BodyComponent>().loadMeshResource(
 			"Assets/Suzanne_lod0_e3526e1428c0763c.ankimesh"));
 		body->getFirstComponentOfType<BodyComponent>().setWorldTransform(camTrf);
@@ -349,7 +349,7 @@ Error MyApp::userMainLoop(Bool& quit, [[maybe_unused]] Second elapsedTime)
 			static U32 id = 0;
 			ModelNode* monkey;
 			ANKI_CHECK(getSceneGraph().newSceneNode(
-				StringRaii(getSceneGraph().getFrameAllocator()).sprintf("decal%u", id++).toCString(), monkey));
+				StringRaii(&getSceneGraph().getFrameMemoryPool()).sprintf("decal%u", id++).toCString(), monkey));
 			ANKI_CHECK(monkey->getFirstComponentOfType<ModelComponent>().loadModelResource(
 				"Assets/Suzanne_dynamic_36043dae41fe12d5.ankimdl"));
 			monkey->getFirstComponentOfType<MoveComponent>().setLocalTransform(trf);
@@ -360,7 +360,7 @@ Error MyApp::userMainLoop(Bool& quit, [[maybe_unused]] Second elapsedTime)
 			// Create some particles
 			ParticleEmitterNode* particles;
 			ANKI_CHECK(getSceneGraph().newSceneNode(
-				StringRaii(getSceneGraph().getFrameAllocator()).sprintf("parts%u", id++).toCString(), particles));
+				StringRaii(&getSceneGraph().getFrameMemoryPool()).sprintf("parts%u", id++).toCString(), particles));
 			ANKI_CHECK(particles->getFirstComponentOfType<ParticleEmitterComponent>().loadParticleEmitterResource(
 				"Assets/Smoke.ankipart"));
 			particles->getFirstComponentOfType<MoveComponent>().setLocalTransform(trf);
@@ -371,7 +371,7 @@ Error MyApp::userMainLoop(Bool& quit, [[maybe_unused]] Second elapsedTime)
 			for(U i = 0; i < 1; ++i)
 			{
 				static int id = 0;
-				StringRaii name(getSceneGraph().getFrameAllocator());
+				StringRaii name(&getSceneGraph().getFrameMemoryPool());
 				name.sprintf("fog%u", id++);
 
 				FogDensityNode* fogNode;

+ 8 - 8
Tools/GltfImporter/Main.cpp

@@ -23,11 +23,11 @@ Options:
 class CmdLineArgs
 {
 public:
-	HeapAllocator<U8> m_alloc = {allocAligned, nullptr};
-	StringRaii m_inputFname = {m_alloc};
-	StringRaii m_outDir = {m_alloc};
-	StringRaii m_rpath = {m_alloc};
-	StringRaii m_texRpath = {m_alloc};
+	HeapMemoryPool m_pool = {allocAligned, nullptr};
+	StringRaii m_inputFname = {&m_pool};
+	StringRaii m_outDir = {&m_pool};
+	StringRaii m_rpath = {&m_pool};
+	StringRaii m_texRpath = {&m_pool};
 	Bool m_optimizeMeshes = true;
 	Bool m_optimizeAnimations = true;
 	U32 m_threadCount = kMaxU32;
@@ -211,8 +211,8 @@ int myMain(int argc, char** argv)
 		return 1;
 	}
 
-	HeapAllocator<U8> alloc(allocAligned, nullptr);
-	StringRaii comment(alloc);
+	HeapMemoryPool pool(allocAligned, nullptr);
+	StringRaii comment(&pool);
 	for(I32 i = 0; i < argc; ++i)
 	{
 		if(i != 0)
@@ -243,7 +243,7 @@ int myMain(int argc, char** argv)
 	initInfo.m_threadCount = cmdArgs.m_threadCount;
 	initInfo.m_comment = comment;
 
-	GltfImporter importer(alloc);
+	GltfImporter importer(&pool);
 	if(importer.init(initInfo))
 	{
 		return 1;

+ 9 - 9
Tools/Image/ImageImporterMain.cpp

@@ -13,14 +13,14 @@ namespace {
 class Cleanup
 {
 public:
-	HeapAllocator<U8> m_alloc{allocAligned, nullptr};
-	DynamicArrayRaii<CString> m_inputFilenames{m_alloc};
-	StringRaii m_outFilename{m_alloc};
+	HeapMemoryPool m_pool = {allocAligned, nullptr};
+	DynamicArrayRaii<CString> m_inputFilenames = {&m_pool};
+	StringRaii m_outFilename = {&m_pool};
 };
 
 } // namespace
 
-static const char* USAGE = R"(Usage: %s [options] in_files
+static const char* kUsage = R"(Usage: %s [options] in_files
 Options:
 -o <filename>          : Output filename. If not provided the file will derive it from the input filenames
 -t <type>              : Image type. One of: 2D, 3D, Cube, 2DArray
@@ -276,7 +276,7 @@ static Error parseCommandLineArgs(int argc, char** argv, ImageImporterConfig& co
 	{
 		CString infname = cleanup.m_inputFilenames[0];
 
-		StringRaii ext(cleanup.m_alloc);
+		StringRaii ext(&cleanup.m_pool);
 		getFilepathExtension(infname, ext);
 
 		getFilepathFilename(infname, cleanup.m_outFilename);
@@ -298,18 +298,18 @@ static Error parseCommandLineArgs(int argc, char** argv, ImageImporterConfig& co
 
 int main(int argc, char** argv)
 {
-	HeapAllocator<U8> alloc(allocAligned, nullptr);
+	HeapMemoryPool pool(allocAligned, nullptr);
 
 	ImageImporterConfig config;
-	config.m_allocator = alloc;
+	config.m_pool = &pool;
 	Cleanup cleanup;
 	if(parseCommandLineArgs(argc, argv, config, cleanup))
 	{
-		ANKI_IMPORTER_LOGE(USAGE, argv[0]);
+		ANKI_IMPORTER_LOGE(kUsage, argv[0]);
 		return 1;
 	}
 
-	StringRaii tmp(alloc);
+	StringRaii tmp(&pool);
 	if(getTempDirectory(tmp))
 	{
 		ANKI_IMPORTER_LOGE("getTempDirectory() failed");

+ 5 - 5
Tools/Image/ImageViewerMain.cpp

@@ -121,7 +121,7 @@ private:
 
 		// Mips combo
 		{
-			StringListRaii mipLabels(getFrameAllocator());
+			StringListRaii mipLabels(&getFrameMemoryPool());
 			for(U32 mip = 0; mip < grTex.getMipmapCount(); ++mip)
 			{
 				mipLabels.pushBackSprintf("Mip %u (%u x %u)", mip, grTex.getWidth() >> mip, grTex.getHeight() >> mip);
@@ -161,7 +161,7 @@ private:
 		// Depth
 		if(grTex.getTextureType() == TextureType::k3D)
 		{
-			StringListRaii labels(getFrameAllocator());
+			StringListRaii labels(&getFrameMemoryPool());
 			for(U32 d = 0; d < grTex.getDepth(); ++d)
 			{
 				labels.pushBackSprintf("Depth %u", d);
@@ -275,8 +275,8 @@ public:
 			return Error::kUserData;
 		}
 
-		HeapAllocator<U32> alloc(allocAligned, nullptr);
-		StringRaii mainDataPath(alloc, ANKI_SOURCE_DIRECTORY);
+		HeapMemoryPool pool(allocAligned, nullptr);
+		StringRaii mainDataPath(&pool, ANKI_SOURCE_DIRECTORY);
 
 		config->setWindowFullscreen(false);
 		config->setRsrcDataPaths(mainDataPath);
@@ -291,7 +291,7 @@ public:
 		ANKI_CHECK(getResourceManager().loadResource(argv[1], image, false));
 
 		// Change window name
-		StringRaii title(alloc);
+		StringRaii title(&pool);
 		title.sprintf("%s %u x %u Mips %u Format %s", argv[1], image->getWidth(), image->getHeight(),
 					  image->getTexture()->getMipmapCount(), getFormatInfo(image->getTexture()->getFormat()).m_name);
 		getWindow().setWindowTitle(title);

+ 9 - 8
Tools/Shader/ShaderProgramBinaryDumpMain.cpp

@@ -8,7 +8,7 @@
 
 using namespace anki;
 
-static const char* USAGE = R"(Dump the shader binary to stdout
+static const char* kUsage = R"(Dump the shader binary to stdout
 Usage: %s [options] input_shader_program_binary
 Options:
 -stats : Print performance statistics for all shaders. By default it doesn't
@@ -38,7 +38,7 @@ static Error parseCommandLineArgs(int argc, char** argv, Bool& dumpStats, String
 
 Error dumpStats(const ShaderProgramBinary& bin)
 {
-	HeapAllocator<U8> alloc(allocAligned, nullptr);
+	HeapMemoryPool pool(allocAligned, nullptr);
 
 	printf("\nMali offline compiler stats:\n");
 	fflush(stdout);
@@ -94,7 +94,7 @@ Error dumpStats(const ShaderProgramBinary& bin)
 #else
 #	error "Not supported"
 #endif
-				codeBlock.m_binary, shaderType, alloc, maliocOut);
+				codeBlock.m_binary, shaderType, pool, maliocOut);
 
 			if(err)
 			{
@@ -171,12 +171,12 @@ Error dumpStats(const ShaderProgramBinary& bin)
 
 Error dump(CString fname, Bool bDumpStats)
 {
-	HeapAllocator<U8> alloc(allocAligned, nullptr);
+	HeapMemoryPool pool(allocAligned, nullptr);
 
-	ShaderProgramBinaryWrapper binw(alloc);
+	ShaderProgramBinaryWrapper binw(&pool);
 	ANKI_CHECK(binw.deserializeFromFile(fname));
 
-	StringRaii txt(alloc);
+	StringRaii txt(&pool);
 	dumpShaderProgramBinary(binw.getBinary(), txt);
 
 	printf("%s\n", txt.cstr());
@@ -191,11 +191,12 @@ Error dump(CString fname, Bool bDumpStats)
 
 int main(int argc, char** argv)
 {
-	StringRaii filename(HeapAllocator<U8>(allocAligned, nullptr));
+	HeapMemoryPool pool(allocAligned, nullptr);
+	StringRaii filename(&pool);
 	Bool dumpStats;
 	if(parseCommandLineArgs(argc, argv, dumpStats, filename))
 	{
-		ANKI_LOGE(USAGE, argv[0]);
+		ANKI_LOGE(kUsage, argv[0]);
 		return 1;
 	}
 

+ 18 - 19
Tools/Shader/ShaderProgramCompilerMain.cpp

@@ -7,7 +7,7 @@
 #include <AnKi/Util.h>
 using namespace anki;
 
-static const char* USAGE = R"(Compile an AnKi shader program
+static constexpr char* kUsage = R"(Compile an AnKi shader program
 Usage: %s [options] input_shader_program_file
 Options:
 -o <name of output>  : The name of the output binary
@@ -20,10 +20,10 @@ Options:
 class CmdLineArgs
 {
 public:
-	HeapAllocator<U8> m_alloc = {allocAligned, nullptr};
-	StringRaii m_inputFname = {m_alloc};
-	StringRaii m_outFname = {m_alloc};
-	StringRaii m_includePath = {m_alloc};
+	HeapMemoryPool m_pool = {allocAligned, nullptr};
+	StringRaii m_inputFname = {&m_pool};
+	StringRaii m_outFname = {&m_pool};
+	StringRaii m_includePath = {&m_pool};
 	U32 m_threadCount = getCpuCoresCount();
 	Bool m_fullFpPrecision = false;
 	Bool m_mobilePlatform = false;
@@ -113,7 +113,7 @@ static Error parseCommandLineArgs(int argc, char** argv, CmdLineArgs& info)
 
 static Error work(const CmdLineArgs& info)
 {
-	HeapAllocator<U8> alloc{allocAligned, nullptr};
+	HeapMemoryPool pool(allocAligned, nullptr);
 
 	// Load interface
 	class FSystem : public ShaderProgramFilesystemInterface
@@ -124,7 +124,7 @@ static Error work(const CmdLineArgs& info)
 
 		Error readAllTextInternal(CString filename, StringRaii& txt)
 		{
-			StringRaii fname(txt.getAllocator());
+			StringRaii fname(&txt.getMemoryPool());
 
 			// The first file is the input file. Don't append the include path to it
 			if(m_fileReadCount == 0)
@@ -161,7 +161,7 @@ static Error work(const CmdLineArgs& info)
 	{
 	public:
 		ThreadHive* m_hive = nullptr;
-		HeapAllocator<U8> m_alloc;
+		HeapMemoryPool* m_pool = nullptr;
 
 		void enqueueTask(void (*callback)(void* userData), void* userData)
 		{
@@ -169,20 +169,19 @@ static Error work(const CmdLineArgs& info)
 			{
 				void (*m_callback)(void* userData);
 				void* m_userData;
-				HeapAllocator<U8> m_alloc;
+				HeapMemoryPool* m_pool = nullptr;
 			};
-			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);
 		}
@@ -194,8 +193,8 @@ static Error work(const CmdLineArgs& info)
 		}
 	} taskManager;
 	taskManager.m_hive =
-		(info.m_threadCount) ? alloc.newInstance<ThreadHive>(info.m_threadCount, alloc, true) : nullptr;
-	taskManager.m_alloc = alloc;
+		(info.m_threadCount) ? newInstance<ThreadHive>(pool, info.m_threadCount, &pool, true) : nullptr;
+	taskManager.m_pool = &pool;
 
 	// Compiler options
 	ShaderCompilerOptions compilerOptions;
@@ -203,15 +202,15 @@ static Error work(const CmdLineArgs& info)
 	compilerOptions.m_mobilePlatform = info.m_mobilePlatform;
 
 	// Compile
-	ShaderProgramBinaryWrapper binary(alloc);
+	ShaderProgramBinaryWrapper binary(&pool);
 	ANKI_CHECK(compileShaderProgram(info.m_inputFname, fsystem, nullptr, (info.m_threadCount) ? &taskManager : nullptr,
-									alloc, compilerOptions, binary));
+									pool, compilerOptions, binary));
 
 	// Store the binary
 	ANKI_CHECK(binary.serializeToFile(info.m_outFname));
 
 	// Cleanup
-	alloc.deleteInstance(taskManager.m_hive);
+	deleteInstance(pool, taskManager.m_hive);
 
 	return Error::kNone;
 }
@@ -221,7 +220,7 @@ int main(int argc, char** argv)
 	CmdLineArgs info;
 	if(parseCommandLineArgs(argc, argv, info))
 	{
-		ANKI_LOGE(USAGE, argv[0]);
+		ANKI_LOGE(kUsage, argv[0]);
 		return 1;
 	}