Browse Source

Removing some unused old render system context stuff

Marko Pintera 13 years ago
parent
commit
a569a53a4b

+ 4 - 65
CamelotRenderer/Include/CmRenderSystem.h

@@ -941,16 +941,13 @@ namespace CamelotEngine
 		RenderWorkerFunc* mRenderThreadFunc;
 		bool mRenderThreadShutdown;
 
+		CM_MUTEX(mActiveContextMutex)
+
 		CM_THREAD_ID_TYPE mRenderThreadId;
 		CM_THREAD_SYNCHRONISER(mRenderThreadStartCondition)
-		CM_MUTEX(mRSContextInitMutex)
-		CM_THREAD_SYNCHRONISER(mCommandReadyCondition)
+		CM_MUTEX(mRenderThreadStartMutex)
 		CM_MUTEX(mCommandQueueMutex)
-		CM_THREAD_SYNCHRONISER(mCommandQueueCompleteCondition)
-		CM_MUTEX(mCommandCompleteMutex)
-		CM_MUTEX(mRSRenderCallbackMutex)
-		CM_MUTEX(mActiveContextMutex)
-
+		CM_THREAD_SYNCHRONISER(mCommandReadyCondition)
 		CM_MUTEX(mCommandNotifyMutex)
 		CM_THREAD_SYNCHRONISER(mCommandCompleteCondition)
 
@@ -963,18 +960,9 @@ namespace CamelotEngine
 		UINT32 mMaxCommandNotifyId; // ID that will be assigned to the next command with a notifier callback
 		vector<UINT32>::type mCommandsCompleted; // Completed commands that have notifier callbacks set up
 
-		// Primary context created when the render system is first started up
-		RenderSystemContextPtr mPrimaryContext;
 		// Currently active context. All new commands will be executed on this context.
 		mutable RenderSystemContextPtr mActiveContext;
 
-		// Context that is currently being executed
-		RenderSystemContextPtr mExecutingContext;
-
-		vector<RenderSystemContextPtr>::type mRenderSystemContexts;
-		boost::signal<void()> PreRenderThreadUpdateCallback;
-		boost::signal<void()> PostRenderThreadUpdateCallback;
-
 		/**
 		 * @brief	Initializes a separate render thread. Should only be called once.
 		 */
@@ -1001,23 +989,6 @@ namespace CamelotEngine
 		 */
 		void throwIfInvalidContextThread() const;
 
-		/**
-		 * @brief	Submits the specified context to the GPU. Normally this happens automatically
-		 * 			at the end of each frame for all contexts, but in some cases you might want to do it
-		 * 			manually via this method.
-		 *
-		 * @param	context			  	The context to submit.
-		 * @param	blockUntilComplete	If true, the calling thread will block until all commands are submitted.
-		 */
-		void submitToGpu(RenderSystemContextPtr context, bool blockUntilComplete);
-
-		/**
-		 * @brief	Gets the currently active render system object.
-		 *
-		 * @return	The active context.
-		 */
-		RenderSystemContextPtr getActiveContext() const;
-
 		/**
 		 * @brief	Blocks the calling thread until the command with the specified ID completes.
 		 * 			Make sure that the specified ID actually exists, otherwise this will block forever.
@@ -1040,14 +1011,6 @@ namespace CamelotEngine
 		 */
 		CM_THREAD_ID_TYPE getRenderThreadId() const { return mRenderThreadId; }
 
-		/**
-		 * @brief	Creates a new render system context that you can use for rendering on 
-		 * 			a non-render thread. You can have as many of these as you wish, the only limitation
-		 * 			is that you do not use a single instance on more than one thread. Each thread
-		 * 			requires its own context.
-		 */
-		RenderSystemContextPtr createRenderSystemContext();
-
 		/**
 		 * @brief	Creates a new render system context that you can use for rendering on 
 		 * 			a non-render thread. You can have as many of these as you wish, the only limitation
@@ -1056,13 +1019,6 @@ namespace CamelotEngine
 		 */
 		DeferredRenderContextPtr createDeferredContext();
 
-		/**
-		 * @brief	Sets an active context on which all subsequent RenderSystem calls will be executed on.
-		 * 			
-		 * @note	context must not be null.
-		 */
-		void setActiveContext(RenderSystemContextPtr context);
-
 		/**
 		 * @brief	Queues a new command that will be added to the global command queue. You are allowed to call this from any thread,
 		 * 			however be aware that it involves possibly slow synchronization primitives, so limit your usage.
@@ -1083,23 +1039,6 @@ namespace CamelotEngine
 		 * @see		CommandQueue::queue
 		 */
 		void queueCommand(boost::function<void()> commandCallback, bool blockUntilComplete = false);
-
-		/**
-		 * @brief	Callback that is called from the render thread before it starts processing
-		 * 			deferred render commands.
-		 */
-		void addPreRenderThreadUpdateCallback(boost::function<void()> callback);
-
-		/**
-		 * @brief	Callback that is called from the render thread after it ends processing
-		 * 			deferred render commands.
-		 */
-		void addPostRenderThreadUpdateCallback(boost::function<void()> callback);
-
-		/**
-		 * @brief	Called every frame
-		 */
-		void update();
 	};
 	/** @} */
 	/** @} */

+ 4 - 6
CamelotRenderer/Source/CmApplication.cpp

@@ -63,9 +63,6 @@ namespace CamelotEngine
 		loadPlugin("CamelotFBXImporter"); // TODO - Load this automatically somehow
 
 		loadPlugin("CamelotOISInput"); // TODO - Load this automatically somehow
-
-		renderSystem->addPreRenderThreadUpdateCallback(boost::bind(&Application::updateMessagePump, this));
-		renderSystem->addPreRenderThreadUpdateCallback(boost::bind(&Application::updateResourcesCallback, this));
 	}
 
 	void Application::runMainLoop()
@@ -74,12 +71,13 @@ namespace CamelotEngine
 		{
 			gSceneManager().update();
 
+			RenderSystem* renderSystem = RenderSystemManager::getActive();
+			renderSystem->queueCommand(boost::bind(&Application::updateMessagePump, this));
+			renderSystem->queueCommand(boost::bind(&Application::updateResourcesCallback, this));
+
 			RendererManager::getActive()->renderAll();
 			mPrimaryRenderContext->submitToGpu();
 
-			RenderSystem* renderSystem = RenderSystemManager::getActive();
-			renderSystem->update();
-
 			gTime().update();
 			gInput().update();
 		}

+ 3 - 97
CamelotRenderer/Source/CmRenderSystem.cpp

@@ -88,8 +88,6 @@ namespace CamelotEngine {
 	void RenderSystem::startUp()
 	{
 		mRenderThreadId = CM_THREAD_CURRENT_ID;
-		mPrimaryContext = createRenderSystemContext();
-		mActiveContext = mPrimaryContext;
 		mCommandQueue = new CommandQueue(CM_THREAD_CURRENT_ID);
 
 		initRenderThread();
@@ -861,8 +859,8 @@ namespace CamelotEngine {
 		CM_THREAD_CREATE(t, *mRenderThreadFunc);
 		mRenderThread = t;
 
-		CM_LOCK_MUTEX_NAMED(mRSContextInitMutex, lock)
-		CM_THREAD_WAIT(mRenderThreadStartCondition, mRSContextInitMutex, lock)
+		CM_LOCK_MUTEX_NAMED(mRenderThreadStartMutex, lock)
+		CM_THREAD_WAIT(mRenderThreadStartCondition, mRenderThreadStartMutex, lock)
 
 #else
 		CM_EXCEPT(InternalErrorException, "Attempting to start a render thread but Camelot isn't compiled with thread support.");
@@ -891,24 +889,8 @@ namespace CamelotEngine {
 				commands = mCommandQueue->flush();
 			}
 
-			{
-				CM_LOCK_MUTEX(mRSRenderCallbackMutex)
-
-				if(!PreRenderThreadUpdateCallback.empty())
-					PreRenderThreadUpdateCallback();
-			}
-
 			// Play commands
 			mCommandQueue->playback(commands, boost::bind(&RenderSystem::commandCompletedNotify, this, _1)); 
-
-			{
-				CM_LOCK_MUTEX(mRSRenderCallbackMutex)
-
-				if(!PostRenderThreadUpdateCallback.empty())
-					PostRenderThreadUpdateCallback();
-			}
-
-			CM_THREAD_NOTIFY_ALL(mCommandQueueCompleteCondition);
 		}
 
 	}
@@ -925,67 +907,12 @@ namespace CamelotEngine {
 
 		mRenderThread = nullptr;
 		mRenderThreadId = CM_THREAD_CURRENT_ID;
-		mRenderSystemContexts.clear();
-	}
-
-	RenderSystemContextPtr RenderSystem::createRenderSystemContext()
-	{
-		RenderSystemContextPtr newContext = RenderSystemContextPtr(
-			new RenderSystemFrameContext(CM_THREAD_CURRENT_ID)
-			);
-
-		{
-			CM_LOCK_MUTEX(mCommandQueueMutex);
-			mRenderSystemContexts.push_back(newContext);
-		}
-
-		return newContext;
 	}
 
 	DeferredRenderContextPtr RenderSystem::createDeferredContext()
 	{
 		return DeferredRenderContextPtr(new DeferredRenderContext(this, CM_THREAD_CURRENT_ID));
 	}
-
-	void RenderSystem::addPreRenderThreadUpdateCallback(boost::function<void()> callback)
-	{
-		CM_LOCK_MUTEX(mRSRenderCallbackMutex)
-
-		PreRenderThreadUpdateCallback.connect(callback);
-	}
-
-	void RenderSystem::addPostRenderThreadUpdateCallback(boost::function<void()> callback)
-	{
-		CM_LOCK_MUTEX(mRSRenderCallbackMutex)
-
-		PostRenderThreadUpdateCallback.connect(callback);
-	}
-
-	void RenderSystem::submitToGpu(RenderSystemContextPtr context, bool blockUntilComplete)
-	{
-		if(CM_THREAD_CURRENT_ID == getRenderThreadId())
-			CM_EXCEPT(InternalErrorException, "You are not allowed to call this method on the render thread!");
-
-		{
-			CM_LOCK_MUTEX(mCommandQueueMutex);
-
-			context->submitToGpu();
-		}
-
-		CM_THREAD_NOTIFY_ALL(mCommandReadyCondition);
-
-		if(blockUntilComplete)
-			context->blockUntilExecuted();
-	}
-
-	void RenderSystem::setActiveContext(RenderSystemContextPtr context)
-	{
-		assert(context != nullptr);
-
-		CM_LOCK_MUTEX(mActiveContextMutex);
-
-		mActiveContext = context;
-	}
 	
 	AsyncOp RenderSystem::queueReturnCommand(boost::function<void(AsyncOp&)> commandCallback, bool blockUntilComplete)
 	{
@@ -1062,7 +989,7 @@ namespace CamelotEngine {
 				break;
 			}
 
-			CM_THREAD_WAIT(mCommandQueueCompleteCondition, mCommandNotifyMutex, lock);
+			CM_THREAD_WAIT(mCommandCompleteCondition, mCommandNotifyMutex, lock);
 		}
 	}
 
@@ -1077,27 +1004,6 @@ namespace CamelotEngine {
 		CM_THREAD_NOTIFY_ALL(mCommandCompleteCondition);
 	}
 
-	RenderSystemContextPtr RenderSystem::getActiveContext() const
-	{
-		CM_LOCK_MUTEX(mActiveContextMutex);
-
-		return mActiveContext;
-	}
-
-	void RenderSystem::update()
-	{
-		//{
-		//	CM_LOCK_MUTEX(mRSContextMutex);
-
-		//	for(auto iter = mRenderSystemContexts.begin(); iter != mRenderSystemContexts.end(); ++iter)
-		//	{
-		//		(*iter)->submitToGpu();
-		//	}
-		//}
-
-		//CM_THREAD_NOTIFY_ALL(mCommandReadyCondition)
-	}
-
 	void RenderSystem::throwIfNotRenderThread() const
 	{
 		if(CM_THREAD_CURRENT_ID != getRenderThreadId())