Просмотр исходного кода

Resource refactor finished, will need further testing and bugfixes

Marko Pintera 11 лет назад
Родитель
Сommit
08e7132142
2 измененных файлов с 20 добавлено и 9 удалено
  1. 10 4
      BansheeCore/Source/BsResources.cpp
  2. 10 5
      TODO.txt

+ 10 - 4
BansheeCore/Source/BsResources.cpp

@@ -62,7 +62,11 @@ namespace BansheeEngine
 		if(!foundPath)
 		if(!foundPath)
 		{
 		{
 			gDebug().logWarning("Cannot load resource. Resource with UUID '" + uuid + "' doesn't exist.");
 			gDebug().logWarning("Cannot load resource. Resource with UUID '" + uuid + "' doesn't exist.");
-			return HResource();
+
+			HResource outputResource(uuid);
+			loadComplete(outputResource);
+
+			return outputResource;
 		}
 		}
 
 
 		return loadInternal(filePath, !async);
 		return loadInternal(filePath, !async);
@@ -138,6 +142,7 @@ namespace BansheeEngine
 			ResourceLoadData* loadData = bs_new<ResourceLoadData>(outputResource, 0);
 			ResourceLoadData* loadData = bs_new<ResourceLoadData>(outputResource, 0);
 			mInProgressResources[uuid] = loadData;
 			mInProgressResources[uuid] = loadData;
 			loadData->resource = outputResource;
 			loadData->resource = outputResource;
+			loadData->remainingDependencies = 1;
 
 
 			for (auto& dependency : savedResourceData->getDependencies())
 			for (auto& dependency : savedResourceData->getDependencies())
 			{
 			{
@@ -173,6 +178,8 @@ namespace BansheeEngine
 				TaskScheduler::instance().addTask(task);
 				TaskScheduler::instance().addTask(task);
 			}
 			}
 		}
 		}
+		else
+			loadComplete(outputResource);
 
 
 		return outputResource;
 		return outputResource;
 	}
 	}
@@ -387,7 +394,7 @@ namespace BansheeEngine
 			mDependantLoads.erase(uuid);
 			mDependantLoads.erase(uuid);
 		}
 		}
 
 
-		if (resource)
+		if (myLoadData != nullptr)
 		{
 		{
 			{
 			{
 				BS_LOCK_MUTEX(mLoadedResourceMutex);
 				BS_LOCK_MUTEX(mLoadedResourceMutex);
@@ -396,10 +403,9 @@ namespace BansheeEngine
 
 
 			resource._setHandleData(myLoadData->loadedData, resource.getUUID());
 			resource._setHandleData(myLoadData->loadedData, resource.getUUID());
 			onResourceLoaded(resource);
 			onResourceLoaded(resource);
-		}
 
 
-		if (myLoadData != nullptr)
 			bs_delete(myLoadData);
 			bs_delete(myLoadData);
+		}
 
 
 		for (auto& dependantLoad : dependantLoads)
 		for (auto& dependantLoad : dependantLoads)
 		{
 		{

+ 10 - 5
TODO.txt

@@ -10,15 +10,20 @@ related to lambdas not capturing types as I expect them to. It always happens in
 TODO - Material waits to Shader to be loaded but doesn't wait for shader GpuPrograms or state objects.
 TODO - Material waits to Shader to be loaded but doesn't wait for shader GpuPrograms or state objects.
  - What's the best way to ensure initialization is done when all these are loaded?
  - What's the best way to ensure initialization is done when all these are loaded?
 
 
-Implement resource unloading:
- - Once unload is called, create a unique list of all dependant resources (just direct children)
- - Track how many times is each resource referenced and how many actual references it has
- - If ref count is 1 (just held by Resources manager) unload it
- - Recurse unload over all child resources
+TODO - Material loading issue. Deserializing a material will still call initialize() which will block until shader is loaded.
+ - I should instead wait until everything is loaded before initializing the material. (e.g. when I want to load the material async
+   I shouldn't be blocking.)
+   - Remove call to initialize() in MaterialRTTI and instead add ResourceListener call to Resources?
 
 
 I can get mono errors by checking g_print calls in goutput.c
 I can get mono errors by checking g_print calls in goutput.c
  - Calling thunks incorrectly can cause those weird errors with no real callstack
  - Calling thunks incorrectly can cause those weird errors with no real callstack
 
 
+Multi-resource saving:
+ - Modify Font so it doesn't contain a texture, but instead keeps a handle to it
+ - Register it in its meta file
+ - When saving such a resource with dependencies save the contained files to a sub-directory with the same name as top level resource
+   - If it already exists in the manifest at a different location do it anyway, keep the other copy as-is in case user wanted it that way
+
 Other:
 Other:
 Window resize end callback
 Window resize end callback
 Add cutoff plane when rendering discs for rotation handle.
 Add cutoff plane when rendering discs for rotation handle.