Browse Source

Removed CoreObjectCore::destroy and using destructor instead

Marko Pintera 11 years ago
parent
commit
e77069ae0e
65 changed files with 304 additions and 687 deletions
  1. 0 5
      BansheeCore/Include/BsCoreObjectCore.h
  2. 0 5
      BansheeCore/Include/BsGpuBuffer.h
  3. 1 5
      BansheeCore/Include/BsGpuParamBlockBuffer.h
  4. 2 5
      BansheeCore/Include/BsMesh.h
  5. 3 5
      BansheeCore/Include/BsMeshHeap.h
  6. 0 5
      BansheeCore/Include/BsMultiRenderTexture.h
  7. 0 5
      BansheeCore/Include/BsRenderTexture.h
  8. 2 13
      BansheeCore/Source/BsCoreObjectCore.cpp
  9. 0 7
      BansheeCore/Source/BsGpuBuffer.cpp
  10. 6 8
      BansheeCore/Source/BsGpuParamBlockBuffer.cpp
  11. 10 24
      BansheeCore/Source/BsMesh.cpp
  12. 12 26
      BansheeCore/Source/BsMeshHeap.cpp
  13. 10 15
      BansheeCore/Source/BsMultiRenderTexture.cpp
  14. 7 12
      BansheeCore/Source/BsRenderTexture.cpp
  15. 0 5
      BansheeD3D11RenderSystem/Include/BsD3D11BlendState.h
  16. 0 5
      BansheeD3D11RenderSystem/Include/BsD3D11DepthStencilState.h
  17. 0 5
      BansheeD3D11RenderSystem/Include/BsD3D11GpuBuffer.h
  18. 1 5
      BansheeD3D11RenderSystem/Include/BsD3D11GpuParamBlockBuffer.h
  19. 0 35
      BansheeD3D11RenderSystem/Include/BsD3D11GpuProgram.h
  20. 1 6
      BansheeD3D11RenderSystem/Include/BsD3D11IndexBuffer.h
  21. 0 5
      BansheeD3D11RenderSystem/Include/BsD3D11RasterizerState.h
  22. 0 5
      BansheeD3D11RenderSystem/Include/BsD3D11SamplerState.h
  23. 0 5
      BansheeD3D11RenderSystem/Include/BsD3D11Texture.h
  24. 2 7
      BansheeD3D11RenderSystem/Include/BsD3D11VertexBuffer.h
  25. 3 9
      BansheeD3D11RenderSystem/Source/BsD3D11BlendState.cpp
  26. 2 9
      BansheeD3D11RenderSystem/Source/BsD3D11DepthStencilState.cpp
  27. 5 10
      BansheeD3D11RenderSystem/Source/BsD3D11GpuBuffer.cpp
  28. 8 9
      BansheeD3D11RenderSystem/Source/BsD3D11GpuParamBlockBuffer.cpp
  29. 21 57
      BansheeD3D11RenderSystem/Source/BsD3D11GpuProgram.cpp
  30. 8 10
      BansheeD3D11RenderSystem/Source/BsD3D11IndexBuffer.cpp
  31. 3 8
      BansheeD3D11RenderSystem/Source/BsD3D11RasterizerState.cpp
  32. 3 9
      BansheeD3D11RenderSystem/Source/BsD3D11SamplerState.cpp
  33. 10 14
      BansheeD3D11RenderSystem/Source/BsD3D11Texture.cpp
  34. 8 9
      BansheeD3D11RenderSystem/Source/BsD3D11VertexBuffer.cpp
  35. 0 15
      BansheeD3D9RenderSystem/Include/BsD3D9GpuProgram.h
  36. 1 6
      BansheeD3D9RenderSystem/Include/BsD3D9IndexBuffer.h
  37. 0 5
      BansheeD3D9RenderSystem/Include/BsD3D9RenderWindow.h
  38. 0 5
      BansheeD3D9RenderSystem/Include/BsD3D9Texture.h
  39. 1 6
      BansheeD3D9RenderSystem/Include/BsD3D9VertexBuffer.h
  40. 0 5
      BansheeD3D9RenderSystem/Include/BsD3D9VertexDeclaration.h
  41. 3 1
      BansheeD3D9RenderSystem/Source/BsD3D9GpuBuffer.cpp
  42. 7 23
      BansheeD3D9RenderSystem/Source/BsD3D9GpuProgram.cpp
  43. 22 23
      BansheeD3D9RenderSystem/Source/BsD3D9IndexBuffer.cpp
  44. 17 22
      BansheeD3D9RenderSystem/Source/BsD3D9RenderWindow.cpp
  45. 15 20
      BansheeD3D9RenderSystem/Source/BsD3D9Texture.cpp
  46. 22 23
      BansheeD3D9RenderSystem/Source/BsD3D9VertexBuffer.cpp
  47. 1 5
      BansheeD3D9RenderSystem/Source/BsD3D9VertexDeclaration.cpp
  48. 0 5
      BansheeGLRenderSystem/Include/BsGLGpuBuffer.h
  49. 1 5
      BansheeGLRenderSystem/Include/BsGLGpuParamBlockBuffer.h
  50. 1 6
      BansheeGLRenderSystem/Include/BsGLIndexBuffer.h
  51. 0 5
      BansheeGLRenderSystem/Include/BsGLMultiRenderTexture.h
  52. 0 5
      BansheeGLRenderSystem/Include/BsGLRenderTexture.h
  53. 0 5
      BansheeGLRenderSystem/Include/BsGLTexture.h
  54. 1 6
      BansheeGLRenderSystem/Include/BsGLVertexBuffer.h
  55. 0 5
      BansheeGLRenderSystem/Include/BsWin32Window.h
  56. 2 6
      BansheeGLRenderSystem/Source/BsGLGpuBuffer.cpp
  57. 7 8
      BansheeGLRenderSystem/Source/BsGLGpuParamBlockBuffer.cpp
  58. 7 8
      BansheeGLRenderSystem/Source/BsGLIndexBuffer.cpp
  59. 4 9
      BansheeGLRenderSystem/Source/BsGLMultiRenderTexture.cpp
  60. 4 9
      BansheeGLRenderSystem/Source/BsGLRenderTexture.cpp
  61. 8 12
      BansheeGLRenderSystem/Source/BsGLTexture.cpp
  62. 10 11
      BansheeGLRenderSystem/Source/BsGLVertexBuffer.cpp
  63. 33 38
      BansheeGLRenderSystem/Source/BsWin32Window.cpp
  64. 0 5
      BansheeGLRenderSystem/Source/GLSL/include/BsGLSLGpuProgram.h
  65. 9 13
      BansheeGLRenderSystem/Source/GLSL/src/BsGLSLGpuProgram.cpp

+ 0 - 5
BansheeCore/Include/BsCoreObjectCore.h

@@ -25,11 +25,6 @@ namespace BansheeEngine
 		 */
 		virtual void initialize() { }
 
-		/**
-		 * @brief	Called on the core thread just before the object is destroyed.
-		 */
-		virtual void destroy();
-
 		/**
 		 * @brief	Internal method. Sets a shared this pointer to this object. This MUST be called immediately after construction.
 		 *

+ 0 - 5
BansheeCore/Include/BsGpuBuffer.h

@@ -167,11 +167,6 @@ namespace BansheeEngine
 		 */
 		void clearBufferViews();
 
-		/**
-		 * @copydoc CoreObject::destroy()
-		 */
-		virtual void destroy();
-
 		/**
 		 * @brief	Helper class to help with reference counting for GPU buffer views.
 		 */

+ 1 - 5
BansheeCore/Include/BsGpuParamBlockBuffer.h

@@ -167,6 +167,7 @@ namespace BansheeEngine
 	{
 	public:
 		GenericGpuParamBlockBufferCore(UINT32 size, GpuParamBlockUsage usage);
+		~GenericGpuParamBlockBufferCore();
 
 		/**
 		 * @copydoc	GpuParamBlockBufferCore::writeData
@@ -185,10 +186,5 @@ namespace BansheeEngine
 		 * @copydoc CoreObjectCore::initialize
 		 */
 		virtual void initialize();
-
-		/**
-		 * @copydoc CoreObjectCore::destroy
-		 */
-		virtual void destroy();
 	};
 }

+ 2 - 5
BansheeCore/Include/BsMesh.h

@@ -24,16 +24,13 @@ namespace BansheeEngine
 			const Vector<SubMesh>& subMeshes, MeshBufferType bufferType, IndexType indexType,
 			MeshDataPtr initialMeshData);
 
+		~MeshCore();
+
 		/**
 		 * @brief	CoreObjectCore::initialize
 		 */
 		virtual void initialize();
 
-		/**
-		 * @brief	CoreObjectCore::destroy
-		 */
-		virtual void destroy();
-
 		/**
 		 * @copydoc MeshCoreBase::getVertexData
 		 */

+ 3 - 5
BansheeCore/Include/BsMeshHeap.h

@@ -57,6 +57,9 @@ namespace BansheeEngine
 			UINT32 queryId;
 		};
 
+	public:
+		~MeshHeapCore();
+
 	private:
 		friend class MeshHeap;
 		friend class TransientMesh;
@@ -70,11 +73,6 @@ namespace BansheeEngine
 		 */
 		virtual void initialize();
 
-		/**
-		 * @copydoc CoreObjectCore::destroy()
-		 */
-		virtual void destroy();
-
 		/**
 		 * @brief	Allocates a new mesh in the heap, expanding the heap if needed. 
 		 *

+ 0 - 5
BansheeCore/Include/BsMultiRenderTexture.h

@@ -46,11 +46,6 @@ namespace BansheeEngine
 		 */
 		virtual void initialize();
 
-		/**
-		 * @copydoc	CoreObjectCore::destroy
-		 */
-		virtual void destroy();
-
 		/**
 		 * @brief	Returns properties that describe the render texture.
 		 */

+ 0 - 5
BansheeCore/Include/BsRenderTexture.h

@@ -45,11 +45,6 @@ namespace BansheeEngine
 		 */
 		virtual void initialize();
 
-		/**
-		 * @copydoc	CoreObjectCore::destroy
-		 */
-		virtual void destroy();
-
 		/**
 		 * @brief	Returns a color surface texture you may bind as an input to an GPU program.
 		 *

+ 2 - 13
BansheeCore/Source/BsCoreObjectCore.cpp

@@ -4,23 +4,12 @@
 namespace BansheeEngine
 {
 	CoreObjectCore::CoreObjectCore()
-		:mCoreDirtyFlags(0xFFFFFFFF), mIsDestroyed(false)
+		:mCoreDirtyFlags(0xFFFFFFFF)
 	{ }
 
 	CoreObjectCore::~CoreObjectCore()
-	{
-		// This should only trigger for objects created directly by core thread.
-		// If you are not sure this will get called by the core thread, make sure 
-		// to destroy() the object manually before it goes out of scope.
-		if (!mIsDestroyed)
-			destroy(); //assert(false && "Destructing an object that has not been destroyed previously. This is not allowed.");
-	}
-
-	void CoreObjectCore::destroy() 
 	{ 
-		throwIfNotCoreThread();
-
-		mIsDestroyed = true;
+		THROW_IF_NOT_CORE_THREAD;
 	}
 
 	void CoreObjectCore::_setThisPtr(std::shared_ptr<CoreObjectCore> ptrThis)

+ 0 - 7
BansheeCore/Source/BsGpuBuffer.cpp

@@ -24,13 +24,6 @@ namespace BansheeEngine
 		// I can't call it here since it needs a virtual method call
 	}
 
-	void GpuBufferCore::destroy()
-	{
-		clearBufferViews();
-
-		CoreObjectCore::destroy();
-	}
-
 	void GpuBufferCore::clearBufferViews()
 	{
 		for (auto iter = mBufferViews.begin(); iter != mBufferViews.end(); ++iter)

+ 6 - 8
BansheeCore/Source/BsGpuParamBlockBuffer.cpp

@@ -160,6 +160,12 @@ namespace BansheeEngine
 		:GpuParamBlockBufferCore(size, usage), mData(nullptr)
 	{ }
 
+	GenericGpuParamBlockBufferCore::~GenericGpuParamBlockBufferCore()
+	{
+		if (mData != nullptr)
+			bs_free<ScratchAlloc>(mData);
+	}
+
 	void GenericGpuParamBlockBufferCore::writeToGPU(const UINT8* data)
 	{
 		memcpy(mData, data, mSize);
@@ -182,14 +188,6 @@ namespace BansheeEngine
 		GpuParamBlockBufferCore::initialize();
 	}
 
-	void GenericGpuParamBlockBufferCore::destroy()
-	{
-		if(mData != nullptr)
-			bs_free<ScratchAlloc>(mData);
-
-		GpuParamBlockBufferCore::destroy();
-	}
-
 	static GpuParamBlockBufferPtr create(UINT32 size, GpuParamBlockUsage usage)
 	{
 		return HardwareBufferManager::instance().createGpuParamBlockBuffer(size, usage);

+ 10 - 24
BansheeCore/Source/BsMesh.cpp

@@ -21,6 +21,16 @@ namespace BansheeEngine
 		mVertexDesc(vertexDesc), mBufferType(bufferType), mIndexType(indexType), mTempInitialMeshData(initialMeshData)
 	{ }
 
+	MeshCore::~MeshCore()
+	{
+		THROW_IF_NOT_CORE_THREAD;
+
+		mVertexData = nullptr;
+		mIndexBuffer = nullptr;
+		mVertexDesc = nullptr;
+		mTempInitialMeshData = nullptr;
+	}
+
 	void MeshCore::initialize()
 	{
 		THROW_IF_NOT_CORE_THREAD;
@@ -59,30 +69,6 @@ namespace BansheeEngine
 		MeshCoreBase::initialize();
 	}
 
-	void MeshCore::destroy()
-	{
-		THROW_IF_NOT_CORE_THREAD;
-
-		if (mVertexData != nullptr)
-		{
-			for (UINT32 i = 0; i < mVertexData->getBufferCount(); i++)
-			{
-				if (mVertexData->getBuffer(i) != nullptr)
-					mVertexData->getBuffer(i)->destroy();
-			}
-		}
-
-		if (mIndexBuffer != nullptr)
-			mIndexBuffer->destroy();
-
-		mVertexData = nullptr;
-		mIndexBuffer = nullptr;
-		mVertexDesc = nullptr;
-		mTempInitialMeshData = nullptr;
-
-		MeshCoreBase::destroy();
-	}
-
 	std::shared_ptr<VertexData> MeshCore::getVertexData() const
 	{
 		THROW_IF_NOT_CORE_THREAD;

+ 12 - 26
BansheeCore/Source/BsMeshHeap.cpp

@@ -23,43 +23,29 @@ namespace BansheeEngine
 		}
 	}
 
-	void MeshHeapCore::initialize()
+	MeshHeapCore::~MeshHeapCore()
 	{
 		THROW_IF_NOT_CORE_THREAD;
 
-		growVertexBuffer(mNumVertices);
-		growIndexBuffer(mNumIndices);
-
-		CoreObjectCore::initialize();
-	}
-
-	void MeshHeapCore::destroy()
-	{
-		THROW_IF_NOT_CORE_THREAD;
-
-		for(auto& cpuVertBuffer : mCPUVertexData)
+		for (auto& cpuVertBuffer : mCPUVertexData)
 			bs_free(cpuVertBuffer);
 
-		if(mCPUIndexData != nullptr)
+		if (mCPUIndexData != nullptr)
 			bs_free(mCPUIndexData);
 
-		if (mVertexData != nullptr)
-		{
-			for (UINT32 i = 0; i < mVertexData->getBufferCount(); i++)
-			{
-				if (mVertexData->getBuffer(i) != nullptr)
-					mVertexData->getBuffer(i)->destroy();
-			}
-		}
-
-		if (mIndexBuffer != nullptr)
-			mIndexBuffer->destroy();
-
 		mVertexData = nullptr;
 		mIndexBuffer = nullptr;
 		mVertexDesc = nullptr;
+	}
+
+	void MeshHeapCore::initialize()
+	{
+		THROW_IF_NOT_CORE_THREAD;
+
+		growVertexBuffer(mNumVertices);
+		growIndexBuffer(mNumIndices);
 
-		CoreObjectCore::destroy();
+		CoreObjectCore::initialize();
 	}
 
 	void MeshHeapCore::alloc(SPtr<TransientMeshCore> mesh, const MeshDataPtr& meshData)

+ 10 - 15
BansheeCore/Source/BsMultiRenderTexture.cpp

@@ -37,7 +37,16 @@ namespace BansheeEngine
 	{ }
 
 	MultiRenderTextureCore::~MultiRenderTextureCore()
-	{ }
+	{
+		for (auto iter = mColorSurfaces.begin(); iter != mColorSurfaces.end(); ++iter)
+		{
+			if (*iter != nullptr)
+				TextureCore::releaseView(*iter);
+		}
+
+		if (mDepthStencilSurface != nullptr)
+			TextureCore::releaseView(mDepthStencilSurface);
+	}
 
 	void MultiRenderTextureCore::initialize()
 	{
@@ -81,20 +90,6 @@ namespace BansheeEngine
 		throwIfBuffersDontMatch();
 	}
 
-	void MultiRenderTextureCore::destroy()
-	{
-		for (auto iter = mColorSurfaces.begin(); iter != mColorSurfaces.end(); ++iter)
-		{
-			if (*iter != nullptr)
-				TextureCore::releaseView(*iter);
-		}
-
-		if (mDepthStencilSurface != nullptr)
-			TextureCore::releaseView(mDepthStencilSurface);
-
-		RenderTargetCore::destroy();
-	}
-
 	CoreSyncData MultiRenderTextureCore::syncFromCore(FrameAlloc* allocator)
 	{
 		UINT32 size = sizeof(MultiRenderTextureProperties);

+ 7 - 12
BansheeCore/Source/BsRenderTexture.cpp

@@ -34,7 +34,13 @@ namespace BansheeEngine
 	{ }
 
 	RenderTextureCore::~RenderTextureCore()
-	{ }
+	{ 
+		if (mColorSurface != nullptr)
+			TextureCore::releaseView(mColorSurface);
+
+		if (mDepthStencilSurface != nullptr)
+			TextureCore::releaseView(mDepthStencilSurface);
+	}
 
 	void RenderTextureCore::initialize()
 	{
@@ -86,17 +92,6 @@ namespace BansheeEngine
 		}
 	}
 
-	void RenderTextureCore::destroy()
-	{
-		if (mColorSurface != nullptr)
-			TextureCore::releaseView(mColorSurface);
-
-		if (mDepthStencilSurface != nullptr)
-			TextureCore::releaseView(mDepthStencilSurface);
-
-		RenderTargetCore::destroy();
-	}
-
 	CoreSyncData RenderTextureCore::syncFromCore(FrameAlloc* allocator)
 	{
 		UINT32 size = sizeof(RenderTextureProperties);

+ 0 - 5
BansheeD3D11RenderSystem/Include/BsD3D11BlendState.h

@@ -29,11 +29,6 @@ namespace BansheeEngine
 		 */
 		void initialize();
 
-		/**
-		 * @copydoc BlendStateCore::destroy
-		 */
-		void destroy();
-
 		ID3D11BlendState* mBlendState;
 	};
 }

+ 0 - 5
BansheeD3D11RenderSystem/Include/BsD3D11DepthStencilState.h

@@ -29,11 +29,6 @@ namespace BansheeEngine
 		 */
 		void initialize();
 
-		/**
-		 * @copydoc DepthStencilStateCore::destroy()
-		 */
-		void destroy();
-
 		ID3D11DepthStencilState* mDepthStencilState;
 	};
 }

+ 0 - 5
BansheeD3D11RenderSystem/Include/BsD3D11GpuBuffer.h

@@ -68,11 +68,6 @@ namespace BansheeEngine
 		 * @copydoc GpuBufferCore::initialize
 		 */
 		void initialize();	
-		
-		/**
-		 * @copydoc GpuBufferCore::destroy
-		 */
-		void destroy();
 
 	private:
 		D3D11HardwareBuffer* mBuffer;

+ 1 - 5
BansheeD3D11RenderSystem/Include/BsD3D11GpuParamBlockBuffer.h

@@ -12,6 +12,7 @@ namespace BansheeEngine
 	{
 	public:
 		D3D11GpuParamBlockBufferCore(UINT32 size, GpuParamBlockUsage usage);
+		~D3D11GpuParamBlockBufferCore();
 
 		/**
 		 * @copydoc GpuParamBlockBufferCore::writeData.
@@ -33,11 +34,6 @@ namespace BansheeEngine
 		 */
 		virtual void initialize();
 
-		/**
-		 * @copydoc GpuParamBlockBufferCore::destroy
-		 */
-		virtual void destroy();
-
 	private:
 		D3D11HardwareBuffer* mBuffer;
 	};

+ 0 - 35
BansheeD3D11RenderSystem/Include/BsD3D11GpuProgram.h

@@ -45,11 +45,6 @@ namespace BansheeEngine
 		 */
 		void initialize();
 
-		/**
-		 * @copydoc GpuProgramCore::destroy
-		 */
-		void destroy();
-
 		/**
 		 * @brief	Loads the shader from microcode.
 		 */
@@ -99,11 +94,6 @@ namespace BansheeEngine
 		D3D11GpuVertexProgramCore(const String& source, const String& entryPoint,
 			GpuProgramProfile profile);
 
-		/**
-		 * @copydoc GpuProgramCore::destroy
-		 */
-		void destroy();
-
 		/**
 		 * @copydoc	D3D11GpuProgramCore::loadFromMicrocode
 		 */
@@ -135,11 +125,6 @@ namespace BansheeEngine
 		D3D11GpuFragmentProgramCore(const String& source, const String& entryPoint,
 			GpuProgramProfile profile);
 
-		/**
-		 * @copydoc GpuProgramCore::destroy
-		 */
-		void destroy();
-
 		/**
 		 * @copydoc	D3D11GpuProgramCore::loadFromMicrocode
 		 */
@@ -171,11 +156,6 @@ namespace BansheeEngine
 		D3D11GpuDomainProgramCore(const String& source, const String& entryPoint,
 			GpuProgramProfile profile);
 
-		/**
-		 * @copydoc GpuProgramCore::destroy
-		 */
-		void destroy();
-
 		/**
 		 * @copydoc	D3D11GpuProgramCore::loadFromMicrocode
 		 */
@@ -207,11 +187,6 @@ namespace BansheeEngine
 		D3D11GpuHullProgramCore(const String& source, const String& entryPoint,
 			GpuProgramProfile profile);
 
-		/**
-		 * @copydoc GpuProgramCore::destroy
-		 */
-		void destroy();
-
 		/**
 		 * @copydoc	D3D11GpuProgramCore::loadFromMicrocode
 		 */
@@ -243,11 +218,6 @@ namespace BansheeEngine
 		D3D11GpuGeometryProgramCore(const String& source, const String& entryPoint,
 			GpuProgramProfile profile, bool isAdjacencyInfoRequired);
 
-		/**
-		 * @copydoc GpuProgramCore::destroy
-		 */
-		void destroy();
-
 		/**
 		 * @copydoc	D3D11GpuProgramCore::loadFromMicrocode
 		 */
@@ -279,11 +249,6 @@ namespace BansheeEngine
 		D3D11GpuComputeProgramCore(const String& source, const String& entryPoint,
 			GpuProgramProfile profile);
 
-		/**
-		 * @copydoc GpuProgramCore::destroy
-		 */
-		void destroy();
-
 		/**
 		 * @copydoc	D3D11GpuProgramCore::loadFromMicrocode
 		 */

+ 1 - 6
BansheeD3D11RenderSystem/Include/BsD3D11IndexBuffer.h

@@ -14,7 +14,7 @@ namespace BansheeEngine
 	public:
 		D3D11IndexBufferCore(D3D11Device& device, IndexType idxType, UINT32 numIndexes, GpuBufferUsage usage);
 
-		~D3D11IndexBufferCore() { }
+		~D3D11IndexBufferCore();
 
 		/**
 		 * @copydoc IndexBufferCore::readData
@@ -51,11 +51,6 @@ namespace BansheeEngine
 		 * @copydoc IndexBufferCore::initialize
 		 */
 		void initialize();	
-		
-		/**
-		 * @copydoc IndexBufferCore::destroy
-		 */
-		void destroy();
 
 		D3D11HardwareBuffer* mBuffer;
 		D3D11Device& mDevice;

+ 0 - 5
BansheeD3D11RenderSystem/Include/BsD3D11RasterizerState.h

@@ -25,11 +25,6 @@ namespace BansheeEngine
 		 */
 		void initialize();
 
-		/**
-		 * @copydoc RasterizerStateCore::destroy
-		 */
-		void destroy();
-
 		ID3D11RasterizerState* mRasterizerState;
 	};
 }

+ 0 - 5
BansheeD3D11RenderSystem/Include/BsD3D11SamplerState.h

@@ -25,11 +25,6 @@ namespace BansheeEngine
 		 */
 		void initialize();
 
-		/**
-		 * @copydoc SamplerStateCore::destroy
-		 */
-		void destroy();
-
 		ID3D11SamplerState* mSamplerState;
 	};
 }

+ 0 - 5
BansheeD3D11RenderSystem/Include/BsD3D11Texture.h

@@ -39,11 +39,6 @@ namespace BansheeEngine
 		*/
 		void initialize();
 
-		/**
-		* @copydoc CoreObjectCore::destroy()
-		*/
-		void destroy();
-
 		/**
 		 * @copydoc Texture::lockImpl
 		 */

+ 2 - 7
BansheeD3D11RenderSystem/Include/BsD3D11VertexBuffer.h

@@ -15,7 +15,7 @@ namespace BansheeEngine
 		D3D11VertexBufferCore(D3D11Device& device, UINT32 vertexSize, UINT32 numVertices, 
 			GpuBufferUsage usage, bool streamOut);
 
-		~D3D11VertexBufferCore() { }
+		~D3D11VertexBufferCore();
 
 		/**
 		 * @copydoc VertexBufferCore::readData
@@ -51,12 +51,7 @@ namespace BansheeEngine
 		/**
 		 * @copydoc VertexBufferCore::initialize
 		 */
-		void initialize();	
-		
-		/**
-		 * @copydoc VertexBufferCore::destroy
-		 */
-		void destroy();
+		void initialize();
 
 		D3D11HardwareBuffer* mBuffer;
 		D3D11Device& mDevice;

+ 3 - 9
BansheeD3D11RenderSystem/Source/BsD3D11BlendState.cpp

@@ -12,6 +12,9 @@ namespace BansheeEngine
 
 	D3D11BlendStateCore::~D3D11BlendStateCore()
 	{
+		SAFE_RELEASE(mBlendState);
+
+		BS_INC_RENDER_STAT_CAT(ResDestroyed, RenderStatObject_BlendState);
 	}
 
 	void D3D11BlendStateCore::initialize()
@@ -48,13 +51,4 @@ namespace BansheeEngine
 
 		BlendStateCore::initialize();
 	}
-
-	void D3D11BlendStateCore::destroy()
-	{
-		SAFE_RELEASE(mBlendState);
-
-		BS_INC_RENDER_STAT_CAT(ResDestroyed, RenderStatObject_BlendState);
-
-		BlendStateCore::destroy();
-	}
 }

+ 2 - 9
BansheeD3D11RenderSystem/Source/BsD3D11DepthStencilState.cpp

@@ -12,7 +12,9 @@ namespace BansheeEngine
 
 	D3D11DepthStencilStateCore::~D3D11DepthStencilStateCore()
 	{
+		SAFE_RELEASE(mDepthStencilState);
 
+		BS_INC_RENDER_STAT_CAT(ResDestroyed, RenderStatObject_DepthStencilState);
 	}
 
 	void D3D11DepthStencilStateCore::initialize()
@@ -49,13 +51,4 @@ namespace BansheeEngine
 
 		DepthStencilStateCore::initialize();
 	}
-
-	void D3D11DepthStencilStateCore::destroy()
-	{
-		SAFE_RELEASE(mDepthStencilState);
-
-		BS_INC_RENDER_STAT_CAT(ResDestroyed, RenderStatObject_DepthStencilState);
-
-		DepthStencilStateCore::destroy();
-	}
 }

+ 5 - 10
BansheeD3D11RenderSystem/Source/BsD3D11GpuBuffer.cpp

@@ -15,7 +15,11 @@ namespace BansheeEngine
 	{ }
 
 	D3D11GpuBufferCore::~D3D11GpuBufferCore()
-	{ }
+	{ 
+		bs_delete<PoolAlloc>(mBuffer);
+		clearBufferViews();
+		BS_INC_RENDER_STAT_CAT(ResDestroyed, RenderStatObject_GpuBuffer);
+	}
 
 	void D3D11GpuBufferCore::initialize()
 	{
@@ -50,15 +54,6 @@ namespace BansheeEngine
 		GpuBufferCore::initialize();
 	}
 
-	void D3D11GpuBufferCore::destroy()
-	{
-		bs_delete<PoolAlloc>(mBuffer);
-
-		BS_INC_RENDER_STAT_CAT(ResDestroyed, RenderStatObject_GpuBuffer);
-
-		GpuBufferCore::destroy();
-	}
-
 	void* D3D11GpuBufferCore::lock(UINT32 offset, UINT32 length, GpuLockOptions options)
 	{
 #if BS_PROFILING_ENABLED

+ 8 - 9
BansheeD3D11RenderSystem/Source/BsD3D11GpuParamBlockBuffer.cpp

@@ -12,6 +12,14 @@ namespace BansheeEngine
 
 	}
 
+	D3D11GpuParamBlockBufferCore::~D3D11GpuParamBlockBufferCore()
+	{
+		if (mBuffer != nullptr)
+			bs_delete<PoolAlloc>(mBuffer);
+
+		BS_INC_RENDER_STAT_CAT(ResDestroyed, RenderStatObject_GpuParamBuffer);
+	}
+
 	void D3D11GpuParamBlockBufferCore::initialize()
 	{
 		D3D11RenderSystem* d3d11rs = static_cast<D3D11RenderSystem*>(RenderSystem::instancePtr());
@@ -29,15 +37,6 @@ namespace BansheeEngine
 		GpuParamBlockBufferCore::initialize();
 	}
 
-	void D3D11GpuParamBlockBufferCore::destroy()
-	{
-		if(mBuffer != nullptr)
-			bs_delete<PoolAlloc>(mBuffer);
-
-		BS_INC_RENDER_STAT_CAT(ResDestroyed, RenderStatObject_GpuParamBuffer);
-
-		GpuParamBlockBufferCore::destroy();
-	}
 
 	ID3D11Buffer* D3D11GpuParamBlockBufferCore::getD3D11Buffer() const
 	{

+ 21 - 57
BansheeD3D11RenderSystem/Source/BsD3D11GpuProgram.cpp

@@ -23,7 +23,10 @@ namespace BansheeEngine
 
 	D3D11GpuProgramCore::~D3D11GpuProgramCore()
 	{
+		mMicrocode.clear();
+		mInputDeclaration = nullptr;
 
+		BS_INC_RENDER_STAT_CAT(ResDestroyed, RenderStatObject_GpuProgram);
 	}
 
 	void D3D11GpuProgramCore::initialize()
@@ -60,16 +63,6 @@ namespace BansheeEngine
 		GpuProgramCore::initialize();
 	}
 
-	void D3D11GpuProgramCore::destroy()
-	{
-		mMicrocode.clear();
-		mInputDeclaration = nullptr;
-
-		BS_INC_RENDER_STAT_CAT(ResDestroyed, RenderStatObject_GpuProgram);
-
-		GpuProgramCore::destroy();
-	}
-
 	ID3DBlob* D3D11GpuProgramCore::compileMicrocode(const String& profile)
 	{
 		// TODO - Preprocessor defines aren't supported
@@ -153,7 +146,9 @@ namespace BansheeEngine
 	{ }
 
 	D3D11GpuVertexProgramCore::~D3D11GpuVertexProgramCore()
-	{ }
+	{
+		SAFE_RELEASE(mVertexShader);
+	}
 
 	void D3D11GpuVertexProgramCore::loadFromMicrocode(D3D11Device& device, ID3D10Blob*  microcode)
 	{
@@ -170,13 +165,6 @@ namespace BansheeEngine
 		}
 	}
 
-	void D3D11GpuVertexProgramCore::destroy()
-	{
-		SAFE_RELEASE(mVertexShader);
-
-		D3D11GpuProgramCore::destroy();
-	}
-
 	ID3D11VertexShader * D3D11GpuVertexProgramCore::getVertexShader() const
 	{
 		return mVertexShader;
@@ -189,7 +177,9 @@ namespace BansheeEngine
 	{ }
 
 	D3D11GpuFragmentProgramCore::~D3D11GpuFragmentProgramCore()
-	{ }
+	{
+		SAFE_RELEASE(mPixelShader);
+	}
 
 	void D3D11GpuFragmentProgramCore::loadFromMicrocode(D3D11Device& device, ID3D10Blob* microcode)
 	{
@@ -205,13 +195,6 @@ namespace BansheeEngine
 		}
 	}
 
-	void D3D11GpuFragmentProgramCore::destroy()
-	{
-		SAFE_RELEASE(mPixelShader);
-
-		D3D11GpuProgramCore::destroy();
-	}
-
 	ID3D11PixelShader * D3D11GpuFragmentProgramCore::getPixelShader() const
 	{
 		return mPixelShader;
@@ -225,7 +208,9 @@ namespace BansheeEngine
 	{ }
 
 	D3D11GpuGeometryProgramCore::~D3D11GpuGeometryProgramCore()
-	{ }
+	{ 
+		SAFE_RELEASE(mGeometryShader);
+	}
 
 	void D3D11GpuGeometryProgramCore::loadFromMicrocode(D3D11Device& device, ID3D10Blob* microcode)
 	{
@@ -241,13 +226,6 @@ namespace BansheeEngine
 		}
 	}
 
-	void D3D11GpuGeometryProgramCore::destroy()
-	{
-		SAFE_RELEASE(mGeometryShader);
-
-		D3D11GpuProgramCore::destroy();
-	}
-
 	ID3D11GeometryShader * D3D11GpuGeometryProgramCore::getGeometryShader() const
 	{
 		return mGeometryShader;
@@ -260,7 +238,9 @@ namespace BansheeEngine
 	{ }
 
 	D3D11GpuDomainProgramCore::~D3D11GpuDomainProgramCore()
-	{ }
+	{ 
+		SAFE_RELEASE(mDomainShader);
+	}
 
 	void D3D11GpuDomainProgramCore::loadFromMicrocode(D3D11Device& device, ID3D10Blob* microcode)
 	{
@@ -276,13 +256,6 @@ namespace BansheeEngine
 		}
 	}
 
-	void D3D11GpuDomainProgramCore::destroy()
-	{
-		SAFE_RELEASE(mDomainShader);
-
-		D3D11GpuProgramCore::destroy();
-	}
-
 	ID3D11DomainShader * D3D11GpuDomainProgramCore::getDomainShader() const
 	{
 		return mDomainShader;
@@ -295,7 +268,9 @@ namespace BansheeEngine
 	{ }
 
 	D3D11GpuHullProgramCore::~D3D11GpuHullProgramCore()
-	{ }
+	{ 
+		SAFE_RELEASE(mHullShader);
+	}
 
 	void D3D11GpuHullProgramCore::loadFromMicrocode(D3D11Device& device, ID3D10Blob* microcode)
 	{
@@ -312,13 +287,6 @@ namespace BansheeEngine
 		}
 	}
 
-	void D3D11GpuHullProgramCore::destroy()
-	{
-		SAFE_RELEASE(mHullShader);
-
-		D3D11GpuProgramCore::destroy();
-	}
-
 	ID3D11HullShader* D3D11GpuHullProgramCore::getHullShader() const
 	{
 		return mHullShader;
@@ -332,7 +300,9 @@ namespace BansheeEngine
 	{ }
 
 	D3D11GpuComputeProgramCore::~D3D11GpuComputeProgramCore()
-	{ }
+	{
+		SAFE_RELEASE(mComputeShader);
+	}
 
 	void D3D11GpuComputeProgramCore::loadFromMicrocode(D3D11Device& device, ID3D10Blob* microcode)
 	{
@@ -348,12 +318,6 @@ namespace BansheeEngine
 		}
 	}
 
-	void D3D11GpuComputeProgramCore::destroy()
-	{
-		SAFE_RELEASE(mComputeShader);
-
-		D3D11GpuProgramCore::destroy();
-	}
 
 	ID3D11ComputeShader* D3D11GpuComputeProgramCore::getComputeShader() const
 	{

+ 8 - 10
BansheeD3D11RenderSystem/Source/BsD3D11IndexBuffer.cpp

@@ -10,22 +10,20 @@ namespace BansheeEngine
 
 	}
 
-	void D3D11IndexBufferCore::initialize()
+	D3D11IndexBufferCore::~D3D11IndexBufferCore()
 	{
-		mBuffer = bs_new<D3D11HardwareBuffer, PoolAlloc>(D3D11HardwareBuffer::BT_INDEX, mUsage, 1, mSizeInBytes, std::ref(mDevice), mSystemMemory);
+		if (mBuffer != nullptr)
+			bs_delete<PoolAlloc>(mBuffer);
 
-		BS_INC_RENDER_STAT_CAT(ResCreated, RenderStatObject_IndexBuffer);
-		IndexBufferCore::initialize();
+		BS_INC_RENDER_STAT_CAT(ResDestroyed, RenderStatObject_IndexBuffer);
 	}
 
-	void D3D11IndexBufferCore::destroy()
+	void D3D11IndexBufferCore::initialize()
 	{
-		if(mBuffer != nullptr)
-			bs_delete<PoolAlloc>(mBuffer) ;
-
-		BS_INC_RENDER_STAT_CAT(ResDestroyed, RenderStatObject_IndexBuffer);
+		mBuffer = bs_new<D3D11HardwareBuffer, PoolAlloc>(D3D11HardwareBuffer::BT_INDEX, mUsage, 1, mSizeInBytes, std::ref(mDevice), mSystemMemory);
 
-		IndexBufferCore::destroy();
+		BS_INC_RENDER_STAT_CAT(ResCreated, RenderStatObject_IndexBuffer);
+		IndexBufferCore::initialize();
 	}
 
 	void* D3D11IndexBufferCore::lockImpl(UINT32 offset, UINT32 length, GpuLockOptions options)

+ 3 - 8
BansheeD3D11RenderSystem/Source/BsD3D11RasterizerState.cpp

@@ -12,6 +12,9 @@ namespace BansheeEngine
 
 	D3D11RasterizerStateCore::~D3D11RasterizerStateCore()
 	{
+		SAFE_RELEASE(mRasterizerState);
+
+		BS_INC_RENDER_STAT_CAT(ResDestroyed, RenderStatObject_RasterizerState);
 	}
 
 	void D3D11RasterizerStateCore::initialize()
@@ -43,12 +46,4 @@ namespace BansheeEngine
 		BS_INC_RENDER_STAT_CAT(ResCreated, RenderStatObject_RasterizerState);
 		RasterizerStateCore::initialize();
 	}
-
-	void D3D11RasterizerStateCore::destroy()
-	{
-		SAFE_RELEASE(mRasterizerState);
-
-		BS_INC_RENDER_STAT_CAT(ResDestroyed, RenderStatObject_RasterizerState);
-		RasterizerStateCore::destroy();
-	}
 }

+ 3 - 9
BansheeD3D11RenderSystem/Source/BsD3D11SamplerState.cpp

@@ -12,6 +12,9 @@ namespace BansheeEngine
 
 	D3D11SamplerStateCore::~D3D11SamplerStateCore()
 	{
+		SAFE_RELEASE(mSamplerState);
+
+		BS_INC_RENDER_STAT_CAT(ResDestroyed, RenderStatObject_SamplerState);
 	}
 
 	void D3D11SamplerStateCore::initialize()
@@ -103,13 +106,4 @@ namespace BansheeEngine
 
 		SamplerStateCore::initialize();
 	}
-
-	void D3D11SamplerStateCore::destroy()
-	{
-		SAFE_RELEASE(mSamplerState);
-
-		BS_INC_RENDER_STAT_CAT(ResDestroyed, RenderStatObject_SamplerState);
-
-		SamplerStateCore::destroy();
-	}
 }

+ 10 - 14
BansheeD3D11RenderSystem/Source/BsD3D11Texture.cpp

@@ -20,7 +20,16 @@ namespace BansheeEngine
 	{ }
 
 	D3D11TextureCore::~D3D11TextureCore()
-	{ }
+	{ 
+		SAFE_RELEASE(mTex);
+		SAFE_RELEASE(mShaderResourceView);
+		SAFE_RELEASE(m1DTex);
+		SAFE_RELEASE(m2DTex);
+		SAFE_RELEASE(m3DTex);
+		SAFE_RELEASE(mStagingBuffer);
+
+		BS_INC_RENDER_STAT_CAT(ResDestroyed, RenderStatObject_Texture);
+	}
 
 	void D3D11TextureCore::initialize()
 	{
@@ -46,19 +55,6 @@ namespace BansheeEngine
 		TextureCore::initialize();
 	}
 
-	void D3D11TextureCore::destroy()
-	{
-		SAFE_RELEASE(mTex);
-		SAFE_RELEASE(mShaderResourceView);
-		SAFE_RELEASE(m1DTex);
-		SAFE_RELEASE(m2DTex);
-		SAFE_RELEASE(m3DTex);
-		SAFE_RELEASE(mStagingBuffer);
-
-		BS_INC_RENDER_STAT_CAT(ResDestroyed, RenderStatObject_Texture);
-		TextureCore::destroy();
-	}
-
 	void D3D11TextureCore::copyImpl(UINT32 srcFace, UINT32 srcMipLevel, UINT32 destFace, UINT32 destMipLevel, const SPtr<TextureCore>& target)
 	{
 		D3D11TextureCore* other = static_cast<D3D11TextureCore*>(target.get());

+ 8 - 9
BansheeD3D11RenderSystem/Source/BsD3D11VertexBuffer.cpp

@@ -8,6 +8,14 @@ namespace BansheeEngine
 		:VertexBufferCore(vertexSize, numVertices, usage, streamOut), mDevice(device), mStreamOut(streamOut), mBuffer(nullptr)
 	{ }
 
+	D3D11VertexBufferCore::~D3D11VertexBufferCore()
+	{
+		if (mBuffer != nullptr)
+			bs_delete<PoolAlloc>(mBuffer);
+
+		BS_INC_RENDER_STAT_CAT(ResDestroyed, RenderStatObject_VertexBuffer);
+	}
+
 	void* D3D11VertexBufferCore::lockImpl(UINT32 offset, UINT32 length, GpuLockOptions options)
 	{
 #if BS_PROFILING_ENABLED
@@ -56,13 +64,4 @@ namespace BansheeEngine
 		BS_INC_RENDER_STAT_CAT(ResCreated, RenderStatObject_VertexBuffer);
 		VertexBufferCore::initialize();
 	}
-
-	void D3D11VertexBufferCore::destroy()
-	{
-		if(mBuffer != nullptr)
-			bs_delete<PoolAlloc>(mBuffer);
-
-		BS_INC_RENDER_STAT_CAT(ResDestroyed, RenderStatObject_VertexBuffer);
-		VertexBufferCore::destroy();
-	}
 }

+ 0 - 15
BansheeD3D9RenderSystem/Include/BsD3D9GpuProgram.h

@@ -53,11 +53,6 @@ namespace BansheeEngine
 		 * @copydoc GpuProgramCore::initialize
 		 */
 		void initialize();
-
-		/**
-		 * @copydoc GpuProgramCore::destroy
-		 */
-		void destroy();
       
 		/**
 		 * @brief	Loads the GPU program from compiled microcode.
@@ -100,11 +95,6 @@ namespace BansheeEngine
 
 		D3D9GpuVertexProgramCore(const String& source, const String& entryPoint, GpuProgramProfile profile);
 
-		/**
-		 * @copydoc D3D9GpuProgramCore::destroy.
-		 */
-		void destroy();
-
 		/**
 		 * @copydoc	D3D9GpuProgramCore::loadFromMicrocode
 		 */
@@ -140,11 +130,6 @@ namespace BansheeEngine
 
 		D3D9GpuFragmentProgramCore(const String& source, const String& entryPoint, GpuProgramProfile profile);
 
-		/**
-		 * @copydoc D3D9GpuProgramCore::destroy
-		 */
-		void destroy();
-
 		/**
 		 * @copydoc	D3D9GpuProgramCore::loadFromMicrocode
 		 */

+ 1 - 6
BansheeD3D9RenderSystem/Include/BsD3D9IndexBuffer.h

@@ -26,7 +26,7 @@ namespace BansheeEngine
 
     public:
 		D3D9IndexBufferCore(IndexType idxType, UINT32 numIndexes, GpuBufferUsage usage);
-		~D3D9IndexBufferCore() { }
+		~D3D9IndexBufferCore();
 
 		/**
 		 * @copydoc	IndexBufferCore::readData
@@ -89,11 +89,6 @@ namespace BansheeEngine
 		 */
 		void initialize();	
 		
-		/**
-		 * @copydoc IndexBufferCore::destroy
-		 */
-		void destroy();
-
 	protected:		
 		Map<IDirect3DDevice9*, BufferResources*> mMapDeviceToBufferResources;
 		D3DINDEXBUFFER_DESC	mBufferDesc;	

+ 0 - 5
BansheeD3D9RenderSystem/Include/BsD3D9RenderWindow.h

@@ -131,11 +131,6 @@ namespace BansheeEngine
 		 */
 		virtual void initialize();
 
-		/**
-		 * @copydoc	CoreObjectCore::destroy
-		 */
-		virtual void destroy();
-
 		/**
 		 * @brief	Updates window coordinates and size from actual values provided by Windows.
 		 */

+ 0 - 5
BansheeD3D9RenderSystem/Include/BsD3D9Texture.h

@@ -99,11 +99,6 @@ namespace BansheeEngine
 		 */
 		void initialize();
 		
-		/**
-		 * @copydoc TextureCore::destroy
-		 */
-		void destroy();
-
 		/**
 		 * @copydoc TextureCore::lock
 		 */

+ 1 - 6
BansheeD3D9RenderSystem/Include/BsD3D9VertexBuffer.h

@@ -26,7 +26,7 @@ namespace BansheeEngine
 
     public:
 		D3D9VertexBufferCore(UINT32 vertexSize, UINT32 numVertices, GpuBufferUsage usage, bool streamOut);
-		~D3D9VertexBufferCore() { }
+		~D3D9VertexBufferCore();
 
 		/**
 		 * @copydoc	VertexBufferCore::readData
@@ -74,11 +74,6 @@ namespace BansheeEngine
 		 */
 		void initialize();	
 		
-		/**
-		 * @copydoc VertexBufferCore::destroy
-		 */
-		void destroy();
-
 		/**
 		 * @copydoc	VertexBufferCore::lockImpl
 		 */

+ 0 - 5
BansheeD3D9RenderSystem/Include/BsD3D9VertexDeclaration.h

@@ -39,11 +39,6 @@ namespace BansheeEngine
 		 */
 		void releaseDeclaration();
 
-		/**
-		 * @copydoc	VertexDeclarationCore::destroy
-		 */
-		void destroy();
-
 	protected:        
 		Map<IDirect3DDevice9*, IDirect3DVertexDeclaration9*> mMapDeviceToDeclaration;
     };

+ 3 - 1
BansheeD3D9RenderSystem/Source/BsD3D9GpuBuffer.cpp

@@ -10,7 +10,9 @@ namespace BansheeEngine
 	}
 
 	D3D9GpuBufferCore::~D3D9GpuBufferCore()
-	{ }
+	{ 
+		clearBufferViews();
+	}
 
 	void D3D9GpuBufferCore::initialize()
 	{

+ 7 - 23
BansheeD3D9RenderSystem/Source/BsD3D9GpuProgram.cpp

@@ -19,7 +19,11 @@ namespace BansheeEngine
     { }
 
 	D3D9GpuProgramCore::~D3D9GpuProgramCore()
-	{ }
+	{ 
+		SAFE_RELEASE(mMicrocode);
+
+		BS_INC_RENDER_STAT_CAT(ResDestroyed, RenderStatObject_GpuProgram);
+	}
 
 	void D3D9GpuProgramCore::initialize()
 	{
@@ -199,14 +203,6 @@ namespace BansheeEngine
 		GpuProgramCore::initialize();
 	}
 
-	void D3D9GpuProgramCore::destroy()
-	{
-		SAFE_RELEASE(mMicrocode);
-
-		BS_INC_RENDER_STAT_CAT(ResDestroyed, RenderStatObject_GpuProgram);
-		GpuProgramCore::destroy();
-	}
-
 	D3D9GpuVertexProgramCore::D3D9GpuVertexProgramCore(const String& source, const String& entryPoint,
 		GpuProgramProfile profile)
 		: D3D9GpuProgramCore(source, entryPoint, GPT_VERTEX_PROGRAM, profile)
@@ -216,10 +212,6 @@ namespace BansheeEngine
 
 	D3D9GpuVertexProgramCore::~D3D9GpuVertexProgramCore()
 	{	
-	}
-
-	void D3D9GpuVertexProgramCore::destroy()
-	{
 		auto it = mMapDeviceToVertexShader.begin();
 
 		while (it != mMapDeviceToVertexShader.end())
@@ -227,9 +219,7 @@ namespace BansheeEngine
 			SAFE_RELEASE(it->second);
 			++it;
 		}
-		mMapDeviceToVertexShader.clear();	
-
-		D3D9GpuProgramCore::destroy();
+		mMapDeviceToVertexShader.clear();
 	}
 
     void D3D9GpuVertexProgramCore::loadFromMicrocode(IDirect3DDevice9* d3d9Device, ID3DXBuffer* microcode)
@@ -298,10 +288,6 @@ namespace BansheeEngine
     }
 
 	D3D9GpuFragmentProgramCore::~D3D9GpuFragmentProgramCore()
-	{
-	}
-
-	void D3D9GpuFragmentProgramCore::destroy()
 	{
 		auto it = mMapDeviceToPixelShader.begin();
 
@@ -310,9 +296,7 @@ namespace BansheeEngine
 			SAFE_RELEASE(it->second);
 			++it;
 		}
-		mMapDeviceToPixelShader.clear();	
-
-		D3D9GpuProgramCore::destroy();
+		mMapDeviceToPixelShader.clear();
 	}
 
 	void D3D9GpuFragmentProgramCore::loadFromMicrocode(IDirect3DDevice9* d3d9Device, ID3DXBuffer* microcode)

+ 22 - 23
BansheeD3D9RenderSystem/Source/BsD3D9IndexBuffer.cpp

@@ -13,6 +13,28 @@ namespace BansheeEngine
 		: IndexBufferCore(idxType, numIndexes, usage), mSystemMemoryBuffer(nullptr)
 	{ }
 
+	D3D9IndexBufferCore::~D3D9IndexBufferCore()
+	{
+		D3D9_DEVICE_ACCESS_CRITICAL_SECTION;
+
+		for (auto& bufferResourcesPair : mMapDeviceToBufferResources)
+		{
+			BufferResources* bufferResources = bufferResourcesPair.second;
+
+			SAFE_RELEASE(bufferResources->mBuffer);
+
+			if (bufferResources != nullptr)
+				bs_delete(bufferResources);
+		}
+
+		mMapDeviceToBufferResources.clear();
+
+		if (mSystemMemoryBuffer != nullptr)
+			bs_free(mSystemMemoryBuffer);
+
+		BS_INC_RENDER_STAT_CAT(ResDestroyed, RenderStatObject_IndexBuffer);
+	}
+
 	void D3D9IndexBufferCore::initialize()
 	{
 		D3D9_DEVICE_ACCESS_CRITICAL_SECTION;
@@ -39,29 +61,6 @@ namespace BansheeEngine
 		IndexBufferCore::initialize();
 	}
 
-	void D3D9IndexBufferCore::destroy()
-	{
-		D3D9_DEVICE_ACCESS_CRITICAL_SECTION;
-
-		for (auto& bufferResourcesPair : mMapDeviceToBufferResources)
-		{
-			BufferResources* bufferResources = bufferResourcesPair.second;
-
-			SAFE_RELEASE(bufferResources->mBuffer);
-
-			if (bufferResources != nullptr)
-				bs_delete(bufferResources);
-		}
-
-		mMapDeviceToBufferResources.clear();   
-
-		if(mSystemMemoryBuffer != nullptr)
-			bs_free(mSystemMemoryBuffer);
-
-		BS_INC_RENDER_STAT_CAT(ResDestroyed, RenderStatObject_IndexBuffer);
-		IndexBufferCore::destroy();
-	}
-
 	void* D3D9IndexBufferCore::lockImpl(UINT32 offset, UINT32 length, GpuLockOptions options)
     {		
 		D3D9_DEVICE_ACCESS_CRITICAL_SECTION

+ 17 - 22
BansheeD3D9RenderSystem/Source/BsD3D9RenderWindow.cpp

@@ -24,7 +24,23 @@ namespace BansheeEngine
 	{ }
 
 	D3D9RenderWindowCore::~D3D9RenderWindowCore()
-	{ }
+	{ 
+		if (mDevice != nullptr)
+		{
+			mDevice->detachRenderWindow(this);
+			mDevice = nullptr;
+		}
+
+		if (mHWnd && !mIsExternal)
+		{
+			DestroyWindow(mHWnd);
+		}
+
+		mHWnd = 0;
+		mProperties.mActive = false;
+
+		markCoreDirty();
+	}
 
 	void D3D9RenderWindowCore::initialize()
 	{
@@ -224,27 +240,6 @@ namespace BansheeEngine
 		rs->registerWindow(*this);
 	}
 
-	void D3D9RenderWindowCore::destroy()
-	{
-		if (mDevice != nullptr)
-		{
-			mDevice->detachRenderWindow(this);
-			mDevice = nullptr;
-		}
-
-		if (mHWnd && !mIsExternal)
-		{
-			DestroyWindow(mHWnd);
-		}
-
-		mHWnd = 0;
-		mProperties.mActive = false;
-
-		markCoreDirty();
-
-		RenderWindowCore::destroy();
-	}
-
 	void D3D9RenderWindowCore::setFullscreen(UINT32 width, UINT32 height, float refreshRate, UINT32 monitorIdx)
 	{
 		THROW_IF_NOT_CORE_THREAD;

+ 15 - 20
BansheeD3D9RenderSystem/Source/BsD3D9Texture.cpp

@@ -22,25 +22,6 @@ namespace BansheeEngine
 	
 	D3D9TextureCore::~D3D9TextureCore()
 	{	
-	}
-
-	void D3D9TextureCore::initialize()
-	{
-		THROW_IF_NOT_CORE_THREAD;
-
-		for (UINT32 i = 0; i < D3D9RenderSystem::getResourceCreationDeviceCount(); ++i)
-		{
-			IDirect3DDevice9* d3d9Device = D3D9RenderSystem::getResourceCreationDevice(i);
-
-			createInternalResources(d3d9Device);
-		}
-
-		BS_INC_RENDER_STAT_CAT(ResCreated, RenderStatObject_Texture);
-		TextureCore::initialize();
-	}
-
-	void D3D9TextureCore::destroy()
-	{
 		THROW_IF_NOT_CORE_THREAD;
 
 		for (auto& resPair : mMapDeviceToTextureResources)
@@ -62,7 +43,21 @@ namespace BansheeEngine
 		mSurfaceList.clear();
 
 		BS_INC_RENDER_STAT_CAT(ResDestroyed, RenderStatObject_Texture);
-		TextureCore::destroy();
+	}
+
+	void D3D9TextureCore::initialize()
+	{
+		THROW_IF_NOT_CORE_THREAD;
+
+		for (UINT32 i = 0; i < D3D9RenderSystem::getResourceCreationDeviceCount(); ++i)
+		{
+			IDirect3DDevice9* d3d9Device = D3D9RenderSystem::getResourceCreationDevice(i);
+
+			createInternalResources(d3d9Device);
+		}
+
+		BS_INC_RENDER_STAT_CAT(ResCreated, RenderStatObject_Texture);
+		TextureCore::initialize();
 	}
 
 	PixelData D3D9TextureCore::lockImpl(GpuLockOptions options, UINT32 mipLevel, UINT32 face)

+ 22 - 23
BansheeD3D9RenderSystem/Source/BsD3D9VertexBuffer.cpp

@@ -13,6 +13,28 @@ namespace BansheeEngine
 		: VertexBufferCore(vertexSize, numVertices, usage, streamOut), mSystemMemoryBuffer(nullptr)
     { }
 
+	D3D9VertexBufferCore::~D3D9VertexBufferCore()
+	{
+		D3D9_DEVICE_ACCESS_CRITICAL_SECTION;
+
+		for (auto& bufferResourcesPair : mMapDeviceToBufferResources)
+		{
+			BufferResources* bufferResources = bufferResourcesPair.second;
+
+			SAFE_RELEASE(bufferResources->mBuffer);
+
+			if (bufferResources != nullptr)
+				bs_delete(bufferResources);
+		}
+
+		mMapDeviceToBufferResources.clear();
+
+		if (mSystemMemoryBuffer != nullptr)
+			bs_free(mSystemMemoryBuffer);
+
+		BS_INC_RENDER_STAT_CAT(ResDestroyed, RenderStatObject_VertexBuffer);
+	}
+
 	void D3D9VertexBufferCore::initialize()
 	{
 		D3D9_DEVICE_ACCESS_CRITICAL_SECTION;
@@ -39,29 +61,6 @@ namespace BansheeEngine
 		VertexBufferCore::initialize();
 	}
 
-	void D3D9VertexBufferCore::destroy()
-	{
-		D3D9_DEVICE_ACCESS_CRITICAL_SECTION;
-
-		for (auto& bufferResourcesPair : mMapDeviceToBufferResources)
-		{
-			BufferResources* bufferResources = bufferResourcesPair.second;
-
-			SAFE_RELEASE(bufferResources->mBuffer);
-
-			if (bufferResources != nullptr)
-				bs_delete(bufferResources);
-		}
-
-		mMapDeviceToBufferResources.clear();
-
-		if (mSystemMemoryBuffer != nullptr)
-			bs_free(mSystemMemoryBuffer);
-
-		BS_INC_RENDER_STAT_CAT(ResDestroyed, RenderStatObject_VertexBuffer);
-		VertexBufferCore::destroy();
-	}
-
 	void* D3D9VertexBufferCore::lockImpl(UINT32 offset, UINT32 length, GpuLockOptions options)
     {		
 		D3D9_DEVICE_ACCESS_CRITICAL_SECTION

+ 1 - 5
BansheeD3D9RenderSystem/Source/BsD3D9VertexDeclaration.cpp

@@ -12,14 +12,10 @@ namespace BansheeEngine
     { }
 
 	D3D9VertexDeclarationCore::~D3D9VertexDeclarationCore()
-    {    }
-
-	void D3D9VertexDeclarationCore::destroy()
-	{
+    {    
 		releaseDeclaration();
 
 		BS_INC_RENDER_STAT_CAT(ResDestroyed, RenderStatObject_VertexDeclaration);
-		VertexDeclarationCore::destroy();
 	}
 
 	void D3D9VertexDeclarationCore::notifyOnDeviceCreate(IDirect3DDevice9* d3d9Device)

+ 0 - 5
BansheeGLRenderSystem/Include/BsGLGpuBuffer.h

@@ -52,11 +52,6 @@ namespace BansheeEngine
 		 */
 		void initialize();	
 
-		/**
-		 * @copydoc GpuBufferCore::destroy
-		 */
-		void destroy();	
-
 		/**
 		 * @copydoc GpuBufferCore::createView
 		 */

+ 1 - 5
BansheeGLRenderSystem/Include/BsGLGpuParamBlockBuffer.h

@@ -12,6 +12,7 @@ namespace BansheeEngine
 	{
 	public:
 		GLGpuParamBlockBufferCore(UINT32 size, GpuParamBlockUsage usage);
+		~GLGpuParamBlockBufferCore();
 
 		/**
 		 * @copydoc GpuParamBlockBufferCore::writeData
@@ -33,11 +34,6 @@ namespace BansheeEngine
 		 */
 		virtual void initialize();
 
-		/**
-		 * @copydoc GpuParamBlockBufferCore::destroy
-		 */
-		virtual void destroy();
-
 	private:
 		GLuint mGLHandle;
 	};

+ 1 - 6
BansheeGLRenderSystem/Include/BsGLIndexBuffer.h

@@ -12,7 +12,7 @@ namespace BansheeEngine
     {
     public:
 		GLIndexBufferCore(IndexType idxType, UINT32 numIndexes, GpuBufferUsage usage);
-		~GLIndexBufferCore() { }
+		~GLIndexBufferCore();
 
 		/**
 		 * @copydoc IndexBufferCore::readData
@@ -35,11 +35,6 @@ namespace BansheeEngine
 		 * @copydoc IndexBufferCore::initialize
 		 */
 		void initialize();	
-		
-		/**
-		 * @copydoc IndexBufferCore::destroy
-		 */
-		void destroy();
 
 		/**
 		 * @copydoc IndexBufferCore::lockImpl

+ 0 - 5
BansheeGLRenderSystem/Include/BsGLMultiRenderTexture.h

@@ -31,11 +31,6 @@ namespace BansheeEngine
 		 */
 		virtual void initialize();
 
-		/**
-		 * @copydoc	CoreObjectCore::destroy
-		 */
-		virtual void destroy();
-
 	private:
 		GLFrameBufferObject* mFB;
 

+ 0 - 5
BansheeGLRenderSystem/Include/BsGLRenderTexture.h

@@ -35,11 +35,6 @@ namespace BansheeEngine
 		 */
 		virtual void initialize();
 
-		/**
-		 * @copydoc	RenderTextureCore::destroy
-		 */
-		virtual void destroy();
-
 		/**
 		 * @copydoc	RenderTextureCore::getProperties
 		 */

+ 0 - 5
BansheeGLRenderSystem/Include/BsGLTexture.h

@@ -53,11 +53,6 @@ namespace BansheeEngine
 		 */
 		void initialize();
 
-		/**
-		 * @copydoc TextureCore::destroy
-		 */
-		void destroy();
-
 		/**
 		 * @copydoc TextureCore::lock
 		 */

+ 1 - 6
BansheeGLRenderSystem/Include/BsGLVertexBuffer.h

@@ -13,7 +13,7 @@ namespace BansheeEngine
     {
     public:
 		GLVertexBufferCore(UINT32 vertexSize, UINT32 numVertices, GpuBufferUsage usage, bool streamOut);
-		~GLVertexBufferCore() { }
+		~GLVertexBufferCore();
 
 		/**
 		 * @copydoc	VertexBufferCore::readData
@@ -46,11 +46,6 @@ namespace BansheeEngine
 		 */
 		void initialize();
 
-		/**
-		 * @copydoc VertexBufferCore::destroy
-		 */
-		void destroy();
-
 		/**
 		 * @copydoc	VertexBufferCore::lockImpl
 		 */

+ 0 - 5
BansheeGLRenderSystem/Include/BsWin32Window.h

@@ -105,11 +105,6 @@ namespace BansheeEngine
 		 */
 		virtual void initialize();
 
-		/**
-		 * @copydoc	CoreObjectCore::destroy
-		 */
-		virtual void destroy();
-
 		/**
 		 * @brief	Calculates window size based on provided client area size and currently set window style. 
 		 */

+ 2 - 6
BansheeGLRenderSystem/Source/BsGLGpuBuffer.cpp

@@ -11,6 +11,8 @@ namespace BansheeEngine
 
 	GLGpuBufferCore::~GLGpuBufferCore()
 	{
+		BS_INC_RENDER_STAT_CAT(ResDestroyed, RenderStatObject_GpuBuffer);
+		clearBufferViews();
 	}
 
 	void GLGpuBufferCore::initialize()
@@ -21,12 +23,6 @@ namespace BansheeEngine
 		GpuBufferCore::initialize();
 	}
 
-	void GLGpuBufferCore::destroy()
-	{
-		BS_INC_RENDER_STAT_CAT(ResDestroyed, RenderStatObject_GpuBuffer);
-		GpuBufferCore::destroy();
-	}
-
 	void* GLGpuBufferCore::lock(UINT32 offset, UINT32 length, GpuLockOptions options)
 	{
 #if BS_PROFILING_ENABLED

+ 7 - 8
BansheeGLRenderSystem/Source/BsGLGpuParamBlockBuffer.cpp

@@ -9,6 +9,13 @@ namespace BansheeEngine
 	{
 	}
 
+	GLGpuParamBlockBufferCore::~GLGpuParamBlockBufferCore()
+	{
+		glDeleteBuffers(1, &mGLHandle);
+
+		BS_INC_RENDER_STAT_CAT(ResDestroyed, RenderStatObject_GpuParamBuffer);
+	}
+
 	void GLGpuParamBlockBufferCore::initialize()
 	{
 		glGenBuffers(1, &mGLHandle);
@@ -26,14 +33,6 @@ namespace BansheeEngine
 		GpuParamBlockBufferCore::initialize();
 	}
 
-	void GLGpuParamBlockBufferCore::destroy()
-	{
-		glDeleteBuffers(1, &mGLHandle);
-
-		BS_INC_RENDER_STAT_CAT(ResDestroyed, RenderStatObject_GpuParamBuffer);
-		GpuParamBlockBufferCore::destroy();
-	}
-
 	void GLGpuParamBlockBufferCore::writeToGPU(const UINT8* data)
 	{
 		glBindBuffer(GL_UNIFORM_BUFFER, mGLHandle);

+ 7 - 8
BansheeGLRenderSystem/Source/BsGLIndexBuffer.cpp

@@ -9,6 +9,13 @@ namespace BansheeEngine
 		:IndexBufferCore(idxType, numIndexes, usage), mZeroLocked(false)
 	{  }
 
+	GLIndexBufferCore::~GLIndexBufferCore()
+	{
+		glDeleteBuffers(1, &mBufferId);
+
+		BS_INC_RENDER_STAT_CAT(ResDestroyed, RenderStatObject_IndexBuffer);
+	}
+
 	void GLIndexBufferCore::initialize()
 	{
 		glGenBuffers(1, &mBufferId );
@@ -27,14 +34,6 @@ namespace BansheeEngine
 		IndexBufferCore::initialize();
 	}
 
-	void GLIndexBufferCore::destroy()
-	{
-		glDeleteBuffers(1, &mBufferId);
-
-		BS_INC_RENDER_STAT_CAT(ResDestroyed, RenderStatObject_IndexBuffer);
-		IndexBufferCore::destroy();
-	}
-
 	void* GLIndexBufferCore::lockImpl(UINT32 offset, UINT32 length, GpuLockOptions options)
     {
         GLenum access = 0;

+ 4 - 9
BansheeGLRenderSystem/Source/BsGLMultiRenderTexture.cpp

@@ -8,7 +8,10 @@ namespace BansheeEngine
 	{ }
 
 	GLMultiRenderTextureCore::~GLMultiRenderTextureCore()
-	{ }
+	{ 
+		if (mFB != nullptr)
+			bs_delete(mFB);
+	}
 
 	void GLMultiRenderTextureCore::initialize()
 	{
@@ -71,14 +74,6 @@ namespace BansheeEngine
 		MultiRenderTextureCore::initialize();
 	}
 
-	void GLMultiRenderTextureCore::destroy()
-	{
-		if (mFB != nullptr)
-			bs_delete(mFB);
-
-		MultiRenderTextureCore::destroy();
-	}
-
 	void GLMultiRenderTextureCore::getCustomAttribute(const String& name, void* pData) const
 	{
 		if(name=="FBO")

+ 4 - 9
BansheeGLRenderSystem/Source/BsGLRenderTexture.cpp

@@ -28,7 +28,10 @@ namespace BansheeEngine
 	{ }
 
 	GLRenderTextureCore::~GLRenderTextureCore()
-	{ }
+	{ 
+		if (mFB != nullptr)
+			bs_delete<PoolAlloc>(mFB);
+	}
 
 	void GLRenderTextureCore::initialize()
 	{
@@ -69,14 +72,6 @@ namespace BansheeEngine
 		mFB->bindDepthStencil(depthStencilBuffer);
 	}
 
-	void GLRenderTextureCore::destroy()
-	{
-		if (mFB != nullptr)
-			bs_delete<PoolAlloc>(mFB);
-
-		RenderTextureCore::destroy();
-	}
-
 	void GLRenderTextureCore::getCustomAttribute(const String& name, void* pData) const
 	{
 		if(name=="FBO")

+ 8 - 12
BansheeGLRenderSystem/Source/BsGLTexture.cpp

@@ -18,7 +18,14 @@ namespace BansheeEngine
     { }
 
 	GLTextureCore::~GLTextureCore()
-    { }
+    { 
+		mSurfaceList.clear();
+		glDeleteTextures(1, &mTextureID);
+
+		clearBufferViews();
+
+		BS_INC_RENDER_STAT_CAT(ResDestroyed, RenderStatObject_Texture);
+	}
 
 	void GLTextureCore::initialize()
 	{
@@ -153,17 +160,6 @@ namespace BansheeEngine
 		TextureCore::initialize();
 	}
 
-	void GLTextureCore::destroy()
-	{
-		mSurfaceList.clear();
-		glDeleteTextures(1, &mTextureID);
-
-		clearBufferViews();
-
-		BS_INC_RENDER_STAT_CAT(ResDestroyed, RenderStatObject_Texture);
-		TextureCore::destroy();
-	}
-
     GLenum GLTextureCore::getGLTextureTarget() const
     {
 		switch (mProperties.getTextureType())

+ 10 - 11
BansheeGLRenderSystem/Source/BsGLVertexBuffer.cpp

@@ -12,6 +12,16 @@ namespace BansheeEngine
 
     }
 
+	GLVertexBufferCore::~GLVertexBufferCore()
+	{
+		glDeleteBuffers(1, &mBufferId);
+
+		while (mVAObjects.size() > 0)
+			GLVertexArrayObjectManager::instance().notifyBufferDestroyed(mVAObjects[0]);
+
+		BS_INC_RENDER_STAT_CAT(ResDestroyed, RenderStatObject_VertexBuffer);
+	}
+
 	void GLVertexBufferCore::initialize()
 	{
 		glGenBuffers(1, &mBufferId);
@@ -31,17 +41,6 @@ namespace BansheeEngine
 		VertexBufferCore::initialize();
 	}
 
-	void GLVertexBufferCore::destroy()
-	{
-		glDeleteBuffers(1, &mBufferId);
-
-		while (mVAObjects.size() > 0)
-			GLVertexArrayObjectManager::instance().notifyBufferDestroyed(mVAObjects[0]);
-
-		BS_INC_RENDER_STAT_CAT(ResDestroyed, RenderStatObject_VertexBuffer);
-		VertexBufferCore::destroy();
-	}
-
 	void GLVertexBufferCore::registerVAO(const GLVertexArrayObject& vao)
 	{
 		mVAObjects.push_back(vao);

+ 33 - 38
BansheeGLRenderSystem/Source/BsWin32Window.cpp

@@ -29,7 +29,39 @@ namespace BansheeEngine
 	{ }
 
 	Win32WindowCore::~Win32WindowCore()
-	{ }
+	{ 
+		Win32RenderWindowProperties& props = mProperties;
+
+		if (!mHWnd)
+			return;
+
+		// Unregister and destroy GLContext
+		bs_delete(mContext);
+
+		if (!mIsExternal)
+		{
+			if (props.mIsFullScreen)
+				ChangeDisplaySettingsEx(mDeviceName, NULL, NULL, 0, NULL);
+			DestroyWindow(mHWnd);
+		}
+		else
+		{
+			// just release the DC
+			ReleaseDC(mHWnd, mHDC);
+		}
+
+		props.mActive = false;
+		mHDC = 0; // no release thanks to CS_OWNDC wndclass style
+		mHWnd = 0;
+
+		if (mDeviceName != NULL)
+		{
+			bs_free<ScratchAlloc>(mDeviceName);
+			mDeviceName = NULL;
+		}
+
+		markCoreDirty();
+	}
 
 	void Win32WindowCore::initialize()
 	{
@@ -322,43 +354,6 @@ namespace BansheeEngine
 		mContext = mGLSupport.createContext(mHDC, glrc);
 	}
 
-	void Win32WindowCore::destroy()
-	{
-		Win32RenderWindowProperties& props = mProperties;
-
-		if (!mHWnd)
-			return;
-
-		// Unregister and destroy GLContext
-		bs_delete(mContext);
-
-		if (!mIsExternal)
-		{
-			if (props.mIsFullScreen)
-				ChangeDisplaySettingsEx(mDeviceName, NULL, NULL, 0, NULL);
-			DestroyWindow(mHWnd);
-		}
-		else
-		{
-			// just release the DC
-			ReleaseDC(mHWnd, mHDC);
-		}
-
-		props.mActive = false;
-		mHDC = 0; // no release thanks to CS_OWNDC wndclass style
-		mHWnd = 0;
-
-		if (mDeviceName != NULL)
-		{
-			bs_free<ScratchAlloc>(mDeviceName);
-			mDeviceName = NULL;
-		}
-
-		markCoreDirty();
-
-		RenderWindowCore::destroy();
-	}
-
 	void Win32WindowCore::setFullscreen(UINT32 width, UINT32 height, float refreshRate, UINT32 monitorIdx)
 	{
 		THROW_IF_NOT_CORE_THREAD;

+ 0 - 5
BansheeGLRenderSystem/Source/GLSL/include/BsGLSLGpuProgram.h

@@ -52,11 +52,6 @@ namespace BansheeEngine
 		 */
 		void initialize();
 
-		/**
-		 * @copydoc GpuProgramCore::destroy
-		 */
-		void destroy();
-
 	private:
 		UINT32 mProgramID;
 		GLuint mGLHandle;

+ 9 - 13
BansheeGLRenderSystem/Source/GLSL/src/BsGLSLGpuProgram.cpp

@@ -75,7 +75,15 @@ namespace BansheeEngine
     { }
 
 	GLSLGpuProgramCore::~GLSLGpuProgramCore()
-    { }
+    { 
+		if (mIsCompiled && mGLHandle != 0)
+		{
+			glDeleteProgram(mGLHandle);
+			mGLHandle = 0;
+		}
+
+		BS_INC_RENDER_STAT_CAT(ResDestroyed, RenderStatObject_GpuProgram);
+	}
 
 	void GLSLGpuProgramCore::initialize()
 	{
@@ -195,18 +203,6 @@ namespace BansheeEngine
 		GpuProgramCore::initialize();
 	}
 
-	void GLSLGpuProgramCore::destroy()
-	{
-		if (mIsCompiled && mGLHandle != 0)
-		{
-			glDeleteProgram(mGLHandle);
-			mGLHandle = 0;
-		}
-
-		BS_INC_RENDER_STAT_CAT(ResDestroyed, RenderStatObject_GpuProgram);
-		GpuProgramCore::destroy();
-	}
-
 	bool GLSLGpuProgramCore::isSupported() const
 	{
 		if (!isRequiredCapabilitiesSupported())