Browse Source

Finalized removing all raw pointers from RenderSystem

Marko Pintera 13 years ago
parent
commit
3e47d2941c

+ 34 - 34
CamelotClient/CamelotClient.cpp

@@ -33,8 +33,8 @@ int CALLBACK WinMain(
 	)
 	)
 {
 {
 	//gApplication().startUp("CamelotGLRenderSystem", "CamelotForwardRenderer");
 	//gApplication().startUp("CamelotGLRenderSystem", "CamelotForwardRenderer");
-	gApplication().startUp("CamelotD3D9RenderSystem", "CamelotForwardRenderer");
-	//gApplication().startUp("CamelotD3D11RenderSystem", "CamelotForwardRenderer");
+	//gApplication().startUp("CamelotD3D9RenderSystem", "CamelotForwardRenderer");
+	gApplication().startUp("CamelotD3D11RenderSystem", "CamelotForwardRenderer");
 
 
 	RenderSystem* renderSystem = RenderSystem::instancePtr();
 	RenderSystem* renderSystem = RenderSystem::instancePtr();
 	RenderWindowPtr renderWindow = gApplication().getPrimaryRenderWindow();
 	RenderWindowPtr renderWindow = gApplication().getPrimaryRenderWindow();
@@ -54,51 +54,51 @@ int CALLBACK WinMain(
 	RenderablePtr testRenderable = testModelGO->addComponent<Renderable>();
 	RenderablePtr testRenderable = testModelGO->addComponent<Renderable>();
 
 
 	/////////////////// HLSL 9 SHADERS //////////////////////////
 	/////////////////// HLSL 9 SHADERS //////////////////////////
-	String fragShaderCode = "sampler2D tex;			\
-							float4 ps_main(float2 uv : TEXCOORD0) : COLOR0		\
-							{														\
-							float4 color = tex2D(tex, uv);				\
-							return color;										\
-							}";
-
-	HighLevelGpuProgramHandle fragProgRef =  HighLevelGpuProgram::create(fragShaderCode, "ps_main", "hlsl", GPT_FRAGMENT_PROGRAM, GPP_PS_2_0);
-
-	String vertShaderCode = "float4x4 matViewProjection;	\
-							void vs_main(										\
-							float4 inPos : POSITION,							\
-							float2 uv : TEXCOORD0,								\
-							out float4 oPosition : POSITION,					\
-							out float2 oUv : TEXCOORD0)							\
-							{														\
-							oPosition = mul(matViewProjection, inPos);			\
-							oUv = uv;											\
-							}";
-
-	HighLevelGpuProgramHandle vertProgRef =  HighLevelGpuProgram::create(vertShaderCode, "vs_main", "hlsl", GPT_VERTEX_PROGRAM, GPP_VS_2_0);
-
-	/////////////////// HLSL 11 SHADERS //////////////////////////
-	//String fragShaderCode = "SamplerState samp : register(s0);			\
-	//						Texture2D tex : register(t0); \
-	//						float4 ps_main(in float4 inPos : SV_Position, float2 uv : TEXCOORD0) : SV_Target		\
+	//String fragShaderCode = "sampler2D tex;			\
+	//						float4 ps_main(float2 uv : TEXCOORD0) : COLOR0		\
 	//						{														\
 	//						{														\
-	//						float4 color = tex.Sample(samp, uv);				\
+	//						float4 color = tex2D(tex, uv);				\
 	//						return color;										\
 	//						return color;										\
 	//						}";
 	//						}";
 
 
-	//HighLevelGpuProgramHandle fragProgRef =  HighLevelGpuProgram::create(fragShaderCode, "ps_main", "hlsl", GPT_FRAGMENT_PROGRAM, GPP_PS_4_0);
+	//HighLevelGpuProgramHandle fragProgRef =  HighLevelGpuProgram::create(fragShaderCode, "ps_main", "hlsl", GPT_FRAGMENT_PROGRAM, GPP_PS_2_0);
 
 
 	//String vertShaderCode = "float4x4 matViewProjection;	\
 	//String vertShaderCode = "float4x4 matViewProjection;	\
 	//						void vs_main(										\
 	//						void vs_main(										\
-	//						in float4 inPos : POSITION,							\
-	//						in float2 uv : TEXCOORD0,								\
-	//						out float4 oPosition : SV_Position,					\
+	//						float4 inPos : POSITION,							\
+	//						float2 uv : TEXCOORD0,								\
+	//						out float4 oPosition : POSITION,					\
 	//						out float2 oUv : TEXCOORD0)							\
 	//						out float2 oUv : TEXCOORD0)							\
 	//						{														\
 	//						{														\
 	//						oPosition = mul(matViewProjection, inPos);			\
 	//						oPosition = mul(matViewProjection, inPos);			\
 	//						oUv = uv;											\
 	//						oUv = uv;											\
 	//						}";
 	//						}";
 
 
-	//HighLevelGpuProgramHandle vertProgRef =  HighLevelGpuProgram::create(vertShaderCode, "vs_main", "hlsl", GPT_VERTEX_PROGRAM, GPP_VS_4_0);
+	//HighLevelGpuProgramHandle vertProgRef =  HighLevelGpuProgram::create(vertShaderCode, "vs_main", "hlsl", GPT_VERTEX_PROGRAM, GPP_VS_2_0);
+
+	/////////////////// HLSL 11 SHADERS //////////////////////////
+	String fragShaderCode = "SamplerState samp : register(s0);			\
+							Texture2D tex : register(t0); \
+							float4 ps_main(in float4 inPos : SV_Position, float2 uv : TEXCOORD0) : SV_Target		\
+							{														\
+							float4 color = tex.Sample(samp, uv);				\
+							return color;										\
+							}";
+
+	HighLevelGpuProgramHandle fragProgRef =  HighLevelGpuProgram::create(fragShaderCode, "ps_main", "hlsl", GPT_FRAGMENT_PROGRAM, GPP_PS_4_0);
+
+	String vertShaderCode = "float4x4 matViewProjection;	\
+							void vs_main(										\
+							in float4 inPos : POSITION,							\
+							in float2 uv : TEXCOORD0,								\
+							out float4 oPosition : SV_Position,					\
+							out float2 oUv : TEXCOORD0)							\
+							{														\
+							oPosition = mul(matViewProjection, inPos);			\
+							oUv = uv;											\
+							}";
+
+	HighLevelGpuProgramHandle vertProgRef =  HighLevelGpuProgram::create(vertShaderCode, "vs_main", "hlsl", GPT_VERTEX_PROGRAM, GPP_VS_4_0);
 
 
 	/////////////////// CG SHADERS //////////////////////////
 	/////////////////// CG SHADERS //////////////////////////
 	//String fragShaderCode = "sampler2D tex;					\
 	//String fragShaderCode = "sampler2D tex;					\

+ 1 - 0
CamelotD3D11RenderSystem/Include/CmD3D11Prerequisites.h

@@ -72,6 +72,7 @@ namespace CamelotEngine
 	typedef std::shared_ptr<D3D11SamplerState> D3D11SamplerStatePtr;
 	typedef std::shared_ptr<D3D11SamplerState> D3D11SamplerStatePtr;
 	typedef std::shared_ptr<D3D11DepthStencilState> D3D11DepthStencilStatePtr;
 	typedef std::shared_ptr<D3D11DepthStencilState> D3D11DepthStencilStatePtr;
 	typedef std::shared_ptr<D3D11RenderWindow> D3D11RenderWindowPtr;
 	typedef std::shared_ptr<D3D11RenderWindow> D3D11RenderWindowPtr;
+	typedef std::shared_ptr<D3D11HLSLProgram> D3D11HLSLProgramPtr;
 
 
 // Should we ask D3D to manage vertex/index buffers automatically?
 // Should we ask D3D to manage vertex/index buffers automatically?
 // Doing so avoids lost devices, but also has a performance impact
 // Doing so avoids lost devices, but also has a performance impact

+ 1 - 1
CamelotD3D11RenderSystem/Include/CmD3D11RenderSystem.h

@@ -110,7 +110,7 @@ namespace CamelotEngine
 		D3D11_RECT			mScissorRect;
 		D3D11_RECT			mScissorRect;
 
 
 		VertexDeclarationPtr mActiveVertexDeclaration;
 		VertexDeclarationPtr mActiveVertexDeclaration;
-		D3D11HLSLProgram*	 mActiveVertexShader;
+		D3D11HLSLProgramPtr	 mActiveVertexShader;
 
 
 		/**
 		/**
 		 * @brief	Creates or retrieves a proper input layout depending on the currently set vertex shader
 		 * @brief	Creates or retrieves a proper input layout depending on the currently set vertex shader

+ 11 - 8
CamelotD3D11RenderSystem/Source/CmD3D11RenderSystem.cpp

@@ -36,7 +36,7 @@ namespace CamelotEngine
 		: mDXGIFactory(nullptr), mDevice(nullptr), mDriverList(nullptr)
 		: mDXGIFactory(nullptr), mDevice(nullptr), mDriverList(nullptr)
 		, mActiveD3DDriver(nullptr), mFeatureLevel(D3D_FEATURE_LEVEL_9_1)
 		, mActiveD3DDriver(nullptr), mFeatureLevel(D3D_FEATURE_LEVEL_9_1)
 		, mHLSLFactory(nullptr), mIAManager(nullptr)
 		, mHLSLFactory(nullptr), mIAManager(nullptr)
-		, mStencilRef(0), mActiveVertexShader(nullptr)
+		, mStencilRef(0)
 	{
 	{
 		mClipPlanesDirty = false; // DX11 handles clip planes through shaders
 		mClipPlanesDirty = false; // DX11 handles clip planes through shaders
 	}
 	}
@@ -142,6 +142,9 @@ namespace CamelotEngine
 		SAFE_DELETE(mIAManager);
 		SAFE_DELETE(mIAManager);
 		SAFE_DELETE(mHLSLFactory);
 		SAFE_DELETE(mHLSLFactory);
 
 
+		mActiveVertexDeclaration = nullptr;
+		mActiveVertexShader = nullptr;
+
 		RenderStateManager::shutDown();
 		RenderStateManager::shutDown();
 		RenderWindowManager::shutDown();
 		RenderWindowManager::shutDown();
 		GpuProgramManager::shutDown();
 		GpuProgramManager::shutDown();
@@ -364,38 +367,38 @@ namespace CamelotEngine
 		{
 		{
 		case GPT_VERTEX_PROGRAM:
 		case GPT_VERTEX_PROGRAM:
 			{
 			{
-				D3D11GpuVertexProgram* d3d11GpuProgram = static_cast<D3D11GpuVertexProgram*>(prg->getBindingDelegate());
+				D3D11GpuVertexProgram* d3d11GpuProgram = static_cast<D3D11GpuVertexProgram*>(prg->getBindingDelegate().get());
 				mDevice->getImmediateContext()->VSSetShader(d3d11GpuProgram->getVertexShader(), nullptr, 0);
 				mDevice->getImmediateContext()->VSSetShader(d3d11GpuProgram->getVertexShader(), nullptr, 0);
-				mActiveVertexShader = static_cast<D3D11HLSLProgram*>(prg.get());
+				mActiveVertexShader = std::static_pointer_cast<D3D11HLSLProgram>(prg.getInternalPtr());
 				break;
 				break;
 			}
 			}
 		case GPT_FRAGMENT_PROGRAM:
 		case GPT_FRAGMENT_PROGRAM:
 			{
 			{
-				D3D11GpuFragmentProgram* d3d11GpuProgram = static_cast<D3D11GpuFragmentProgram*>(prg->getBindingDelegate());
+				D3D11GpuFragmentProgram* d3d11GpuProgram = static_cast<D3D11GpuFragmentProgram*>(prg->getBindingDelegate().get());
 				mDevice->getImmediateContext()->PSSetShader(d3d11GpuProgram->getPixelShader(), nullptr, 0);
 				mDevice->getImmediateContext()->PSSetShader(d3d11GpuProgram->getPixelShader(), nullptr, 0);
 				break;
 				break;
 			}
 			}
 		case GPT_GEOMETRY_PROGRAM:
 		case GPT_GEOMETRY_PROGRAM:
 			{
 			{
-				D3D11GpuGeometryProgram* d3d11GpuProgram = static_cast<D3D11GpuGeometryProgram*>(prg->getBindingDelegate());
+				D3D11GpuGeometryProgram* d3d11GpuProgram = static_cast<D3D11GpuGeometryProgram*>(prg->getBindingDelegate().get());
 				mDevice->getImmediateContext()->GSSetShader(d3d11GpuProgram->getGeometryShader(), nullptr, 0);
 				mDevice->getImmediateContext()->GSSetShader(d3d11GpuProgram->getGeometryShader(), nullptr, 0);
 				break;
 				break;
 			}
 			}
 		case GPT_DOMAIN_PROGRAM:
 		case GPT_DOMAIN_PROGRAM:
 			{
 			{
-				D3D11GpuDomainProgram* d3d11GpuProgram = static_cast<D3D11GpuDomainProgram*>(prg->getBindingDelegate());
+				D3D11GpuDomainProgram* d3d11GpuProgram = static_cast<D3D11GpuDomainProgram*>(prg->getBindingDelegate().get());
 				mDevice->getImmediateContext()->DSSetShader(d3d11GpuProgram->getDomainShader(), nullptr, 0);
 				mDevice->getImmediateContext()->DSSetShader(d3d11GpuProgram->getDomainShader(), nullptr, 0);
 				break;
 				break;
 			}
 			}
 		case GPT_HULL_PROGRAM:
 		case GPT_HULL_PROGRAM:
 			{
 			{
-				D3D11GpuHullProgram* d3d11GpuProgram = static_cast<D3D11GpuHullProgram*>(prg->getBindingDelegate());
+				D3D11GpuHullProgram* d3d11GpuProgram = static_cast<D3D11GpuHullProgram*>(prg->getBindingDelegate().get());
 				mDevice->getImmediateContext()->HSSetShader(d3d11GpuProgram->getHullShader(), nullptr, 0);
 				mDevice->getImmediateContext()->HSSetShader(d3d11GpuProgram->getHullShader(), nullptr, 0);
 				break;
 				break;
 			}
 			}
 		case GPT_COMPUTE_PROGRAM:
 		case GPT_COMPUTE_PROGRAM:
 			{
 			{
-				D3D11GpuComputeProgram* d3d11GpuProgram = static_cast<D3D11GpuComputeProgram*>(prg->getBindingDelegate());
+				D3D11GpuComputeProgram* d3d11GpuProgram = static_cast<D3D11GpuComputeProgram*>(prg->getBindingDelegate().get());
 				mDevice->getImmediateContext()->CSSetShader(d3d11GpuProgram->getComputeShader(), nullptr, 0);
 				mDevice->getImmediateContext()->CSSetShader(d3d11GpuProgram->getComputeShader(), nullptr, 0);
 				break;
 				break;
 			}
 			}

+ 3 - 3
CamelotD3D9Renderer/Source/CmD3D9RenderSystem.cpp

@@ -263,14 +263,14 @@ namespace CamelotEngine
 		if(!prg.isLoaded())
 		if(!prg.isLoaded())
 			return;
 			return;
 
 
-		GpuProgram* bindingPrg = prg->getBindingDelegate();
+		GpuProgramPtr bindingPrg = prg->getBindingDelegate();
 
 
 		HRESULT hr;
 		HRESULT hr;
 		switch (bindingPrg->getType())
 		switch (bindingPrg->getType())
 		{
 		{
 		case GPT_VERTEX_PROGRAM:
 		case GPT_VERTEX_PROGRAM:
 			hr = getActiveD3D9Device()->SetVertexShader(
 			hr = getActiveD3D9Device()->SetVertexShader(
-				static_cast<D3D9GpuVertexProgram*>(bindingPrg)->getVertexShader());
+				static_cast<D3D9GpuVertexProgram*>(bindingPrg.get())->getVertexShader());
 			if (FAILED(hr))
 			if (FAILED(hr))
 			{
 			{
 				CM_EXCEPT(RenderingAPIException, "Error calling SetVertexShader");
 				CM_EXCEPT(RenderingAPIException, "Error calling SetVertexShader");
@@ -278,7 +278,7 @@ namespace CamelotEngine
 			break;
 			break;
 		case GPT_FRAGMENT_PROGRAM:
 		case GPT_FRAGMENT_PROGRAM:
 			hr = getActiveD3D9Device()->SetPixelShader(
 			hr = getActiveD3D9Device()->SetPixelShader(
-				static_cast<D3D9GpuFragmentProgram*>(bindingPrg)->getPixelShader());
+				static_cast<D3D9GpuFragmentProgram*>(bindingPrg.get())->getPixelShader());
 			if (FAILED(hr))
 			if (FAILED(hr))
 			{
 			{
 				CM_EXCEPT(RenderingAPIException, "Error calling SetPixelShader");
 				CM_EXCEPT(RenderingAPIException, "Error calling SetPixelShader");

+ 2 - 0
CamelotGLRenderer/Include/CmGLPrerequisites.h

@@ -41,11 +41,13 @@ namespace CamelotEngine {
     class GLRTTManager;
     class GLRTTManager;
     class GLPixelBuffer;
     class GLPixelBuffer;
 	class GLGpuParamBlock;
 	class GLGpuParamBlock;
+	class GLSLGpuProgram;
 	struct GLSLProgramPipeline;
 	struct GLSLProgramPipeline;
 	class GLSLProgramPipelineManager;
 	class GLSLProgramPipelineManager;
 
 
 	typedef std::shared_ptr<GLPixelBuffer> GLPixelBufferPtr;
 	typedef std::shared_ptr<GLPixelBuffer> GLPixelBufferPtr;
 	typedef std::shared_ptr<GLGpuParamBlock> GLGpuParamBlockPtr;
 	typedef std::shared_ptr<GLGpuParamBlock> GLGpuParamBlockPtr;
+	typedef std::shared_ptr<GLSLGpuProgram> GLSLGpuProgramPtr;
 
 
 	enum TypeID_D3D9
 	enum TypeID_D3D9
 	{
 	{

+ 7 - 7
CamelotGLRenderer/Include/CmGLRenderSystem.h

@@ -261,11 +261,11 @@ namespace CamelotEngine {
 
 
         GLuint getCombinedMinMipFilter(void) const;
         GLuint getCombinedMinMipFilter(void) const;
 
 
-        GLSLGpuProgram* mCurrentVertexProgram;
-        GLSLGpuProgram* mCurrentFragmentProgram;
-		GLSLGpuProgram* mCurrentGeometryProgram;
-		GLSLGpuProgram* mCurrentHullProgram;
-		GLSLGpuProgram* mCurrentDomainProgram;
+        GLSLGpuProgramPtr mCurrentVertexProgram;
+        GLSLGpuProgramPtr mCurrentFragmentProgram;
+		GLSLGpuProgramPtr mCurrentGeometryProgram;
+		GLSLGpuProgramPtr mCurrentHullProgram;
+		GLSLGpuProgramPtr mCurrentDomainProgram;
 
 
 		const GLSLProgramPipeline* mActivePipeline;
 		const GLSLProgramPipeline* mActivePipeline;
 
 
@@ -583,8 +583,8 @@ namespace CamelotEngine {
 		 */
 		 */
 		void endDraw();
 		void endDraw();
 
 
-		void setActiveProgram(GpuProgramType gptype, GLSLGpuProgram* program);
-		GLSLGpuProgram* getActiveProgram(GpuProgramType gptype) const;
+		void setActiveProgram(GpuProgramType gptype, GLSLGpuProgramPtr program);
+		GLSLGpuProgramPtr getActiveProgram(GpuProgramType gptype) const;
 
 
 		/** Returns the main context */
 		/** Returns the main context */
 		GLContext* _getMainContext() {return mMainContext;} 
 		GLContext* _getMainContext() {return mMainContext;} 

+ 13 - 12
CamelotGLRenderer/Source/CmGLRenderSystem.cpp

@@ -113,11 +113,6 @@ namespace CamelotEngine
 
 
 		mMinFilter = FO_LINEAR;
 		mMinFilter = FO_LINEAR;
 		mMipFilter = FO_POINT;
 		mMipFilter = FO_POINT;
-		mCurrentVertexProgram = nullptr;
-		mCurrentGeometryProgram = nullptr;
-		mCurrentFragmentProgram = nullptr;
-		mCurrentHullProgram = nullptr;
-		mCurrentDomainProgram = nullptr;
 
 
 		mProgramPipelineManager = new GLSLProgramPipelineManager();
 		mProgramPipelineManager = new GLSLProgramPipelineManager();
 	}
 	}
@@ -196,6 +191,12 @@ namespace CamelotEngine
 		mBoundVertexDeclaration = nullptr;
 		mBoundVertexDeclaration = nullptr;
 		mBoundIndexBuffer = nullptr;
 		mBoundIndexBuffer = nullptr;
 
 
+		mCurrentVertexProgram = nullptr;
+		mCurrentFragmentProgram = nullptr;
+		mCurrentGeometryProgram = nullptr;
+		mCurrentHullProgram = nullptr;
+		mCurrentDomainProgram = nullptr;
+
 		mGLSupport->stop();
 		mGLSupport->stop();
 
 
 		TextureManager::shutDown();
 		TextureManager::shutDown();
@@ -219,8 +220,8 @@ namespace CamelotEngine
 	{
 	{
 		THROW_IF_NOT_RENDER_THREAD;
 		THROW_IF_NOT_RENDER_THREAD;
 
 
-		GpuProgram* bindingPrg = prg->getBindingDelegate();
-		GLSLGpuProgram* glprg = static_cast<GLSLGpuProgram*>(bindingPrg);
+		GpuProgramPtr bindingPrg = prg->getBindingDelegate();
+		GLSLGpuProgramPtr glprg = std::static_pointer_cast<GLSLGpuProgram>(bindingPrg);
 
 
 		switch (glprg->getType())
 		switch (glprg->getType())
 		{
 		{
@@ -279,7 +280,7 @@ namespace CamelotEngine
 		THROW_IF_NOT_RENDER_THREAD;
 		THROW_IF_NOT_RENDER_THREAD;
 
 
 		const GpuParamDesc& paramDesc = params->getParamDesc();
 		const GpuParamDesc& paramDesc = params->getParamDesc();
-		GLSLGpuProgram* activeProgram = getActiveProgram(gptype);
+		GLSLGpuProgramPtr activeProgram = getActiveProgram(gptype);
 		GLuint glProgram = activeProgram->getGLSLProgram()->getGLHandle();
 		GLuint glProgram = activeProgram->getGLSLProgram()->getGLHandle();
 
 
 		for(auto iter = paramDesc.textures.begin(); iter != paramDesc.textures.end(); ++iter)
 		for(auto iter = paramDesc.textures.begin(); iter != paramDesc.textures.end(); ++iter)
@@ -1625,8 +1626,8 @@ namespace CamelotEngine
 			return;
 			return;
 		}
 		}
 
 
-		const GLSLProgramPipeline* pipeline = mProgramPipelineManager->getPipeline(mCurrentVertexProgram, 
-			mCurrentFragmentProgram, mCurrentGeometryProgram, mCurrentHullProgram, mCurrentDomainProgram);
+		const GLSLProgramPipeline* pipeline = mProgramPipelineManager->getPipeline(mCurrentVertexProgram.get(), 
+			mCurrentFragmentProgram.get(), mCurrentGeometryProgram.get(), mCurrentHullProgram.get(), mCurrentDomainProgram.get());
 
 
 		if(mActivePipeline != pipeline)
 		if(mActivePipeline != pipeline)
 		{
 		{
@@ -2369,7 +2370,7 @@ namespace CamelotEngine
 		}
 		}
 	}
 	}
 
 
-	void GLRenderSystem::setActiveProgram(GpuProgramType gptype, GLSLGpuProgram* program)
+	void GLRenderSystem::setActiveProgram(GpuProgramType gptype, GLSLGpuProgramPtr program)
 	{
 	{
 		switch (gptype)
 		switch (gptype)
 		{
 		{
@@ -2391,7 +2392,7 @@ namespace CamelotEngine
 		}
 		}
 	}
 	}
 
 
-	GLSLGpuProgram* GLRenderSystem::getActiveProgram(GpuProgramType gptype) const
+	GLSLGpuProgramPtr GLRenderSystem::getActiveProgram(GpuProgramType gptype) const
 	{
 	{
 		switch (gptype)
 		switch (gptype)
 		{
 		{

+ 1 - 1
CamelotRenderer/Include/CmCgProgram.h

@@ -54,7 +54,7 @@ namespace CamelotEngine {
 		/**
 		/**
 		 * @copydoc HighLevelGpuProgram::getBindingDelegate().
 		 * @copydoc HighLevelGpuProgram::getBindingDelegate().
 		 */
 		 */
-		GpuProgram* getBindingDelegate();
+		GpuProgramPtr getBindingDelegate();
 
 
 		/**
 		/**
 		 * @copydoc HighLevelGpuProgram::createParameters().
 		 * @copydoc HighLevelGpuProgram::createParameters().

+ 1 - 1
CamelotRenderer/Include/CmGpuProgram.h

@@ -114,7 +114,7 @@ namespace CamelotEngine {
         @remarks
         @remarks
             This method is simply to allow some subclasses of GpuProgram to delegate
             This method is simply to allow some subclasses of GpuProgram to delegate
             the program which is bound to the pipeline to a delegate, if required. */
             the program which is bound to the pipeline to a delegate, if required. */
-        virtual GpuProgram* getBindingDelegate(void) { return this; }
+        virtual GpuProgramPtr getBindingDelegate(void) { return std::static_pointer_cast<GpuProgram>(getThisPtr()); }
 
 
         /** Returns whether this program can be supported on the current renderer and hardware. */
         /** Returns whether this program can be supported on the current renderer and hardware. */
         virtual bool isSupported(void) const;
         virtual bool isSupported(void) const;

+ 1 - 1
CamelotRenderer/Include/CmHighLevelGpuProgram.h

@@ -66,7 +66,7 @@ namespace CamelotEngine {
         virtual ~HighLevelGpuProgram();
         virtual ~HighLevelGpuProgram();
 
 
         /** @copydoc GpuProgram::getBindingDelegate */
         /** @copydoc GpuProgram::getBindingDelegate */
-        virtual GpuProgram* getBindingDelegate(void) { return mAssemblerProgram.get(); }
+        virtual GpuProgramPtr getBindingDelegate(void) { return mAssemblerProgram; }
 
 
     protected:
     protected:
 		friend class HighLevelGpuProgramManager;
 		friend class HighLevelGpuProgramManager;

+ 1 - 1
CamelotRenderer/Source/CmCgProgram.cpp

@@ -123,7 +123,7 @@ namespace CamelotEngine {
 		return getWrappedProgram()->createParameters();
 		return getWrappedProgram()->createParameters();
 	}
 	}
 
 
-	GpuProgram* CgProgram::getBindingDelegate(void)
+	GpuProgramPtr CgProgram::getBindingDelegate(void)
 	{
 	{
 		if(mAssemblerProgram)
 		if(mAssemblerProgram)
 			return getWrappedProgram()->getBindingDelegate();
 			return getWrappedProgram()->getBindingDelegate();

+ 0 - 8
CamelotRenderer/TODO.txt

@@ -21,14 +21,6 @@ Add support for include file resource
 Make sure we can add an include file to a HighLevelGpuProgram, and make sure it uses it
 Make sure we can add an include file to a HighLevelGpuProgram, and make sure it uses it
  - Also a way to list all referenced includes, and a way to remove them
  - 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:
-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
-
-GL keeps a list of RAW pointers for every Gpuprogram!
- - also a bound vertex/index buffer & vertex declaration
-
-
 Seems there is a possible deadlock when starting the render thread, while waiting for the thread to be started
 Seems there is a possible deadlock when starting the render thread, while waiting for the thread to be started
 Get rid of resource handlers in Resources?
 Get rid of resource handlers in Resources?