Explorar el Código

Removed register/unregisterObjectToDestroy as it's no longer needed and it just requires an additional sync lock

Marko Pintera hace 13 años
padre
commit
fea3072466

+ 0 - 10
CamelotRenderer/Include/CmCoreGpuObjectManager.h

@@ -15,20 +15,10 @@ namespace CamelotEngine
 
 		UINT64 registerObject(CoreGpuObject* object);
 		void unregisterObject(CoreGpuObject* object);
-
-		void registerObjectToDestroy(std::shared_ptr<CoreGpuObject> object);
-		void unregisterObjectToDestroy(std::shared_ptr<CoreGpuObject> object);
 	private:
 		// Keeps a list of ALL loaded core GPU objects
 		UINT64 mNextAvailableID;
 		map<UINT64, CoreGpuObject*>::type mObjects;
 		CM_MUTEX(mObjectsMutex);
-
-		// Keeps a list of GPU objects scheduled to be destroyed. We need a reference
-		// to the object here, otherwise the object may reach reference count of 0 and be
-		// deleted before its scheduled destroy() method is called. Object is added to the list
-		// when destroy() is initialized, and removed when it is finished.
-		map<UINT64, std::shared_ptr<CoreGpuObject>>::type mObjectsToDestroy;
-		CM_MUTEX(mObjectsToDestroyMutex);
 	};
 }

+ 0 - 6
CamelotRenderer/Source/CmCoreGpuObject.cpp

@@ -37,7 +37,6 @@ namespace CamelotEngine
 	void CoreGpuObject::destroy()
 	{
 		setScheduledToBeDeleted(true);
-		CoreGpuObjectManager::instance().registerObjectToDestroy(mThis.lock());
 
 		queueGpuCommand(mThis.lock(), boost::bind(&CoreGpuObject::destroy_internal, this));
 	}
@@ -46,15 +45,10 @@ namespace CamelotEngine
 	{
 #if CM_DEBUG_MODE
 		if(!isInitialized())
-		{
-			CoreGpuObjectManager::instance().unregisterObjectToDestroy(mThis.lock());
 			CM_EXCEPT(InternalErrorException, "Trying to destroy an object that is already destroyed (or it never was initialized).");
-		}
 #endif
 
 		setIsInitialized(false);
-
-		CoreGpuObjectManager::instance().unregisterObjectToDestroy(mThis.lock());
 	}
 
 	void CoreGpuObject::initialize()

+ 0 - 20
CamelotRenderer/Source/CmCoreGpuObjectManager.cpp

@@ -23,12 +23,6 @@ namespace CamelotEngine
 			CM_EXCEPT(InternalErrorException, "Core GPU object manager destroyed, but not all objects were released. User must release ALL " \
 				"engine objects before application shutdown.");
 		}
-
-		if(mObjectsToDestroy.size() > 0)
-		{
-			// This should never happen as higher levels of the engine make sure all scheduled objects are destroyed before shutdown is initialized.
-			CM_EXCEPT(InternalErrorException, "Objects scheduled for destruction, but shutdown initialized before destruction completed.");
-		}
 	}
 
 	UINT64 CoreGpuObjectManager::registerObject(CoreGpuObject* object)
@@ -50,18 +44,4 @@ namespace CamelotEngine
 
 		mObjects.erase(object->getInternalID());
 	}
-
-	void CoreGpuObjectManager::registerObjectToDestroy(std::shared_ptr<CoreGpuObject> object)
-	{
-		CM_LOCK_MUTEX(mObjectsToDestroyMutex);
-
-		mObjectsToDestroy[object->getInternalID()] = object;
-	}
-
-	void CoreGpuObjectManager::unregisterObjectToDestroy(std::shared_ptr<CoreGpuObject> object)
-	{
-		CM_LOCK_MUTEX(mObjectsToDestroyMutex);
-
-		mObjectsToDestroy.erase(object->getInternalID());
-	}
 }

+ 0 - 4
CamelotRenderer/TODO.txt

@@ -22,9 +22,6 @@ Make sure we can add an include file to a HighLevelGpuProgram, and make sure it
  - Also a way to list all referenced includes, and a way to remove them
 
 Go through RenderSystem classes and make sure we don't hold any raw pointer references:
-D3D9 keeps a list of render windows
- - it keeps a list of RAW pointers to those windows. That NEEDS to change
-
 D3D11 keeps an active vertex shader & active vertex delecaration
  - should be okay if they are both shared_ptr (they're not atm), and user knows how to reset them
 
@@ -48,7 +45,6 @@ Can be delayed:
  Material RTTI should also serialize shared buffers (they need to be made into a resource)
  - BE CAREFUL on how this will be implemented. Likely it will have much of the same interface as a material and/or GpuParams
  Mesh::setMeshData is currently always synced
-  register/unregisterObjectToDestroy might be redundant now that I save a reference with each queue entry?
  queueGpuCommand is handled weird. shared_ptr isn't used for setting (this) parameter, and could be optimized out by the compiler
   - test if everything is okay in release mode
 >>>>>>>>>>>>>>>START WORKING ON THE EDITOR!