Browse Source

Make the ResourceManager a singleton

Panagiotis Christopoulos Charitos 2 years ago
parent
commit
c50ad6b63b
100 changed files with 524 additions and 794 deletions
  1. 7 23
      AnKi/Core/App.cpp
  2. 1 10
      AnKi/Core/App.h
  3. 3 2
      AnKi/Core/GpuMemoryPools.cpp
  4. 1 1
      AnKi/Core/GpuMemoryPools.h
  5. 10 10
      AnKi/Renderer/Bloom.cpp
  6. 1 2
      AnKi/Renderer/ClusterBinning.cpp
  7. 0 1
      AnKi/Renderer/Common.h
  8. 1 1
      AnKi/Renderer/Dbg.cpp
  9. 4 4
      AnKi/Renderer/DepthDownscale.cpp
  10. 4 4
      AnKi/Renderer/DownscaleBlur.cpp
  11. 4 5
      AnKi/Renderer/FinalComposite.cpp
  12. 1 2
      AnKi/Renderer/GBufferPost.cpp
  13. 4 4
      AnKi/Renderer/IndirectDiffuse.cpp
  14. 2 2
      AnKi/Renderer/IndirectDiffuseProbes.cpp
  15. 5 6
      AnKi/Renderer/IndirectSpecular.cpp
  16. 3 4
      AnKi/Renderer/LensFlare.cpp
  17. 10 10
      AnKi/Renderer/LightShading.cpp
  18. 1 1
      AnKi/Renderer/MainRenderer.cpp
  19. 4 4
      AnKi/Renderer/MotionVectors.cpp
  20. 2 2
      AnKi/Renderer/PackVisibleClusteredObjects.cpp
  21. 5 5
      AnKi/Renderer/ProbeReflections.cpp
  22. 6 6
      AnKi/Renderer/Renderer.cpp
  23. 16 16
      AnKi/Renderer/RtShadows.cpp
  24. 4 4
      AnKi/Renderer/Scale.cpp
  25. 2 2
      AnKi/Renderer/ShadowMapping.cpp
  26. 5 6
      AnKi/Renderer/ShadowmapsResolve.cpp
  27. 4 4
      AnKi/Renderer/TemporalAA.cpp
  28. 2 2
      AnKi/Renderer/Tonemapping.cpp
  29. 3 3
      AnKi/Renderer/TraditionalDeferredShading.cpp
  30. 2 2
      AnKi/Renderer/VolumetricFog.cpp
  31. 3 4
      AnKi/Renderer/VolumetricLightingAccumulation.cpp
  32. 6 6
      AnKi/Renderer/VrsSriGeneration.cpp
  33. 9 24
      AnKi/Resource/AnimationResource.cpp
  34. 8 17
      AnKi/Resource/AnimationResource.h
  35. 3 9
      AnKi/Resource/AsyncLoader.cpp
  36. 1 9
      AnKi/Resource/AsyncLoader.h
  37. 2 3
      AnKi/Resource/Common.cpp
  38. 16 3
      AnKi/Resource/Common.h
  39. 2 20
      AnKi/Resource/CpuMeshResource.cpp
  40. 4 4
      AnKi/Resource/CpuMeshResource.h
  41. 6 8
      AnKi/Resource/DummyResource.h
  42. 1 11
      AnKi/Resource/GenericResource.cpp
  43. 3 3
      AnKi/Resource/GenericResource.h
  44. 4 15
      AnKi/Resource/ImageAtlasResource.cpp
  45. 4 4
      AnKi/Resource/ImageAtlasResource.h
  46. 12 23
      AnKi/Resource/ImageResource.cpp
  47. 1 4
      AnKi/Resource/ImageResource.h
  48. 18 33
      AnKi/Resource/MaterialResource.cpp
  49. 5 5
      AnKi/Resource/MaterialResource.h
  50. 3 3
      AnKi/Resource/MeshBinaryLoader.cpp
  51. 4 6
      AnKi/Resource/MeshBinaryLoader.h
  52. 23 24
      AnKi/Resource/MeshResource.cpp
  53. 3 3
      AnKi/Resource/MeshResource.h
  54. 6 16
      AnKi/Resource/ModelResource.cpp
  55. 4 5
      AnKi/Resource/ModelResource.h
  56. 2 11
      AnKi/Resource/ParticleEmitterResource.cpp
  57. 2 2
      AnKi/Resource/ParticleEmitterResource.h
  58. 24 42
      AnKi/Resource/ResourceFilesystem.cpp
  59. 18 20
      AnKi/Resource/ResourceFilesystem.h
  60. 22 40
      AnKi/Resource/ResourceManager.cpp
  61. 27 30
      AnKi/Resource/ResourceManager.h
  62. 4 30
      AnKi/Resource/ResourceObject.cpp
  63. 5 19
      AnKi/Resource/ResourceObject.h
  64. 1 6
      AnKi/Resource/ScriptResource.cpp
  65. 3 6
      AnKi/Resource/ScriptResource.h
  66. 16 24
      AnKi/Resource/ShaderProgramResource.cpp
  67. 6 6
      AnKi/Resource/ShaderProgramResource.h
  68. 28 39
      AnKi/Resource/ShaderProgramResourceSystem.cpp
  69. 9 20
      AnKi/Resource/ShaderProgramResourceSystem.h
  70. 5 14
      AnKi/Resource/SkeletonResource.cpp
  71. 5 13
      AnKi/Resource/SkeletonResource.h
  72. 7 9
      AnKi/Resource/TransferGpuAllocator.cpp
  73. 3 4
      AnKi/Resource/TransferGpuAllocator.h
  74. 0 1
      AnKi/Scene/Common.h
  75. 1 1
      AnKi/Scene/Components/BodyComponent.cpp
  76. 1 1
      AnKi/Scene/Components/DecalComponent.cpp
  77. 2 2
      AnKi/Scene/Components/GlobalIlluminationProbeComponent.cpp
  78. 1 1
      AnKi/Scene/Components/LensFlareComponent.cpp
  79. 1 1
      AnKi/Scene/Components/ModelComponent.cpp
  80. 1 1
      AnKi/Scene/Components/ParticleEmitterComponent.cpp
  81. 1 1
      AnKi/Scene/Components/ScriptComponent.cpp
  82. 1 1
      AnKi/Scene/Components/SkinComponent.cpp
  83. 1 1
      AnKi/Scene/Components/SkyboxComponent.cpp
  84. 1 1
      AnKi/Scene/Events/AnimationEvent.cpp
  85. 1 1
      AnKi/Scene/Events/ScriptEvent.cpp
  86. 4 4
      AnKi/ShaderCompiler/ShaderProgramReflection.cpp
  87. 1 1
      AnKi/Ui/Canvas.cpp
  88. 0 2
      AnKi/Ui/Common.h
  89. 1 1
      AnKi/Ui/Font.cpp
  90. 0 18
      AnKi/Util/File.cpp
  91. 18 1
      AnKi/Util/File.h
  92. 22 0
      AnKi/Util/Forward.h
  93. 1 1
      AnKi/Util/HashMap.h
  94. 1 1
      AnKi/Util/List.h
  95. 1 1
      AnKi/Util/StringList.h
  96. 1 0
      AnKi/Util/Xml.h
  97. 1 1
      Samples/PhysicsPlayground/Main.cpp
  98. 1 1
      Samples/SimpleScene/Main.cpp
  99. 4 3
      Samples/SkeletalAnimation/Main.cpp
  100. 1 1
      Samples/Sponza/Main.cpp

+ 7 - 23
AnKi/Core/App.cpp

@@ -127,10 +127,7 @@ void App::cleanup()
 	deleteInstance(m_mainPool, m_ui);
 	m_ui = nullptr;
 	GpuSceneMicroPatcher::freeSingleton();
-	deleteInstance(m_mainPool, m_resources);
-	m_resources = nullptr;
-	deleteInstance(m_mainPool, m_resourceFs);
-	m_resourceFs = nullptr;
+	ResourceManager::freeSingleton();
 	PhysicsWorld::freeSingleton();
 	RebarStagingGpuMemoryPool::freeSingleton();
 	UnifiedGeometryMemoryPool::freeSingleton();
@@ -295,7 +292,7 @@ Error App::initInternal(AllocAlignedCallback allocCb, void* allocCbUserData)
 												 m_mainPool.getAllocationCallbackUserData()));
 
 	//
-	// Resource FS
+	// Resources
 	//
 #if !ANKI_OS_ANDROID
 	// Add the location of the executable where the shaders are supposed to be
@@ -309,20 +306,11 @@ Error App::initInternal(AllocAlignedCallback allocCb, void* allocCbUserData)
 	ConfigSet::getSingleton().setRsrcDataPaths(shadersPath);
 #endif
 
-	m_resourceFs = newInstance<ResourceFilesystem>(m_mainPool);
-	ANKI_CHECK(m_resourceFs->init(m_mainPool.getAllocationCallback(), m_mainPool.getAllocationCallbackUserData()));
-
-	//
-	// Resources
-	//
 	ResourceManagerInitInfo rinit;
 	rinit.m_grManager = m_gr;
-	rinit.m_resourceFilesystem = m_resourceFs;
 	rinit.m_allocCallback = m_mainPool.getAllocationCallback();
 	rinit.m_allocCallbackData = m_mainPool.getAllocationCallbackUserData();
-	m_resources = newInstance<ResourceManager>(m_mainPool);
-
-	ANKI_CHECK(m_resources->init(rinit));
+	ANKI_CHECK(ResourceManager::allocateSingleton().init(rinit));
 
 	//
 	// UI
@@ -331,15 +319,13 @@ Error App::initInternal(AllocAlignedCallback allocCb, void* allocCbUserData)
 	uiInitInfo.m_allocCallback = m_mainPool.getAllocationCallback();
 	uiInitInfo.m_allocCallbackUserData = m_mainPool.getAllocationCallbackUserData();
 	uiInitInfo.m_grManager = m_gr;
-	uiInitInfo.m_resourceFilesystem = m_resourceFs;
-	uiInitInfo.m_resourceManager = m_resources;
 	m_ui = newInstance<UiManager>(m_mainPool);
 	ANKI_CHECK(m_ui->init(uiInitInfo));
 
 	//
 	// GPU scene
 	//
-	ANKI_CHECK(GpuSceneMicroPatcher::allocateSingleton().init(m_resources));
+	ANKI_CHECK(GpuSceneMicroPatcher::allocateSingleton().init());
 
 	//
 	// Renderer
@@ -349,7 +335,6 @@ Error App::initInternal(AllocAlignedCallback allocCb, void* allocCbUserData)
 		UVec2(NativeWindow::getSingleton().getWidth(), NativeWindow::getSingleton().getHeight());
 	renderInit.m_allocCallback = m_mainPool.getAllocationCallback();
 	renderInit.m_allocCallbackUserData = m_mainPool.getAllocationCallbackUserData();
-	renderInit.m_resourceManager = m_resources;
 	renderInit.m_grManager = m_gr;
 	renderInit.m_uiManager = m_ui;
 	renderInit.m_globTimestamp = &m_globalTimestamp;
@@ -371,7 +356,6 @@ Error App::initInternal(AllocAlignedCallback allocCb, void* allocCbUserData)
 	sceneInit.m_allocCallback = m_mainPool.getAllocationCallback();
 	sceneInit.m_allocCallbackData = m_mainPool.getAllocationCallbackUserData();
 	sceneInit.m_globalTimestamp = &m_globalTimestamp;
-	sceneInit.m_resourceManager = m_resources;
 	sceneInit.m_scriptManager = m_script;
 	sceneInit.m_uiManager = m_ui;
 	sceneInit.m_grManager = m_gr;
@@ -490,7 +474,7 @@ Error App::mainLoop()
 			ANKI_CHECK(m_renderer->render(rqueue, presentableTex));
 
 			// Pause and sync async loader. That will force all tasks before the pause to finish in this frame.
-			m_resources->getAsyncLoader().pause();
+			ResourceManager::getSingleton().getAsyncLoader().pause();
 
 			// If we get stats exclude the time of GR because it forces some GPU-CPU serialization. We don't want to
 			// count that
@@ -512,12 +496,12 @@ Error App::mainLoop()
 			GpuSceneMemoryPool::getSingleton().endFrame();
 
 			// Update the trace info with some async loader stats
-			U64 asyncTaskCount = m_resources->getAsyncLoader().getCompletedTaskCount();
+			U64 asyncTaskCount = ResourceManager::getSingleton().getAsyncLoader().getCompletedTaskCount();
 			ANKI_TRACE_INC_COUNTER(RsrcAsyncTasks, asyncTaskCount - m_resourceCompletedAsyncTaskCount);
 			m_resourceCompletedAsyncTaskCount = asyncTaskCount;
 
 			// Now resume the loader
-			m_resources->getAsyncLoader().resume();
+			ResourceManager::getSingleton().getAsyncLoader().resume();
 
 			// Sleep
 			const Second endTime = HighRezTimer::getCurrentTime();

+ 1 - 10
AnKi/Core/App.h

@@ -17,8 +17,6 @@ class GrManager;
 class MainRenderer;
 class SceneGraph;
 class ScriptManager;
-class ResourceManager;
-class ResourceFilesystem;
 class UiManager;
 class UiQueueElement;
 class RenderQueue;
@@ -73,11 +71,6 @@ public:
 		return *m_renderer;
 	}
 
-	ResourceManager& getResourceManager()
-	{
-		return *m_resources;
-	}
-
 	ScriptManager& getScriptManager()
 	{
 		return *m_script;
@@ -94,12 +87,10 @@ public:
 	}
 
 private:
-	HeapMemoryPool m_mainPool;
+	HeapMemoryPool m_mainPool; // TODO glob: rm
 
 	// Sybsystems
 	GrManager* m_gr = nullptr;
-	ResourceFilesystem* m_resourceFs = nullptr;
-	ResourceManager* m_resources = nullptr;
 	UiManager* m_ui = nullptr;
 	MainRenderer* m_renderer = nullptr;
 	SceneGraph* m_scene = nullptr;

+ 3 - 2
AnKi/Core/GpuMemoryPools.cpp

@@ -139,9 +139,10 @@ GpuSceneMicroPatcher::~GpuSceneMicroPatcher()
 	static_assert(sizeof(PatchHeader) == 8);
 }
 
-Error GpuSceneMicroPatcher::init(ResourceManager* rsrc)
+Error GpuSceneMicroPatcher::init()
 {
-	ANKI_CHECK(rsrc->loadResource("ShaderBinaries/GpuSceneMicroPatching.ankiprogbin", m_copyProgram));
+	ANKI_CHECK(ResourceManager::getSingleton().loadResource("ShaderBinaries/GpuSceneMicroPatching.ankiprogbin",
+															m_copyProgram));
 	const ShaderProgramResourceVariant* variant;
 	m_copyProgram->getOrCreateVariant(variant);
 	m_grProgram = variant->getProgram();

+ 1 - 1
AnKi/Core/GpuMemoryPools.h

@@ -197,7 +197,7 @@ public:
 
 	GpuSceneMicroPatcher& operator=(const GpuSceneMicroPatcher&) = delete;
 
-	Error init(ResourceManager* rsrc);
+	Error init();
 
 	/// Copy data for the GPU scene to a staging buffer.
 	/// @note It's thread-safe.

+ 10 - 10
AnKi/Renderer/Bloom.cpp

@@ -44,10 +44,10 @@ Error Bloom::initExposure()
 	m_exposure.m_rtDescr.bake();
 
 	// init shaders
-	ANKI_CHECK(getExternalSubsystems().m_resourceManager->loadResource((ConfigSet::getSingleton().getRPreferCompute())
-																		   ? "ShaderBinaries/BloomCompute.ankiprogbin"
-																		   : "ShaderBinaries/BloomRaster.ankiprogbin",
-																	   m_exposure.m_prog));
+	ANKI_CHECK(ResourceManager::getSingleton().loadResource((ConfigSet::getSingleton().getRPreferCompute())
+																? "ShaderBinaries/BloomCompute.ankiprogbin"
+																: "ShaderBinaries/BloomRaster.ankiprogbin",
+															m_exposure.m_prog));
 
 	ShaderProgramResourceVariantInitInfo variantInitInfo(m_exposure.m_prog);
 	if(ConfigSet::getSingleton().getRPreferCompute())
@@ -73,10 +73,10 @@ Error Bloom::initUpscale()
 	m_upscale.m_rtDescr.bake();
 
 	// init shaders
-	ANKI_CHECK(getExternalSubsystems().m_resourceManager->loadResource(
-		(ConfigSet::getSingleton().getRPreferCompute()) ? "ShaderBinaries/BloomUpscaleCompute.ankiprogbin"
-														: "ShaderBinaries/BloomUpscaleRaster.ankiprogbin",
-		m_upscale.m_prog));
+	ANKI_CHECK(ResourceManager::getSingleton().loadResource((ConfigSet::getSingleton().getRPreferCompute())
+																? "ShaderBinaries/BloomUpscaleCompute.ankiprogbin"
+																: "ShaderBinaries/BloomUpscaleRaster.ankiprogbin",
+															m_upscale.m_prog));
 
 	ShaderProgramResourceVariantInitInfo variantInitInfo(m_upscale.m_prog);
 	variantInitInfo.addConstant("kInputTextureSize", UVec2(m_exposure.m_width, m_exposure.m_height));
@@ -90,8 +90,8 @@ Error Bloom::initUpscale()
 	m_upscale.m_grProg = variant->getProgram();
 
 	// Textures
-	ANKI_CHECK(getExternalSubsystems().m_resourceManager->loadResource("EngineAssets/LensDirt.ankitex",
-																	   m_upscale.m_lensDirtImage));
+	ANKI_CHECK(
+		ResourceManager::getSingleton().loadResource("EngineAssets/LensDirt.ankitex", m_upscale.m_lensDirtImage));
 
 	return Error::kNone;
 }

+ 1 - 2
AnKi/Renderer/ClusterBinning.cpp

@@ -31,8 +31,7 @@ Error ClusterBinning::init()
 {
 	ANKI_R_LOGV("Initializing clusterer binning");
 
-	ANKI_CHECK(
-		getExternalSubsystems().m_resourceManager->loadResource("ShaderBinaries/ClusterBinning.ankiprogbin", m_prog));
+	ANKI_CHECK(ResourceManager::getSingleton().loadResource("ShaderBinaries/ClusterBinning.ankiprogbin", m_prog));
 
 	ShaderProgramResourceVariantInitInfo variantInitInfo(m_prog);
 	variantInitInfo.addConstant("kTileSize", m_r->getTileSize());

+ 0 - 1
AnKi/Renderer/Common.h

@@ -75,7 +75,6 @@ inline constexpr Array<Format, kGBufferColorRenderTargetCount> kGBufferColorRend
 class RendererExternalSubsystems
 {
 public:
-	ResourceManager* m_resourceManager = nullptr;
 	GrManager* m_grManager = nullptr;
 	UiManager* m_uiManager = nullptr;
 	Timestamp* m_globTimestamp = nullptr;

+ 1 - 1
AnKi/Renderer/Dbg.cpp

@@ -44,7 +44,7 @@ Error Dbg::init()
 	m_fbDescr.m_depthStencilAttachment.m_aspect = DepthStencilAspectBit::kDepth;
 	m_fbDescr.bake();
 
-	ResourceManager& rsrcManager = *getExternalSubsystems().m_resourceManager;
+	ResourceManager& rsrcManager = ResourceManager::getSingleton();
 	ANKI_CHECK(m_drawer.init(&rsrcManager, getExternalSubsystems().m_grManager));
 	ANKI_CHECK(rsrcManager.loadResource("EngineAssets/GiProbe.ankitex", m_giProbeImage));
 	ANKI_CHECK(rsrcManager.loadResource("EngineAssets/LightBulb.ankitex", m_pointLightImage));

+ 4 - 4
AnKi/Renderer/DepthDownscale.cpp

@@ -74,8 +74,8 @@ Error DepthDownscale::initInternal()
 	// Progs
 	if(preferCompute)
 	{
-		ANKI_CHECK(getExternalSubsystems().m_resourceManager->loadResource(
-			"ShaderBinaries/DepthDownscaleCompute.ankiprogbin", m_prog));
+		ANKI_CHECK(
+			ResourceManager::getSingleton().loadResource("ShaderBinaries/DepthDownscaleCompute.ankiprogbin", m_prog));
 
 		ShaderProgramResourceVariantInitInfo variantInitInfo(m_prog);
 		variantInitInfo.addMutation("WAVE_OPERATIONS", 0);
@@ -86,8 +86,8 @@ Error DepthDownscale::initInternal()
 	}
 	else
 	{
-		ANKI_CHECK(getExternalSubsystems().m_resourceManager->loadResource(
-			"ShaderBinaries/DepthDownscaleRaster.ankiprogbin", m_prog));
+		ANKI_CHECK(
+			ResourceManager::getSingleton().loadResource("ShaderBinaries/DepthDownscaleRaster.ankiprogbin", m_prog));
 
 		ShaderProgramResourceVariantInitInfo variantInitInfo(m_prog);
 		variantInitInfo.addMutation("REDUCTION_SAMPLER", supportsReductionSampler);

+ 4 - 4
AnKi/Renderer/DownscaleBlur.cpp

@@ -66,10 +66,10 @@ Error DownscaleBlur::initInternal()
 	}
 
 	// Shader programs
-	ANKI_CHECK(getExternalSubsystems().m_resourceManager->loadResource(
-		(preferCompute) ? "ShaderBinaries/DownscaleBlurCompute.ankiprogbin"
-						: "ShaderBinaries/DownscaleBlurRaster.ankiprogbin",
-		m_prog));
+	ANKI_CHECK(ResourceManager::getSingleton().loadResource((preferCompute)
+																? "ShaderBinaries/DownscaleBlurCompute.ankiprogbin"
+																: "ShaderBinaries/DownscaleBlurRaster.ankiprogbin",
+															m_prog));
 	const ShaderProgramResourceVariant* variant = nullptr;
 	m_prog->getOrCreateVariant(variant);
 	m_grProg = variant->getProgram();

+ 4 - 5
AnKi/Renderer/FinalComposite.cpp

@@ -38,8 +38,7 @@ Error FinalComposite::initInternal()
 	m_fbDescr.bake();
 
 	// Progs
-	ANKI_CHECK(
-		getExternalSubsystems().m_resourceManager->loadResource("ShaderBinaries/FinalComposite.ankiprogbin", m_prog));
+	ANKI_CHECK(ResourceManager::getSingleton().loadResource("ShaderBinaries/FinalComposite.ankiprogbin", m_prog));
 
 	ShaderProgramResourceVariantInitInfo variantInitInfo(m_prog);
 	variantInitInfo.addMutation("FILM_GRAIN", (ConfigSet::getSingleton().getRFilmGrainStrength() > 0.0) ? 1 : 0);
@@ -56,8 +55,8 @@ Error FinalComposite::initInternal()
 		m_grProgs[dbg] = variant->getProgram();
 	}
 
-	ANKI_CHECK(getExternalSubsystems().m_resourceManager->loadResource(
-		"ShaderBinaries/VisualizeRenderTarget.ankiprogbin", m_defaultVisualizeRenderTargetProg));
+	ANKI_CHECK(ResourceManager::getSingleton().loadResource("ShaderBinaries/VisualizeRenderTarget.ankiprogbin",
+															m_defaultVisualizeRenderTargetProg));
 	const ShaderProgramResourceVariant* variant;
 	m_defaultVisualizeRenderTargetProg->getOrCreateVariant(variant);
 	m_defaultVisualizeRenderTargetGrProg = variant->getProgram();
@@ -79,7 +78,7 @@ Error FinalComposite::init()
 Error FinalComposite::loadColorGradingTextureImage(CString filename)
 {
 	m_lut.reset(nullptr);
-	ANKI_CHECK(getExternalSubsystems().m_resourceManager->loadResource(filename, m_lut));
+	ANKI_CHECK(ResourceManager::getSingleton().loadResource(filename, m_lut));
 	ANKI_ASSERT(m_lut->getWidth() == kLutSize);
 	ANKI_ASSERT(m_lut->getHeight() == kLutSize);
 	ANKI_ASSERT(m_lut->getDepth() == kLutSize);

+ 1 - 2
AnKi/Renderer/GBufferPost.cpp

@@ -31,8 +31,7 @@ Error GBufferPost::initInternal()
 	ANKI_R_LOGV("Initializing GBufferPost pass");
 
 	// Load shaders
-	ANKI_CHECK(
-		getExternalSubsystems().m_resourceManager->loadResource("ShaderBinaries/GBufferPost.ankiprogbin", m_prog));
+	ANKI_CHECK(ResourceManager::getSingleton().loadResource("ShaderBinaries/GBufferPost.ankiprogbin", m_prog));
 
 	ShaderProgramResourceVariantInitInfo variantInitInfo(m_prog);
 	variantInitInfo.addConstant("kTileCount", m_r->getTileCounts());

+ 4 - 4
AnKi/Renderer/IndirectDiffuse.cpp

@@ -69,7 +69,7 @@ Error IndirectDiffuse::initInternal()
 			m_r->create2DRenderTargetDescription(rez.x(), rez.y(), Format::kR8_Uint, "IndirectDiffuseVrsSri");
 		m_vrs.m_rtHandle.bake();
 
-		ANKI_CHECK(getExternalSubsystems().m_resourceManager->loadResource(
+		ANKI_CHECK(ResourceManager::getSingleton().loadResource(
 			"ShaderBinaries/IndirectDiffuseVrsSriGeneration.ankiprogbin", m_vrs.m_prog));
 
 		ShaderProgramResourceVariantInitInfo variantInit(m_vrs.m_prog);
@@ -100,7 +100,7 @@ Error IndirectDiffuse::initInternal()
 		m_vrs.m_prog->getOrCreateVariant(variantInit, variant);
 		m_vrs.m_grProg = variant->getProgram();
 
-		ANKI_CHECK(getExternalSubsystems().m_resourceManager->loadResource(
+		ANKI_CHECK(ResourceManager::getSingleton().loadResource(
 			"ShaderBinaries/VrsSriVisualizeRenderTarget.ankiprogbin", m_vrs.m_visualizeProg));
 		m_vrs.m_visualizeProg->getOrCreateVariant(variant);
 		m_vrs.m_visualizeGrProg = variant->getProgram();
@@ -108,7 +108,7 @@ Error IndirectDiffuse::initInternal()
 
 	// Init SSGI+probes pass
 	{
-		ANKI_CHECK(getExternalSubsystems().m_resourceManager->loadResource(
+		ANKI_CHECK(ResourceManager::getSingleton().loadResource(
 			(preferCompute) ? "ShaderBinaries/IndirectDiffuseCompute.ankiprogbin"
 							: "ShaderBinaries/IndirectDiffuseRaster.ankiprogbin",
 			m_main.m_prog));
@@ -123,7 +123,7 @@ Error IndirectDiffuse::initInternal()
 		m_denoise.m_fbDescr.m_colorAttachmentCount = 1;
 		m_denoise.m_fbDescr.bake();
 
-		ANKI_CHECK(getExternalSubsystems().m_resourceManager->loadResource(
+		ANKI_CHECK(ResourceManager::getSingleton().loadResource(
 			(preferCompute) ? "ShaderBinaries/IndirectDiffuseDenoiseCompute.ankiprogbin"
 							: "ShaderBinaries/IndirectDiffuseDenoiseRaster.ankiprogbin",
 			m_denoise.m_prog));

+ 2 - 2
AnKi/Renderer/IndirectDiffuseProbes.cpp

@@ -161,8 +161,8 @@ Error IndirectDiffuseProbes::initLightShading()
 
 Error IndirectDiffuseProbes::initIrradiance()
 {
-	ANKI_CHECK(getExternalSubsystems().m_resourceManager->loadResource("ShaderBinaries/IrradianceDice.ankiprogbin",
-																	   m_irradiance.m_prog));
+	ANKI_CHECK(
+		ResourceManager::getSingleton().loadResource("ShaderBinaries/IrradianceDice.ankiprogbin", m_irradiance.m_prog));
 
 	ShaderProgramResourceVariantInitInfo variantInitInfo(m_irradiance.m_prog);
 	variantInitInfo.addMutation("WORKGROUP_SIZE_XY", m_tileSize);

+ 5 - 6
AnKi/Renderer/IndirectSpecular.cpp

@@ -39,8 +39,7 @@ Error IndirectSpecular::initInternal()
 
 	ANKI_R_LOGV("Initializing indirect specular. Resolution %ux%u", size.x(), size.y());
 
-	ANKI_CHECK(getExternalSubsystems().m_resourceManager->loadResource("EngineAssets/BlueNoise_Rgba8_64x64.png",
-																	   m_noiseImage));
+	ANKI_CHECK(ResourceManager::getSingleton().loadResource("EngineAssets/BlueNoise_Rgba8_64x64.png", m_noiseImage));
 
 	// Create RT
 	TextureUsageBit usage = TextureUsageBit::kAllSampled;
@@ -57,10 +56,10 @@ Error IndirectSpecular::initInternal()
 	m_fbDescr.bake();
 
 	// Create shader
-	ANKI_CHECK(getExternalSubsystems().m_resourceManager->loadResource(
-		(ConfigSet::getSingleton().getRPreferCompute()) ? "ShaderBinaries/IndirectSpecularCompute.ankiprogbin"
-														: "ShaderBinaries/IndirectSpecularRaster.ankiprogbin",
-		m_prog));
+	ANKI_CHECK(ResourceManager::getSingleton().loadResource((ConfigSet::getSingleton().getRPreferCompute())
+																? "ShaderBinaries/IndirectSpecularCompute.ankiprogbin"
+																: "ShaderBinaries/IndirectSpecularRaster.ankiprogbin",
+															m_prog));
 
 	ShaderProgramResourceVariantInitInfo variantInit(m_prog);
 	variantInit.addMutation("EXTRA_REJECTION", false);

+ 3 - 4
AnKi/Renderer/LensFlare.cpp

@@ -51,8 +51,7 @@ Error LensFlare::initSprite()
 	m_maxSprites = U16(m_maxSpritesPerFlare * m_maxFlares);
 
 	// Load prog
-	ANKI_CHECK(getExternalSubsystems().m_resourceManager->loadResource("ShaderBinaries/LensFlareSprite.ankiprogbin",
-																	   m_realProg));
+	ANKI_CHECK(ResourceManager::getSingleton().loadResource("ShaderBinaries/LensFlareSprite.ankiprogbin", m_realProg));
 	const ShaderProgramResourceVariant* variant;
 	m_realProg->getOrCreateVariant(variant);
 	m_realGrProg = variant->getProgram();
@@ -68,8 +67,8 @@ Error LensFlare::initOcclusion()
 												 BufferUsageBit::kIndirectDraw | BufferUsageBit::kStorageComputeWrite,
 												 BufferMapAccessBit::kNone, "LensFlares"));
 
-	ANKI_CHECK(getExternalSubsystems().m_resourceManager->loadResource(
-		"ShaderBinaries/LensFlareUpdateIndirectInfo.ankiprogbin", m_updateIndirectBuffProg));
+	ANKI_CHECK(ResourceManager::getSingleton().loadResource("ShaderBinaries/LensFlareUpdateIndirectInfo.ankiprogbin",
+															m_updateIndirectBuffProg));
 
 	ShaderProgramResourceVariantInitInfo variantInitInfo(m_updateIndirectBuffProg);
 	variantInitInfo.addConstant(

+ 10 - 10
AnKi/Renderer/LightShading.cpp

@@ -65,8 +65,8 @@ Error LightShading::init()
 Error LightShading::initLightShading()
 {
 	// Load shaders and programs
-	ANKI_CHECK(getExternalSubsystems().m_resourceManager->loadResource("ShaderBinaries/LightShading.ankiprogbin",
-																	   m_lightShading.m_prog));
+	ANKI_CHECK(
+		ResourceManager::getSingleton().loadResource("ShaderBinaries/LightShading.ankiprogbin", m_lightShading.m_prog));
 
 	ShaderProgramResourceVariantInitInfo variantInitInfo(m_lightShading.m_prog);
 	variantInitInfo.addConstant("kTileCount", m_r->getTileCounts());
@@ -102,8 +102,8 @@ Error LightShading::initLightShading()
 	m_lightShading.m_fbDescr.bake();
 
 	// Debug visualization
-	ANKI_CHECK(getExternalSubsystems().m_resourceManager->loadResource(
-		"ShaderBinaries/VisualizeHdrRenderTarget.ankiprogbin", m_visualizeRtProg));
+	ANKI_CHECK(ResourceManager::getSingleton().loadResource("ShaderBinaries/VisualizeHdrRenderTarget.ankiprogbin",
+															m_visualizeRtProg));
 	m_visualizeRtProg->getOrCreateVariant(variant);
 	m_visualizeRtGrProg = variant->getProgram();
 
@@ -112,8 +112,8 @@ Error LightShading::initLightShading()
 
 Error LightShading::initSkybox()
 {
-	ANKI_CHECK(getExternalSubsystems().m_resourceManager->loadResource("ShaderBinaries/LightShadingSkybox.ankiprogbin",
-																	   m_skybox.m_prog));
+	ANKI_CHECK(
+		ResourceManager::getSingleton().loadResource("ShaderBinaries/LightShadingSkybox.ankiprogbin", m_skybox.m_prog));
 
 	for(U32 method = 0; method < 2; ++method)
 	{
@@ -131,8 +131,8 @@ Error LightShading::initSkybox()
 Error LightShading::initApplyFog()
 {
 	// Load shaders and programs
-	ANKI_CHECK(getExternalSubsystems().m_resourceManager->loadResource(
-		"ShaderBinaries/LightShadingApplyFog.ankiprogbin", m_applyFog.m_prog));
+	ANKI_CHECK(ResourceManager::getSingleton().loadResource("ShaderBinaries/LightShadingApplyFog.ankiprogbin",
+															m_applyFog.m_prog));
 
 	ShaderProgramResourceVariantInitInfo variantInitInfo(m_applyFog.m_prog);
 	variantInitInfo.addConstant("kZSplitCount", m_r->getZSplitCount());
@@ -147,8 +147,8 @@ Error LightShading::initApplyFog()
 
 Error LightShading::initApplyIndirect()
 {
-	ANKI_CHECK(getExternalSubsystems().m_resourceManager->loadResource(
-		"ShaderBinaries/LightShadingApplyIndirect.ankiprogbin", m_applyIndirect.m_prog));
+	ANKI_CHECK(ResourceManager::getSingleton().loadResource("ShaderBinaries/LightShadingApplyIndirect.ankiprogbin",
+															m_applyIndirect.m_prog));
 	const ShaderProgramResourceVariant* variant;
 	m_applyIndirect.m_prog->getOrCreateVariant(variant);
 	m_applyIndirect.m_grProg = variant->getProgram();

+ 1 - 1
AnKi/Renderer/MainRenderer.cpp

@@ -46,7 +46,7 @@ Error MainRenderer::init(const MainRendererInitInfo& inf)
 	// Init other
 	if(!m_rDrawToDefaultFb)
 	{
-		ANKI_CHECK(inf.m_resourceManager->loadResource("ShaderBinaries/BlitRaster.ankiprogbin", m_blitProg));
+		ANKI_CHECK(ResourceManager::getSingleton().loadResource("ShaderBinaries/BlitRaster.ankiprogbin", m_blitProg));
 		const ShaderProgramResourceVariant* variant;
 		m_blitProg->getOrCreateVariant(variant);
 		m_blitGrProg = variant->getProgram();

+ 4 - 4
AnKi/Renderer/MotionVectors.cpp

@@ -30,10 +30,10 @@ Error MotionVectors::initInternal()
 	ANKI_R_LOGV("Initializing motion vectors");
 
 	// Prog
-	ANKI_CHECK(getExternalSubsystems().m_resourceManager->loadResource(
-		(ConfigSet::getSingleton().getRPreferCompute()) ? "ShaderBinaries/MotionVectorsCompute.ankiprogbin"
-														: "ShaderBinaries/MotionVectorsRaster.ankiprogbin",
-		m_prog));
+	ANKI_CHECK(ResourceManager::getSingleton().loadResource((ConfigSet::getSingleton().getRPreferCompute())
+																? "ShaderBinaries/MotionVectorsCompute.ankiprogbin"
+																: "ShaderBinaries/MotionVectorsRaster.ankiprogbin",
+															m_prog));
 	ShaderProgramResourceVariantInitInfo variantInitInfo(m_prog);
 	variantInitInfo.addConstant("kFramebufferSize",
 								UVec2(m_r->getInternalResolution().x(), m_r->getInternalResolution().y()));

+ 2 - 2
AnKi/Renderer/PackVisibleClusteredObjects.cpp

@@ -23,8 +23,8 @@ PackVisibleClusteredObjects::~PackVisibleClusteredObjects()
 
 Error PackVisibleClusteredObjects::init()
 {
-	ANKI_CHECK(m_r->getExternalSubsystems().m_resourceManager->loadResource(
-		"ShaderBinaries/PackVisibleClusteredObjects.ankiprogbin", m_packProg));
+	ANKI_CHECK(ResourceManager::getSingleton().loadResource("ShaderBinaries/PackVisibleClusteredObjects.ankiprogbin",
+															m_packProg));
 
 	U32 maxWaveSize = m_r->getExternalSubsystems().m_grManager->getDeviceCapabilities().m_maxSubgroupSize;
 	if(maxWaveSize == 16 || maxWaveSize == 32)

+ 5 - 5
AnKi/Renderer/ProbeReflections.cpp

@@ -47,7 +47,7 @@ Error ProbeReflections::initInternal()
 	ANKI_CHECK(initShadowMapping());
 
 	// Load split sum integration LUT
-	ANKI_CHECK(getExternalSubsystems().m_resourceManager->loadResource("EngineAssets/IblDfg.png", m_integrationLut));
+	ANKI_CHECK(ResourceManager::getSingleton().loadResource("EngineAssets/IblDfg.png", m_integrationLut));
 
 	SamplerInitInfo sinit;
 	sinit.m_minMagFilter = SamplingFilter::kLinear;
@@ -133,8 +133,8 @@ Error ProbeReflections::initIrradiance()
 
 	// Create prog
 	{
-		ANKI_CHECK(getExternalSubsystems().m_resourceManager->loadResource("ShaderBinaries/IrradianceDice.ankiprogbin",
-																		   m_irradiance.m_prog));
+		ANKI_CHECK(ResourceManager::getSingleton().loadResource("ShaderBinaries/IrradianceDice.ankiprogbin",
+																m_irradiance.m_prog));
 
 		ShaderProgramResourceVariantInitInfo variantInitInfo(m_irradiance.m_prog);
 
@@ -162,8 +162,8 @@ Error ProbeReflections::initIrradiance()
 Error ProbeReflections::initIrradianceToRefl()
 {
 	// Create program
-	ANKI_CHECK(getExternalSubsystems().m_resourceManager->loadResource(
-		"ShaderBinaries/ApplyIrradianceToReflection.ankiprogbin", m_irradianceToRefl.m_prog));
+	ANKI_CHECK(ResourceManager::getSingleton().loadResource("ShaderBinaries/ApplyIrradianceToReflection.ankiprogbin",
+															m_irradianceToRefl.m_prog));
 
 	const ShaderProgramResourceVariant* variant;
 	m_irradianceToRefl.m_prog->getOrCreateVariant(ShaderProgramResourceVariantInitInfo(m_irradianceToRefl.m_prog),

+ 6 - 6
AnKi/Renderer/Renderer.cpp

@@ -139,7 +139,7 @@ Error Renderer::initInternal(UVec2 swapchainResolution)
 		return Error::kUserData;
 	}
 
-	ANKI_CHECK(m_subsystems.m_resourceManager->loadResource("ShaderBinaries/ClearTextureCompute.ankiprogbin",
+	ANKI_CHECK(ResourceManager::getSingleton().loadResource("ShaderBinaries/ClearTextureCompute.ankiprogbin",
 															m_clearTexComputeProg));
 
 	// Dummy resources
@@ -333,11 +333,11 @@ Error Renderer::populateRenderGraph(RenderingContext& ctx)
 	ctx.m_matrices.m_unprojectionParameters = ctx.m_matrices.m_projection.extractPerspectiveUnprojectionParams();
 
 	// Check if resources got loaded
-	if(m_prevLoadRequestCount != m_subsystems.m_resourceManager->getLoadingRequestCount()
-	   || m_prevAsyncTasksCompleted != m_subsystems.m_resourceManager->getAsyncTaskCompletedCount())
+	if(m_prevLoadRequestCount != ResourceManager::getSingleton().getLoadingRequestCount()
+	   || m_prevAsyncTasksCompleted != ResourceManager::getSingleton().getAsyncTaskCompletedCount())
 	{
-		m_prevLoadRequestCount = m_subsystems.m_resourceManager->getLoadingRequestCount();
-		m_prevAsyncTasksCompleted = m_subsystems.m_resourceManager->getAsyncTaskCompletedCount();
+		m_prevLoadRequestCount = ResourceManager::getSingleton().getLoadingRequestCount();
+		m_prevAsyncTasksCompleted = ResourceManager::getSingleton().getAsyncTaskCompletedCount();
 		m_resourcesDirty = true;
 	}
 	else
@@ -703,7 +703,7 @@ void Renderer::gpuSceneCopy(RenderingContext& ctx)
 		ComputeRenderPassDescription& rpass = rgraph.newComputeRenderPass("GPU scene patching");
 		rpass.newBufferDependency(m_runCtx.m_gpuSceneHandle, BufferUsageBit::kStorageComputeWrite);
 
-		rpass.setWork([this](RenderPassWorkContext& rgraphCtx) {
+		rpass.setWork([](RenderPassWorkContext& rgraphCtx) {
 			GpuSceneMicroPatcher::getSingleton().patchGpuScene(*rgraphCtx.m_commandBuffer.get());
 		});
 	}

+ 16 - 16
AnKi/Renderer/RtShadows.cpp

@@ -42,13 +42,13 @@ Error RtShadows::initInternal()
 	m_useSvgf = ConfigSet::getSingleton().getRRtShadowsSvgf();
 	m_atrousPassCount = ConfigSet::getSingleton().getRRtShadowsSvgfAtrousPassCount();
 
-	ANKI_CHECK(getExternalSubsystems().m_resourceManager->loadResource("EngineAssets/BlueNoise_Rgba8_64x64.png",
-																	   m_blueNoiseImage));
+	ANKI_CHECK(
+		ResourceManager::getSingleton().loadResource("EngineAssets/BlueNoise_Rgba8_64x64.png", m_blueNoiseImage));
 
 	// Ray gen program
 	{
-		ANKI_CHECK(getExternalSubsystems().m_resourceManager->loadResource("ShaderBinaries/RtShadowsRayGen.ankiprogbin",
-																		   m_rayGenProg));
+		ANKI_CHECK(
+			ResourceManager::getSingleton().loadResource("ShaderBinaries/RtShadowsRayGen.ankiprogbin", m_rayGenProg));
 
 		ShaderProgramResourceVariantInitInfo variantInitInfo(m_rayGenProg);
 		variantInitInfo.addMutation("RAYS_PER_PIXEL", ConfigSet::getSingleton().getRRtShadowsRaysPerPixel());
@@ -61,8 +61,8 @@ Error RtShadows::initInternal()
 
 	// Miss prog
 	{
-		ANKI_CHECK(getExternalSubsystems().m_resourceManager->loadResource("ShaderBinaries/RtShadowsMiss.ankiprogbin",
-																		   m_missProg));
+		ANKI_CHECK(
+			ResourceManager::getSingleton().loadResource("ShaderBinaries/RtShadowsMiss.ankiprogbin", m_missProg));
 		const ShaderProgramResourceVariant* variant;
 		m_missProg->getOrCreateVariant(variant);
 		m_missShaderGroupIdx = variant->getShaderGroupHandleIndex();
@@ -71,8 +71,8 @@ Error RtShadows::initInternal()
 	// Denoise program
 	if(!m_useSvgf)
 	{
-		ANKI_CHECK(getExternalSubsystems().m_resourceManager->loadResource(
-			"ShaderBinaries/RtShadowsDenoise.ankiprogbin", m_denoiseProg));
+		ANKI_CHECK(
+			ResourceManager::getSingleton().loadResource("ShaderBinaries/RtShadowsDenoise.ankiprogbin", m_denoiseProg));
 		ShaderProgramResourceVariantInitInfo variantInitInfo(m_denoiseProg);
 		variantInitInfo.addConstant("kOutImageSize",
 									UVec2(m_r->getInternalResolution().x() / 2, m_r->getInternalResolution().y() / 2));
@@ -92,8 +92,8 @@ Error RtShadows::initInternal()
 	// SVGF variance program
 	if(m_useSvgf)
 	{
-		ANKI_CHECK(getExternalSubsystems().m_resourceManager->loadResource(
-			"ShaderBinaries/RtShadowsSvgfVariance.ankiprogbin", m_svgfVarianceProg));
+		ANKI_CHECK(ResourceManager::getSingleton().loadResource("ShaderBinaries/RtShadowsSvgfVariance.ankiprogbin",
+																m_svgfVarianceProg));
 		ShaderProgramResourceVariantInitInfo variantInitInfo(m_svgfVarianceProg);
 		variantInitInfo.addConstant("kFramebufferSize",
 									UVec2(m_r->getInternalResolution().x() / 2, m_r->getInternalResolution().y() / 2));
@@ -106,8 +106,8 @@ Error RtShadows::initInternal()
 	// SVGF atrous program
 	if(m_useSvgf)
 	{
-		ANKI_CHECK(getExternalSubsystems().m_resourceManager->loadResource(
-			"ShaderBinaries/RtShadowsSvgfAtrous.ankiprogbin", m_svgfAtrousProg));
+		ANKI_CHECK(ResourceManager::getSingleton().loadResource("ShaderBinaries/RtShadowsSvgfAtrous.ankiprogbin",
+																m_svgfAtrousProg));
 		ShaderProgramResourceVariantInitInfo variantInitInfo(m_svgfAtrousProg);
 		variantInitInfo.addConstant("kFramebufferSize",
 									UVec2(m_r->getInternalResolution().x() / 2, m_r->getInternalResolution().y() / 2));
@@ -124,8 +124,8 @@ Error RtShadows::initInternal()
 
 	// Upscale program
 	{
-		ANKI_CHECK(getExternalSubsystems().m_resourceManager->loadResource(
-			"ShaderBinaries/RtShadowsUpscale.ankiprogbin", m_upscaleProg));
+		ANKI_CHECK(
+			ResourceManager::getSingleton().loadResource("ShaderBinaries/RtShadowsUpscale.ankiprogbin", m_upscaleProg));
 		ShaderProgramResourceVariantInitInfo variantInitInfo(m_upscaleProg);
 		variantInitInfo.addConstant("kOutImageSize",
 									UVec2(m_r->getInternalResolution().x(), m_r->getInternalResolution().y()));
@@ -136,8 +136,8 @@ Error RtShadows::initInternal()
 	}
 
 	// Debug program
-	ANKI_CHECK(getExternalSubsystems().m_resourceManager->loadResource(
-		"ShaderBinaries/RtShadowsVisualizeRenderTarget.ankiprogbin", m_visualizeRenderTargetsProg));
+	ANKI_CHECK(ResourceManager::getSingleton().loadResource("ShaderBinaries/RtShadowsVisualizeRenderTarget.ankiprogbin",
+															m_visualizeRenderTargetsProg));
 
 	// Quarter rez shadow RT
 	{

+ 4 - 4
AnKi/Renderer/Scale.cpp

@@ -85,7 +85,7 @@ Error Scale::init()
 		const CString shaderFname =
 			(preferCompute) ? "ShaderBinaries/BlitCompute.ankiprogbin" : "ShaderBinaries/BlitRaster.ankiprogbin";
 
-		ANKI_CHECK(getExternalSubsystems().m_resourceManager->loadResource(shaderFname, m_scaleProg));
+		ANKI_CHECK(ResourceManager::getSingleton().loadResource(shaderFname, m_scaleProg));
 
 		const ShaderProgramResourceVariant* variant;
 		m_scaleProg->getOrCreateVariant(variant);
@@ -96,7 +96,7 @@ Error Scale::init()
 		const CString shaderFname =
 			(preferCompute) ? "ShaderBinaries/FsrCompute.ankiprogbin" : "ShaderBinaries/FsrRaster.ankiprogbin";
 
-		ANKI_CHECK(getExternalSubsystems().m_resourceManager->loadResource(shaderFname, m_scaleProg));
+		ANKI_CHECK(ResourceManager::getSingleton().loadResource(shaderFname, m_scaleProg));
 
 		ShaderProgramResourceVariantInitInfo variantInitInfo(m_scaleProg);
 		variantInitInfo.addMutation("SHARPEN", 0);
@@ -119,7 +119,7 @@ Error Scale::init()
 	// Sharpen programs
 	if(m_sharpenMethod == SharpenMethod::kRcas)
 	{
-		ANKI_CHECK(getExternalSubsystems().m_resourceManager->loadResource(
+		ANKI_CHECK(ResourceManager::getSingleton().loadResource(
 			(preferCompute) ? "ShaderBinaries/FsrCompute.ankiprogbin" : "ShaderBinaries/FsrRaster.ankiprogbin",
 			m_sharpenProg));
 		ShaderProgramResourceVariantInitInfo variantInitInfo(m_sharpenProg);
@@ -133,7 +133,7 @@ Error Scale::init()
 	// Tonemapping programs
 	if(m_neeedsTonemapping)
 	{
-		ANKI_CHECK(getExternalSubsystems().m_resourceManager->loadResource(
+		ANKI_CHECK(ResourceManager::getSingleton().loadResource(
 			(preferCompute) ? "ShaderBinaries/TonemapCompute.ankiprogbin" : "ShaderBinaries/TonemapRaster.ankiprogbin",
 			m_tonemapProg));
 		const ShaderProgramResourceVariant* variant;

+ 2 - 2
AnKi/Renderer/ShadowMapping.cpp

@@ -75,8 +75,8 @@ Error ShadowMapping::initInternal()
 	m_fbDescr.m_depthStencilAttachment.m_loadOperation = AttachmentLoadOperation::kLoad;
 	m_fbDescr.bake();
 
-	ANKI_CHECK(getExternalSubsystems().m_resourceManager->loadResource(
-		"ShaderBinaries/ShadowmappingClearDepth.ankiprogbin", m_clearDepthProg));
+	ANKI_CHECK(ResourceManager::getSingleton().loadResource("ShaderBinaries/ShadowmappingClearDepth.ankiprogbin",
+															m_clearDepthProg));
 	const ShaderProgramResourceVariant* variant;
 	m_clearDepthProg->getOrCreateVariant(variant);
 	m_clearDepthGrProg = variant->getProgram();

+ 5 - 6
AnKi/Renderer/ShadowmapsResolve.cpp

@@ -45,10 +45,10 @@ Error ShadowmapsResolve::initInternal()
 	m_fbDescr.bake();
 
 	// Prog
-	ANKI_CHECK(getExternalSubsystems().m_resourceManager->loadResource(
-		(ConfigSet::getSingleton().getRPreferCompute()) ? "ShaderBinaries/ShadowmapsResolveCompute.ankiprogbin"
-														: "ShaderBinaries/ShadowmapsResolveRaster.ankiprogbin",
-		m_prog));
+	ANKI_CHECK(ResourceManager::getSingleton().loadResource((ConfigSet::getSingleton().getRPreferCompute())
+																? "ShaderBinaries/ShadowmapsResolveCompute.ankiprogbin"
+																: "ShaderBinaries/ShadowmapsResolveRaster.ankiprogbin",
+															m_prog));
 	ShaderProgramResourceVariantInitInfo variantInitInfo(m_prog);
 	variantInitInfo.addConstant("kFramebufferSize", UVec2(width, height));
 	variantInitInfo.addConstant("kTileCount", m_r->getTileCounts());
@@ -59,8 +59,7 @@ Error ShadowmapsResolve::initInternal()
 	m_prog->getOrCreateVariant(variantInitInfo, variant);
 	m_grProg = variant->getProgram();
 
-	ANKI_CHECK(getExternalSubsystems().m_resourceManager->loadResource("EngineAssets/BlueNoise_Rgba8_64x64.png",
-																	   m_noiseImage));
+	ANKI_CHECK(ResourceManager::getSingleton().loadResource("EngineAssets/BlueNoise_Rgba8_64x64.png", m_noiseImage));
 
 	return Error::kNone;
 }

+ 4 - 4
AnKi/Renderer/TemporalAA.cpp

@@ -37,10 +37,10 @@ Error TemporalAA::initInternal()
 {
 	ANKI_R_LOGV("Initializing TAA");
 
-	ANKI_CHECK(getExternalSubsystems().m_resourceManager->loadResource(
-		(ConfigSet::getSingleton().getRPreferCompute()) ? "ShaderBinaries/TemporalAACompute.ankiprogbin"
-														: "ShaderBinaries/TemporalAARaster.ankiprogbin",
-		m_prog));
+	ANKI_CHECK(ResourceManager::getSingleton().loadResource((ConfigSet::getSingleton().getRPreferCompute())
+																? "ShaderBinaries/TemporalAACompute.ankiprogbin"
+																: "ShaderBinaries/TemporalAARaster.ankiprogbin",
+															m_prog));
 
 	{
 		ShaderProgramResourceVariantInitInfo variantInitInfo(m_prog);

+ 2 - 2
AnKi/Renderer/Tonemapping.cpp

@@ -29,8 +29,8 @@ Error Tonemapping::initInternal()
 	ANKI_R_LOGV("Initializing tonemapping. Resolution %ux%u", width, height);
 
 	// Create program
-	ANKI_CHECK(getExternalSubsystems().m_resourceManager->loadResource(
-		"ShaderBinaries/TonemappingAverageLuminance.ankiprogbin", m_prog));
+	ANKI_CHECK(
+		ResourceManager::getSingleton().loadResource("ShaderBinaries/TonemappingAverageLuminance.ankiprogbin", m_prog));
 
 	ShaderProgramResourceVariantInitInfo variantInitInfo(m_prog);
 	variantInitInfo.addConstant("kInputTexSize", UVec2(width, height));

+ 3 - 3
AnKi/Renderer/TraditionalDeferredShading.cpp

@@ -69,8 +69,8 @@ Error TraditionalDeferredLightShading::init()
 {
 	// Init progs
 	{
-		ANKI_CHECK(getExternalSubsystems().m_resourceManager->loadResource(
-			"ShaderBinaries/TraditionalDeferredShading.ankiprogbin", m_lightProg));
+		ANKI_CHECK(ResourceManager::getSingleton().loadResource("ShaderBinaries/TraditionalDeferredShading.ankiprogbin",
+																m_lightProg));
 
 		for(U32 specular = 0; specular <= 1; ++specular)
 		{
@@ -106,7 +106,7 @@ Error TraditionalDeferredLightShading::init()
 
 	// Skybox
 	{
-		ANKI_CHECK(getExternalSubsystems().m_resourceManager->loadResource(
+		ANKI_CHECK(ResourceManager::getSingleton().loadResource(
 			"ShaderBinaries/TraditionalDeferredShadingSkybox.ankiprogbin", m_skyboxProg));
 
 		for(U32 i = 0; i < m_skyboxGrProgs.getSize(); ++i)

+ 2 - 2
AnKi/Renderer/VolumetricFog.cpp

@@ -29,8 +29,8 @@ Error VolumetricFog::init()
 	ANKI_R_LOGV("Initializing volumetric fog. Resolution %ux%ux%u", m_volumeSize[0], m_volumeSize[1], m_volumeSize[2]);
 
 	// Shaders
-	ANKI_CHECK(getExternalSubsystems().m_resourceManager->loadResource(
-		"ShaderBinaries/VolumetricFogAccumulation.ankiprogbin", m_prog));
+	ANKI_CHECK(
+		ResourceManager::getSingleton().loadResource("ShaderBinaries/VolumetricFogAccumulation.ankiprogbin", m_prog));
 
 	ShaderProgramResourceVariantInitInfo variantInitInfo(m_prog);
 	const ShaderProgramResourceVariant* variant;

+ 3 - 4
AnKi/Renderer/VolumetricLightingAccumulation.cpp

@@ -44,12 +44,11 @@ Error VolumetricLightingAccumulation::init()
 		return Error::kUserData;
 	}
 
-	ANKI_CHECK(getExternalSubsystems().m_resourceManager->loadResource("EngineAssets/BlueNoise_Rgba8_64x64.png",
-																	   m_noiseImage));
+	ANKI_CHECK(ResourceManager::getSingleton().loadResource("EngineAssets/BlueNoise_Rgba8_64x64.png", m_noiseImage));
 
 	// Shaders
-	ANKI_CHECK(getExternalSubsystems().m_resourceManager->loadResource(
-		"ShaderBinaries/VolumetricLightingAccumulation.ankiprogbin", m_prog));
+	ANKI_CHECK(ResourceManager::getSingleton().loadResource("ShaderBinaries/VolumetricLightingAccumulation.ankiprogbin",
+															m_prog));
 
 	ShaderProgramResourceVariantInitInfo variantInitInfo(m_prog);
 	variantInitInfo.addMutation("ENABLE_SHADOWS", 1);

+ 6 - 6
AnKi/Renderer/VrsSriGeneration.cpp

@@ -57,8 +57,8 @@ Error VrsSriGeneration::initInternal()
 	m_downscaledSriTex = m_r->createAndClearRenderTarget(sriInitInfo, TextureUsageBit::kFramebufferShadingRate);
 
 	// Load programs
-	ANKI_CHECK(getExternalSubsystems().m_resourceManager->loadResource(
-		"ShaderBinaries/VrsSriGenerationCompute.ankiprogbin", m_prog));
+	ANKI_CHECK(
+		ResourceManager::getSingleton().loadResource("ShaderBinaries/VrsSriGenerationCompute.ankiprogbin", m_prog));
 	ShaderProgramResourceVariantInitInfo variantInit(m_prog);
 	variantInit.addMutation("SRI_TEXEL_DIMENSION", m_sriTexelDimension);
 
@@ -87,13 +87,13 @@ Error VrsSriGeneration::initInternal()
 	m_prog->getOrCreateVariant(variantInit, variant);
 	m_grProg = variant->getProgram();
 
-	ANKI_CHECK(getExternalSubsystems().m_resourceManager->loadResource(
-		"ShaderBinaries/VrsSriVisualizeRenderTarget.ankiprogbin", m_visualizeProg));
+	ANKI_CHECK(ResourceManager::getSingleton().loadResource("ShaderBinaries/VrsSriVisualizeRenderTarget.ankiprogbin",
+															m_visualizeProg));
 	m_visualizeProg->getOrCreateVariant(variant);
 	m_visualizeGrProg = variant->getProgram();
 
-	ANKI_CHECK(getExternalSubsystems().m_resourceManager->loadResource("ShaderBinaries/VrsSriDownscale.ankiprogbin",
-																	   m_downscaleProg));
+	ANKI_CHECK(
+		ResourceManager::getSingleton().loadResource("ShaderBinaries/VrsSriDownscale.ankiprogbin", m_downscaleProg));
 	m_downscaleProg->getOrCreateVariant(variant);
 	m_downscaleGrProg = variant->getProgram();
 

+ 9 - 24
AnKi/Resource/AnimationResource.cpp

@@ -8,21 +8,6 @@
 
 namespace anki {
 
-AnimationResource::AnimationResource(ResourceManager* manager)
-	: ResourceObject(manager)
-{
-}
-
-AnimationResource::~AnimationResource()
-{
-	for(AnimationChannel& ch : m_channels)
-	{
-		ch.destroy(getMemoryPool());
-	}
-
-	m_channels.destroy(getMemoryPool());
-}
-
 Error AnimationResource::load(const ResourceFilename& filename, [[maybe_unused]] Bool async)
 {
 	XmlElement el;
@@ -31,7 +16,7 @@ Error AnimationResource::load(const ResourceFilename& filename, [[maybe_unused]]
 	Second maxTime = kMinSecond;
 
 	// Document
-	XmlDocument doc(&getTempMemoryPool());
+	XmlDocument doc(&ResourceMemoryPool::getSingleton());
 	ANKI_CHECK(openFileParseXml(filename, doc));
 	XmlElement rootel;
 	ANKI_CHECK(doc.getChildElement("animation", rootel));
@@ -55,7 +40,7 @@ Error AnimationResource::load(const ResourceFilename& filename, [[maybe_unused]]
 		ANKI_RESOURCE_LOGE("Didn't found any channels");
 		return Error::kUserData;
 	}
-	m_channels.create(getMemoryPool(), channelCount);
+	m_channels.create(channelCount);
 
 	// For all channels
 	channelCount = 0;
@@ -66,7 +51,7 @@ Error AnimationResource::load(const ResourceFilename& filename, [[maybe_unused]]
 		// <name>
 		CString strtmp;
 		ANKI_CHECK(chEl.getAttributeText("name", strtmp));
-		ch.m_name.create(getMemoryPool(), strtmp);
+		ch.m_name.create(strtmp);
 
 		XmlElement keysEl, keyEl;
 
@@ -79,7 +64,7 @@ Error AnimationResource::load(const ResourceFilename& filename, [[maybe_unused]]
 			U32 count = 0;
 			ANKI_CHECK(keyEl.getSiblingElementsCount(count));
 			++count;
-			ch.m_positions.create(getMemoryPool(), count);
+			ch.m_positions.create(count);
 
 			count = 0;
 			do
@@ -114,7 +99,7 @@ Error AnimationResource::load(const ResourceFilename& filename, [[maybe_unused]]
 			U32 count = 0;
 			ANKI_CHECK(keyEl.getSiblingElementsCount(count));
 			++count;
-			ch.m_rotations.create(getMemoryPool(), count);
+			ch.m_rotations.create(count);
 
 			count = 0;
 			do
@@ -149,7 +134,7 @@ Error AnimationResource::load(const ResourceFilename& filename, [[maybe_unused]]
 			U32 count = 0;
 			ANKI_CHECK(keyEl.getSiblingElementsCount(count));
 			++count;
-			ch.m_scales.create(getMemoryPool(), count);
+			ch.m_scales.create(count);
 
 			count = 0;
 			do
@@ -179,17 +164,17 @@ Error AnimationResource::load(const ResourceFilename& filename, [[maybe_unused]]
 		// Remove identity vectors
 		if(identPosCount == ch.m_positions.getSize())
 		{
-			ch.m_positions.destroy(getMemoryPool());
+			ch.m_positions.destroy();
 		}
 
 		if(identRotCount == ch.m_rotations.getSize())
 		{
-			ch.m_rotations.destroy(getMemoryPool());
+			ch.m_rotations.destroy();
 		}
 
 		if(identScaleCount == ch.m_scales.getSize())
 		{
-			ch.m_scales.destroy(getMemoryPool());
+			ch.m_scales.destroy();
 		}
 
 		// Move to next channel

+ 8 - 17
AnKi/Resource/AnimationResource.h

@@ -44,32 +44,23 @@ private:
 class AnimationChannel
 {
 public:
-	String m_name;
+	ResourceString m_name;
 
 	I32 m_boneIndex = -1; ///< For skeletal animations
 
-	DynamicArray<AnimationKeyframe<Vec3>> m_positions;
-	DynamicArray<AnimationKeyframe<Quat>> m_rotations;
-	DynamicArray<AnimationKeyframe<F32>> m_scales;
-	DynamicArray<AnimationKeyframe<F32>> m_cameraFovs;
-
-	void destroy(HeapMemoryPool& pool)
-	{
-		m_name.destroy(pool);
-		m_positions.destroy(pool);
-		m_rotations.destroy(pool);
-		m_scales.destroy(pool);
-		m_cameraFovs.destroy(pool);
-	}
+	ResourceDynamicArray<AnimationKeyframe<Vec3>> m_positions;
+	ResourceDynamicArray<AnimationKeyframe<Quat>> m_rotations;
+	ResourceDynamicArray<AnimationKeyframe<F32>> m_scales;
+	ResourceDynamicArray<AnimationKeyframe<F32>> m_cameraFovs;
 };
 
 /// Animation consists of keyframe data.
 class AnimationResource : public ResourceObject
 {
 public:
-	AnimationResource(ResourceManager* manager);
+	AnimationResource() = default;
 
-	~AnimationResource();
+	~AnimationResource() = default;
 
 	Error load(const ResourceFilename& filename, Bool async);
 
@@ -95,7 +86,7 @@ public:
 	void interpolate(U32 channelIndex, Second time, Vec3& position, Quat& rotation, F32& scale) const;
 
 private:
-	DynamicArray<AnimationChannel> m_channels;
+	ResourceDynamicArray<AnimationChannel> m_channels;
 	Second m_duration;
 	Second m_startTime;
 };

+ 3 - 9
AnKi/Resource/AsyncLoader.cpp

@@ -12,6 +12,7 @@ namespace anki {
 AsyncLoader::AsyncLoader()
 	: m_thread("AsyncLoad")
 {
+	m_thread.start(this, threadCallback);
 }
 
 AsyncLoader::~AsyncLoader()
@@ -26,18 +27,11 @@ AsyncLoader::~AsyncLoader()
 		{
 			AsyncLoaderTask* task = &m_taskQueue.getFront();
 			m_taskQueue.popFront();
-			deleteInstance(*m_pool, task);
+			deleteInstance(ResourceMemoryPool::getSingleton(), task);
 		}
 	}
 }
 
-void AsyncLoader::init(HeapMemoryPool* pool)
-{
-	ANKI_ASSERT(pool);
-	m_pool = pool;
-	m_thread.start(this, threadCallback);
-}
-
 void AsyncLoader::stop()
 {
 	{
@@ -146,7 +140,7 @@ Error AsyncLoader::threadWorker()
 			else
 			{
 				// Delete the task
-				deleteInstance(*m_pool, task);
+				deleteInstance(ResourceMemoryPool::getSingleton(), task);
 			}
 
 			if(ctx.m_pause)

+ 1 - 9
AnKi/Resource/AsyncLoader.h

@@ -46,8 +46,6 @@ public:
 
 	~AsyncLoader();
 
-	void init(HeapMemoryPool* pool);
-
 	/// Submit a task.
 	void submitTask(AsyncLoaderTask* task);
 
@@ -55,7 +53,7 @@ public:
 	template<typename TTask, typename... TArgs>
 	TTask* newTask(TArgs&&... args)
 	{
-		return newInstance<TTask>(*m_pool, std::forward<TArgs>(args)...);
+		return newInstance<TTask>(ResourceMemoryPool::getSingleton(), std::forward<TArgs>(args)...);
 	}
 
 	/// Create and submit a new asynchronous loading task.
@@ -72,11 +70,6 @@ public:
 	/// Resume the async loading.
 	void resume();
 
-	HeapMemoryPool& getMemoryPool() const
-	{
-		return *m_pool;
-	}
-
 	/// Get the total number of completed tasks.
 	U64 getCompletedTaskCount() const
 	{
@@ -84,7 +77,6 @@ public:
 	}
 
 private:
-	mutable HeapMemoryPool* m_pool = nullptr;
 	Thread m_thread;
 	Barrier m_barrier = {2};
 

+ 2 - 3
AnKi/Resource/Common.cpp

@@ -13,9 +13,8 @@ namespace anki {
 template<typename T>
 void ResourcePtrDeleter<T>::operator()(T* ptr)
 {
-	ptr->getManager().unregisterResource(ptr);
-	HeapMemoryPool& pool = ptr->getMemoryPool();
-	deleteInstance(pool, ptr);
+	ResourceManager::getSingleton().unregisterResource(ptr);
+	deleteInstance(ResourceMemoryPool::getSingleton(), ptr);
 }
 
 #define ANKI_INSTANTIATE_RESOURCE(rsrc_, ptr_) template void ResourcePtrDeleter<rsrc_>::operator()(rsrc_* ptr);

+ 16 - 3
AnKi/Resource/Common.h

@@ -5,8 +5,6 @@
 
 #pragma once
 
-#include <AnKi/Util/DynamicArray.h>
-#include <AnKi/Util/String.h>
 #include <AnKi/Util/Ptr.h>
 #include <AnKi/Gr/Common.h>
 #include <AnKi/Shaders/Include/ModelTypes.h>
@@ -32,6 +30,22 @@ class UnifiedGeometryMemoryPool;
 #define ANKI_RESOURCE_LOGF(...) ANKI_LOG("RSRC", kFatal, __VA_ARGS__)
 #define ANKI_RESOURCE_LOGV(...) ANKI_LOG("RSRC", kVerbose, __VA_ARGS__)
 
+class ResourceMemoryPool : public HeapMemoryPool, public MakeSingleton<ResourceMemoryPool>
+{
+	template<typename>
+	friend class MakeSingleton;
+
+private:
+	ResourceMemoryPool(AllocAlignedCallback allocCb, void* allocCbUserData)
+		: HeapMemoryPool(allocCb, allocCbUserData, "ResourceMemPool")
+	{
+	}
+
+	~ResourceMemoryPool() = default;
+};
+
+ANKI_DEFINE_SUBMODULE_UTIL_CONTAINERS(Resource, ResourceMemoryPool)
+
 /// Deleter for ResourcePtr.
 template<typename T>
 class ResourcePtrDeleter
@@ -62,7 +76,6 @@ class ResourceManagerExternalSubsystems
 {
 public:
 	GrManager* m_grManager = nullptr;
-	ResourceFilesystem* m_resourceFilesystem = nullptr;
 };
 /// @}
 

+ 2 - 20
AnKi/Resource/CpuMeshResource.cpp

@@ -10,30 +10,12 @@
 
 namespace anki {
 
-CpuMeshResource::CpuMeshResource(ResourceManager* manager)
-	: ResourceObject(manager)
-{
-}
-
-CpuMeshResource::~CpuMeshResource()
-{
-	m_indices.destroy(getMemoryPool());
-	m_positions.destroy(getMemoryPool());
-}
-
 Error CpuMeshResource::load(const ResourceFilename& filename, [[maybe_unused]] Bool async)
 {
-	MeshBinaryLoader loader(getExternalSubsystems().m_resourceFilesystem, &getTempMemoryPool());
+	MeshBinaryLoader loader(&ResourceMemoryPool::getSingleton());
 
 	ANKI_CHECK(loader.load(filename));
-
-	DynamicArrayRaii<Vec3> tempPositions(&getMemoryPool());
-	DynamicArrayRaii<U32> tempIndices(&getMemoryPool());
-
-	ANKI_CHECK(loader.storeIndicesAndPosition(0, tempIndices, tempPositions));
-
-	m_indices = std::move(tempIndices);
-	m_positions = std::move(tempPositions);
+	ANKI_CHECK(loader.storeIndicesAndPosition(0, m_indices, m_positions));
 
 	// Create the collision shape
 	const Bool convex = !!(loader.getHeader().m_flags & MeshBinaryFlag::kConvex);

+ 4 - 4
AnKi/Resource/CpuMeshResource.h

@@ -20,9 +20,9 @@ class CpuMeshResource : public ResourceObject
 {
 public:
 	/// Default constructor
-	CpuMeshResource(ResourceManager* manager);
+	CpuMeshResource() = default;
 
-	~CpuMeshResource();
+	~CpuMeshResource() = default;
 
 	/// Load from a mesh file
 	Error load(const ResourceFilename& filename, Bool async);
@@ -43,8 +43,8 @@ public:
 	}
 
 private:
-	DynamicArray<Vec3> m_positions;
-	DynamicArray<U32> m_indices;
+	ResourceDynamicArray<Vec3> m_positions;
+	ResourceDynamicArray<U32> m_indices;
 	PhysicsCollisionShapePtr m_physicsShape;
 };
 /// @}

+ 6 - 8
AnKi/Resource/DummyResource.h

@@ -6,6 +6,7 @@
 #pragma once
 
 #include <AnKi/Resource/ResourceObject.h>
+#include <AnKi/Resource/ResourceManager.h>
 
 namespace anki {
 
@@ -16,16 +17,13 @@ namespace anki {
 class DummyResource : public ResourceObject
 {
 public:
-	DummyResource(ResourceManager* manager)
-		: ResourceObject(manager)
-	{
-	}
+	DummyResource() = default;
 
 	~DummyResource()
 	{
 		if(m_memory)
 		{
-			getMemoryPool().free(m_memory);
+			ResourceMemoryPool::getSingleton().free(m_memory);
 		}
 	}
 
@@ -34,10 +32,10 @@ public:
 		Error err = Error::kNone;
 		if(filename.find("error") == CString::kNpos)
 		{
-			m_memory = getMemoryPool().allocate(128, 1);
-			void* tempMem = getTempMemoryPool().allocate(128, 1);
+			m_memory = ResourceMemoryPool::getSingleton().allocate(128, 1);
+			void* tempMem = ResourceMemoryPool::getSingleton().allocate(128, 1);
 
-			getTempMemoryPool().free(tempMem);
+			ResourceMemoryPool::getSingleton().free(tempMem);
 		}
 		else
 		{

+ 1 - 11
AnKi/Resource/GenericResource.cpp

@@ -7,23 +7,13 @@
 
 namespace anki {
 
-GenericResource::GenericResource(ResourceManager* manager)
-	: ResourceObject(manager)
-{
-}
-
-GenericResource::~GenericResource()
-{
-	m_data.destroy(getMemoryPool());
-}
-
 Error GenericResource::load(const ResourceFilename& filename, [[maybe_unused]] Bool async)
 {
 	ResourceFilePtr file;
 	ANKI_CHECK(openFile(filename, file));
 
 	const U32 size = U32(file->getSize());
-	m_data.create(getMemoryPool(), size);
+	m_data.create(size);
 	ANKI_CHECK(file->read(&m_data[0], size));
 
 	return Error::kNone;

+ 3 - 3
AnKi/Resource/GenericResource.h

@@ -17,9 +17,9 @@ namespace anki {
 class GenericResource : public ResourceObject
 {
 public:
-	GenericResource(ResourceManager* manager);
+	GenericResource() = default;
 
-	~GenericResource();
+	~GenericResource() = default;
 
 	Error load(const ResourceFilename& filename, Bool async);
 
@@ -29,7 +29,7 @@ public:
 	}
 
 private:
-	DynamicArray<U8> m_data;
+	ResourceDynamicArray<U8> m_data;
 };
 /// @}
 

+ 4 - 15
AnKi/Resource/ImageAtlasResource.cpp

@@ -9,20 +9,9 @@
 
 namespace anki {
 
-ImageAtlasResource::ImageAtlasResource(ResourceManager* manager)
-	: ResourceObject(manager)
-{
-}
-
-ImageAtlasResource::~ImageAtlasResource()
-{
-	m_subTexes.destroy(getMemoryPool());
-	m_subTexNames.destroy(getMemoryPool());
-}
-
 Error ImageAtlasResource::load(const ResourceFilename& filename, Bool async)
 {
-	XmlDocument doc(&getTempMemoryPool());
+	XmlDocument doc(&ResourceMemoryPool::getSingleton());
 	ANKI_CHECK(openFileParseXml(filename, doc));
 
 	XmlElement rootel, el;
@@ -38,7 +27,7 @@ Error ImageAtlasResource::load(const ResourceFilename& filename, Bool async)
 	ANKI_CHECK(rootel.getChildElement("image", el));
 	CString texFname;
 	ANKI_CHECK(el.getText(texFname));
-	ANKI_CHECK(getManager().loadResource<ImageResource>(texFname, m_image, async));
+	ANKI_CHECK(ResourceManager::getSingleton().loadResource<ImageResource>(texFname, m_image, async));
 
 	m_size[0] = m_image->getWidth();
 	m_size[1] = m_image->getHeight();
@@ -85,8 +74,8 @@ Error ImageAtlasResource::load(const ResourceFilename& filename, Bool async)
 	} while(subTexEl);
 
 	// Allocate
-	m_subTexNames.create(getMemoryPool(), namesSize);
-	m_subTexes.create(getMemoryPool(), subTexesCount);
+	m_subTexNames.create(namesSize);
+	m_subTexes.create(subTexesCount);
 
 	// Iterate again and populate
 	subTexesCount = 0;

+ 4 - 4
AnKi/Resource/ImageAtlasResource.h

@@ -34,9 +34,9 @@ namespace anki {
 class ImageAtlasResource : public ResourceObject
 {
 public:
-	ImageAtlasResource(ResourceManager* manager);
+	ImageAtlasResource() = default;
 
-	~ImageAtlasResource();
+	~ImageAtlasResource() = default;
 
 	/// Load the atlas.
 	Error load(const ResourceFilename& filename, Bool async);
@@ -78,8 +78,8 @@ private:
 	};
 
 	ImageResourcePtr m_image;
-	DynamicArray<char> m_subTexNames;
-	DynamicArray<SubTex> m_subTexes;
+	ResourceDynamicArray<char> m_subTexNames;
+	ResourceDynamicArray<SubTex> m_subTexes;
 	Array<U32, 2> m_size;
 	U32 m_margin = 0;
 };

+ 12 - 23
AnKi/Resource/ImageResource.cpp

@@ -15,18 +15,12 @@ namespace anki {
 class ImageResource::LoadingContext
 {
 public:
-	ImageLoader m_loader;
+	ImageLoader m_loader{&ResourceMemoryPool::getSingleton()};
 	U32 m_faces = 0;
 	U32 m_layerCount = 0;
 	GrManager* m_gr ANKI_DEBUG_CODE(= nullptr);
-	TransferGpuAllocator* m_trfAlloc ANKI_DEBUG_CODE(= nullptr);
 	TextureType m_texType;
 	TexturePtr m_tex;
-
-	LoadingContext(BaseMemoryPool* pool)
-		: m_loader(pool)
-	{
-	}
 };
 
 /// Image upload async task.
@@ -35,11 +29,6 @@ class ImageResource::TexUploadTask : public AsyncLoaderTask
 public:
 	ImageResource::LoadingContext m_ctx;
 
-	TexUploadTask(BaseMemoryPool* pool)
-		: m_ctx(pool)
-	{
-	}
-
 	Error operator()([[maybe_unused]] AsyncLoaderTaskContext& ctx) final
 	{
 		return ImageResource::load(m_ctx);
@@ -54,11 +43,11 @@ Error ImageResource::load(const ResourceFilename& filename, Bool async)
 {
 	TexUploadTask* task;
 	LoadingContext* ctx;
-	LoadingContext localCtx(&getTempMemoryPool());
+	LoadingContext localCtx;
 
 	if(async)
 	{
-		task = getManager().getAsyncLoader().newTask<TexUploadTask>(&getManager().getAsyncLoader().getMemoryPool());
+		task = ResourceManager::getSingleton().getAsyncLoader().newTask<TexUploadTask>();
 		ctx = &task->m_ctx;
 	}
 	else
@@ -68,7 +57,7 @@ Error ImageResource::load(const ResourceFilename& filename, Bool async)
 	}
 	ImageLoader& loader = ctx->m_loader;
 
-	StringRaii filenameExt(&getTempMemoryPool());
+	StringRaii filenameExt(&ResourceMemoryPool::getSingleton());
 	getFilepathFilename(filename, filenameExt);
 
 	TextureInitInfo init(filenameExt);
@@ -204,13 +193,14 @@ Error ImageResource::load(const ResourceFilename& filename, Bool async)
 	init.m_mipmapCount = U8(loader.getMipmapCount());
 
 	// Create the texture
-	m_tex = getExternalSubsystems().m_grManager->newTexture(init);
+	m_tex = ResourceManager::getSingleton().getExternalSubsystems().m_grManager->newTexture(init);
 
 	// Transition it. TODO remove that eventually
 	{
 		CommandBufferInitInfo cmdbinit;
 		cmdbinit.m_flags = CommandBufferFlag::kGeneralWork | CommandBufferFlag::kSmallBatch;
-		CommandBufferPtr cmdb = getExternalSubsystems().m_grManager->newCommandBuffer(cmdbinit);
+		CommandBufferPtr cmdb =
+			ResourceManager::getSingleton().getExternalSubsystems().m_grManager->newCommandBuffer(cmdbinit);
 
 		TextureSubresourceInfo subresource;
 		subresource.m_faceCount = textureTypeIsCube(init.m_type) ? 6 : 1;
@@ -229,15 +219,14 @@ Error ImageResource::load(const ResourceFilename& filename, Bool async)
 	// Set the context
 	ctx->m_faces = faces;
 	ctx->m_layerCount = init.m_layerCount;
-	ctx->m_gr = getExternalSubsystems().m_grManager;
-	ctx->m_trfAlloc = &getManager().getTransferGpuAllocator();
+	ctx->m_gr = ResourceManager::getSingleton().getExternalSubsystems().m_grManager;
 	ctx->m_texType = init.m_type;
 	ctx->m_tex = m_tex;
 
 	// Upload the data
 	if(async)
 	{
-		getManager().getAsyncLoader().submitTask(task);
+		ResourceManager::getSingleton().getAsyncLoader().submitTask(task);
 	}
 	else
 	{
@@ -249,7 +238,7 @@ Error ImageResource::load(const ResourceFilename& filename, Bool async)
 
 	// Create the texture view
 	TextureViewInitInfo viewInit(m_tex, "Rsrc");
-	m_texView = getExternalSubsystems().m_grManager->newTextureView(viewInit);
+	m_texView = ResourceManager::getSingleton().getExternalSubsystems().m_grManager->newTextureView(viewInit);
 
 	return Error::kNone;
 }
@@ -324,7 +313,7 @@ Error ImageResource::load(LoadingContext& ctx)
 
 			ANKI_ASSERT(allocationSize >= surfOrVolSize);
 			TransferGpuAllocatorHandle& handle = handles[handleCount++];
-			ANKI_CHECK(ctx.m_trfAlloc->allocate(allocationSize, handle));
+			ANKI_CHECK(ResourceManager::getSingleton().getTransferGpuAllocator().allocate(allocationSize, handle));
 			void* data = handle.getMappedMemory();
 			ANKI_ASSERT(data);
 
@@ -374,7 +363,7 @@ Error ImageResource::load(LoadingContext& ctx)
 
 		for(U i = 0; i < handleCount; ++i)
 		{
-			ctx.m_trfAlloc->release(handles[i], fence);
+			ResourceManager::getSingleton().getTransferGpuAllocator().release(handles[i], fence);
 		}
 		cmdb.reset(nullptr);
 	}

+ 1 - 4
AnKi/Resource/ImageResource.h

@@ -20,10 +20,7 @@ namespace anki {
 class ImageResource : public ResourceObject
 {
 public:
-	ImageResource(ResourceManager* manager)
-		: ResourceObject(manager)
-	{
-	}
+	ImageResource() = default;
 
 	~ImageResource();
 

+ 18 - 33
AnKi/Resource/MaterialResource.cpp

@@ -75,7 +75,7 @@ public:
 	mutable Array3d<MaterialVariant, U(RenderingTechnique::kCount), 2, 2> m_variantMatrix;
 	mutable RWMutex m_variantMatrixMtx;
 
-	DynamicArray<PartialMutation> m_partialMutation; ///< Only with the non-builtins.
+	ResourceDynamicArray<PartialMutation> m_partialMutation; ///< Only with the non-builtins.
 
 	U32 m_presentBuildinMutators = 0;
 	U32 m_localUniformsStructIdx = 0; ///< Struct index in the program binary.
@@ -114,30 +114,14 @@ public:
 	}
 };
 
-MaterialResource::MaterialResource(ResourceManager* manager)
-	: ResourceObject(manager)
+MaterialResource::MaterialResource()
 {
 	memset(m_techniqueToProgram.getBegin(), 0xFF, m_techniqueToProgram.getSizeInBytes());
 }
 
 MaterialResource::~MaterialResource()
 {
-	for(Program& p : m_programs)
-	{
-		p.m_partialMutation.destroy(getMemoryPool());
-	}
-
-	m_textures.destroy(getMemoryPool());
-
-	for(MaterialVariable& var : m_vars)
-	{
-		var.m_name.destroy(getMemoryPool());
-	}
-
-	m_vars.destroy(getMemoryPool());
-	m_programs.destroy(getMemoryPool());
-
-	getMemoryPool().free(m_prefilledLocalUniforms);
+	ResourceMemoryPool::getSingleton().free(m_prefilledLocalUniforms);
 }
 
 const MaterialVariable* MaterialResource::tryFindVariableInternal(CString name) const
@@ -155,7 +139,7 @@ const MaterialVariable* MaterialResource::tryFindVariableInternal(CString name)
 
 Error MaterialResource::load(const ResourceFilename& filename, Bool async)
 {
-	XmlDocument doc(&getTempMemoryPool());
+	XmlDocument doc(&ResourceMemoryPool::getSingleton());
 	XmlElement el;
 	ANKI_CHECK(openFileParseXml(filename, doc));
 
@@ -208,17 +192,18 @@ Error MaterialResource::parseShaderProgram(XmlElement shaderProgramEl, Bool asyn
 	CString shaderName;
 	ANKI_CHECK(shaderProgramEl.getAttributeText("name", shaderName));
 
-	if(!getExternalSubsystems().m_grManager->getDeviceCapabilities().m_rayTracingEnabled && shaderName.find("Rt") == 0)
+	if(!ResourceManager::getSingleton().getExternalSubsystems().m_grManager->getDeviceCapabilities().m_rayTracingEnabled
+	   && shaderName.find("Rt") == 0)
 	{
 		// Skip RT programs when RT is disabled
 		return Error::kNone;
 	}
 
-	StringRaii fname(&getTempMemoryPool());
+	ResourceString fname;
 	fname.sprintf("ShaderBinaries/%s.ankiprogbin", shaderName.cstr());
 
-	Program& prog = *m_programs.emplaceBack(getMemoryPool());
-	ANKI_CHECK(getManager().loadResource(fname, prog.m_prog, async));
+	Program& prog = *m_programs.emplaceBack();
+	ANKI_CHECK(ResourceManager::getSingleton().loadResource(fname, prog.m_prog, async));
 
 	// <mutation>
 	XmlElement mutatorsEl;
@@ -333,8 +318,8 @@ Error MaterialResource::createVars(Program& prog)
 				}
 
 				// All good, add it
-				var = m_vars.emplaceBack(getMemoryPool());
-				var->m_name.create(getMemoryPool(), memberName);
+				var = m_vars.emplaceBack();
+				var->m_name.create(memberName);
 				var->m_offsetInLocalUniforms = offsetof;
 				var->m_dataType = member.m_type;
 
@@ -424,8 +409,8 @@ Error MaterialResource::createVars(Program& prog)
 				}
 
 				// All good, add it
-				var = m_vars.emplaceBack(getMemoryPool());
-				var->m_name.create(getMemoryPool(), opaqueName);
+				var = m_vars.emplaceBack();
+				var->m_name.create(opaqueName);
 				var->m_opaqueBinding = opaque.m_binding;
 				var->m_dataType = opaque.m_type;
 			}
@@ -450,7 +435,7 @@ Error MaterialResource::parseMutators(XmlElement mutatorsEl, Program& prog)
 	ANKI_CHECK(mutatorEl.getSiblingElementsCount(mutatorCount));
 	++mutatorCount;
 	ANKI_ASSERT(mutatorCount > 0);
-	prog.m_partialMutation.create(getMemoryPool(), mutatorCount);
+	prog.m_partialMutation.create(mutatorCount);
 	mutatorCount = 0;
 
 	do
@@ -645,9 +630,9 @@ Error MaterialResource::parseInput(XmlElement inputEl, Bool async, BitSet<128>&
 	{
 		CString texfname;
 		ANKI_CHECK(inputEl.getAttributeText("value", texfname));
-		ANKI_CHECK(getManager().loadResource(texfname, foundVar->m_image, async));
+		ANKI_CHECK(ResourceManager::getSingleton().loadResource(texfname, foundVar->m_image, async));
 
-		m_textures.emplaceBack(getMemoryPool(), foundVar->m_image->getTexture());
+		m_textures.emplaceBack(foundVar->m_image->getTexture());
 	}
 	else if(foundVar->m_dataType == ShaderVariableDataType::kU32)
 	{
@@ -670,7 +655,7 @@ Error MaterialResource::parseInput(XmlElement inputEl, Bool async, BitSet<128>&
 		// If it has letters it's a texture
 		if(containsAlpharithmetic)
 		{
-			ANKI_CHECK(getManager().loadResource(value, foundVar->m_image, async));
+			ANKI_CHECK(ResourceManager::getSingleton().loadResource(value, foundVar->m_image, async));
 
 			foundVar->m_U32 = foundVar->m_image->getTextureView()->getOrCreateBindlessTextureIndex();
 		}
@@ -705,7 +690,7 @@ void MaterialResource::prefillLocalUniforms()
 		return;
 	}
 
-	m_prefilledLocalUniforms = getMemoryPool().allocate(m_localUniformsSize, 1);
+	m_prefilledLocalUniforms = ResourceMemoryPool::getSingleton().allocate(m_localUniformsSize, 1);
 	memset(m_prefilledLocalUniforms, 0, m_localUniformsSize);
 
 	for(const MaterialVariable& var : m_vars)

+ 5 - 5
AnKi/Resource/MaterialResource.h

@@ -109,7 +109,7 @@ public:
 	}
 
 protected:
-	String m_name;
+	ResourceString m_name;
 	U32 m_offsetInLocalUniforms = kMaxU32;
 	U32 m_opaqueBinding = kMaxU32; ///< Binding for textures and samplers.
 	ShaderVariableDataType m_dataType = ShaderVariableDataType::kNone;
@@ -217,7 +217,7 @@ private:
 class MaterialResource : public ResourceObject
 {
 public:
-	MaterialResource(ResourceManager* manager);
+	MaterialResource();
 
 	~MaterialResource();
 
@@ -270,16 +270,16 @@ private:
 
 	class Program;
 
-	DynamicArray<Program> m_programs;
+	ResourceDynamicArray<Program> m_programs;
 
 	Array<U8, U(RenderingTechnique::kCount)> m_techniqueToProgram;
 	RenderingTechniqueBit m_techniquesMask = RenderingTechniqueBit::kNone;
 
-	DynamicArray<MaterialVariable> m_vars;
+	ResourceDynamicArray<MaterialVariable> m_vars;
 
 	Bool m_supportsSkinning = false;
 
-	DynamicArray<TexturePtr> m_textures;
+	ResourceDynamicArray<TexturePtr> m_textures;
 
 	void* m_prefilledLocalUniforms = nullptr;
 	U32 m_localUniformsSize = 0;

+ 3 - 3
AnKi/Resource/MeshBinaryLoader.cpp

@@ -16,7 +16,7 @@ MeshBinaryLoader::~MeshBinaryLoader()
 Error MeshBinaryLoader::load(const ResourceFilename& filename)
 {
 	// Load header + submeshes
-	ANKI_CHECK(m_fs->openFile(filename, m_file));
+	ANKI_CHECK(ResourceManager::getSingleton().getFilesystem().openFile(filename, m_file));
 	ANKI_CHECK(m_file->read(&m_header, sizeof(m_header)));
 	ANKI_CHECK(checkHeader());
 	ANKI_CHECK(loadSubmeshes());
@@ -288,8 +288,8 @@ Error MeshBinaryLoader::storeVertexBuffer(U32 lod, U32 bufferIdx, void* ptr, Ptr
 	return Error::kNone;
 }
 
-Error MeshBinaryLoader::storeIndicesAndPosition(U32 lod, DynamicArrayRaii<U32>& indices,
-												DynamicArrayRaii<Vec3>& positions)
+Error MeshBinaryLoader::storeIndicesAndPosition(U32 lod, ResourceDynamicArray<U32>& indices,
+												ResourceDynamicArray<Vec3>& positions)
 {
 	ANKI_ASSERT(isLoaded());
 	ANKI_ASSERT(lod < m_header.m_lodCount);

+ 4 - 6
AnKi/Resource/MeshBinaryLoader.h

@@ -26,11 +26,10 @@ namespace anki {
 class MeshBinaryLoader
 {
 public:
-	MeshBinaryLoader(ResourceFilesystem* fs, BaseMemoryPool* pool)
-		: m_fs(fs)
-		, m_pool(pool)
+	MeshBinaryLoader(BaseMemoryPool* pool)
+		: m_pool(pool)
 	{
-		ANKI_ASSERT(fs && pool);
+		ANKI_ASSERT(pool);
 	}
 
 	~MeshBinaryLoader();
@@ -42,7 +41,7 @@ public:
 	Error storeVertexBuffer(U32 lod, U32 bufferIdx, void* ptr, PtrSize size);
 
 	/// Instead of calling storeIndexBuffer and storeVertexBuffer use this method to get those buffers into the CPU.
-	Error storeIndicesAndPosition(U32 lod, DynamicArrayRaii<U32>& indices, DynamicArrayRaii<Vec3>& positions);
+	Error storeIndicesAndPosition(U32 lod, ResourceDynamicArray<U32>& indices, ResourceDynamicArray<Vec3>& positions);
 
 	const MeshBinaryHeader& getHeader() const
 	{
@@ -56,7 +55,6 @@ public:
 	}
 
 private:
-	ResourceFilesystem* m_fs = nullptr;
 	BaseMemoryPool* m_pool = nullptr;
 	ResourceFilePtr m_file;
 

+ 23 - 24
AnKi/Resource/MeshResource.cpp

@@ -19,9 +19,9 @@ public:
 	MeshResourcePtr m_mesh;
 	MeshBinaryLoader m_loader;
 
-	LoadContext(MeshResource* mesh, BaseMemoryPool* pool)
+	LoadContext(MeshResource* mesh)
 		: m_mesh(mesh)
-		, m_loader(mesh->getExternalSubsystems().m_resourceFilesystem, pool)
+		, m_loader(&ResourceMemoryPool::getSingleton())
 	{
 	}
 };
@@ -33,7 +33,7 @@ public:
 	MeshResource::LoadContext m_ctx;
 
 	LoadTask(MeshResource* mesh)
-		: m_ctx(mesh, &mesh->getManager().getAsyncLoader().getMemoryPool())
+		: m_ctx(mesh)
 	{
 	}
 
@@ -42,21 +42,18 @@ public:
 		return m_ctx.m_mesh->loadAsync(m_ctx.m_loader);
 	}
 
-	BaseMemoryPool& getMemoryPool() const
+	static BaseMemoryPool& getMemoryPool()
 	{
-		return m_ctx.m_mesh->getManager().getAsyncLoader().getMemoryPool();
+		return ResourceMemoryPool::getSingleton();
 	}
 };
 
-MeshResource::MeshResource(ResourceManager* manager)
-	: ResourceObject(manager)
+MeshResource::MeshResource()
 {
 }
 
 MeshResource::~MeshResource()
 {
-	m_subMeshes.destroy(getMemoryPool());
-
 	for(Lod& lod : m_lods)
 	{
 		UnifiedGeometryMemoryPool::getSingleton().deferredFree(lod.m_indexBufferAllocationToken);
@@ -66,24 +63,25 @@ MeshResource::~MeshResource()
 			UnifiedGeometryMemoryPool::getSingleton().deferredFree(lod.m_vertexBuffersAllocationToken[stream]);
 		}
 	}
-
-	m_lods.destroy(getMemoryPool());
 }
 
 Error MeshResource::load(const ResourceFilename& filename, Bool async)
 {
 	UniquePtr<LoadTask> task;
 	LoadContext* ctx;
-	LoadContext localCtx(this, &getTempMemoryPool());
+	LoadContext localCtx(this);
 
-	StringRaii basename(&getTempMemoryPool());
+	StringRaii basename(&ResourceMemoryPool::getSingleton());
 	getFilepathFilename(filename, basename);
 
-	const Bool rayTracingEnabled = getExternalSubsystems().m_grManager->getDeviceCapabilities().m_rayTracingEnabled;
+	const Bool rayTracingEnabled = ResourceManager::getSingleton()
+									   .getExternalSubsystems()
+									   .m_grManager->getDeviceCapabilities()
+									   .m_rayTracingEnabled;
 
 	if(async)
 	{
-		task.reset(getManager().getAsyncLoader().newTask<LoadTask>(this));
+		task.reset(ResourceManager::getSingleton().getAsyncLoader().newTask<LoadTask>(this));
 		ctx = &task->m_ctx;
 	}
 	else
@@ -105,7 +103,7 @@ Error MeshResource::load(const ResourceFilename& filename, Bool async)
 	m_positionsTranslation = Vec3(&header.m_vertexAttributes[VertexStreamId::kPosition].m_translation[0]);
 
 	// Submeshes
-	m_subMeshes.create(getMemoryPool(), header.m_subMeshCount);
+	m_subMeshes.create(header.m_subMeshCount);
 	for(U32 i = 0; i < m_subMeshes.getSize(); ++i)
 	{
 		m_subMeshes[i].m_firstIndices = loader.getSubMeshes()[i].m_firstIndices;
@@ -115,7 +113,7 @@ Error MeshResource::load(const ResourceFilename& filename, Bool async)
 	}
 
 	// LODs
-	m_lods.create(getMemoryPool(), header.m_lodCount);
+	m_lods.create(header.m_lodCount);
 	for(I32 l = I32(header.m_lodCount - 1); l >= 0; --l)
 	{
 		Lod& lod = m_lods[l];
@@ -160,8 +158,7 @@ Error MeshResource::load(const ResourceFilename& filename, Bool async)
 		// BLAS
 		if(rayTracingEnabled)
 		{
-			AccelerationStructureInitInfo inf(
-				StringRaii(&getTempMemoryPool()).sprintf("%s_%s", "Blas", basename.cstr()));
+			AccelerationStructureInitInfo inf(ResourceString().sprintf("%s_%s", "Blas", basename.cstr()));
 			inf.m_type = AccelerationStructureType::kBottomLevel;
 
 			inf.m_bottomLevel.m_indexBuffer = UnifiedGeometryMemoryPool::getSingleton().getBuffer();
@@ -177,7 +174,8 @@ Error MeshResource::load(const ResourceFilename& filename, Bool async)
 			inf.m_bottomLevel.m_positionsFormat = kMeshRelatedVertexStreamFormats[VertexStreamId::kPosition];
 			inf.m_bottomLevel.m_positionCount = lod.m_vertexCount;
 
-			lod.m_blas = getExternalSubsystems().m_grManager->newAccelerationStructure(inf);
+			lod.m_blas =
+				ResourceManager::getSingleton().getExternalSubsystems().m_grManager->newAccelerationStructure(inf);
 		}
 	}
 
@@ -186,7 +184,8 @@ Error MeshResource::load(const ResourceFilename& filename, Bool async)
 	{
 		CommandBufferInitInfo cmdbinit("MeshResourceClear");
 		cmdbinit.m_flags = CommandBufferFlag::kSmallBatch | CommandBufferFlag::kGeneralWork;
-		CommandBufferPtr cmdb = getExternalSubsystems().m_grManager->newCommandBuffer(cmdbinit);
+		CommandBufferPtr cmdb =
+			ResourceManager::getSingleton().getExternalSubsystems().m_grManager->newCommandBuffer(cmdbinit);
 
 		for(const Lod& lod : m_lods)
 		{
@@ -218,7 +217,7 @@ Error MeshResource::load(const ResourceFilename& filename, Bool async)
 	// Submit the loading task
 	if(async)
 	{
-		getManager().getAsyncLoader().submitTask(task.get());
+		ResourceManager::getSingleton().getAsyncLoader().submitTask(task.get());
 		LoadTask* pTask;
 		task.moveAndReset(pTask);
 	}
@@ -232,8 +231,8 @@ Error MeshResource::load(const ResourceFilename& filename, Bool async)
 
 Error MeshResource::loadAsync(MeshBinaryLoader& loader) const
 {
-	GrManager& gr = *getExternalSubsystems().m_grManager;
-	TransferGpuAllocator& transferAlloc = getManager().getTransferGpuAllocator();
+	GrManager& gr = *ResourceManager::getSingleton().getExternalSubsystems().m_grManager;
+	TransferGpuAllocator& transferAlloc = ResourceManager::getSingleton().getTransferGpuAllocator();
 
 	Array<TransferGpuAllocatorHandle, kMaxLodCount*(U32(VertexStreamId::kMeshRelatedCount) + 1)> handles;
 	U32 handleCount = 0;

+ 3 - 3
AnKi/Resource/MeshResource.h

@@ -25,7 +25,7 @@ class MeshResource : public ResourceObject
 {
 public:
 	/// Default constructor
-	MeshResource(ResourceManager* manager);
+	MeshResource();
 
 	~MeshResource();
 
@@ -121,8 +121,8 @@ private:
 		Aabb m_aabb;
 	};
 
-	DynamicArray<SubMesh> m_subMeshes;
-	DynamicArray<Lod> m_lods;
+	ResourceDynamicArray<SubMesh> m_subMeshes;
+	ResourceDynamicArray<Lod> m_lods;
 	Aabb m_aabb;
 	IndexType m_indexType;
 	VertexStreamMask m_presentVertStreams = VertexStreamMask::kNone;

+ 6 - 16
AnKi/Resource/ModelResource.cpp

@@ -50,17 +50,17 @@ void ModelPatch::getRayTracingInfo(const RenderingKey& key, ModelRayTracingInfo&
 }
 
 Error ModelPatch::init([[maybe_unused]] ModelResource* model, CString meshFName, const CString& mtlFName,
-					   U32 subMeshIndex, Bool async, ResourceManager* manager)
+					   U32 subMeshIndex, Bool async)
 {
 #if ANKI_ENABLE_ASSERTIONS
 	m_model = model;
 #endif
 
 	// Load material
-	ANKI_CHECK(manager->loadResource(mtlFName, m_mtl, async));
+	ANKI_CHECK(ResourceManager::getSingleton().loadResource(mtlFName, m_mtl, async));
 
 	// Load mesh
-	ANKI_CHECK(manager->loadResource(meshFName, m_mesh, async));
+	ANKI_CHECK(ResourceManager::getSingleton().loadResource(meshFName, m_mesh, async));
 
 	if(subMeshIndex != kMaxU32 && subMeshIndex >= m_mesh->getSubMeshCount())
 	{
@@ -109,22 +109,12 @@ Error ModelPatch::init([[maybe_unused]] ModelResource* model, CString meshFName,
 	return Error::kNone;
 }
 
-ModelResource::ModelResource(ResourceManager* manager)
-	: ResourceObject(manager)
-{
-}
-
-ModelResource::~ModelResource()
-{
-	m_modelPatches.destroy(getMemoryPool());
-}
-
 Error ModelResource::load(const ResourceFilename& filename, Bool async)
 {
 	// Load
 	//
 	XmlElement el;
-	XmlDocument doc(&getTempMemoryPool());
+	XmlDocument doc(&ResourceMemoryPool::getSingleton());
 	ANKI_CHECK(openFileParseXml(filename, doc));
 
 	XmlElement rootEl;
@@ -153,7 +143,7 @@ Error ModelResource::load(const ResourceFilename& filename, Bool async)
 		return Error::kUserData;
 	}
 
-	m_modelPatches.create(getMemoryPool(), count);
+	m_modelPatches.create(count);
 
 	count = 0;
 	ANKI_CHECK(modelPatchesEl.getChildElement("modelPatch", modelPatchEl));
@@ -178,7 +168,7 @@ Error ModelResource::load(const ResourceFilename& filename, Bool async)
 		CString cstr;
 		ANKI_CHECK(materialEl.getText(cstr));
 
-		ANKI_CHECK(m_modelPatches[count].init(this, meshFname, cstr, subMeshIndex, async, &getManager()));
+		ANKI_CHECK(m_modelPatches[count].init(this, meshFname, cstr, subMeshIndex, async));
 
 		if(count > 0 && m_modelPatches[count].supportsSkinning() != m_modelPatches[count - 1].supportsSkinning())
 		{

+ 4 - 5
AnKi/Resource/ModelResource.h

@@ -97,8 +97,7 @@ private:
 		return m_mesh->isVertexStreamPresent(VertexStreamId::kBoneIds) && m_mtl->supportsSkinning();
 	}
 
-	Error init(ModelResource* model, CString meshFName, const CString& mtlFName, U32 subMeshIndex, Bool async,
-			   ResourceManager* resources);
+	Error init(ModelResource* model, CString meshFName, const CString& mtlFName, U32 subMeshIndex, Bool async);
 };
 
 /// Model is an entity that acts as a container for other resources. Models are all the non static objects in a map.
@@ -123,9 +122,9 @@ private:
 class ModelResource : public ResourceObject
 {
 public:
-	ModelResource(ResourceManager* manager);
+	ModelResource() = default;
 
-	~ModelResource();
+	~ModelResource() = default;
 
 	ConstWeakArray<ModelPatch> getModelPatches() const
 	{
@@ -141,7 +140,7 @@ public:
 	Error load(const ResourceFilename& filename, Bool async);
 
 private:
-	DynamicArray<ModelPatch> m_modelPatches;
+	ResourceDynamicArray<ModelPatch> m_modelPatches;
 	Aabb m_boundingVolume;
 };
 /// @}

+ 2 - 11
AnKi/Resource/ParticleEmitterResource.cpp

@@ -24,18 +24,9 @@ Error getXmlVal(const XmlElement& el, const CString& tag, Vec3& out, Bool& found
 	return el.getAttributeNumbersOptional(tag, out, found);
 }
 
-ParticleEmitterResource::ParticleEmitterResource(ResourceManager* manager)
-	: ResourceObject(manager)
-{
-}
-
-ParticleEmitterResource::~ParticleEmitterResource()
-{
-}
-
 Error ParticleEmitterResource::load(const ResourceFilename& filename, Bool async)
 {
-	XmlDocument doc(&getTempMemoryPool());
+	XmlDocument doc(&ResourceMemoryPool::getSingleton());
 	ANKI_CHECK(openFileParseXml(filename, doc));
 	XmlElement rootEl; // Root element
 	ANKI_CHECK(doc.getChildElement("particleEmitter", rootEl));
@@ -83,7 +74,7 @@ Error ParticleEmitterResource::load(const ResourceFilename& filename, Bool async
 	CString cstr;
 	ANKI_CHECK(rootEl.getChildElement("material", el));
 	ANKI_CHECK(el.getAttributeText("value", cstr));
-	ANKI_CHECK(getManager().loadResource(cstr, m_material, async));
+	ANKI_CHECK(ResourceManager::getSingleton().loadResource(cstr, m_material, async));
 
 	return Error::kNone;
 }

+ 2 - 2
AnKi/Resource/ParticleEmitterResource.h

@@ -103,9 +103,9 @@ public:
 class ParticleEmitterResource : public ResourceObject, private ParticleEmitterProperties
 {
 public:
-	ParticleEmitterResource(ResourceManager* manager);
+	ParticleEmitterResource() = default;
 
-	~ParticleEmitterResource();
+	~ParticleEmitterResource() = default;
 
 	const ParticleEmitterProperties& getProperties() const
 	{

+ 24 - 42
AnKi/Resource/ResourceFilesystem.cpp

@@ -20,18 +20,13 @@ class CResourceFile final : public ResourceFile
 public:
 	File m_file;
 
-	CResourceFile(HeapMemoryPool* pool)
-		: ResourceFile(pool)
-	{
-	}
-
 	Error read(void* buff, PtrSize size) override
 	{
 		ANKI_TRACE_SCOPED_EVENT(RsrcFileRead);
 		return m_file.read(buff, size);
 	}
 
-	Error readAllText(StringRaii& out) override
+	Error readAllText(ResourceString& out) override
 	{
 		ANKI_TRACE_SCOPED_EVENT(RsrcFileRead);
 		return m_file.readAllText(out);
@@ -67,11 +62,6 @@ public:
 	unzFile m_archive = nullptr;
 	PtrSize m_size = 0;
 
-	ZipResourceFile(HeapMemoryPool* pool)
-		: ResourceFile(pool)
-	{
-	}
-
 	~ZipResourceFile()
 	{
 		if(m_archive)
@@ -143,7 +133,7 @@ public:
 		return Error::kNone;
 	}
 
-	Error readAllText(StringRaii& out) override
+	Error readAllText(ResourceString& out) override
 	{
 		ANKI_ASSERT(m_size);
 		out.create('?', m_size);
@@ -197,28 +187,19 @@ public:
 
 ResourceFilesystem::~ResourceFilesystem()
 {
-	for(Path& p : m_paths)
-	{
-		p.m_files.destroy(m_pool);
-		p.m_path.destroy(m_pool);
-	}
-
-	m_paths.destroy(m_pool);
-	m_cacheDir.destroy(m_pool);
 }
 
-Error ResourceFilesystem::init(AllocAlignedCallback allocCallback, void* allocCallbackUserData)
+Error ResourceFilesystem::init()
 {
-	m_pool.init(allocCallback, allocCallbackUserData);
-	StringListRaii paths(&m_pool);
+	ResourceStringList paths;
 	paths.splitString(ConfigSet::getSingleton().getRsrcDataPaths(), ':');
 
-	StringListRaii excludedStrings(&m_pool);
+	ResourceStringList excludedStrings;
 	excludedStrings.splitString(ConfigSet::getSingleton().getRsrcDataPathExcludedStrings(), ':');
 
 	// Workaround the fact that : is used in drives in Windows
 #if ANKI_OS_WINDOWS
-	StringListRaii paths2(&m_pool);
+	ResourceStringList paths2;
 	StringListRaii::Iterator it = paths.getBegin();
 	while(it != paths.getEnd())
 	{
@@ -260,7 +241,7 @@ Error ResourceFilesystem::init(AllocAlignedCallback allocCallback, void* allocCa
 	return Error::kNone;
 }
 
-Error ResourceFilesystem::addNewPath(const CString& filepath, const StringListRaii& excludedStrings)
+Error ResourceFilesystem::addNewPath(const CString& filepath, const ResourceStringList& excludedStrings)
 {
 	ANKI_RESOURCE_LOGV("Adding new resource path: %s", filepath.cstr());
 
@@ -316,7 +297,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("%s", &filename[0]);
 				++fileCount;
 			}
 		} while(unzGoToNextFile(zfile) == UNZ_OK);
@@ -329,15 +310,16 @@ 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 {
-			if(!isDir && !rejectPath(fname))
-			{
-				path.m_files.pushBackSprintf(m_pool, "%s", fname.cstr());
-				++fileCount;
-			}
+		ANKI_CHECK(walkDirectoryTree(filepath, ResourceMemoryPool::getSingleton(),
+									 [&, this](const CString& fname, Bool isDir) -> Error {
+										 if(!isDir && !rejectPath(fname))
+										 {
+											 path.m_files.pushBackSprintf("%s", fname.cstr());
+											 ++fileCount;
+										 }
 
-			return Error::kNone;
-		}));
+										 return Error::kNone;
+									 }));
 	}
 
 	ANKI_ASSERT(path.m_files.getSize() == fileCount);
@@ -347,8 +329,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("%s", &filepath[0]);
+		m_paths.emplaceFront(std::move(path));
 
 		ANKI_RESOURCE_LOGI("Added new data path \"%s\" that contains %u files", &filepath[0], fileCount);
 	}
@@ -372,7 +354,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(ResourceMemoryPool::getSingleton(), rfile);
 	}
 	else
 	{
@@ -400,17 +382,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>(ResourceMemoryPool::getSingleton());
 				rfile = file;
 
 				ANKI_CHECK(file->open(p.m_path.toCString(), filename));
 			}
 			else
 			{
-				StringRaii newFname(&m_pool);
+				ResourceString newFname;
 				newFname.sprintf("%s/%s", &p.m_path[0], &filename[0]);
 
-				CResourceFile* file = newInstance<CResourceFile>(m_pool, &m_pool);
+				CResourceFile* file = newInstance<CResourceFile>(ResourceMemoryPool::getSingleton());
 				rfile = file;
 				ANKI_CHECK(file->m_file.open(newFname, FileOpenFlag::kRead));
 
@@ -429,7 +411,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>(ResourceMemoryPool::getSingleton());
 		rfile = file;
 
 		FileOpenFlag openFlags = FileOpenFlag::kRead;

+ 18 - 20
AnKi/Resource/ResourceFilesystem.h

@@ -20,11 +20,7 @@ namespace anki {
 class ResourceFile
 {
 public:
-	ResourceFile(HeapMemoryPool* pool)
-		: m_pool(pool)
-	{
-		ANKI_ASSERT(pool);
-	}
+	ResourceFile() = default;
 
 	ResourceFile(const ResourceFile&) = delete; // Non-copyable
 
@@ -38,7 +34,7 @@ public:
 	virtual Error read(void* buff, PtrSize size) = 0;
 
 	/// Read all the contents of a text file. If the file is not rewined it will probably fail
-	virtual Error readAllText(StringRaii& out) = 0;
+	virtual Error readAllText(ResourceString& out) = 0;
 
 	/// Read 32bit unsigned integer. Set the endianness if the file's endianness is different from the machine's
 	virtual Error readU32(U32& u) = 0;
@@ -64,18 +60,21 @@ public:
 		return m_refcount.fetchSub(1);
 	}
 
-	HeapMemoryPool& getMemoryPool() const
-	{
-		return *m_pool;
-	}
-
 private:
-	mutable HeapMemoryPool* m_pool = nullptr;
 	mutable Atomic<I32> m_refcount = {0};
 };
 
 /// Resource file smart pointer.
-using ResourceFilePtr = IntrusivePtr<ResourceFile>;
+class ResourceFileDeleter
+{
+public:
+	void operator()(ResourceFile* x)
+	{
+		deleteInstance(ResourceMemoryPool::getSingleton(), x);
+	}
+};
+
+using ResourceFilePtr = IntrusivePtr<ResourceFile, ResourceFileDeleter>;
 
 /// Resource filesystem.
 class ResourceFilesystem
@@ -89,7 +88,7 @@ public:
 
 	ResourceFilesystem& operator=(const ResourceFilesystem&) = delete; // Non-copyable
 
-	Error init(AllocAlignedCallback allocCallback, void* allocCallbackUserData);
+	Error init();
 
 	/// 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);
@@ -114,8 +113,8 @@ private:
 	class Path
 	{
 	public:
-		StringList m_files; ///< Files inside the directory.
-		String m_path; ///< A directory or an archive.
+		ResourceStringList m_files; ///< Files inside the directory.
+		ResourceString m_path; ///< A directory or an archive.
 		Bool m_isArchive = false;
 
 		Path() = default;
@@ -138,12 +137,11 @@ private:
 		}
 	};
 
-	HeapMemoryPool m_pool;
-	List<Path> m_paths;
-	String m_cacheDir;
+	ResourceList<Path> m_paths;
+	ResourceString m_cacheDir;
 
 	/// Add a filesystem path or an archive. The path is read-only.
-	Error addNewPath(const CString& path, const StringListRaii& excludedStrings);
+	Error addNewPath(const CString& path, const ResourceStringList& excludedStrings);
 
 	Error openFileInternal(const ResourceFilename& filename, ResourceFile*& rfile);
 };

+ 22 - 40
AnKi/Resource/ResourceManager.cpp

@@ -33,37 +33,35 @@ ResourceManager::~ResourceManager()
 {
 	ANKI_RESOURCE_LOGI("Destroying resource manager");
 
-	deleteInstance(m_pool, m_asyncLoader);
-	deleteInstance(m_pool, m_shaderProgramSystem);
-	deleteInstance(m_pool, m_transferGpuAlloc);
+	deleteInstance(ResourceMemoryPool::getSingleton(), m_asyncLoader);
+	deleteInstance(ResourceMemoryPool::getSingleton(), m_shaderProgramSystem);
+	deleteInstance(ResourceMemoryPool::getSingleton(), m_transferGpuAlloc);
+	deleteInstance(ResourceMemoryPool::getSingleton(), m_fs);
+
+	ResourceMemoryPool::freeSingleton();
 }
 
 Error ResourceManager::init(ResourceManagerInitInfo& init)
 {
 	ANKI_RESOURCE_LOGI("Initializing resource manager");
-	m_subsystems = init;
 
-	m_pool.init(init.m_allocCallback, init.m_allocCallbackData, "Resources");
-	m_tmpPool.init(init.m_allocCallback, init.m_allocCallbackData, 10_MB);
+	ResourceMemoryPool::allocateSingleton(init.m_allocCallback, init.m_allocCallbackData);
 
-	// Init type resource managers
-#define ANKI_INSTANTIATE_RESOURCE(rsrc_, ptr_) TypeResourceManager<rsrc_>::init(&m_pool);
-#define ANKI_INSTANSIATE_RESOURCE_DELIMITER()
-#include <AnKi/Resource/InstantiationMacros.h>
-#undef ANKI_INSTANTIATE_RESOURCE
-#undef ANKI_INSTANSIATE_RESOURCE_DELIMITER
+	m_subsystems = init;
+
+	m_fs = newInstance<ResourceFilesystem>(ResourceMemoryPool::getSingleton());
+	ANKI_CHECK(m_fs->init());
 
 	// Init the thread
-	m_asyncLoader = newInstance<AsyncLoader>(m_pool);
-	m_asyncLoader->init(&m_pool);
+	m_asyncLoader = newInstance<AsyncLoader>(ResourceMemoryPool::getSingleton());
 
-	m_transferGpuAlloc = newInstance<TransferGpuAllocator>(m_pool);
+	m_transferGpuAlloc = newInstance<TransferGpuAllocator>(ResourceMemoryPool::getSingleton());
 	ANKI_CHECK(m_transferGpuAlloc->init(ConfigSet::getSingleton().getRsrcTransferScratchMemorySize(),
-										m_subsystems.m_grManager, &m_pool));
+										m_subsystems.m_grManager));
 
 	// Init the programs
-	m_shaderProgramSystem = newInstance<ShaderProgramResourceSystem>(m_pool, &m_pool);
-	ANKI_CHECK(m_shaderProgramSystem->init(*m_subsystems.m_resourceFilesystem, *m_subsystems.m_grManager));
+	m_shaderProgramSystem = newInstance<ShaderProgramResourceSystem>(ResourceMemoryPool::getSingleton());
+	ANKI_CHECK(m_shaderProgramSystem->init(*m_subsystems.m_grManager));
 
 	return Error::kNone;
 }
@@ -91,39 +89,23 @@ Error ResourceManager::loadResource(const CString& filename, ResourcePtr<T>& out
 	else
 	{
 		// Allocate ptr
-		T* ptr = newInstance<T>(m_pool, this);
+		T* ptr = newInstance<T>(ResourceMemoryPool::getSingleton());
 		ANKI_ASSERT(ptr->getRefcount() == 0);
 
 		// Increment the refcount in that case where async jobs increment it and decrement it in the scope of a load()
 		ptr->retain();
 
-		// Populate the ptr. Use a block to cleanup temp_pool allocations
-		StackMemoryPool& tmpPool = m_tmpPool;
-
+		err = ptr->load(filename, async);
+		if(err)
 		{
-			[[maybe_unused]] const U allocsCountBefore = tmpPool.getAllocationCount();
-
-			err = ptr->load(filename, async);
-			if(err)
-			{
-				ANKI_RESOURCE_LOGE("Failed to load resource: %s", &filename[0]);
-				deleteInstance(m_pool, ptr);
-				return err;
-			}
-
-			ANKI_ASSERT(tmpPool.getAllocationCount() == allocsCountBefore && "Forgot to deallocate");
+			ANKI_RESOURCE_LOGE("Failed to load resource: %s", &filename[0]);
+			deleteInstance(ResourceMemoryPool::getSingleton(), ptr);
+			return err;
 		}
 
 		ptr->setFilename(filename);
 		ptr->setUuid(++m_uuid);
 
-		// Reset the memory pool if no-one is using it.
-		// NOTE: Check because resources load other resources
-		if(tmpPool.getAllocationCount() == 0)
-		{
-			tmpPool.reset();
-		}
-
 		// Register resource
 		registerResource(ptr);
 		out.reset(ptr);

+ 27 - 30
AnKi/Resource/ResourceManager.h

@@ -6,6 +6,7 @@
 #pragma once
 
 #include <AnKi/Resource/TransferGpuAllocator.h>
+#include <AnKi/Resource/ResourceFilesystem.h>
 #include <AnKi/Util/List.h>
 #include <AnKi/Util/Functions.h>
 #include <AnKi/Util/String.h>
@@ -37,7 +38,7 @@ protected:
 	~TypeResourceManager()
 	{
 		ANKI_ASSERT(m_ptrs.isEmpty() && "Forgot to delete some resources");
-		m_ptrs.destroy(*m_pool);
+		m_ptrs.destroy();
 	}
 
 	Type* findLoadedResource(const CString& filename)
@@ -49,26 +50,19 @@ protected:
 	void registerResource(Type* ptr)
 	{
 		ANKI_ASSERT(find(ptr->getFilename()) == m_ptrs.getEnd());
-		m_ptrs.pushBack(*m_pool, ptr);
+		m_ptrs.pushBack(ptr);
 	}
 
 	void unregisterResource(Type* ptr)
 	{
 		auto it = find(ptr->getFilename());
 		ANKI_ASSERT(it != m_ptrs.end());
-		m_ptrs.erase(*m_pool, it);
-	}
-
-	void init(HeapMemoryPool* pool)
-	{
-		ANKI_ASSERT(pool);
-		m_pool = pool;
+		m_ptrs.erase(it);
 	}
 
 private:
-	using Container = List<Type*>;
+	using Container = ResourceList<Type*>;
 
-	HeapMemoryPool* m_pool = nullptr;
 	Container m_ptrs;
 
 	typename Container::Iterator find(const CString& filename)
@@ -95,7 +89,7 @@ public:
 };
 
 /// Resource manager. It holds a few global variables
-class ResourceManager:
+class ResourceManager : public MakeSingleton<ResourceManager>,
 
 #define ANKI_INSTANTIATE_RESOURCE(rsrc_, ptr_) \
 public \
@@ -112,11 +106,10 @@ public \
 	friend class ResourcePtrDeleter;
 	friend class ResourceObject;
 
-public:
-	ResourceManager();
-
-	~ResourceManager();
+	template<typename>
+	friend class MakeSingleton;
 
+public:
 	Error init(ResourceManagerInitInfo& init);
 
 	/// Load a resource.
@@ -125,16 +118,6 @@ public:
 
 	// Internals:
 
-	ANKI_INTERNAL HeapMemoryPool& getMemoryPool() const
-	{
-		return m_pool;
-	}
-
-	ANKI_INTERNAL StackMemoryPool& getTempMemoryPool() const
-	{
-		return m_tmpPool;
-	}
-
 	ANKI_INTERNAL TransferGpuAllocator& getTransferGpuAllocator()
 	{
 		return *m_transferGpuAlloc;
@@ -173,20 +156,34 @@ public:
 	ANKI_INTERNAL U64 getAsyncTaskCompletedCount() const;
 
 	/// Return the container of program libraries.
-	const ShaderProgramResourceSystem& getShaderProgramResourceSystem() const
+	ANKI_INTERNAL const ShaderProgramResourceSystem& getShaderProgramResourceSystem() const
 	{
 		return *m_shaderProgramSystem;
 	}
 
+	ANKI_INTERNAL ResourceFilesystem& getFilesystem()
+	{
+		return *m_fs;
+	}
+
+	ResourceManagerExternalSubsystems& getExternalSubsystems()
+	{
+		return m_subsystems;
+	}
+
 private:
 	ResourceManagerExternalSubsystems m_subsystems;
-	mutable HeapMemoryPool m_pool; ///< Mutable because it's thread-safe and is may be called by const methods.
-	mutable StackMemoryPool m_tmpPool; ///< Same as above.
+	ResourceFilesystem* m_fs = nullptr;
 	AsyncLoader* m_asyncLoader = nullptr; ///< Async loading thread
 	ShaderProgramResourceSystem* m_shaderProgramSystem = nullptr;
+	TransferGpuAllocator* m_transferGpuAlloc = nullptr;
+
 	U64 m_uuid = 0;
 	U64 m_loadRequestCount = 0;
-	TransferGpuAllocator* m_transferGpuAlloc = nullptr;
+
+	ResourceManager();
+
+	~ResourceManager();
 };
 /// @}
 

+ 4 - 30
AnKi/Resource/ResourceObject.cpp

@@ -9,37 +9,16 @@
 
 namespace anki {
 
-ResourceObject::ResourceObject(ResourceManager* manager)
-	: m_manager(manager)
-	, m_refcount(0)
-{
-}
-
-ResourceObject::~ResourceObject()
-{
-	m_fname.destroy(getMemoryPool());
-}
-
-HeapMemoryPool& ResourceObject::getMemoryPool() const
-{
-	return m_manager->getMemoryPool();
-}
-
-StackMemoryPool& ResourceObject::getTempMemoryPool() const
-{
-	return m_manager->getTempMemoryPool();
-}
-
 Error ResourceObject::openFile(const CString& filename, ResourceFilePtr& file)
 {
-	return getExternalSubsystems().m_resourceFilesystem->openFile(filename, file);
+	return ResourceManager::getSingleton().getFilesystem().openFile(filename, file);
 }
 
-Error ResourceObject::openFileReadAllText(const CString& filename, StringRaii& text)
+Error ResourceObject::openFileReadAllText(const CString& filename, ResourceString& text)
 {
 	// Load file
 	ResourceFilePtr file;
-	ANKI_CHECK(getExternalSubsystems().m_resourceFilesystem->openFile(filename, file));
+	ANKI_CHECK(ResourceManager::getSingleton().getFilesystem().openFile(filename, file));
 
 	// Read string
 	ANKI_CHECK(file->readAllText(text));
@@ -49,7 +28,7 @@ Error ResourceObject::openFileReadAllText(const CString& filename, StringRaii& t
 
 Error ResourceObject::openFileParseXml(const CString& filename, XmlDocument& xml)
 {
-	StringRaii txt(&xml.getMemoryPool());
+	ResourceString txt;
 	ANKI_CHECK(openFileReadAllText(filename, txt));
 
 	ANKI_CHECK(xml.parse(txt.toCString()));
@@ -57,9 +36,4 @@ Error ResourceObject::openFileParseXml(const CString& filename, XmlDocument& xml
 	return Error::kNone;
 }
 
-ResourceManagerExternalSubsystems& ResourceObject::getExternalSubsystems() const
-{
-	return m_manager->m_subsystems;
-}
-
 } // end namespace anki

+ 5 - 19
AnKi/Resource/ResourceObject.h

@@ -27,12 +27,7 @@ class ResourceObject
 	friend class ResourcePtrDeleter;
 
 public:
-	ResourceObject(ResourceManager* manager);
-
-	virtual ~ResourceObject();
-
-	HeapMemoryPool& getMemoryPool() const;
-	StackMemoryPool& getTempMemoryPool() const;
+	virtual ~ResourceObject() = default;
 
 	void retain() const
 	{
@@ -60,7 +55,7 @@ public:
 	ANKI_INTERNAL void setFilename(const CString& fname)
 	{
 		ANKI_ASSERT(m_fname.isEmpty());
-		m_fname.create(getMemoryPool(), fname);
+		m_fname.create(fname);
 	}
 
 	ANKI_INTERNAL void setUuid(U64 uuid)
@@ -78,22 +73,13 @@ public:
 
 	ANKI_INTERNAL Error openFile(const ResourceFilename& filename, ResourceFilePtr& file);
 
-	ANKI_INTERNAL Error openFileReadAllText(const ResourceFilename& filename, StringRaii& file);
+	ANKI_INTERNAL Error openFileReadAllText(const ResourceFilename& filename, ResourceString& file);
 
 	ANKI_INTERNAL Error openFileParseXml(const ResourceFilename& filename, XmlDocument& xml);
 
-protected:
-	ResourceManager& getManager() const
-	{
-		return *m_manager;
-	}
-
-	ResourceManagerExternalSubsystems& getExternalSubsystems() const;
-
 private:
-	ResourceManager* m_manager;
-	mutable Atomic<I32> m_refcount;
-	String m_fname; ///< Unique resource name.
+	mutable Atomic<I32> m_refcount = {0};
+	ResourceString m_fname; ///< Unique resource name.
 	U64 m_uuid = 0;
 };
 /// @}

+ 1 - 6
AnKi/Resource/ScriptResource.cpp

@@ -8,17 +8,12 @@
 
 namespace anki {
 
-ScriptResource::~ScriptResource()
-{
-	m_source.destroy(getMemoryPool());
-}
-
 Error ScriptResource::load(const ResourceFilename& filename, [[maybe_unused]] Bool async)
 {
 	ResourceFilePtr file;
 	ANKI_CHECK(openFile(filename, file));
 
-	StringRaii src(&getMemoryPool());
+	ResourceString src;
 	ANKI_CHECK(file->readAllText(src));
 	m_source = std::move(src);
 

+ 3 - 6
AnKi/Resource/ScriptResource.h

@@ -16,12 +16,9 @@ namespace anki {
 class ScriptResource : public ResourceObject
 {
 public:
-	ScriptResource(ResourceManager* manager)
-		: ResourceObject(manager)
-	{
-	}
+	ScriptResource() = default;
 
-	~ScriptResource();
+	~ScriptResource() = default;
 
 	Error load(const ResourceFilename& filename, Bool async);
 
@@ -31,7 +28,7 @@ public:
 	}
 
 private:
-	String m_source;
+	ResourceString m_source;
 };
 /// @}
 

+ 16 - 24
AnKi/Resource/ShaderProgramResource.cpp

@@ -22,29 +22,18 @@ ShaderProgramResourceVariant::~ShaderProgramResourceVariant()
 {
 }
 
-ShaderProgramResource::ShaderProgramResource(ResourceManager* manager)
-	: ResourceObject(manager)
-	, m_binary(&getMemoryPool())
+ShaderProgramResource::ShaderProgramResource()
+	: m_binary(&ResourceMemoryPool::getSingleton())
 {
 }
 
 ShaderProgramResource::~ShaderProgramResource()
 {
-	m_mutators.destroy(getMemoryPool());
-
-	for(ShaderProgramResourceConstant& c : m_consts)
-	{
-		c.m_name.destroy(getMemoryPool());
-	}
-	m_consts.destroy(getMemoryPool());
-	m_constBinaryMapping.destroy(getMemoryPool());
-
 	for(auto it : m_variants)
 	{
 		ShaderProgramResourceVariant* variant = &(*it);
-		deleteInstance(getMemoryPool(), variant);
+		deleteInstance(ResourceMemoryPool::getSingleton(), variant);
 	}
-	m_variants.destroy(getMemoryPool());
 }
 
 Error ShaderProgramResource::load(const ResourceFilename& filename, [[maybe_unused]] Bool async)
@@ -58,7 +47,7 @@ Error ShaderProgramResource::load(const ResourceFilename& filename, [[maybe_unus
 	// Create the mutators
 	if(binary.m_mutators.getSize() > 0)
 	{
-		m_mutators.create(getMemoryPool(), binary.m_mutators.getSize());
+		m_mutators.create(binary.m_mutators.getSize());
 
 		for(U32 i = 0; i < binary.m_mutators.getSize(); ++i)
 		{
@@ -90,7 +79,7 @@ Error ShaderProgramResource::load(const ResourceFilename& filename, [[maybe_unus
 			mapping.m_constsIdx = m_consts.getSize();
 		}
 
-		m_constBinaryMapping.emplaceBack(getMemoryPool(), mapping);
+		m_constBinaryMapping.emplaceBack(mapping);
 
 		// Skip if const is there
 		if(componentIdx > 0)
@@ -99,8 +88,8 @@ Error ShaderProgramResource::load(const ResourceFilename& filename, [[maybe_unus
 		}
 
 		// Create new one
-		ShaderProgramResourceConstant& in = *m_consts.emplaceBack(getMemoryPool());
-		in.m_name.create(getMemoryPool(), name);
+		ShaderProgramResourceConstant& in = *m_consts.emplaceBack();
+		in.m_name.create(name);
 		in.m_index = m_consts.getSize() - 1;
 
 		if(componentCount == 1)
@@ -253,7 +242,7 @@ void ShaderProgramResource::getOrCreateVariant(const ShaderProgramResourceVarian
 	ShaderProgramResourceVariant* v = createNewVariant(info);
 	if(v)
 	{
-		m_variants.emplace(getMemoryPool(), hash, v);
+		m_variants.emplace(hash, v);
 	}
 	variant = v;
 }
@@ -294,7 +283,8 @@ ShaderProgramResource::createNewVariant(const ShaderProgramResourceVariantInitIn
 		binaryVariant = &binary.m_variants[0];
 	}
 	ANKI_ASSERT(binaryVariant);
-	ShaderProgramResourceVariant* variant = newInstance<ShaderProgramResourceVariant>(getMemoryPool());
+	ShaderProgramResourceVariant* variant =
+		newInstance<ShaderProgramResourceVariant>(ResourceMemoryPool::getSingleton());
 	variant->m_binaryVariant = binaryVariant;
 
 	// Set the constant values
@@ -371,7 +361,7 @@ ShaderProgramResource::createNewVariant(const ShaderProgramResourceVariantInitIn
 	if(!!(m_shaderStages & (ShaderTypeBit::kAllGraphics | ShaderTypeBit::kCompute)))
 	{
 		// Create the program name
-		StringRaii progName(&getTempMemoryPool());
+		StringRaii progName(&ResourceMemoryPool::getSingleton());
 		getFilepathFilename(getFilename(), progName);
 		char* cprogName = const_cast<char*>(progName.cstr());
 		if(progName.getLength() > kMaxGrObjectNameLength)
@@ -391,7 +381,7 @@ ShaderProgramResource::createNewVariant(const ShaderProgramResourceVariantInitIn
 			inf.m_shaderType = shaderType;
 			inf.m_binary = binary.m_codeBlocks[binaryVariant->m_codeBlockIndices[shaderType]].m_binary;
 			inf.m_constValues.setArray((constValueCount) ? constValues.getBegin() : nullptr, constValueCount);
-			ShaderPtr shader = getExternalSubsystems().m_grManager->newShader(inf);
+			ShaderPtr shader = ResourceManager::getSingleton().getExternalSubsystems().m_grManager->newShader(inf);
 
 			const ShaderTypeBit shaderBit = ShaderTypeBit(1 << shaderType);
 			if(!!(shaderBit & ShaderTypeBit::kAllGraphics))
@@ -409,7 +399,8 @@ ShaderProgramResource::createNewVariant(const ShaderProgramResourceVariantInitIn
 		}
 
 		// Create the program
-		variant->m_prog = getExternalSubsystems().m_grManager->newShaderProgram(progInf);
+		variant->m_prog =
+			ResourceManager::getSingleton().getExternalSubsystems().m_grManager->newShaderProgram(progInf);
 	}
 	else
 	{
@@ -419,7 +410,8 @@ ShaderProgramResource::createNewVariant(const ShaderProgramResourceVariantInitIn
 		CString libName = &binary.m_libraryName[0];
 		ANKI_ASSERT(libName.getLength() > 0);
 
-		const ShaderProgramResourceSystem& progSystem = getManager().getShaderProgramResourceSystem();
+		const ShaderProgramResourceSystem& progSystem =
+			ResourceManager::getSingleton().getShaderProgramResourceSystem();
 		const ShaderProgramRaytracingLibrary* foundLib = nullptr;
 		for(const ShaderProgramRaytracingLibrary& lib : progSystem.getRayTracingLibraries())
 		{

+ 6 - 6
AnKi/Resource/ShaderProgramResource.h

@@ -54,7 +54,7 @@ public:
 class ShaderProgramResourceConstant
 {
 public:
-	String m_name;
+	ResourceString m_name;
 	ShaderVariableDataType m_dataType = ShaderVariableDataType::kNone;
 	U32 m_index = kMaxU32;
 };
@@ -183,7 +183,7 @@ private:
 class ShaderProgramResource : public ResourceObject
 {
 public:
-	ShaderProgramResource(ResourceManager* manager);
+	ShaderProgramResource();
 
 	~ShaderProgramResource();
 
@@ -256,8 +256,8 @@ private:
 
 	ShaderProgramBinaryWrapper m_binary;
 
-	DynamicArray<Const> m_consts;
-	DynamicArray<Mutator> m_mutators;
+	ResourceDynamicArray<Const> m_consts;
+	ResourceDynamicArray<Mutator> m_mutators;
 
 	class ConstMapping
 	{
@@ -266,9 +266,9 @@ private:
 		U32 m_constsIdx = 0; ///< Index in m_consts
 	};
 
-	DynamicArray<ConstMapping> m_constBinaryMapping;
+	ResourceDynamicArray<ConstMapping> m_constBinaryMapping;
 
-	mutable HashMap<U64, ShaderProgramResourceVariant*> m_variants;
+	mutable ResourceHashMap<U64, ShaderProgramResourceVariant*> m_variants;
 	mutable RWMutex m_mtx;
 
 	ShaderTypeBit m_shaderStages = ShaderTypeBit::kNone;

+ 28 - 39
AnKi/Resource/ShaderProgramResourceSystem.cpp

@@ -5,6 +5,7 @@
 
 #include <AnKi/Resource/ShaderProgramResourceSystem.h>
 #include <AnKi/Resource/ResourceFilesystem.h>
+#include <AnKi/Resource/ResourceManager.h>
 #include <AnKi/Util/Tracer.h>
 #include <AnKi/Gr/GrManager.h>
 #include <AnKi/ShaderCompiler/ShaderProgramCompiler.h>
@@ -16,22 +17,16 @@
 
 namespace anki {
 
-U64 ShaderProgramRaytracingLibrary::generateShaderGroupGroupHash(CString resourceFilename, U64 mutationHash,
-																 HeapMemoryPool& pool)
+U64 ShaderProgramRaytracingLibrary::generateShaderGroupGroupHash(CString resourceFilename, U64 mutationHash)
 {
 	ANKI_ASSERT(resourceFilename.getLength() > 0);
-	StringRaii basename(&pool);
+	StringRaii basename(&ResourceMemoryPool::getSingleton());
 	getFilepathFilename(resourceFilename, basename);
 	const U64 hash = appendHash(basename.cstr(), basename.getLength(), mutationHash);
 	return hash;
 }
 
-ShaderProgramResourceSystem::~ShaderProgramResourceSystem()
-{
-	m_rtLibraries.destroy(*m_pool);
-}
-
-Error ShaderProgramResourceSystem::init(ResourceFilesystem& fs, GrManager& gr)
+Error ShaderProgramResourceSystem::init(GrManager& gr)
 {
 	if(!gr.getDeviceCapabilities().m_rayTracingEnabled)
 	{
@@ -39,7 +34,7 @@ Error ShaderProgramResourceSystem::init(ResourceFilesystem& fs, GrManager& gr)
 	}
 
 	// Create RT pipeline libraries
-	const Error err = createRayTracingPrograms(fs, gr, *m_pool, m_rtLibraries);
+	const Error err = createRayTracingPrograms(gr, m_rtLibraries);
 	if(err)
 	{
 		ANKI_RESOURCE_LOGE("Failed to create ray tracing programs");
@@ -48,8 +43,8 @@ Error ShaderProgramResourceSystem::init(ResourceFilesystem& fs, GrManager& gr)
 	return err;
 }
 
-Error ShaderProgramResourceSystem::createRayTracingPrograms(ResourceFilesystem& fs, GrManager& gr, HeapMemoryPool& pool,
-															DynamicArray<ShaderProgramRaytracingLibrary>& outLibs)
+Error ShaderProgramResourceSystem::createRayTracingPrograms(
+	GrManager& gr, ResourceDynamicArray<ShaderProgramRaytracingLibrary>& outLibs)
 {
 	ANKI_RESOURCE_LOGI("Creating ray tracing programs");
 	U32 rtProgramCount = 0;
@@ -74,11 +69,10 @@ Error ShaderProgramResourceSystem::createRayTracingPrograms(ResourceFilesystem&
 	class Lib
 	{
 	public:
-		HeapMemoryPool* m_pool = nullptr;
 		GrManager* m_gr;
-		StringRaii m_name = {m_pool};
-		DynamicArrayRaii<Shader> m_shaders = {m_pool};
-		DynamicArrayRaii<ShaderGroup> m_shaderGroups = {m_pool};
+		ResourceString m_name;
+		ResourceDynamicArray<Shader> m_shaders;
+		ResourceDynamicArray<ShaderGroup> m_shaderGroups;
 		ShaderTypeBit m_presentStages = ShaderTypeBit::kNone;
 		U32 m_rayTypeCount = 0;
 		BitSet<64> m_rayTypeMask = {false};
@@ -86,11 +80,9 @@ Error ShaderProgramResourceSystem::createRayTracingPrograms(ResourceFilesystem&
 		U32 m_missShaderGroupCount = 0;
 		U32 m_hitShaderGroupCount = 0;
 
-		Lib(HeapMemoryPool* pool, GrManager* gr)
-			: m_pool(pool)
-			, m_gr(gr)
+		Lib(GrManager* gr)
+			: m_gr(gr)
 		{
-			ANKI_ASSERT(pool);
 		}
 
 		U32 addShader(const ShaderProgramBinaryCodeBlock& codeBlock, CString progName, ShaderType shaderType)
@@ -123,8 +115,7 @@ Error ShaderProgramResourceSystem::createRayTracingPrograms(ResourceFilesystem&
 
 		void addGroup(CString filename, U64 mutationHash, U32 rayGen, U32 miss, U32 chit, U32 ahit)
 		{
-			const U64 groupHash =
-				ShaderProgramRaytracingLibrary::generateShaderGroupGroupHash(filename, mutationHash, *m_pool);
+			const U64 groupHash = ShaderProgramRaytracingLibrary::generateShaderGroupGroupHash(filename, mutationHash);
 #if ANKI_ENABLE_ASSERTIONS
 			for(const ShaderGroup& group : m_shaderGroups)
 			{
@@ -156,11 +147,11 @@ Error ShaderProgramResourceSystem::createRayTracingPrograms(ResourceFilesystem&
 		}
 	};
 
-	DynamicArrayRaii<Lib> libs(&pool);
+	ResourceDynamicArray<Lib> libs;
 
-	ANKI_CHECK(fs.iterateAllFilenames([&](CString filename) -> Error {
+	ANKI_CHECK(ResourceManager::getSingleton().getFilesystem().iterateAllFilenames([&](CString filename) -> Error {
 		// Check file extension
-		StringRaii extension(&pool);
+		StringRaii extension(&ResourceMemoryPool::getSingleton());
 		getFilepathExtension(filename, extension);
 		const Char binExtension[] = "ankiprogbin";
 		if(extension.getLength() != sizeof(binExtension) - 1 || extension != binExtension)
@@ -176,8 +167,8 @@ Error ShaderProgramResourceSystem::createRayTracingPrograms(ResourceFilesystem&
 
 		// Get the binary
 		ResourceFilePtr file;
-		ANKI_CHECK(fs.openFile(filename, file));
-		ShaderProgramBinaryWrapper binaryw(&pool);
+		ANKI_CHECK(ResourceManager::getSingleton().getFilesystem().openFile(filename, file));
+		ShaderProgramBinaryWrapper binaryw(&ResourceMemoryPool::getSingleton());
 		ANKI_CHECK(binaryw.deserializeFromAnyFile(*file));
 		const ShaderProgramBinary& binary = binaryw.getBinary();
 
@@ -194,7 +185,7 @@ Error ShaderProgramResourceSystem::createRayTracingPrograms(ResourceFilesystem&
 		}
 
 		// Create the program name
-		StringRaii progName(&pool);
+		StringRaii progName(&ResourceMemoryPool::getSingleton());
 		getFilepathFilename(filename, progName);
 
 		// Find or create the lib
@@ -211,7 +202,7 @@ Error ShaderProgramResourceSystem::createRayTracingPrograms(ResourceFilesystem&
 
 			if(lib == nullptr)
 			{
-				libs.emplaceBack(&pool, &gr);
+				libs.emplaceBack(&gr);
 				lib = &libs.getBack();
 				lib->m_name.create(CString(&binary.m_libraryName[0]));
 			}
@@ -371,15 +362,13 @@ Error ShaderProgramResourceSystem::createRayTracingPrograms(ResourceFilesystem&
 	// See the ShaderProgram class for info.
 	if(libs.getSize() != 0)
 	{
-		outLibs.create(pool, libs.getSize());
+		outLibs.create(libs.getSize());
 
 		for(U32 libIdx = 0; libIdx < libs.getSize(); ++libIdx)
 		{
 			ShaderProgramRaytracingLibrary& outLib = outLibs[libIdx];
 			const Lib& inLib = libs[libIdx];
 
-			outLib.m_pool = &pool;
-
 			if(inLib.m_presentStages
 			   != (ShaderTypeBit::kRayGen | ShaderTypeBit::kMiss | ShaderTypeBit::kClosestHit | ShaderTypeBit::kAnyHit))
 			{
@@ -393,12 +382,12 @@ Error ShaderProgramResourceSystem::createRayTracingPrograms(ResourceFilesystem&
 				return Error::kUserData;
 			}
 
-			outLib.m_libraryName.create(pool, inLib.m_name);
+			outLib.m_libraryName.create(inLib.m_name);
 			outLib.m_rayTypeCount = inLib.m_rayTypeCount;
 
-			DynamicArrayRaii<RayTracingHitGroup> initInfoHitGroups(&pool);
-			DynamicArrayRaii<ShaderPtr> missShaders(&pool);
-			DynamicArrayRaii<ShaderPtr> rayGenShaders(&pool);
+			ResourceDynamicArray<RayTracingHitGroup> initInfoHitGroups;
+			ResourceDynamicArray<ShaderPtr> missShaders;
+			ResourceDynamicArray<ShaderPtr> rayGenShaders;
 
 			// Add the hitgroups to the init info
 			for(U32 shaderGroupIdx = 0; shaderGroupIdx < inLib.m_shaderGroups.getSize(); ++shaderGroupIdx)
@@ -426,7 +415,7 @@ Error ShaderProgramResourceSystem::createRayTracingPrograms(ResourceFilesystem&
 					// The hit shaders are after ray gen and miss shaders
 					const U32 idx =
 						inLib.m_rayGenShaderGroupCount + inLib.m_missShaderGroupCount + initInfoHitGroups.getSize() - 1;
-					outLib.m_resourceHashToShaderGroupHandleIndex.emplace(pool, inShaderGroup.m_hitGroupHash, idx);
+					outLib.m_resourceHashToShaderGroupHandleIndex.emplace(inShaderGroup.m_hitGroupHash, idx);
 				}
 				else if(inShaderGroup.m_miss < kMaxU32)
 				{
@@ -439,7 +428,7 @@ Error ShaderProgramResourceSystem::createRayTracingPrograms(ResourceFilesystem&
 
 					// The miss shaders are after ray gen
 					const U32 idx = inLib.m_rayGenShaderGroupCount + missShaders.getSize() - 1;
-					outLib.m_resourceHashToShaderGroupHandleIndex.emplace(pool, inShaderGroup.m_hitGroupHash, idx);
+					outLib.m_resourceHashToShaderGroupHandleIndex.emplace(inShaderGroup.m_hitGroupHash, idx);
 				}
 				else
 				{
@@ -452,7 +441,7 @@ Error ShaderProgramResourceSystem::createRayTracingPrograms(ResourceFilesystem&
 
 					// Ray gen shaders are first
 					const U32 idx = rayGenShaders.getSize() - 1;
-					outLib.m_resourceHashToShaderGroupHandleIndex.emplace(pool, inShaderGroup.m_hitGroupHash, idx);
+					outLib.m_resourceHashToShaderGroupHandleIndex.emplace(inShaderGroup.m_hitGroupHash, idx);
 				}
 			} // end for all groups
 

+ 9 - 20
AnKi/Resource/ShaderProgramResourceSystem.h

@@ -22,12 +22,6 @@ class ShaderProgramRaytracingLibrary
 	friend class ShaderProgramResourceSystem;
 
 public:
-	~ShaderProgramRaytracingLibrary()
-	{
-		m_libraryName.destroy(*m_pool);
-		m_resourceHashToShaderGroupHandleIndex.destroy(*m_pool);
-	}
-
 	CString getLibraryName() const
 	{
 		return m_libraryName;
@@ -48,18 +42,17 @@ public:
 	/// handle index.
 	U32 getShaderGroupHandleIndex(CString resourceFilename, U64 mutationHash) const
 	{
-		return getIndex(generateShaderGroupGroupHash(resourceFilename, mutationHash, *m_pool));
+		return getIndex(generateShaderGroupGroupHash(resourceFilename, mutationHash));
 	}
 
 private:
-	HeapMemoryPool* m_pool = nullptr;
-	String m_libraryName;
+	ResourceString m_libraryName;
 	U32 m_rayTypeCount = kMaxU32;
 	ShaderProgramPtr m_program;
-	HashMap<U64, U32> m_resourceHashToShaderGroupHandleIndex;
+	ResourceHashMap<U64, U32> m_resourceHashToShaderGroupHandleIndex;
 
 	/// Given the filename of a program (that contains ray tracing shaders) and a specific mutation get a hash back.
-	static U64 generateShaderGroupGroupHash(CString resourceFilename, U64 mutationHash, HeapMemoryPool& pool);
+	static U64 generateShaderGroupGroupHash(CString resourceFilename, U64 mutationHash);
 
 	/// The hash generated by generateShaderGroupGroupHash() can be used to retrieve the group position in the
 	/// m_program.
@@ -75,15 +68,13 @@ private:
 class ShaderProgramResourceSystem
 {
 public:
-	ShaderProgramResourceSystem(HeapMemoryPool* pool)
-		: m_pool(pool)
+	ShaderProgramResourceSystem()
 	{
-		ANKI_ASSERT(pool);
 	}
 
-	~ShaderProgramResourceSystem();
+	~ShaderProgramResourceSystem() = default;
 
-	Error init(ResourceFilesystem& fs, GrManager& gr);
+	Error init(GrManager& gr);
 
 	ConstWeakArray<ShaderProgramRaytracingLibrary> getRayTracingLibraries() const
 	{
@@ -91,11 +82,9 @@ public:
 	}
 
 private:
-	HeapMemoryPool* m_pool = nullptr;
-	DynamicArray<ShaderProgramRaytracingLibrary> m_rtLibraries;
+	ResourceDynamicArray<ShaderProgramRaytracingLibrary> m_rtLibraries;
 
-	static Error createRayTracingPrograms(ResourceFilesystem& fs, GrManager& gr, HeapMemoryPool& pool,
-										  DynamicArray<ShaderProgramRaytracingLibrary>& outLibs);
+	static Error createRayTracingPrograms(GrManager& gr, ResourceDynamicArray<ShaderProgramRaytracingLibrary>& outLibs);
 };
 /// @}
 

+ 5 - 14
AnKi/Resource/SkeletonResource.cpp

@@ -4,24 +4,15 @@
 // http://www.anki3d.org/LICENSE
 
 #include <AnKi/Resource/SkeletonResource.h>
+#include <AnKi/Resource/ResourceManager.h>
 #include <AnKi/Util/Xml.h>
 #include <AnKi/Util/StringList.h>
 
 namespace anki {
 
-SkeletonResource::~SkeletonResource()
-{
-	for(Bone& b : m_bones)
-	{
-		b.destroy(getMemoryPool());
-	}
-
-	m_bones.destroy(getMemoryPool());
-}
-
 Error SkeletonResource::load(const ResourceFilename& filename, [[maybe_unused]] Bool async)
 {
-	XmlDocument doc(&getTempMemoryPool());
+	XmlDocument doc(&ResourceMemoryPool::getSingleton());
 	ANKI_CHECK(openFileParseXml(filename, doc));
 
 	XmlElement rootEl;
@@ -37,9 +28,9 @@ Error SkeletonResource::load(const ResourceFilename& filename, [[maybe_unused]]
 	ANKI_CHECK(boneEl.getSiblingElementsCount(boneCount));
 	++boneCount;
 
-	m_bones.create(getMemoryPool(), boneCount);
+	m_bones.create(boneCount);
 
-	StringListRaii boneParents(&getMemoryPool());
+	ResourceStringList boneParents;
 
 	// Load every bone
 	boneCount = 0;
@@ -51,7 +42,7 @@ Error SkeletonResource::load(const ResourceFilename& filename, [[maybe_unused]]
 		// name
 		CString name;
 		ANKI_CHECK(boneEl.getAttributeText("name", name));
-		bone.m_name.create(getMemoryPool(), name);
+		bone.m_name.create(name);
 
 		// transform
 		ANKI_CHECK(boneEl.getAttributeNumbers("transform", bone.m_transform));

+ 5 - 13
AnKi/Resource/SkeletonResource.h

@@ -26,7 +26,7 @@ public:
 
 	~Bone() = default;
 
-	const String& getName() const
+	CString getName() const
 	{
 		return m_name;
 	}
@@ -57,7 +57,7 @@ public:
 	}
 
 private:
-	String m_name; ///< The name of the bone
+	ResourceString m_name; ///< The name of the bone
 
 	Mat3x4 m_transform; ///< See the class notes.
 	Mat3x4 m_vertTrf;
@@ -67,11 +67,6 @@ private:
 	Bone* m_parent = nullptr;
 	Array<Bone*, kMaxChildrenPerBone> m_children = {};
 	U8 m_childrenCount = 0;
-
-	void destroy(HeapMemoryPool& pool)
-	{
-		m_name.destroy(pool);
-	}
 };
 
 /// It contains the bones with their position and hierarchy
@@ -94,12 +89,9 @@ private:
 class SkeletonResource : public ResourceObject
 {
 public:
-	SkeletonResource(ResourceManager* manager)
-		: ResourceObject(manager)
-	{
-	}
+	SkeletonResource() = default;
 
-	~SkeletonResource();
+	~SkeletonResource() = default;
 
 	/// Load file
 	Error load(const ResourceFilename& filename, Bool async);
@@ -129,7 +121,7 @@ public:
 	}
 
 private:
-	DynamicArray<Bone> m_bones;
+	ResourceDynamicArray<Bone> m_bones;
 	U32 m_rootBoneIdx = kMaxU32;
 };
 /// @}

+ 7 - 9
AnKi/Resource/TransferGpuAllocator.cpp

@@ -13,7 +13,7 @@ namespace anki {
 
 Error TransferGpuAllocator::StackAllocatorBuilderInterface::allocateChunk(PtrSize size, Chunk*& out)
 {
-	out = newInstance<Chunk>(*m_parent->m_pool);
+	out = newInstance<Chunk>(ResourceMemoryPool::getSingleton());
 
 	BufferInitInfo bufferInit(size, BufferUsageBit::kTransferSource, BufferMapAccessBit::kWrite, "Transfer");
 	out->m_buffer = m_parent->m_gr->newBuffer(bufferInit);
@@ -29,7 +29,7 @@ void TransferGpuAllocator::StackAllocatorBuilderInterface::freeChunk(Chunk* chun
 
 	chunk->m_buffer->unmap();
 
-	deleteInstance(*m_parent->m_pool, chunk);
+	deleteInstance(ResourceMemoryPool::getSingleton(), chunk);
 }
 
 TransferGpuAllocator::TransferGpuAllocator()
@@ -41,14 +41,12 @@ TransferGpuAllocator::~TransferGpuAllocator()
 	for(Pool& pool : m_pools)
 	{
 		ANKI_ASSERT(pool.m_pendingReleases == 0);
-		pool.m_fences.destroy(*m_pool);
+		pool.m_fences.destroy(ResourceMemoryPool::getSingleton());
 	}
 }
 
-Error TransferGpuAllocator::init(PtrSize maxSize, GrManager* gr, HeapMemoryPool* pool)
+Error TransferGpuAllocator::init(PtrSize maxSize, GrManager* gr)
 {
-	ANKI_ASSERT(pool);
-	m_pool = pool;
 	m_gr = gr;
 
 	m_maxAllocSize = getAlignedRoundUp(kChunkInitialSize * kPoolCount, maxSize);
@@ -101,7 +99,7 @@ Error TransferGpuAllocator::allocate(PtrSize size, TransferGpuAllocatorHandle& h
 				const Bool done = fence->clientWait(kMaxFenceWaitTime);
 				if(done)
 				{
-					pool->m_fences.popFront(*m_pool);
+					pool->m_fences.popFront(ResourceMemoryPool::getSingleton());
 				}
 			}
 		}
@@ -135,7 +133,7 @@ Error TransferGpuAllocator::allocate(PtrSize size, TransferGpuAllocatorHandle& h
 			if(fenceDone)
 			{
 				auto nextIt = it + 1;
-				p.m_fences.erase(*m_pool, it);
+				p.m_fences.erase(ResourceMemoryPool::getSingleton(), it);
 				it = nextIt;
 			}
 			else
@@ -158,7 +156,7 @@ void TransferGpuAllocator::release(TransferGpuAllocatorHandle& handle, FencePtr
 	{
 		LockGuard<Mutex> lock(m_mtx);
 
-		pool.m_fences.pushBack(*m_pool, fence);
+		pool.m_fences.pushBack(ResourceMemoryPool::getSingleton(), fence);
 
 		ANKI_ASSERT(pool.m_pendingReleases > 0);
 		--pool.m_pendingReleases;

+ 3 - 4
AnKi/Resource/TransferGpuAllocator.h

@@ -111,7 +111,7 @@ public:
 
 	~TransferGpuAllocator();
 
-	Error init(PtrSize maxSize, GrManager* gr, HeapMemoryPool* pool);
+	Error init(PtrSize maxSize, GrManager* gr);
 
 	/// Allocate some transfer memory. If there is not enough memory it will block until some is releaced. It's
 	/// threadsafe.
@@ -145,7 +145,7 @@ private:
 	class StackAllocatorBuilderInterface
 	{
 	public:
-		TransferGpuAllocator* m_parent = nullptr;
+		TransferGpuAllocator* m_parent = nullptr; // TODO glob: maybe rm
 
 		// The rest of the functions implement the StackAllocatorBuilder TInterface.
 
@@ -197,8 +197,7 @@ private:
 		U32 m_pendingReleases = 0;
 	};
 
-	HeapMemoryPool* m_pool = nullptr;
-	GrManager* m_gr = nullptr;
+	GrManager* m_gr = nullptr; // TODO glob: rm
 	PtrSize m_maxAllocSize = 0;
 
 	Mutex m_mtx; ///< Protect all members bellow.

+ 0 - 1
AnKi/Scene/Common.h

@@ -45,7 +45,6 @@ class PhysicsWorld;
 class SceneGraphExternalSubsystems
 {
 public:
-	ResourceManager* m_resourceManager = nullptr;
 	ScriptManager* m_scriptManager = nullptr;
 	UiManager* m_uiManager = nullptr;
 	GrManager* m_grManager = nullptr;

+ 1 - 1
AnKi/Scene/Components/BodyComponent.cpp

@@ -28,7 +28,7 @@ BodyComponent::~BodyComponent()
 void BodyComponent::loadMeshResource(CString meshFilename)
 {
 	CpuMeshResourcePtr rsrc;
-	const Error err = getExternalSubsystems(*m_node).m_resourceManager->loadResource(meshFilename, rsrc);
+	const Error err = ResourceManager::getSingleton().loadResource(meshFilename, rsrc);
 	if(err)
 	{
 		ANKI_SCENE_LOGE("Failed to load mesh");

+ 1 - 1
AnKi/Scene/Components/DecalComponent.cpp

@@ -36,7 +36,7 @@ void DecalComponent::setLayer(CString fname, F32 blendFactor, LayerType type)
 
 	ImageResourcePtr rsrc;
 
-	const Error err = getExternalSubsystems(*m_node).m_resourceManager->loadResource(fname, rsrc);
+	const Error err = ResourceManager::getSingleton().loadResource(fname, rsrc);
 	if(err)
 	{
 		ANKI_SCENE_LOGE("Failed to load image");

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

@@ -29,8 +29,8 @@ GlobalIlluminationProbeComponent::GlobalIlluminationProbeComponent(SceneNode* no
 	m_gpuSceneIndex = node->getSceneGraph().getAllGpuSceneContiguousArrays().allocate(
 		GpuSceneContiguousArrayType::kGlobalIlluminationProbes);
 
-	const Error err = getExternalSubsystems(*node).m_resourceManager->loadResource(
-		"ShaderBinaries/ClearTextureCompute.ankiprogbin", m_clearTextureProg);
+	const Error err = ResourceManager::getSingleton().loadResource("ShaderBinaries/ClearTextureCompute.ankiprogbin",
+																   m_clearTextureProg);
 	if(err)
 	{
 		ANKI_LOGF("Failed to load shader");

+ 1 - 1
AnKi/Scene/Components/LensFlareComponent.cpp

@@ -25,7 +25,7 @@ LensFlareComponent::~LensFlareComponent()
 void LensFlareComponent::loadImageResource(CString filename)
 {
 	ImageResourcePtr image;
-	const Error err = getExternalSubsystems(*m_node).m_resourceManager->loadResource(filename, image);
+	const Error err = ResourceManager::getSingleton().loadResource(filename, image);
 	if(err)
 	{
 		ANKI_SCENE_LOGE("Failed to load lens flare image");

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

@@ -46,7 +46,7 @@ ModelComponent::~ModelComponent()
 void ModelComponent::loadModelResource(CString filename)
 {
 	ModelResourcePtr rsrc;
-	const Error err = getExternalSubsystems(*m_node).m_resourceManager->loadResource(filename, rsrc);
+	const Error err = ResourceManager::getSingleton().loadResource(filename, rsrc);
 	if(err)
 	{
 		ANKI_SCENE_LOGE("Failed to load model resource");

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

@@ -224,7 +224,7 @@ void ParticleEmitterComponent::loadParticleEmitterResource(CString filename)
 {
 	// Load
 	ParticleEmitterResourcePtr rsrc;
-	const Error err = getExternalSubsystems(*m_node).m_resourceManager->loadResource(filename, rsrc);
+	const Error err = ResourceManager::getSingleton().loadResource(filename, rsrc);
 	if(err)
 	{
 		ANKI_SCENE_LOGE("Failed to load particle emitter");

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

@@ -28,7 +28,7 @@ void ScriptComponent::loadScriptResource(CString fname)
 {
 	// Load
 	ScriptResourcePtr rsrc;
-	Error err = getExternalSubsystems(*m_node).m_resourceManager->loadResource(fname, rsrc);
+	Error err = ResourceManager::getSingleton().loadResource(fname, rsrc);
 
 	// Create the env
 	ScriptEnvironment* newEnv = nullptr;

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

@@ -31,7 +31,7 @@ SkinComponent::~SkinComponent()
 void SkinComponent::loadSkeletonResource(CString fname)
 {
 	SkeletonResourcePtr rsrc;
-	const Error err = getExternalSubsystems(*m_node).m_resourceManager->loadResource(fname, rsrc);
+	const Error err = ResourceManager::getSingleton().loadResource(fname, rsrc);
 	if(err)
 	{
 		ANKI_SCENE_LOGE("Failed to load skeleton");

+ 1 - 1
AnKi/Scene/Components/SkyboxComponent.cpp

@@ -29,7 +29,7 @@ SkyboxComponent::~SkyboxComponent()
 void SkyboxComponent::loadImageResource(CString filename)
 {
 	ImageResourcePtr img;
-	const Error err = getExternalSubsystems(*m_node).m_resourceManager->loadResource(filename, img);
+	const Error err = ResourceManager::getSingleton().loadResource(filename, img);
 	if(err)
 	{
 		ANKI_SCENE_LOGE("Setting skybox image failed. Ignoring error");

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

@@ -18,7 +18,7 @@ AnimationEvent::AnimationEvent(EventManager* manager)
 Error AnimationEvent::init(CString animationFilename, CString channelName, SceneNode* movableSceneNode)
 {
 	ANKI_ASSERT(movableSceneNode);
-	ANKI_CHECK(getExternalSubsystems().m_resourceManager->loadResource(animationFilename, m_anim));
+	ANKI_CHECK(ResourceManager::getSingleton().loadResource(animationFilename, m_anim));
 
 	m_channelIndex = 0;
 	for(const AnimationChannel& channel : m_anim->getChannels())

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

@@ -37,7 +37,7 @@ Error ScriptEvent::init(Second startTime, Second duration, CString script)
 	if(!extension.isEmpty() && extension == "lua")
 	{
 		// It's a file
-		ANKI_CHECK(getExternalSubsystems().m_resourceManager->loadResource(script, m_scriptRsrc));
+		ANKI_CHECK(ResourceManager::getSingleton().loadResource(script, m_scriptRsrc));
 
 		// Exec the script
 		ANKI_CHECK(m_env.evalString(m_scriptRsrc->getSource()));

+ 4 - 4
AnKi/ShaderCompiler/ShaderProgramReflection.cpp

@@ -1010,10 +1010,10 @@ Error SpirvReflector::performSpirvReflection(Array<ConstWeakArray<U8>, U32(Shade
 		for(U32 j = 0; j < s.m_members.getSize(); ++j)
 		{
 			const StructMember& sm = s.m_members[j];
-			ANKI_CHECK(interface.visitStructMember(i, s.m_name, j, sm.m_name, sm.m_type,
-												   (sm.m_structIndex != kMaxU32) ? structs[sm.m_structIndex].m_name.toCString()
-																				 : CString(),
-												   sm.m_offset, sm.m_arraySize));
+			ANKI_CHECK(interface.visitStructMember(
+				i, s.m_name, j, sm.m_name, sm.m_type,
+				(sm.m_structIndex != kMaxU32) ? structs[sm.m_structIndex].m_name.toCString() : CString(), sm.m_offset,
+				sm.m_arraySize));
 		}
 	}
 

+ 1 - 1
AnKi/Ui/Canvas.cpp

@@ -36,7 +36,7 @@ Error Canvas::init(FontPtr font, U32 fontHeight, U32 width, U32 height)
 	resize(width, height);
 
 	// Create program
-	ANKI_CHECK(getExternalSubsystems().m_resourceManager->loadResource("ShaderBinaries/Ui.ankiprogbin", m_prog));
+	ANKI_CHECK(ResourceManager::getSingleton().loadResource("ShaderBinaries/Ui.ankiprogbin", m_prog));
 
 	for(U32 i = 0; i < kShaderCount; ++i)
 	{

+ 0 - 2
AnKi/Ui/Common.h

@@ -42,8 +42,6 @@ ANKI_UI_OBJECT_FW(UiImmediateModeBuilder)
 class UiExternalSubsystems
 {
 public:
-	ResourceManager* m_resourceManager = nullptr;
-	ResourceFilesystem* m_resourceFilesystem = nullptr;
 	GrManager* m_grManager = nullptr;
 };
 

+ 1 - 1
AnKi/Ui/Font.cpp

@@ -31,7 +31,7 @@ Error Font::init(const CString& filename, ConstWeakArray<U32> fontHeights)
 
 	// Load font in memory
 	ResourceFilePtr file;
-	ANKI_CHECK(getExternalSubsystems().m_resourceFilesystem->openFile(filename, file));
+	ANKI_CHECK(ResourceManager::getSingleton().getFilesystem().openFile(filename, file));
 	m_fontData.create(getMemoryPool(), U32(file->getSize()));
 	ANKI_CHECK(file->read(&m_fontData[0], file->getSize()));
 

+ 0 - 18
AnKi/Util/File.cpp

@@ -478,22 +478,4 @@ Error File::readAllText(BaseMemoryPool& pool, String& out)
 	return err;
 }
 
-Error File::readAllText(StringRaii& out)
-{
-	Error err = Error::kNone;
-	PtrSize size = getSize();
-
-	if(size != 0)
-	{
-		out.create('?', size);
-		err = read(&out[0], size);
-	}
-	else
-	{
-		err = Error::kFunctionFailed;
-	}
-
-	return err;
-}
-
 } // end namespace anki

+ 18 - 1
AnKi/Util/File.h

@@ -90,7 +90,24 @@ public:
 	Error readAllText(BaseMemoryPool& pool, String& out);
 
 	/// Read all the contents of a text file. If the file is not rewined it will probably fail.
-	Error readAllText(StringRaii& out);
+	template<typename TMemPool = MemoryPoolPtrWrapper<BaseMemoryPool>> // TODO glob: maybe change that
+	Error readAllText(BaseStringRaii<TMemPool>& out)
+	{
+		Error err = Error::kNone;
+		PtrSize size = getSize();
+
+		if(size != 0)
+		{
+			out.create('?', size);
+			err = read(&out[0], size);
+		}
+		else
+		{
+			err = Error::kFunctionFailed;
+		}
+
+		return err;
+	}
 
 	/// Read 32bit unsigned integer. Set the endianness if the file's endianness is different from the machine's.
 	Error readU32(U32& u);

+ 22 - 0
AnKi/Util/Forward.h

@@ -23,6 +23,11 @@ class HashMap;
 template<typename, typename, typename, typename, typename>
 class HashMapRaii;
 
+template<typename TKey>
+class DefaultHasher;
+
+class HashMapSparseArrayConfig;
+
 template<typename T>
 class Hierarchy;
 
@@ -41,6 +46,9 @@ class String;
 template<typename>
 class BaseStringRaii;
 
+template<typename>
+class BaseStringListRaii;
+
 class ThreadHive;
 
 template<typename, PtrSize kPreallocatedStorage = ANKI_SAFE_ALIGNMENT>
@@ -63,4 +71,18 @@ class DynamicArrayRaii;
 
 class F16;
 
+/// This macro defines typedefs for all the common containers that take a memory pool using a singleton memory pool
+/// memory pool.
+#define ANKI_DEFINE_SUBMODULE_UTIL_CONTAINERS(submoduleName, singletonMemoryPool) \
+	using submoduleName##MemPoolWrapper = SingletonMemoryPoolWrapper<singletonMemoryPool>; \
+	using submoduleName##String = BaseStringRaii<submoduleName##MemPoolWrapper>; \
+	template<typename T> \
+	using submoduleName##DynamicArray = DynamicArrayRaii<T, U32, submoduleName##MemPoolWrapper>; \
+	template<typename TKey, typename TValue> \
+	using submoduleName##HashMap = \
+		HashMapRaii<TKey, TValue, DefaultHasher<TKey>, HashMapSparseArrayConfig, submoduleName##MemPoolWrapper>; \
+	template<typename T> \
+	using submoduleName##List = ListRaii<T, submoduleName##MemPoolWrapper>; \
+	using submoduleName##StringList = BaseStringListRaii<submoduleName##MemPoolWrapper>;
+
 } // end namespace anki

+ 1 - 1
AnKi/Util/HashMap.h

@@ -232,7 +232,7 @@ public:
 	using MemoryPool = TMemPool;
 
 	/// Default constructor.
-	HashMapRaii(const TMemPool& pool)
+	HashMapRaii(const MemoryPool& pool = MemoryPool())
 		: m_pool(pool)
 	{
 	}

+ 1 - 1
AnKi/Util/List.h

@@ -499,7 +499,7 @@ public:
 	using MemoryPool = TMemPool;
 
 	/// Construct using a mem pool.
-	ListRaii(const MemoryPool& pool)
+	ListRaii(const MemoryPool& pool = MemoryPool())
 		: Base()
 		, m_pool(pool)
 	{

+ 1 - 1
AnKi/Util/StringList.h

@@ -106,7 +106,7 @@ public:
 	using MemoryPool = TMemPool;
 
 	/// Create using a mem pool.
-	BaseStringListRaii(const MemoryPool& pool)
+	BaseStringListRaii(const MemoryPool& pool = MemoryPool())
 		: Base()
 		, m_pool(pool)
 	{

+ 1 - 0
AnKi/Util/Xml.h

@@ -190,6 +190,7 @@ private:
 };
 
 /// XML document.
+// TODO glob: add the allocator in a template just like the other containers
 class XmlDocument
 {
 public:

+ 1 - 1
Samples/PhysicsPlayground/Main.cpp

@@ -109,7 +109,7 @@ public:
 Error MyApp::sampleExtraInit()
 {
 	ScriptResourcePtr script;
-	ANKI_CHECK(getResourceManager().loadResource("Assets/Scene.lua", script));
+	ANKI_CHECK(ResourceManager::getSingleton().loadResource("Assets/Scene.lua", script));
 	ANKI_CHECK(getScriptManager().evalString(script->getSource()));
 
 	// Create the player

+ 1 - 1
Samples/SimpleScene/Main.cpp

@@ -14,7 +14,7 @@ public:
 	Error sampleExtraInit()
 	{
 		ScriptResourcePtr script;
-		ANKI_CHECK(getResourceManager().loadResource("Assets/Scene.lua", script));
+		ANKI_CHECK(ResourceManager::getSingleton().loadResource("Assets/Scene.lua", script));
 		ANKI_CHECK(getScriptManager().evalString(script->getSource()));
 
 		return Error::kNone;

+ 4 - 3
Samples/SkeletalAnimation/Main.cpp

@@ -17,11 +17,12 @@ public:
 	Error sampleExtraInit() override
 	{
 		ScriptResourcePtr script;
-		ANKI_CHECK(getResourceManager().loadResource("Assets/Scene.lua", script));
+		ANKI_CHECK(ResourceManager::getSingleton().loadResource("Assets/Scene.lua", script));
 		ANKI_CHECK(getScriptManager().evalString(script->getSource()));
 
-		ANKI_CHECK(getResourceManager().loadResource("Assets/float.001_ccb9eb33e30c8fa4.ankianim", m_floatAnim));
-		ANKI_CHECK(getResourceManager().loadResource("Assets/wave_6cf284ed471bff3b.ankianim", m_waveAnim));
+		ANKI_CHECK(
+			ResourceManager::getSingleton().loadResource("Assets/float.001_ccb9eb33e30c8fa4.ankianim", m_floatAnim));
+		ANKI_CHECK(ResourceManager::getSingleton().loadResource("Assets/wave_6cf284ed471bff3b.ankianim", m_waveAnim));
 
 		AnimationPlayInfo animInfo;
 		animInfo.m_startTime = 2.0;

+ 1 - 1
Samples/Sponza/Main.cpp

@@ -14,7 +14,7 @@ public:
 	Error sampleExtraInit()
 	{
 		ScriptResourcePtr script;
-		ANKI_CHECK(getResourceManager().loadResource("Assets/Scene.lua", script));
+		ANKI_CHECK(ResourceManager::getSingleton().loadResource("Assets/Scene.lua", script));
 		ANKI_CHECK(getScriptManager().evalString(script->getSource()));
 
 		return Error::kNone;

Some files were not shown because too many files changed in this diff