فهرست منبع

Bunch of renames and starting work on deferred render system

Marko Pintera 13 سال پیش
والد
کامیت
f4cf3ec60e

+ 25 - 25
CamelotD3D9Renderer/Include/CmD3D9RenderSystem.h

@@ -194,7 +194,7 @@ namespace CamelotEngine
 		/**
          * Set current render target to target, enabling its GL context if needed
          */
-		void _setRenderTarget(RenderTarget *target);
+		void setRenderTarget(RenderTarget *target);
 		
 		/// @copydoc RenderSystem::createMultiRenderTarget
 		virtual MultiRenderTarget * createMultiRenderTarget(const String & name);
@@ -216,34 +216,34 @@ namespace CamelotEngine
             bool twoSidedOperation = false);
 
 		// Low-level overridden members, mainly for internal use
-		void _setPointParameters(float size, bool attenuationEnabled, 
+		void setPointParameters(float size, bool attenuationEnabled, 
 			float constant, float linear, float quadratic, float minSize, float maxSize);
-		void _setTexture(size_t unit, bool enabled, const TexturePtr &texPtr);
-		void _setVertexTexture(size_t unit, const TexturePtr& tex);
-		void _disableTextureUnit(size_t texUnit);
-        void _setTextureAddressingMode(size_t stage, const SamplerState::UVWAddressingMode& uvw);
-        void _setTextureBorderColour(size_t stage, const Color& colour);
-		void _setTextureMipmapBias(size_t unit, float bias);
-		void _setSceneBlending( SceneBlendFactor sourceFactor, SceneBlendFactor destFactor, SceneBlendOperation op );
-		void _setSeparateSceneBlending( SceneBlendFactor sourceFactor, SceneBlendFactor destFactor, SceneBlendFactor sourceFactorAlpha, SceneBlendFactor destFactorAlpha, SceneBlendOperation op, SceneBlendOperation alphaOp );
-		void _setAlphaRejectSettings( CompareFunction func, unsigned char value, bool alphaToCoverage );
-		void _setViewport( Viewport *vp );		
-		void _beginFrame();
-		void _endFrame();		
-		void _setCullingMode( CullingMode mode );
-		void _setDepthBufferParams( bool depthTest = true, bool depthWrite = true, CompareFunction depthFunction = CMPF_LESS_EQUAL );
-		void _setDepthBufferCheckEnabled( bool enabled = true );
-		void _setColourBufferWriteEnabled(bool red, bool green, bool blue, bool alpha);
-		void _setDepthBufferWriteEnabled(bool enabled = true);
-		void _setDepthBufferFunction( CompareFunction func = CMPF_LESS_EQUAL );
-		void _setDepthBias(float constantBias, float slopeScaleBias);
+		void setTexture(size_t unit, bool enabled, const TexturePtr &texPtr);
+		void setVertexTexture(size_t unit, const TexturePtr& tex);
+		void disableTextureUnit(size_t texUnit);
+        void setTextureAddressingMode(size_t stage, const SamplerState::UVWAddressingMode& uvw);
+        void setTextureBorderColour(size_t stage, const Color& colour);
+		void setTextureMipmapBias(size_t unit, float bias);
+		void setSceneBlending( SceneBlendFactor sourceFactor, SceneBlendFactor destFactor, SceneBlendOperation op );
+		void setSeparateSceneBlending( SceneBlendFactor sourceFactor, SceneBlendFactor destFactor, SceneBlendFactor sourceFactorAlpha, SceneBlendFactor destFactorAlpha, SceneBlendOperation op, SceneBlendOperation alphaOp );
+		void setAlphaRejectSettings( CompareFunction func, unsigned char value, bool alphaToCoverage );
+		void setViewport( Viewport *vp );		
+		void beginFrame();
+		void endFrame();		
+		void setCullingMode( CullingMode mode );
+		void setDepthBufferParams( bool depthTest = true, bool depthWrite = true, CompareFunction depthFunction = CMPF_LESS_EQUAL );
+		void setDepthBufferCheckEnabled( bool enabled = true );
+		void setColourBufferWriteEnabled(bool red, bool green, bool blue, bool alpha);
+		void setDepthBufferWriteEnabled(bool enabled = true);
+		void setDepthBufferFunction( CompareFunction func = CMPF_LESS_EQUAL );
+		void setDepthBias(float constantBias, float slopeScaleBias);
 		void _convertProjectionMatrix(const Matrix4& matrix, Matrix4& dest, bool forGpuProgram = false);
-		void _setPolygonMode(PolygonMode level);
-        void _setTextureUnitFiltering(size_t unit, FilterType ftype, FilterOptions filter);
-		void _setTextureLayerAnisotropy(size_t unit, unsigned int maxAnisotropy);
+		void setPolygonMode(PolygonMode level);
+        void setTextureUnitFiltering(size_t unit, FilterType ftype, FilterOptions filter);
+		void setTextureLayerAnisotropy(size_t unit, unsigned int maxAnisotropy);
 		void setVertexDeclaration(VertexDeclarationPtr decl);
 		void setVertexBufferBinding(VertexBufferBinding* binding);
-        void _render(const RenderOperation& op);
+        void render(const RenderOperation& op);
         /** See
           RenderSystem
          */

+ 35 - 35
CamelotD3D9Renderer/Source/CmD3D9RenderSystem.cpp

@@ -1466,7 +1466,7 @@ namespace CamelotEngine
 		}
 	}
 	//---------------------------------------------------------------------
-	void D3D9RenderSystem::_setPointParameters(float size, 
+	void D3D9RenderSystem::setPointParameters(float size, 
 		bool attenuationEnabled, float constant, float linear, float quadratic,
 		float minSize, float maxSize)
 	{
@@ -1492,7 +1492,7 @@ namespace CamelotEngine
 
 	}
 	//---------------------------------------------------------------------
-	void D3D9RenderSystem::_setTexture( size_t stage, bool enabled, const TexturePtr& tex )
+	void D3D9RenderSystem::setTexture( size_t stage, bool enabled, const TexturePtr& tex )
 	{
 		HRESULT hr;
 		D3D9TexturePtr dt = std::static_pointer_cast<D3D9Texture>(tex);
@@ -1550,7 +1550,7 @@ namespace CamelotEngine
 		}
 	}
 	//---------------------------------------------------------------------
-	void D3D9RenderSystem::_setVertexTexture(size_t stage, const TexturePtr& tex)
+	void D3D9RenderSystem::setVertexTexture(size_t stage, const TexturePtr& tex)
 	{
 		if (tex == nullptr)
 		{
@@ -1591,15 +1591,15 @@ namespace CamelotEngine
 
 	}
 	//---------------------------------------------------------------------
-	void D3D9RenderSystem::_disableTextureUnit(size_t texUnit)
+	void D3D9RenderSystem::disableTextureUnit(size_t texUnit)
 	{
-		RenderSystem::_disableTextureUnit(texUnit);
+		RenderSystem::disableTextureUnit(texUnit);
 		// also disable vertex texture unit
 		static TexturePtr nullPtr;
-		_setVertexTexture(texUnit, nullPtr);
+		setVertexTexture(texUnit, nullPtr);
 	}
 	//---------------------------------------------------------------------
-	void D3D9RenderSystem::_setTextureMipmapBias(size_t unit, float bias)
+	void D3D9RenderSystem::setTextureMipmapBias(size_t unit, float bias)
 	{
 		if (mCurrentCapabilities->hasCapability(RSC_MIPMAP_LOD_BIAS))
 		{
@@ -1612,7 +1612,7 @@ namespace CamelotEngine
 		}
 	}
 	//---------------------------------------------------------------------
-	void D3D9RenderSystem::_setTextureAddressingMode( size_t stage, 
+	void D3D9RenderSystem::setTextureAddressingMode( size_t stage, 
 		const SamplerState::UVWAddressingMode& uvw )
 	{
 		HRESULT hr;
@@ -1624,7 +1624,7 @@ namespace CamelotEngine
 			CM_EXCEPT(RenderingAPIException, "Failed to set texture addressing mode for W");
 	}
 	//-----------------------------------------------------------------------------
-	void D3D9RenderSystem::_setTextureBorderColour(size_t stage,
+	void D3D9RenderSystem::setTextureBorderColour(size_t stage,
 		const Color& colour)
 	{
 		HRESULT hr;
@@ -1632,7 +1632,7 @@ namespace CamelotEngine
 			CM_EXCEPT(RenderingAPIException, "Failed to set texture border colour");
 	}
 	//---------------------------------------------------------------------
-	void D3D9RenderSystem::_setSceneBlending( SceneBlendFactor sourceFactor, SceneBlendFactor destFactor, SceneBlendOperation op )
+	void D3D9RenderSystem::setSceneBlending( SceneBlendFactor sourceFactor, SceneBlendFactor destFactor, SceneBlendOperation op )
 	{
 		HRESULT hr;
 		if( sourceFactor == SBF_ONE && destFactor == SBF_ZERO)
@@ -1658,7 +1658,7 @@ namespace CamelotEngine
 			CM_EXCEPT(RenderingAPIException, "Failed to set scene blending operation option");
 	}
 	//---------------------------------------------------------------------
-	void D3D9RenderSystem::_setSeparateSceneBlending( SceneBlendFactor sourceFactor, SceneBlendFactor destFactor, SceneBlendFactor sourceFactorAlpha, 
+	void D3D9RenderSystem::setSeparateSceneBlending( SceneBlendFactor sourceFactor, SceneBlendFactor destFactor, SceneBlendFactor sourceFactorAlpha, 
 		SceneBlendFactor destFactorAlpha, SceneBlendOperation op, SceneBlendOperation alphaOp )
 	{
 		HRESULT hr;
@@ -1690,7 +1690,7 @@ namespace CamelotEngine
 			CM_EXCEPT(RenderingAPIException, "Failed to set alpha scene blending operation option");
 	}
 	//---------------------------------------------------------------------
-	void D3D9RenderSystem::_setAlphaRejectSettings( CompareFunction func, unsigned char value, bool alphaToCoverage )
+	void D3D9RenderSystem::setAlphaRejectSettings( CompareFunction func, unsigned char value, bool alphaToCoverage )
 	{
 		HRESULT hr;
 		bool a2c = false;
@@ -1752,7 +1752,7 @@ namespace CamelotEngine
 
 	}
 	//---------------------------------------------------------------------
-	void D3D9RenderSystem::_setCullingMode( CullingMode mode )
+	void D3D9RenderSystem::setCullingMode( CullingMode mode )
 	{
 		mCullingMode = mode;
 		HRESULT hr;
@@ -1764,14 +1764,14 @@ namespace CamelotEngine
 			CM_EXCEPT(RenderingAPIException, "Failed to set culling mode");
 	}
 	//---------------------------------------------------------------------
-	void D3D9RenderSystem::_setDepthBufferParams( bool depthTest, bool depthWrite, CompareFunction depthFunction )
+	void D3D9RenderSystem::setDepthBufferParams( bool depthTest, bool depthWrite, CompareFunction depthFunction )
 	{
-		_setDepthBufferCheckEnabled( depthTest );
-		_setDepthBufferWriteEnabled( depthWrite );
-		_setDepthBufferFunction( depthFunction );
+		setDepthBufferCheckEnabled( depthTest );
+		setDepthBufferWriteEnabled( depthWrite );
+		setDepthBufferFunction( depthFunction );
 	}
 	//---------------------------------------------------------------------
-	void D3D9RenderSystem::_setDepthBufferCheckEnabled( bool enabled )
+	void D3D9RenderSystem::setDepthBufferCheckEnabled( bool enabled )
 	{
 		HRESULT hr;
 
@@ -1784,7 +1784,7 @@ namespace CamelotEngine
 			CM_EXCEPT(RenderingAPIException, "Error setting depth buffer test state");
 	}
 	//---------------------------------------------------------------------
-	void D3D9RenderSystem::_setDepthBufferWriteEnabled( bool enabled )
+	void D3D9RenderSystem::setDepthBufferWriteEnabled( bool enabled )
 	{
 		HRESULT hr;
 
@@ -1792,14 +1792,14 @@ namespace CamelotEngine
 			CM_EXCEPT(RenderingAPIException, "Error setting depth buffer write state");
 	}
 	//---------------------------------------------------------------------
-	void D3D9RenderSystem::_setDepthBufferFunction( CompareFunction func )
+	void D3D9RenderSystem::setDepthBufferFunction( CompareFunction func )
 	{
 		HRESULT hr;
 		if( FAILED( hr = __SetRenderState( D3DRS_ZFUNC, D3D9Mappings::get(func) ) ) )
 			CM_EXCEPT(RenderingAPIException, "Error setting depth buffer test function");
 	}
 	//---------------------------------------------------------------------
-	void D3D9RenderSystem::_setDepthBias(float constantBias, float slopeScaleBias)
+	void D3D9RenderSystem::setDepthBias(float constantBias, float slopeScaleBias)
 	{
 
 		if ((mDeviceManager->getActiveDevice()->getD3D9DeviceCaps().RasterCaps & D3DPRASTERCAPS_DEPTHBIAS) != 0)
@@ -1825,7 +1825,7 @@ namespace CamelotEngine
 
 	}
 	//---------------------------------------------------------------------
-	void D3D9RenderSystem::_setColourBufferWriteEnabled(bool red, bool green, 
+	void D3D9RenderSystem::setColourBufferWriteEnabled(bool red, bool green, 
 		bool blue, bool alpha)
 	{
 		DWORD val = 0;
@@ -1842,7 +1842,7 @@ namespace CamelotEngine
 			CM_EXCEPT(RenderingAPIException, "Error setting colour write enable flags");
 	}
 	//---------------------------------------------------------------------
-	void D3D9RenderSystem::_setPolygonMode(PolygonMode level)
+	void D3D9RenderSystem::setPolygonMode(PolygonMode level)
 	{
 		HRESULT hr = __SetRenderState(D3DRS_FILLMODE, D3D9Mappings::get(level));
 		if (FAILED(hr))
@@ -1933,7 +1933,7 @@ namespace CamelotEngine
 			CM_EXCEPT(RenderingAPIException, "Error setting stencil pass operation.");
 	}
 	//---------------------------------------------------------------------
-	void D3D9RenderSystem::_setTextureUnitFiltering(size_t unit, FilterType ftype, 
+	void D3D9RenderSystem::setTextureUnitFiltering(size_t unit, FilterType ftype, 
 		FilterOptions filter)
 	{
 		HRESULT hr;
@@ -1951,7 +1951,7 @@ namespace CamelotEngine
 		return oldVal;
 	}
 	//---------------------------------------------------------------------
-	void D3D9RenderSystem::_setTextureLayerAnisotropy(size_t unit, unsigned int maxAnisotropy)
+	void D3D9RenderSystem::setTextureLayerAnisotropy(size_t unit, unsigned int maxAnisotropy)
 	{
 		if (static_cast<DWORD>(maxAnisotropy) > mDeviceManager->getActiveDevice()->getD3D9DeviceCaps().MaxAnisotropy)
 			maxAnisotropy = mDeviceManager->getActiveDevice()->getD3D9DeviceCaps().MaxAnisotropy;
@@ -2007,7 +2007,7 @@ namespace CamelotEngine
 		}
 	}
 	//---------------------------------------------------------------------
-	void D3D9RenderSystem::_setRenderTarget(RenderTarget *target)
+	void D3D9RenderSystem::setRenderTarget(RenderTarget *target)
 	{
 		mActiveRenderTarget = target;
 
@@ -2073,7 +2073,7 @@ namespace CamelotEngine
 		}
 	}
 	//---------------------------------------------------------------------
-	void D3D9RenderSystem::_setViewport( Viewport *vp )
+	void D3D9RenderSystem::setViewport( Viewport *vp )
 	{
 		if( vp != mActiveViewport)
 		{
@@ -2085,10 +2085,10 @@ namespace CamelotEngine
 
 			// Set render target
 			RenderTarget* target = vp->getTarget();
-			_setRenderTarget(target);
+			setRenderTarget(target);
 
 
-			_setCullingMode( mCullingMode );
+			setCullingMode( mCullingMode );
 
 			// set viewport dimensions
 			d3dvp.X = vp->getActualLeft();
@@ -2113,7 +2113,7 @@ namespace CamelotEngine
 		}
 	}
 	//---------------------------------------------------------------------
-	void D3D9RenderSystem::_beginFrame()
+	void D3D9RenderSystem::beginFrame()
 	{
 		HRESULT hr;
 
@@ -2135,7 +2135,7 @@ namespace CamelotEngine
  		mDeviceManager->getActiveDevice()->clearDeviceStreams();
 	}
 	//---------------------------------------------------------------------
-	void D3D9RenderSystem::_endFrame()
+	void D3D9RenderSystem::endFrame()
 	{
 		HRESULT hr;
 		if( FAILED( hr = getActiveD3D9Device()->EndScene() ) )
@@ -2234,7 +2234,7 @@ namespace CamelotEngine
 
 	}
 	//---------------------------------------------------------------------
-	void D3D9RenderSystem::_render(const RenderOperation& op)
+	void D3D9RenderSystem::render(const RenderOperation& op)
 	{
 		// Exit immediately if there is nothing to render
 		// This caused a problem on FireGL 8800
@@ -2242,7 +2242,7 @@ namespace CamelotEngine
 			return;
 
 		// Call super class
-		RenderSystem::_render(op);
+		RenderSystem::render(op);
 
 		// To think about: possibly remove setVertexDeclaration and 
 		// setVertexBufferBinding from RenderSystem since the sequence is
@@ -2411,7 +2411,7 @@ namespace CamelotEngine
 
 					const SamplerState& samplerState = params->getSamplerState(i->second.physicalIndex);
 
-					_setTextureUnitSettings(logicalIndex, texture.getInternalPtr(), samplerState);
+					setTextureUnitSettings(logicalIndex, texture.getInternalPtr(), samplerState);
 				}
 			}
 		}
@@ -2936,7 +2936,7 @@ namespace CamelotEngine
 
 		// Reset the texture stages, they will need to be rebound
 		for (size_t i = 0; i < CM_MAX_TEXTURE_LAYERS; ++i)
-			_setTexture(i, false, TexturePtr());
+			setTexture(i, false, TexturePtr());
 	}
 	
 	//---------------------------------------------------------------------

+ 4 - 0
CamelotForwardRenderer/Include/CmForwardRenderer.h

@@ -8,6 +8,9 @@ namespace CamelotEngine
 	class CM_FWDRND_EXPORT ForwardRenderer : public Renderer
 	{
 	public:
+		ForwardRenderer();
+		~ForwardRenderer();
+
 		virtual const String& getName() const;
 
 		virtual void renderAll();
@@ -15,6 +18,7 @@ namespace CamelotEngine
 
 	protected:
 		PassPtr mActivePass;
+		RenderCommandBuffer* mCommandBuffer;
 
 		/**
 		 * @brief	Overriden from Renderer

+ 32 - 18
CamelotForwardRenderer/Source/CmForwardRenderer.cpp

@@ -7,9 +7,20 @@
 #include "CmMaterial.h"
 #include "CmMesh.h"
 #include "CmPass.h"
+#include "CmRenderCommandBuffer.h"
 
 namespace CamelotEngine
 {
+	ForwardRenderer::ForwardRenderer()
+	{
+		//RenderSystem* renderSystem = RenderSystemManager::getActive();
+
+		//mCommandBuffer = renderSystem->createCommandBuffer();
+	}
+
+	ForwardRenderer::~ForwardRenderer()
+	{ }
+
 	const String& ForwardRenderer::getName() const
 	{
 		static String name = "ForwardRenderer";
@@ -22,7 +33,7 @@ namespace CamelotEngine
 
 		// TODO - No point in setting these each frame?
 		renderSystem->setInvertVertexWinding(false);
-		renderSystem->_setDepthBufferParams();
+		renderSystem->setDepthBufferParams();
 
 
 		const vector<CameraPtr>::type& allCameras = gSceneManager().getAllCameras();
@@ -31,7 +42,7 @@ namespace CamelotEngine
 			render(*iter);
 		}
 
-		renderSystem->_swapAllRenderTargetBuffers(false);
+		renderSystem->swapAllRenderTargetBuffers(false);
 	}
 
 	void ForwardRenderer::render(const CameraPtr camera) 
@@ -39,7 +50,7 @@ namespace CamelotEngine
 		vector<RenderablePtr>::type allRenderables = gSceneManager().getVisibleRenderables(camera);
 
 		RenderSystem* renderSystem = RenderSystemManager::getActive();
-		renderSystem->_setViewport(camera->getViewport());
+		renderSystem->setViewport(camera->getViewport());
 
 		Matrix4 projMatrixCstm = camera->getProjectionMatrix();
 		Matrix4 viewMatrixCstm = camera->getViewMatrix();
@@ -47,7 +58,7 @@ namespace CamelotEngine
 		Matrix4 viewProjMatrix = projMatrixCstm * viewMatrixCstm;
 
 		renderSystem->clearFrameBuffer(FBT_COLOUR | FBT_DEPTH, Color::Blue);
-		renderSystem->_beginFrame();
+		renderSystem->beginFrame();
 
 		// TODO - sort renderables by material/pass/parameters to minimize state changes
 		for(auto iter = allRenderables.begin(); iter != allRenderables.end(); ++iter)
@@ -72,11 +83,14 @@ namespace CamelotEngine
 				setPass(material->getPass(i));
 				setPassParameters(material->getPassParameters(i));
 
-				renderSystem->_render(mesh->getRenderOperation());
+				renderSystem->render(mesh->getRenderOperation());
+
+				//mCommandBuffer->applyPass(material->getPass(i), material->getPassParameters(i));
+				//mCommandBuffer->render(mesh->getRenderOperation());
 			}
 		}
 
-		renderSystem->_endFrame();
+		renderSystem->endFrame();
 
 		// TODO - Sort renderables
 		// Render them
@@ -129,7 +143,7 @@ namespace CamelotEngine
 		// Set scene blending
 		if ( pass->hasSeparateSceneBlending( ) )
 		{
-			renderSystem->_setSeparateSceneBlending(
+			renderSystem->setSeparateSceneBlending(
 				pass->getSourceBlendFactor(), pass->getDestBlendFactor(),
 				pass->getSourceBlendFactorAlpha(), pass->getDestBlendFactorAlpha(),
 				pass->getSceneBlendingOperation(), 
@@ -139,20 +153,20 @@ namespace CamelotEngine
 		{
 			if(pass->hasSeparateSceneBlendingOperations( ) )
 			{
-				renderSystem->_setSeparateSceneBlending(
+				renderSystem->setSeparateSceneBlending(
 					pass->getSourceBlendFactor(), pass->getDestBlendFactor(),
 					pass->getSourceBlendFactor(), pass->getDestBlendFactor(),
 					pass->getSceneBlendingOperation(), pass->getSceneBlendingOperationAlpha() );
 			}
 			else
 			{
-				renderSystem->_setSceneBlending(
+				renderSystem->setSceneBlending(
 					pass->getSourceBlendFactor(), pass->getDestBlendFactor(), pass->getSceneBlendingOperation() );
 			}
 		}
 
 		// Set point parameters
-		renderSystem->_setPointParameters(
+		renderSystem->setPointParameters(
 			pass->getPointSize(),
 			false, 
 			false, 
@@ -169,25 +183,25 @@ namespace CamelotEngine
 
 		// Set up non-texture related material settings
 		// Depth buffer settings
-		renderSystem->_setDepthBufferFunction(pass->getDepthFunction());
-		renderSystem->_setDepthBufferCheckEnabled(pass->getDepthCheckEnabled());
-		renderSystem->_setDepthBufferWriteEnabled(pass->getDepthWriteEnabled());
-		renderSystem->_setDepthBias(pass->getDepthBiasConstant(), pass->getDepthBiasSlopeScale());
+		renderSystem->setDepthBufferFunction(pass->getDepthFunction());
+		renderSystem->setDepthBufferCheckEnabled(pass->getDepthCheckEnabled());
+		renderSystem->setDepthBufferWriteEnabled(pass->getDepthWriteEnabled());
+		renderSystem->setDepthBias(pass->getDepthBiasConstant(), pass->getDepthBiasSlopeScale());
 
 		// Alpha-reject settings
-		renderSystem->_setAlphaRejectSettings(
+		renderSystem->setAlphaRejectSettings(
 			pass->getAlphaRejectFunction(), pass->getAlphaRejectValue(), pass->isAlphaToCoverageEnabled());
 
 		// Set colour write mode
 		// Right now we only use on/off, not per-channel
 		bool colWrite = pass->getColourWriteEnabled();
-		renderSystem->_setColourBufferWriteEnabled(colWrite, colWrite, colWrite, colWrite);
+		renderSystem->setColourBufferWriteEnabled(colWrite, colWrite, colWrite, colWrite);
 
 		// Culling mode
-		renderSystem->_setCullingMode(pass->getCullingMode());
+		renderSystem->setCullingMode(pass->getCullingMode());
 
 		// Polygon mode
-		renderSystem->_setPolygonMode(pass->getPolygonMode());
+		renderSystem->setPolygonMode(pass->getPolygonMode());
 	}
 
 	void ForwardRenderer::setPassParameters(PassParametersPtr params)

+ 23 - 23
CamelotGLRenderer/Include/CmGLRenderSystem.h

@@ -200,32 +200,32 @@ namespace CamelotEngine {
         /** See
           RenderSystem
          */
-		void _setPointParameters(float size, bool attenuationEnabled, 
+		void setPointParameters(float size, bool attenuationEnabled, 
 			float constant, float linear, float quadratic, float minSize, float maxSize);
 		/** See
           RenderSystem
          */
-        void _setTexture(size_t unit, bool enabled, const TexturePtr &tex);
+        void setTexture(size_t unit, bool enabled, const TexturePtr &tex);
         /** See
           RenderSystem
          */
-        void _setTextureAddressingMode(size_t stage, const SamplerState::UVWAddressingMode& uvw);
+        void setTextureAddressingMode(size_t stage, const SamplerState::UVWAddressingMode& uvw);
         /** See
           RenderSystem
          */
-        void _setTextureBorderColour(size_t stage, const Color& colour);
+        void setTextureBorderColour(size_t stage, const Color& colour);
 		/** See
 		  RenderSystem
 		 */
-		void _setTextureMipmapBias(size_t unit, float bias);
+		void setTextureMipmapBias(size_t unit, float bias);
         /** See
           RenderSystem
          */
-        void _setSceneBlending(SceneBlendFactor sourceFactor, SceneBlendFactor destFactor, SceneBlendOperation op );
+        void setSceneBlending(SceneBlendFactor sourceFactor, SceneBlendFactor destFactor, SceneBlendOperation op );
         /** See
           RenderSystem
          */
-		void _setSeparateSceneBlending(SceneBlendFactor sourceFactor, SceneBlendFactor destFactor, SceneBlendFactor sourceFactorAlpha, SceneBlendFactor destFactorAlpha, SceneBlendOperation op, SceneBlendOperation alphaOp );
+		void setSeparateSceneBlending(SceneBlendFactor sourceFactor, SceneBlendFactor destFactor, SceneBlendFactor sourceFactorAlpha, SceneBlendFactor destFactorAlpha, SceneBlendOperation op, SceneBlendOperation alphaOp );
         /** See
           RenderSystem
          */
@@ -237,47 +237,47 @@ namespace CamelotEngine {
 		/** See
           RenderSystem
          */
-        void _setAlphaRejectSettings(CompareFunction func, unsigned char value, bool alphaToCoverage);
+        void setAlphaRejectSettings(CompareFunction func, unsigned char value, bool alphaToCoverage);
         /** See
           RenderSystem
          */
-        void _setViewport(Viewport *vp);
+        void setViewport(Viewport *vp);
         /** See
           RenderSystem
          */
-        void _beginFrame(void);
+        void beginFrame(void);
         /** See
           RenderSystem
          */
-        void _endFrame(void);
+        void endFrame(void);
         /** See
           RenderSystem
          */
-        void _setCullingMode(CullingMode mode);
+        void setCullingMode(CullingMode mode);
         /** See
           RenderSystem
          */
-        void _setDepthBufferParams(bool depthTest = true, bool depthWrite = true, CompareFunction depthFunction = CMPF_LESS_EQUAL);
+        void setDepthBufferParams(bool depthTest = true, bool depthWrite = true, CompareFunction depthFunction = CMPF_LESS_EQUAL);
         /** See
           RenderSystem
          */
-        void _setDepthBufferCheckEnabled(bool enabled = true);
+        void setDepthBufferCheckEnabled(bool enabled = true);
         /** See
           RenderSystem
          */
-        void _setDepthBufferWriteEnabled(bool enabled = true);
+        void setDepthBufferWriteEnabled(bool enabled = true);
         /** See
           RenderSystem
          */
-        void _setDepthBufferFunction(CompareFunction func = CMPF_LESS_EQUAL);
+        void setDepthBufferFunction(CompareFunction func = CMPF_LESS_EQUAL);
         /** See
           RenderSystem
          */
-        void _setDepthBias(float constantBias, float slopeScaleBias);
+        void setDepthBias(float constantBias, float slopeScaleBias);
         /** See
           RenderSystem
          */
-        void _setColourBufferWriteEnabled(bool red, bool green, bool blue, bool alpha);
+        void setColourBufferWriteEnabled(bool red, bool green, bool blue, bool alpha);
         /** See
           RenderSystem
          */
@@ -294,7 +294,7 @@ namespace CamelotEngine {
         /** See
           RenderSystem
          */
-        void _setPolygonMode(PolygonMode level);
+        void setPolygonMode(PolygonMode level);
         /** See
           RenderSystem
          */
@@ -311,11 +311,11 @@ namespace CamelotEngine {
         /** See
           RenderSystem
          */
-        void _setTextureUnitFiltering(size_t unit, FilterType ftype, FilterOptions filter);
+        void setTextureUnitFiltering(size_t unit, FilterType ftype, FilterOptions filter);
         /** See
           RenderSystem
          */
-		void _setTextureLayerAnisotropy(size_t unit, unsigned int maxAnisotropy);
+		void setTextureLayerAnisotropy(size_t unit, unsigned int maxAnisotropy);
         /** See
           RenderSystem
          */
@@ -327,7 +327,7 @@ namespace CamelotEngine {
         /** See
           RenderSystem
          */
-        void _render(const RenderOperation& op);
+        void render(const RenderOperation& op);
         /** See
           RenderSystem
          */
@@ -369,7 +369,7 @@ namespace CamelotEngine {
         /**
          * Set current render target to target, enabling its GL context if needed
          */
-        void _setRenderTarget(RenderTarget *target);
+        void setRenderTarget(RenderTarget *target);
         /** Unregister a render target->context mapping. If the context of target 
             is the current context, change the context to the main context so it
             can be destroyed safely. 

+ 1 - 1
CamelotGLRenderer/Source/CmGLHardwarePixelBuffer.cpp

@@ -577,7 +577,7 @@ void GLTextureBuffer::blitFromTexture(GLTextureBuffer *src, const Box &srcBox, c
 
 	// Important to disable all other texture units
 	RenderSystem* rsys = CamelotEngine::RenderSystemManager::getActive();
-	rsys->_disableTextureUnitsFrom(0);
+	rsys->disableTextureUnitsFrom(0);
 	if (GLEW_VERSION_1_2)
 	{
 		glActiveTextureARB(GL_TEXTURE0);

+ 31 - 31
CamelotGLRenderer/Source/CmGLRenderSystem.cpp

@@ -1060,7 +1060,7 @@ namespace CamelotEngine {
 		}
 	}
 	//-----------------------------------------------------------------------------
-	void GLRenderSystem::_setPointParameters(float size, 
+	void GLRenderSystem::setPointParameters(float size, 
 		bool attenuationEnabled, float constant, float linear, float quadratic,
 		float minSize, float maxSize)
 	{
@@ -1130,7 +1130,7 @@ namespace CamelotEngine {
 		
 	}
 	//-----------------------------------------------------------------------------
-	void GLRenderSystem::_setTexture(size_t stage, bool enabled, const TexturePtr &texPtr)
+	void GLRenderSystem::setTexture(size_t stage, bool enabled, const TexturePtr &texPtr)
 	{
 		GLTexturePtr tex = std::static_pointer_cast<GLTexture>(texPtr);
 
@@ -1205,7 +1205,7 @@ namespace CamelotEngine {
 
 	}
 	//-----------------------------------------------------------------------------
-	void GLRenderSystem::_setTextureAddressingMode(size_t stage, const SamplerState::UVWAddressingMode& uvw)
+	void GLRenderSystem::setTextureAddressingMode(size_t stage, const SamplerState::UVWAddressingMode& uvw)
 	{
 		if (!activateGLTextureUnit(stage))
 			return;
@@ -1218,7 +1218,7 @@ namespace CamelotEngine {
 		activateGLTextureUnit(0);
 	}
 	//-----------------------------------------------------------------------------
-	void GLRenderSystem::_setTextureBorderColour(size_t stage, const Color& colour)
+	void GLRenderSystem::setTextureBorderColour(size_t stage, const Color& colour)
 	{
 		GLfloat border[4] = { colour.r, colour.g, colour.b, colour.a };
 		if (activateGLTextureUnit(stage))
@@ -1228,7 +1228,7 @@ namespace CamelotEngine {
 	}
 	}
 	//-----------------------------------------------------------------------------
-	void GLRenderSystem::_setTextureMipmapBias(size_t stage, float bias)
+	void GLRenderSystem::setTextureMipmapBias(size_t stage, float bias)
 	{
 		if (mCurrentCapabilities->hasCapability(RSC_MIPMAP_LOD_BIAS))
 		{
@@ -1270,7 +1270,7 @@ namespace CamelotEngine {
 		return GL_ONE;
 	}
 
-	void GLRenderSystem::_setSceneBlending(SceneBlendFactor sourceFactor, SceneBlendFactor destFactor, SceneBlendOperation op )
+	void GLRenderSystem::setSceneBlending(SceneBlendFactor sourceFactor, SceneBlendFactor destFactor, SceneBlendOperation op )
 	{
 		GLint sourceBlend = getBlendMode(sourceFactor);
 		GLint destBlend = getBlendMode(destFactor);
@@ -1314,7 +1314,7 @@ namespace CamelotEngine {
 		}
 	}
 	//-----------------------------------------------------------------------------
-	void GLRenderSystem::_setSeparateSceneBlending(
+	void GLRenderSystem::setSeparateSceneBlending(
 		SceneBlendFactor sourceFactor, SceneBlendFactor destFactor, 
 		SceneBlendFactor sourceFactorAlpha, SceneBlendFactor destFactorAlpha,
 		SceneBlendOperation op, SceneBlendOperation alphaOp )
@@ -1383,7 +1383,7 @@ namespace CamelotEngine {
 		}
 	}
 	//-----------------------------------------------------------------------------
-	void GLRenderSystem::_setAlphaRejectSettings(CompareFunction func, unsigned char value, bool alphaToCoverage)
+	void GLRenderSystem::setAlphaRejectSettings(CompareFunction func, unsigned char value, bool alphaToCoverage)
 	{
 		bool a2c = false;
 		static bool lasta2c = false;
@@ -1411,14 +1411,14 @@ namespace CamelotEngine {
 
 	}
 	//-----------------------------------------------------------------------------
-	void GLRenderSystem::_setViewport(Viewport *vp)
+	void GLRenderSystem::setViewport(Viewport *vp)
 	{
 		// Check if viewport is different
 		if (vp != mActiveViewport)
 		{
 			RenderTarget* target;
 			target = vp->getTarget();
-			_setRenderTarget(target);
+			setRenderTarget(target);
 			mActiveViewport = vp;
 
 			GLsizei x, y, w, h;
@@ -1454,7 +1454,7 @@ namespace CamelotEngine {
 	}
 
 	//-----------------------------------------------------------------------------
-	void GLRenderSystem::_beginFrame(void)
+	void GLRenderSystem::beginFrame(void)
 	{
 		if (!mActiveViewport)
 			CM_EXCEPT(InvalidStateException, 
@@ -1465,7 +1465,7 @@ namespace CamelotEngine {
 	}
 
 	//-----------------------------------------------------------------------------
-	void GLRenderSystem::_endFrame(void)
+	void GLRenderSystem::endFrame(void)
 	{
 		// Deactivate the viewport clipping.
 		glDisable(GL_SCISSOR_TEST);
@@ -1477,7 +1477,7 @@ namespace CamelotEngine {
 	}
 
 	//-----------------------------------------------------------------------------
-	void GLRenderSystem::_setCullingMode(CullingMode mode)
+	void GLRenderSystem::setCullingMode(CullingMode mode)
 	{
 		mCullingMode = mode;
 		// NB: Because two-sided stencil API dependence of the front face, we must
@@ -1524,14 +1524,14 @@ namespace CamelotEngine {
 		glCullFace( cullMode );
 	}
 	//-----------------------------------------------------------------------------
-	void GLRenderSystem::_setDepthBufferParams(bool depthTest, bool depthWrite, CompareFunction depthFunction)
+	void GLRenderSystem::setDepthBufferParams(bool depthTest, bool depthWrite, CompareFunction depthFunction)
 	{
-		_setDepthBufferCheckEnabled(depthTest);
-		_setDepthBufferWriteEnabled(depthWrite);
-		_setDepthBufferFunction(depthFunction);
+		setDepthBufferCheckEnabled(depthTest);
+		setDepthBufferWriteEnabled(depthWrite);
+		setDepthBufferFunction(depthFunction);
 	}
 	//-----------------------------------------------------------------------------
-	void GLRenderSystem::_setDepthBufferCheckEnabled(bool enabled)
+	void GLRenderSystem::setDepthBufferCheckEnabled(bool enabled)
 	{
 		if (enabled)
 		{
@@ -1544,7 +1544,7 @@ namespace CamelotEngine {
 		}
 	}
 	//-----------------------------------------------------------------------------
-	void GLRenderSystem::_setDepthBufferWriteEnabled(bool enabled)
+	void GLRenderSystem::setDepthBufferWriteEnabled(bool enabled)
 	{
 		GLboolean flag = enabled ? GL_TRUE : GL_FALSE;
 		glDepthMask( flag );  
@@ -1552,12 +1552,12 @@ namespace CamelotEngine {
 		mDepthWrite = enabled;
 	}
 	//-----------------------------------------------------------------------------
-	void GLRenderSystem::_setDepthBufferFunction(CompareFunction func)
+	void GLRenderSystem::setDepthBufferFunction(CompareFunction func)
 	{
 		glDepthFunc(convertCompareFunction(func));
 	}
 	//-----------------------------------------------------------------------------
-	void GLRenderSystem::_setDepthBias(float constantBias, float slopeScaleBias)
+	void GLRenderSystem::setDepthBias(float constantBias, float slopeScaleBias)
 	{
 		if (constantBias != 0 || slopeScaleBias != 0)
 		{
@@ -1574,7 +1574,7 @@ namespace CamelotEngine {
 		}
 	}
 	//-----------------------------------------------------------------------------
-	void GLRenderSystem::_setColourBufferWriteEnabled(bool red, bool green, bool blue, bool alpha)
+	void GLRenderSystem::setColourBufferWriteEnabled(bool red, bool green, bool blue, bool alpha)
 	{
 		glColorMask(red, green, blue, alpha);
 		// record this
@@ -1602,7 +1602,7 @@ namespace CamelotEngine {
 		dest = matrix;
 	}
 	//---------------------------------------------------------------------
-	void GLRenderSystem::_setPolygonMode(PolygonMode level)
+	void GLRenderSystem::setPolygonMode(PolygonMode level)
 	{
 		GLenum glmode;
 		switch(level)
@@ -1796,7 +1796,7 @@ namespace CamelotEngine {
 
 	}
 	//---------------------------------------------------------------------
-	void GLRenderSystem::_setTextureUnitFiltering(size_t unit, 
+	void GLRenderSystem::setTextureUnitFiltering(size_t unit, 
 		FilterType ftype, FilterOptions fo)
 	{
 		if (!activateGLTextureUnit(unit))
@@ -1851,7 +1851,7 @@ namespace CamelotEngine {
 		return curAniso ? curAniso : 1;
 	}
 	//---------------------------------------------------------------------
-	void GLRenderSystem::_setTextureLayerAnisotropy(size_t unit, unsigned int maxAnisotropy)
+	void GLRenderSystem::setTextureLayerAnisotropy(size_t unit, unsigned int maxAnisotropy)
 	{
 		if (!mCurrentCapabilities->hasCapability(RSC_ANISOTROPY))
 			return;
@@ -1878,10 +1878,10 @@ namespace CamelotEngine {
 	{
 	}
 	//---------------------------------------------------------------------
-	void GLRenderSystem::_render(const RenderOperation& op)
+	void GLRenderSystem::render(const RenderOperation& op)
 	{
 		// Call super class
-		RenderSystem::_render(op);
+		RenderSystem::render(op);
 
 		void* pBufferData = 0;
 		bool multitexturing = (getCapabilities()->getNumTextureUnits() > 1);
@@ -2222,11 +2222,11 @@ namespace CamelotEngine {
 					|| def.constType == GCT_SAMPLER2DSHADOW || def.constType == GCT_SAMPLER3D || def.constType == GCT_SAMPLER1DSHADOW)
 				{
 					TextureRef curTexture = params->getTexture(def.physicalIndex);
-					_setTexture(def.physicalIndex, true, curTexture.getInternalPtr());
+					setTexture(def.physicalIndex, true, curTexture.getInternalPtr());
 
 					const SamplerState& samplerState = params->getSamplerState(def.physicalIndex);
 
-					_setTextureUnitSettings(def.physicalIndex, curTexture.getInternalPtr(), samplerState);
+					setTextureUnitSettings(def.physicalIndex, curTexture.getInternalPtr(), samplerState);
 				}
 			}
 		}
@@ -2479,7 +2479,7 @@ namespace CamelotEngine {
 		mCurrentLights = 0;
 
 		// Disable textures
-		_disableTextureUnitsFrom(0);
+		disableTextureUnitsFrom(0);
 
 		// It's ready for switching
 		if (mCurrentContext)
@@ -2511,7 +2511,7 @@ namespace CamelotEngine {
 
 	}
 	//---------------------------------------------------------------------
-	void GLRenderSystem::_setRenderTarget(RenderTarget *target)
+	void GLRenderSystem::setRenderTarget(RenderTarget *target)
 	{
 		// Unbind frame buffer object
 		if(mActiveRenderTarget)

+ 5 - 2
CamelotRenderer/CamelotRenderer.vcxproj

@@ -95,13 +95,15 @@
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="Include\CmApplication.h" />
+    <ClInclude Include="Include\CmDeferredGpuCommands.h" />
+    <ClInclude Include="Include\CmDeferredRenderSystem.h" />
     <ClInclude Include="Include\CmRenderCommand.h" />
     <ClInclude Include="Include\CmCamera.h" />
     <ClInclude Include="Include\CmCameraRTTI.h" />
     <ClInclude Include="Include\CmCgProgram.h" />
     <ClInclude Include="Include\CmCgProgramFactory.h" />
     <ClInclude Include="Include\CmCgProgramRTTI.h" />
-    <ClInclude Include="Include\CmRenderContext.h" />
+    <ClInclude Include="Include\CmRenderCommandBuffer.h" />
     <ClInclude Include="Include\CmCommon.h" />
     <ClInclude Include="Include\CmComponentRTTI.h" />
     <ClInclude Include="Include\CmConfigOptionMap.h" />
@@ -171,7 +173,7 @@
     <ClInclude Include="Source\CmMeshRTTI.h" />
   </ItemGroup>
   <ItemGroup>
-    <ClCompile Include="Include\CmRenderContext.cpp" />
+    <ClCompile Include="Include\CmRenderCommandBuffer.cpp" />
     <ClCompile Include="Source\CamelotRenderer.cpp" />
     <ClCompile Include="Source\CmApplication.cpp" />
     <ClCompile Include="Source\CmCamera.cpp" />
@@ -217,6 +219,7 @@
     <ClCompile Include="Source\CmWindowEventUtilities.cpp" />
     <ClCompile Include="Source\CmGameObject.cpp" />
     <ClCompile Include="Source\CmComponent.cpp" />
+    <ClCompile Include="Source\CmDeferredRenderSystem.cpp" />
     <ClCompile Include="Source\stdafx.cpp" />
     <ClCompile Include="Source\Win32\CmOSCursorImpl.cpp" />
   </ItemGroup>

+ 12 - 3
CamelotRenderer/CamelotRenderer.vcxproj.filters

@@ -307,10 +307,16 @@
     <ClInclude Include="Include\CmRenderOperation.h">
       <Filter>Header Files\RenderSystem</Filter>
     </ClInclude>
-    <ClInclude Include="Include\CmRenderContext.h">
+    <ClInclude Include="Include\CmRenderCommand.h">
       <Filter>Header Files\RenderSystem</Filter>
     </ClInclude>
-    <ClInclude Include="Include\CmRenderCommand.h">
+    <ClInclude Include="Include\CmRenderCommandBuffer.h">
+      <Filter>Header Files\RenderSystem</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\CmDeferredRenderSystem.h">
+      <Filter>Header Files\RenderSystem</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\CmDeferredGpuCommands.h">
       <Filter>Header Files\RenderSystem</Filter>
     </ClInclude>
   </ItemGroup>
@@ -456,7 +462,10 @@
     <ClCompile Include="Source\CmSamplerState.cpp">
       <Filter>Source Files\RenderSystem</Filter>
     </ClCompile>
-    <ClCompile Include="Include\CmRenderContext.cpp">
+    <ClCompile Include="Include\CmRenderCommandBuffer.cpp">
+      <Filter>Source Files\RenderSystem</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\CmDeferredRenderSystem.cpp">
       <Filter>Source Files\RenderSystem</Filter>
     </ClCompile>
   </ItemGroup>

+ 20 - 0
CamelotRenderer/Include/CmDeferredGpuCommands.h

@@ -0,0 +1,20 @@
+#pragma once
+
+#include "CmPrerequisites.h"
+
+namespace CamelotEngine
+{
+	enum DeferredGpuCommandType
+	{
+		Draw,
+		BeginFrame,
+		EndFrame,
+		Present
+	};
+
+	class CM_EXPORT DeferredGpuCommand
+	{
+	public:
+		DeferredGpuCommandType commandType;
+	};
+}

+ 22 - 0
CamelotRenderer/Include/CmDeferredRenderSystem.h

@@ -0,0 +1,22 @@
+#pragma once
+
+#include "CmPrerequisites.h"
+
+namespace CamelotEngine
+{
+	class DeferredRenderSystem
+	{
+	public:
+		/**
+		 * @brief	Wrapper around RenderSystem method of the same name. See RenderSystem doc.
+		 * 			
+		 * @see		RenderSystem::render()
+		 */
+		void render(const RenderOperation& op);
+
+		void submitToGpu();
+
+	private:
+		vector<DeferredGpuCommand*>::type mRenderCommands;
+	};
+}

+ 3 - 0
CamelotRenderer/Include/CmPrerequisites.h

@@ -102,8 +102,11 @@ namespace CamelotEngine {
 	class Renderable;
 	class Renderer;
 	class RendererFactory;
+	class RenderCommandBuffer;
 	class WorkQueue;
 	class PassParameters;
+	class DeferredRenderSystem;
+	class DeferredGpuCommand;
 	// Asset import
 	class SpecificImporter;
 	class Importer;

+ 1 - 1
CamelotRenderer/Include/CmRenderCommand.h

@@ -16,7 +16,7 @@ namespace CamelotEngine
 		PassParametersPtr getPassParameters() const { return mPassParameters; }
 
 	private:
-		RenderOperation mRO;
+		RenderOperation mRO; // TODO Low priority - Keeping this by value is unnecessary overhead
 		PassPtr mPass;
 		PassParametersPtr mPassParameters;
 	};

+ 80 - 0
CamelotRenderer/Include/CmRenderCommandBuffer.cpp

@@ -0,0 +1,80 @@
+#include "CmRenderCommandBuffer.h"
+#include "CmRenderSystem.h"
+#include "CmRenderer.h"
+#include "CmApplication.h"
+#include "CmRenderSystemManager.h"
+#include "CmRendererManager.h"
+#include "CmException.h"
+
+namespace CamelotEngine
+{
+	RenderCommandBuffer::RenderCommandBuffer(CM_THREAD_ID_TYPE threadId)
+	{
+		mMyThreadId = threadId;
+		mRenderCommands = new vector<RenderCommand>::type();
+	}
+
+	RenderCommandBuffer::~RenderCommandBuffer()
+	{
+		mActivePass = nullptr;
+		mActiveParameters = nullptr;
+
+		if(mRenderCommands != nullptr)
+			delete mRenderCommands;
+	}
+
+	void RenderCommandBuffer::render(RenderOperation renderOp)
+	{
+		CM_LOCK_MUTEX(mCommandBufferMutex)
+
+		throwIfInvalidThread();
+
+		RenderCommand newCommand(renderOp, mActivePass, mActiveParameters);
+
+		mRenderCommands->push_back(newCommand);
+	}
+
+	void RenderCommandBuffer::applyPass(PassPtr pass, PassParametersPtr passParameters)
+	{
+		CM_LOCK_MUTEX(mCommandBufferMutex)
+
+		throwIfInvalidThread();
+
+		mActivePass = pass;
+		mActiveParameters = passParameters;
+	}
+
+	void RenderCommandBuffer::playDeferredCommands()
+	{
+		vector<RenderCommand>::type* oldRenderCommands = nullptr;
+		
+		{
+			CM_LOCK_MUTEX(mCommandBufferMutex)
+			oldRenderCommands = mRenderCommands;
+			mRenderCommands = new vector<RenderCommand>::type();
+		}
+
+		RenderSystem* renderSystem = RenderSystemManager::getActive();
+		RendererPtr renderer = RendererManager::getActive();
+		
+		for(auto iter = oldRenderCommands->begin(); iter != oldRenderCommands->end(); ++iter)
+		{
+			renderer->setPass(iter->getPass());
+			renderer->setPassParameters(iter->getPassParameters());
+
+			renderSystem->render(iter->getRenderOperation());
+		}
+
+		if(oldRenderCommands != nullptr)
+			delete oldRenderCommands;
+
+		mActivePass = nullptr;
+		mActiveParameters = nullptr;
+	}
+
+	void RenderCommandBuffer::throwIfInvalidThread()
+	{
+		if(mMyThreadId != CM_THREAD_CURRENT_ID)
+			CM_EXCEPT(InternalErrorException, "Calling the rendering context from an invalid thread.");
+	}
+}

+ 23 - 7
CamelotRenderer/Include/CmRenderContext.h → CamelotRenderer/Include/CmRenderCommandBuffer.h

@@ -6,9 +6,17 @@
 
 namespace CamelotEngine
 {
-	class RenderContext
+	/**
+	 * @brief	Used for multithreaded rendering. One render command buffer should exist per thread.
+	 * 			All render operations are recorded in the buffer, and then played back
+	 * 			on the render thread. 
+	 */
+	class RenderCommandBuffer
 	{
 	public:
+		RenderCommandBuffer(CM_THREAD_ID_TYPE threadId);
+		~RenderCommandBuffer();
+
 		/**
 		 * @brief	Adds a new render command that will be executed when the playback is initiated.
 		 * 			CommandBuffer takes ownership of the command, and will release it after playback is complete.
@@ -21,16 +29,24 @@ namespace CamelotEngine
 		 */
 		void applyPass(PassPtr pass, PassParametersPtr passParameters);
 
+	private:
+		CM_MUTEX(mCommandBufferMutex)
+		vector<RenderCommand>::type* mRenderCommands;
+
+		PassPtr mActivePass;
+		PassParametersPtr mActiveParameters;
+
+		CM_THREAD_ID_TYPE mMyThreadId;
+
+		void throwIfInvalidThread();
+
+	private:
+		friend class RenderSystem;
+
 		/**
 		 * @brief	Executed all commands stored in the buffers, in the order in which they were added.
 		 * 			Must be called on the render thread.
 		 */
 		void playDeferredCommands();
-
-	private:
-		vector<RenderCommand>::type mRenderCommands;
-
-		PassPtr mActivePass;
-		PassParametersPtr mActiveParameters;
 	};
 }

+ 0 - 38
CamelotRenderer/Include/CmRenderContext.cpp

@@ -1,38 +0,0 @@
-#include "CmRenderContext.h"
-#include "CmRenderSystem.h"
-#include "CmRenderer.h"
-#include "CmApplication.h"
-#include "CmRenderSystemManager.h"
-#include "CmRendererManager.h"
-
-namespace CamelotEngine
-{
-	void RenderContext::render(RenderOperation renderOp)
-	{
-		RenderCommand newCommand(renderOp, mActivePass, mActiveParameters);
-
-		mRenderCommands.push_back(newCommand);
-	}
-
-	void RenderContext::applyPass(PassPtr pass, PassParametersPtr passParameters)
-	{
-		mActivePass = pass;
-		mActiveParameters = passParameters;
-	}
-
-	void RenderContext::playDeferredCommands()
-	{
-		RenderSystem* renderSystem = RenderSystemManager::getActive();
-		RendererPtr renderer = RendererManager::getActive();
-		
-		for(auto iter = mRenderCommands.begin(); iter != mRenderCommands.end(); ++iter)
-		{
-			renderer->setPass(iter->getPass());
-			renderer->setPassParameters(iter->getPassParameters());
-
-			renderSystem->_render(iter->getRenderOperation());
-		}
-
-		mRenderCommands.clear();
-	}
-}

+ 35 - 35
CamelotRenderer/Include/CmRenderSystem.h

@@ -493,11 +493,11 @@ namespace CamelotEngine
 		only sets those settings which are different from the current settings for this
 		unit, thus minimising render state changes.
 		*/
-		virtual void _setTextureUnitSettings(size_t texUnit, const TexturePtr& texture, const SamplerState& tl);
+		virtual void setTextureUnitSettings(size_t texUnit, const TexturePtr& texture, const SamplerState& tl);
 		/** Turns off a texture unit. */
-		virtual void _disableTextureUnit(size_t texUnit);
+		virtual void disableTextureUnit(size_t texUnit);
 		/** Disables all texture units from the given unit upwards */
-		virtual void _disableTextureUnitsFrom(size_t texUnit);
+		virtual void disableTextureUnitsFrom(size_t texUnit);
 
 		/** Sets the size of points and how they are attenuated with distance.
 		@remarks
@@ -509,7 +509,7 @@ namespace CamelotEngine
 		you would set constant to 1, and linear and quadratic to 0. A
 		standard perspective attenuation would be 0, 1, 0 respectively.
 		*/
-		virtual void _setPointParameters(float size, bool attenuationEnabled, 
+		virtual void setPointParameters(float size, bool attenuationEnabled, 
 			float constant, float linear, float quadratic, float minSize, float maxSize) = 0;
 
 
@@ -525,7 +525,7 @@ namespace CamelotEngine
 		@param enabled Boolean to turn the unit on/off
 		@param texPtr Pointer to the texture to use.
 		*/
-		virtual void _setTexture(size_t unit, bool enabled, 
+		virtual void setTexture(size_t unit, bool enabled, 
 			const TexturePtr &texPtr) = 0;
 
 		/** Binds a texture to a vertex sampler.
@@ -537,7 +537,7 @@ namespace CamelotEngine
 		fragment units; calling this method will throw an exception.
 		@see RenderSystemCapabilites::getVertexTextureUnitsShared
 		*/
-		virtual void _setVertexTexture(size_t unit, const TexturePtr& tex);
+		virtual void setVertexTexture(size_t unit, const TexturePtr& tex);
 
 		/** Sets the filtering options for a given texture unit.
 		@param unit The texture unit to set the filtering options for
@@ -545,7 +545,7 @@ namespace CamelotEngine
 		@param magFilter The filter used when a texture is magnified
 		@param mipFilter The filter used between mipmap levels, FO_NONE disables mipmapping
 		*/
-		virtual void _setTextureUnitFiltering(size_t unit, FilterOptions minFilter,
+		virtual void setTextureUnitFiltering(size_t unit, FilterOptions minFilter,
 			FilterOptions magFilter, FilterOptions mipFilter);
 
 		/** Sets a single filter for a given texture unit.
@@ -553,16 +553,16 @@ namespace CamelotEngine
 		@param ftype The filter type
 		@param filter The filter to be used
 		*/
-		virtual void _setTextureUnitFiltering(size_t unit, FilterType ftype, FilterOptions filter) = 0;
+		virtual void setTextureUnitFiltering(size_t unit, FilterType ftype, FilterOptions filter) = 0;
 
 		/** Sets the maximal anisotropy for the specified texture unit.*/
-		virtual void _setTextureLayerAnisotropy(size_t unit, unsigned int maxAnisotropy) = 0;
+		virtual void setTextureLayerAnisotropy(size_t unit, unsigned int maxAnisotropy) = 0;
 
 		/** Sets the texture addressing mode for a texture unit.*/
-		virtual void _setTextureAddressingMode(size_t unit, const SamplerState::UVWAddressingMode& uvw) = 0;
+		virtual void setTextureAddressingMode(size_t unit, const SamplerState::UVWAddressingMode& uvw) = 0;
 
 		/** Sets the texture border colour for a texture unit.*/
-		virtual void _setTextureBorderColour(size_t unit, const Color& colour) = 0;
+		virtual void setTextureBorderColour(size_t unit, const Color& colour) = 0;
 
 		/** Sets the mipmap bias value for a given texture unit.
 		@remarks
@@ -572,7 +572,7 @@ namespace CamelotEngine
 		of levels, so +1 forces the mipmaps to one smaller level.
 		@note Only does something if render system has capability RSC_MIPMAP_LOD_BIAS.
 		*/
-		virtual void _setTextureMipmapBias(size_t unit, float bias) = 0;
+		virtual void setTextureMipmapBias(size_t unit, float bias) = 0;
 
 		/** Sets the global blending factors for combining subsequent renders with the existing frame contents.
 		The result of the blending operation is:</p>
@@ -584,7 +584,7 @@ namespace CamelotEngine
 		@param destFactor The destination factor in the above calculation, i.e. multiplied by the pixel colour components.
 		@param op The blend operation mode for combining pixels
 		*/
-		virtual void _setSceneBlending(SceneBlendFactor sourceFactor, SceneBlendFactor destFactor, SceneBlendOperation op = SBO_ADD) = 0;
+		virtual void setSceneBlending(SceneBlendFactor sourceFactor, SceneBlendFactor destFactor, SceneBlendOperation op = SBO_ADD) = 0;
 
 		/** Sets the global blending factors for combining subsequent renders with the existing frame contents.
 		The result of the blending operation is:</p>
@@ -598,7 +598,7 @@ namespace CamelotEngine
 		@param op The blend operation mode for combining pixels
 		@param alphaOp The blend operation mode for combining pixel alpha values
 		*/
-		virtual void _setSeparateSceneBlending(SceneBlendFactor sourceFactor, SceneBlendFactor destFactor, SceneBlendFactor sourceFactorAlpha, 
+		virtual void setSeparateSceneBlending(SceneBlendFactor sourceFactor, SceneBlendFactor destFactor, SceneBlendFactor sourceFactorAlpha, 
 			SceneBlendFactor destFactorAlpha, SceneBlendOperation op = SBO_ADD, SceneBlendOperation alphaOp = SBO_ADD) = 0;
 
 		/** Sets the global alpha rejection approach for future renders.
@@ -607,18 +607,18 @@ namespace CamelotEngine
 		@param val The value to compare each pixels alpha value to (0-255)
 		@param alphaToCoverage Whether to enable alpha to coverage, if supported
 		*/
-		virtual void _setAlphaRejectSettings(CompareFunction func, unsigned char value, bool alphaToCoverage) = 0;
+		virtual void setAlphaRejectSettings(CompareFunction func, unsigned char value, bool alphaToCoverage) = 0;
 
 		/**
 		* Signifies the beginning of a frame, i.e. the start of rendering on a single viewport. Will occur
 		* several times per complete frame if multiple viewports exist.
 		*/
-		virtual void _beginFrame(void) = 0;
+		virtual void beginFrame(void) = 0;
 		
 		/**
 		* Ends rendering of a frame to the current viewport.
 		*/
-		virtual void _endFrame(void) = 0;
+		virtual void endFrame(void) = 0;
 		/**
 		Sets the provided viewport as the active one for future
 		rendering operations. This viewport is aware of it's own
@@ -626,9 +626,9 @@ namespace CamelotEngine
 
 		@param target Pointer to the appropriate viewport.
 		*/
-		virtual void _setViewport(Viewport *vp) = 0;
+		virtual void setViewport(Viewport *vp) = 0;
 		/** Get the current active viewport for rendering. */
-		virtual Viewport* _getViewport(void);
+		virtual Viewport* getViewport(void);
 
 		/** Sets the culling mode for the render system based on the 'vertex winding'.
 		A typical way for the rendering engine to cull triangles is based on the
@@ -641,9 +641,9 @@ namespace CamelotEngine
 		You may wish to use the CULL_NONE option for mesh data that you cull yourself where the vertex
 		winding is uncertain.
 		*/
-		virtual void _setCullingMode(CullingMode mode) = 0;
+		virtual void setCullingMode(CullingMode mode) = 0;
 
-		virtual CullingMode _getCullingMode(void) const;
+		virtual CullingMode getCullingMode(void) const;
 
 		/** Sets the mode of operation for depth buffer tests from this point onwards.
 		Sometimes you may wish to alter the behaviour of the depth buffer to achieve
@@ -658,18 +658,18 @@ namespace CamelotEngine
 		If false, the depth buffer is left unchanged even if a new pixel is written.
 		@param depthFunction Sets the function required for the depth test.
 		*/
-		virtual void _setDepthBufferParams(bool depthTest = true, bool depthWrite = true, CompareFunction depthFunction = CMPF_LESS_EQUAL) = 0;
+		virtual void setDepthBufferParams(bool depthTest = true, bool depthWrite = true, CompareFunction depthFunction = CMPF_LESS_EQUAL) = 0;
 
 		/** Sets whether or not the depth buffer check is performed before a pixel write.
 		@param enabled If true, the depth buffer is tested for each pixel and the frame buffer is only updated
 		if the depth function test succeeds. If false, no test is performed and pixels are always written.
 		*/
-		virtual void _setDepthBufferCheckEnabled(bool enabled = true) = 0;
+		virtual void setDepthBufferCheckEnabled(bool enabled = true) = 0;
 		/** Sets whether or not the depth buffer is updated after a pixel write.
 		@param enabled If true, the depth buffer is updated with the depth of the new pixel if the depth test succeeds.
 		If false, the depth buffer is left unchanged even if a new pixel is written.
 		*/
-		virtual void _setDepthBufferWriteEnabled(bool enabled = true) = 0;
+		virtual void setDepthBufferWriteEnabled(bool enabled = true) = 0;
 		/** Sets the comparison function for the depth buffer check.
 		Advanced use only - allows you to choose the function applied to compare the depth values of
 		new and existing pixels in the depth buffer. Only an issue if the deoth buffer check is enabled
@@ -677,7 +677,7 @@ namespace CamelotEngine
 		@param  func The comparison between the new depth and the existing depth which must return true
 		for the new pixel to be written.
 		*/
-		virtual void _setDepthBufferFunction(CompareFunction func = CMPF_LESS_EQUAL) = 0;
+		virtual void setDepthBufferFunction(CompareFunction func = CMPF_LESS_EQUAL) = 0;
 		/** Sets whether or not colour buffer writing is enabled, and for which channels. 
 		@remarks
 		For some advanced effects, you may wish to turn off the writing of certain colour
@@ -685,7 +685,7 @@ namespace CamelotEngine
 		in a rendering pass. However, the chances are that you really want to use this option
 		through the Material class.
 		@param red, green, blue, alpha Whether writing is enabled for each of the 4 colour channels. */
-		virtual void _setColourBufferWriteEnabled(bool red, bool green, bool blue, bool alpha) = 0;
+		virtual void setColourBufferWriteEnabled(bool red, bool green, bool blue, bool alpha) = 0;
 		/** Sets the depth bias, NB you should use the Material version of this. 
 		@remarks
 		When polygons are coplanar, you can get problems with 'depth fighting' where
@@ -708,16 +708,16 @@ namespace CamelotEngine
 		cards.
 
 		*/
-		virtual void _setDepthBias(float constantBias, float slopeScaleBias = 0.0f) = 0;
+		virtual void setDepthBias(float constantBias, float slopeScaleBias = 0.0f) = 0;
 
 		/** The RenderSystem will keep a count of tris rendered, this resets the count. */
-		virtual void _beginGeometryCount(void);
+		virtual void beginGeometryCount(void);
 		/** Reports the number of tris rendered since the last _beginGeometryCount call. */
-		virtual unsigned int _getFaceCount(void) const;
+		virtual unsigned int getFaceCount(void) const;
 		/** Reports the number of batches rendered since the last _beginGeometryCount call. */
-		virtual unsigned int _getBatchCount(void) const;
+		virtual unsigned int getBatchCount(void) const;
 		/** Reports the number of vertices passed to the renderer since the last _beginGeometryCount call. */
-		virtual unsigned int _getVertexCount(void) const;
+		virtual unsigned int getVertexCount(void) const;
 
 		/** Generates a packed data version of the passed in ColourValue suitable for
 		use as with this RenderSystem.
@@ -743,7 +743,7 @@ namespace CamelotEngine
 			Matrix4& dest, bool forGpuProgram = false) = 0;
 
 		/** Sets how to rasterise triangles, as points, wireframe or solid polys. */
-		virtual void _setPolygonMode(PolygonMode level) = 0;
+		virtual void setPolygonMode(PolygonMode level) = 0;
 
 		/** Turns stencil buffer checking on or off. 
 		@remarks
@@ -830,7 +830,7 @@ namespace CamelotEngine
 		@param op A rendering operation instance, which contains
 		details of the operation to be performed.
 		*/
-		virtual void _render(const RenderOperation& op);
+		virtual void render(const RenderOperation& op);
 
 		/** Gets the capabilities of the render system. */
 		const RenderSystemCapabilities* getCapabilities(void) const { return mCurrentCapabilities; }
@@ -878,7 +878,7 @@ namespace CamelotEngine
 
 		/** Internal method for swapping all the buffers on all render targets,
 		if _updateAllRenderTargets was called with a 'false' parameter. */
-		virtual void _swapAllRenderTargetBuffers(bool waitForVsync = true);
+		virtual void swapAllRenderTargetBuffers(bool waitForVsync = true);
 
 		/** Sets whether or not vertex windings set should be inverted; this can be important
 		for rendering reflections. */
@@ -956,7 +956,7 @@ namespace CamelotEngine
 		/**
          * Set current render target to target, enabling its device context if needed
          */
-        virtual void _setRenderTarget(RenderTarget *target) = 0;
+        virtual void setRenderTarget(RenderTarget *target) = 0;
 
 		/** Register the an additional thread which may make calls to rendersystem-related 
 		objects.

+ 1 - 1
CamelotRenderer/Include/CmRenderer.h

@@ -20,7 +20,7 @@ namespace CamelotEngine
 		virtual void render(const CameraPtr camera) = 0;
 
 	protected:
-		friend class RenderContext;
+		friend class RenderCommandBuffer;
 		/**
 		 * @brief	Sets the currently active pass.
 		 */

+ 6 - 0
CamelotRenderer/Source/CmDeferredRenderSystem.cpp

@@ -0,0 +1,6 @@
+#include "CmDeferredRenderSystem.h"
+
+namespace CamelotEngine
+{
+	
+}

+ 27 - 27
CamelotRenderer/Source/CmRenderSystem.cpp

@@ -75,7 +75,7 @@ namespace CamelotEngine {
 		mCurrentCapabilities = 0;
     }
     //-----------------------------------------------------------------------
-    void RenderSystem::_swapAllRenderTargetBuffers(bool waitForVSync)
+    void RenderSystem::swapAllRenderTargetBuffers(bool waitForVSync)
     {
         // Update all in order of priority
         // This ensures render-to-texture targets get updated before render windows
@@ -250,12 +250,12 @@ namespace CamelotEngine {
         return ret;
     }
     //-----------------------------------------------------------------------
-    Viewport* RenderSystem::_getViewport(void)
+    Viewport* RenderSystem::getViewport(void)
     {
         return mActiveViewport;
     }
     //-----------------------------------------------------------------------
-    void RenderSystem::_setTextureUnitSettings(size_t texUnit, const TexturePtr& tex, const SamplerState& tl)
+    void RenderSystem::setTextureUnitSettings(size_t texUnit, const TexturePtr& tex, const SamplerState& tl)
     {
         // This method is only ever called to set a texture unit to valid details
         // The method _disableTextureUnit is called to turn a unit off
@@ -267,43 +267,43 @@ namespace CamelotEngine {
 			if (tl.getBindingType() == SamplerState::BT_VERTEX)
 			{
 				// Bind vertex texture
-				_setVertexTexture(texUnit, tex);
+				setVertexTexture(texUnit, tex);
 				// bind nothing to fragment unit (hardware isn't shared but fragment
 				// unit can't be using the same index
-				_setTexture(texUnit, true, sNullTexPtr);
+				setTexture(texUnit, true, sNullTexPtr);
 			}
 			else
 			{
 				// vice versa
-				_setVertexTexture(texUnit, sNullTexPtr);
-				_setTexture(texUnit, true, tex);
+				setVertexTexture(texUnit, sNullTexPtr);
+				setTexture(texUnit, true, tex);
 			}
 		}
 		else
 		{
 			// Shared vertex / fragment textures or no vertex texture support
 			// Bind texture (may be blank)
-			_setTexture(texUnit, true, tex);
+			setTexture(texUnit, true, tex);
 		}
 
         // Set texture layer filtering
-        _setTextureUnitFiltering(texUnit, 
+        setTextureUnitFiltering(texUnit, 
             tl.getTextureFiltering(FT_MIN), 
             tl.getTextureFiltering(FT_MAG), 
             tl.getTextureFiltering(FT_MIP));
 
         // Set texture layer filtering
-        _setTextureLayerAnisotropy(texUnit, tl.getTextureAnisotropy());
+        setTextureLayerAnisotropy(texUnit, tl.getTextureAnisotropy());
 
 		// Set mipmap biasing
-		_setTextureMipmapBias(texUnit, tl.getTextureMipmapBias());
+		setTextureMipmapBias(texUnit, tl.getTextureMipmapBias());
 
         // Texture addressing mode
         const SamplerState::UVWAddressingMode& uvw = tl.getTextureAddressingMode();
-        _setTextureAddressingMode(texUnit, uvw);
+        setTextureAddressingMode(texUnit, uvw);
     }
 	//-----------------------------------------------------------------------
-	void RenderSystem::_setVertexTexture(size_t unit, const TexturePtr& tex)
+	void RenderSystem::setVertexTexture(size_t unit, const TexturePtr& tex)
 	{
 		CM_EXCEPT(NotImplementedException, 
 			"This rendersystem does not support separate vertex texture samplers, "
@@ -311,12 +311,12 @@ namespace CamelotEngine {
 			"the vertex and fragment units.");
 	}
     //-----------------------------------------------------------------------
-    void RenderSystem::_disableTextureUnit(size_t texUnit)
+    void RenderSystem::disableTextureUnit(size_t texUnit)
     {
-        _setTexture(texUnit, false, sNullTexPtr);
+        setTexture(texUnit, false, sNullTexPtr);
     }
     //---------------------------------------------------------------------
-    void RenderSystem::_disableTextureUnitsFrom(size_t texUnit)
+    void RenderSystem::disableTextureUnitsFrom(size_t texUnit)
     {
         size_t disableTo = CM_MAX_TEXTURE_LAYERS;
         if (disableTo > mDisabledTexUnitsFrom)
@@ -324,19 +324,19 @@ namespace CamelotEngine {
         mDisabledTexUnitsFrom = texUnit;
         for (size_t i = texUnit; i < disableTo; ++i)
         {
-            _disableTextureUnit(i);
+            disableTextureUnit(i);
         }
     }
     //-----------------------------------------------------------------------
-    void RenderSystem::_setTextureUnitFiltering(size_t unit, FilterOptions minFilter,
+    void RenderSystem::setTextureUnitFiltering(size_t unit, FilterOptions minFilter,
             FilterOptions magFilter, FilterOptions mipFilter)
     {
-        _setTextureUnitFiltering(unit, FT_MIN, minFilter);
-        _setTextureUnitFiltering(unit, FT_MAG, magFilter);
-        _setTextureUnitFiltering(unit, FT_MIP, mipFilter);
+        setTextureUnitFiltering(unit, FT_MIN, minFilter);
+        setTextureUnitFiltering(unit, FT_MAG, magFilter);
+        setTextureUnitFiltering(unit, FT_MIP, mipFilter);
     }
     //-----------------------------------------------------------------------
-    CullingMode RenderSystem::_getCullingMode(void) const
+    CullingMode RenderSystem::getCullingMode(void) const
     {
         return mCullingMode;
     }
@@ -369,23 +369,23 @@ namespace CamelotEngine {
 		mPrioritisedRenderTargets.clear();
     }
     //-----------------------------------------------------------------------
-    void RenderSystem::_beginGeometryCount(void)
+    void RenderSystem::beginGeometryCount(void)
     {
         mBatchCount = mFaceCount = mVertexCount = 0;
 
     }
     //-----------------------------------------------------------------------
-    unsigned int RenderSystem::_getFaceCount(void) const
+    unsigned int RenderSystem::getFaceCount(void) const
     {
         return static_cast< unsigned int >( mFaceCount );
     }
     //-----------------------------------------------------------------------
-    unsigned int RenderSystem::_getBatchCount(void) const
+    unsigned int RenderSystem::getBatchCount(void) const
     {
         return static_cast< unsigned int >( mBatchCount );
     }
     //-----------------------------------------------------------------------
-    unsigned int RenderSystem::_getVertexCount(void) const
+    unsigned int RenderSystem::getVertexCount(void) const
     {
         return static_cast< unsigned int >( mVertexCount );
     }
@@ -396,7 +396,7 @@ namespace CamelotEngine {
 
 	}
     //-----------------------------------------------------------------------
-    void RenderSystem::_render(const RenderOperation& op)
+    void RenderSystem::render(const RenderOperation& op)
     {
         // Update stats
         size_t val;

+ 3 - 3
CamelotRenderer/Source/CmViewport.cpp

@@ -166,14 +166,14 @@ namespace CamelotEngine {
 		RenderSystem* rs = CamelotEngine::RenderSystemManager::getActive();
 		if (rs)
 		{
-			Viewport* currentvp = rs->_getViewport();
+			Viewport* currentvp = rs->getViewport();
 			if (currentvp && currentvp == this)
 				rs->clearFrameBuffer(buffers, col, depth, stencil);
 			else if (currentvp)
 			{
-				rs->_setViewport(this);
+				rs->setViewport(this);
 				rs->clearFrameBuffer(buffers, col, depth, stencil);
-				rs->_setViewport(currentvp);
+				rs->setViewport(currentvp);
 			}
 		}
 	}

+ 27 - 0
CamelotRenderer/TODO.txt

@@ -14,6 +14,33 @@ High-level TODO:
    - Render queue and sorting
  - DX11 render system
 
+
+Command buffer TODO:
+IMPORTANT:
+ I can't just do CommandBuffer->setPass and expect it to work. User can modify the materials at any point before rendering happens, which will cause all kind of problems. I'll need to copy properties one by one.
+  - In order to avoid this, GpuParameters should return a copy of its physical data. (Similar to what Mesh->GetRenderOperation does). 
+  - Pass should return a copy of its own data as well.
+
+MAYBE:
+ - Create DeferredRenderSystem class that has exactly the same public interface as RenderSystem, but defers all calls to a command buffer
+   - As its methods are called we can also filter out values that exactly match the previous ones and minimize number of state changes
+      (Although this should probably be on a higher level, because 1 class 1 use)
+
+Essential TODO for deferred rendering:
+ - Block all calls to RenderSystem outside of Render thread (or at least warn)
+ - Prevent user from accessing vertex/index buffers and similar outside of render thread as well
+ - Start render thread in application
+
+ - Modify resource creation so it calls RenderContext and just schedules resource creation
+
+ - (Optional) Add callbacks from render thread (e.g. pre/post render) and only allow users to create vertex buffer and similar manually from there? at least temporarily. "Direct" access from worker threads might be useful, although users should always be able to use abstractions like Mesh and similar.
+   - Reading from resources should however block the render thread and get the actual resource. Reading is slow anyway and won't be done often.
+   - Writing can be accomplished if RenderContext just returns temporary memory we can write to, and then actually writes it during playback.
+   - Both reading & writing can be accomplished if we keep all data in system memory, which GL does internally (but we can't access it), and optionally DX does too (but again, can't access it). Unless we can access it it's too much memory overhead.
+
+
+
+
 HIGH PRIORITY TODO:
  - Issue with deserialization and value types:
   - Value types are only set at the end of deserialization, because I want to be sure all of their fields are initialized. However there is nothing stopping a custom RTTI method from accessing a (yet uninitialized) value in a ptr field. (See CmMaterialRTTI, setTexParam). I need to initialize fields in a better order.