Browse Source

Renamed IDestroyable to CoreGpuObject and added more features to it

Marko Pintera 13 years ago
parent
commit
59628fa944
37 changed files with 173 additions and 212 deletions
  1. 2 2
      CamelotD3D11RenderSystem/Include/CmD3D11Texture.h
  2. 0 4
      CamelotD3D11RenderSystem/Source/CmD3D11RenderWindow.cpp
  3. 1 1
      CamelotD3D11RenderSystem/Source/CmD3D11Texture.cpp
  4. 7 2
      CamelotD3D9Renderer/Include/CmD3D9Texture.h
  5. 0 1
      CamelotD3D9Renderer/Source/CmD3D9RenderSystem.cpp
  6. 0 4
      CamelotD3D9Renderer/Source/CmD3D9RenderWindow.cpp
  7. 1 1
      CamelotD3D9Renderer/Source/CmD3D9Texture.cpp
  8. 7 0
      CamelotGLRenderer/Include/CmGLTexture.h
  9. 1 1
      CamelotGLRenderer/Source/CmGLTexture.cpp
  10. 0 4
      CamelotGLRenderer/Source/CmWin32Window.cpp
  11. 1 1
      CamelotGLRenderer/Source/GLSL/src/CmGLSLGpuProgram.cpp
  12. 2 0
      CamelotRenderer/CamelotRenderer.vcxproj
  13. 6 0
      CamelotRenderer/CamelotRenderer.vcxproj.filters
  14. 39 0
      CamelotRenderer/Include/CmCoreGpuObject.h
  15. 5 10
      CamelotRenderer/Include/CmGpuBuffer.h
  16. 28 30
      CamelotRenderer/Include/CmIndexBuffer.h
  17. 3 1
      CamelotRenderer/Include/CmMesh.h
  18. 3 11
      CamelotRenderer/Include/CmRenderTarget.h
  19. 4 12
      CamelotRenderer/Include/CmResource.h
  20. 0 3
      CamelotRenderer/Include/CmTextureManager.h
  21. 5 4
      CamelotRenderer/Include/CmVertexBuffer.h
  22. 16 14
      CamelotRenderer/Include/CmVertexDeclaration.h
  23. 28 0
      CamelotRenderer/Source/CmCoreGpuObject.cpp
  24. 1 6
      CamelotRenderer/Source/CmGpuBuffer.cpp
  25. 1 2
      CamelotRenderer/Source/CmGpuProgram.cpp
  26. 1 6
      CamelotRenderer/Source/CmIndexBuffer.cpp
  27. 1 1
      CamelotRenderer/Source/CmMesh.cpp
  28. 1 7
      CamelotRenderer/Source/CmRenderTarget.cpp
  29. 2 2
      CamelotRenderer/Source/CmResource.cpp
  30. 2 12
      CamelotRenderer/Source/CmTextureManager.cpp
  31. 1 6
      CamelotRenderer/Source/CmVertexBuffer.cpp
  32. 1 6
      CamelotRenderer/Source/CmVertexDeclaration.cpp
  33. 3 3
      CamelotRenderer/Source/CmWindowEventUtilities.cpp
  34. 0 2
      CamelotUtility/CamelotUtility.vcxproj
  35. 0 6
      CamelotUtility/CamelotUtility.vcxproj.filters
  36. 0 25
      CamelotUtility/Include/CmIDestroyable.h
  37. 0 22
      CamelotUtility/Source/CmIDestroyable.cpp

+ 2 - 2
CamelotD3D11RenderSystem/Include/CmD3D11Texture.h

@@ -69,12 +69,12 @@ namespace CamelotEngine
 		void _unmapstaticbuffer();
 
 		/**
-		 * @brief	Resource::initialize_internal
+		 * @copydoc	Resource::initialize_internal()
 		 */
 		void initialize_internal();
 
 		/**
-		 * @brief	Resource::destroy_internal
+		 * @copydoc Resource::destroy_internal()
 		 */
 		void destroy_internal();
 

+ 0 - 4
CamelotD3D11RenderSystem/Source/CmD3D11RenderWindow.cpp

@@ -89,10 +89,6 @@ namespace CamelotEngine
 		mActive = true;
 		mClosed = false;
 
-		// Destroy current window if any
-		if(mHWnd)
-			destroy();
-
 		if (!externalHandle)
 		{
 			DWORD dwStyle = (mHidden ? 0 : WS_VISIBLE) | WS_CLIPCHILDREN;

+ 1 - 1
CamelotD3D11RenderSystem/Source/CmD3D11Texture.cpp

@@ -126,7 +126,7 @@ namespace CamelotEngine
 
 		clearBufferViews();
 
-		IDestroyable::destroy();
+		CoreGpuObject::destroy_internal();
 	}
 
 	void D3D11Texture::_create1DTex()

+ 7 - 2
CamelotD3D9Renderer/Include/CmD3D9Texture.h

@@ -134,9 +134,14 @@ namespace CamelotEngine {
 
 		D3D9Texture();
 
-		/// overriden from Resource
+		/**
+		 * @copydoc Resource::initialize_internal()
+		 */
 		void initialize_internal();	
-
+		
+		/**
+		 * @copydoc Resource::destroy_internal()
+		 */
 		void destroy_internal();
 
 		/// overridden from Texture

+ 0 - 1
CamelotD3D9Renderer/Source/CmD3D9RenderSystem.cpp

@@ -244,7 +244,6 @@ namespace CamelotEngine
 		{
 			// after catching the exception, clean up
 			mResourceManager->unlockDeviceAccess();
-			renderWindow->destroy();
 
 			// re-throw
 			throw;

+ 0 - 4
CamelotD3D9Renderer/Source/CmD3D9RenderWindow.cpp

@@ -99,10 +99,6 @@ namespace CamelotEngine
 		if(opt != desc.platformSpecific.end())
 			externalHandle = (HWND)parseUnsignedInt(opt->second);
 
-		// Destroy current window if any
-		if(mHWnd)
-			destroy();
-
 		if (!externalHandle)
 		{
 			DWORD		dwStyle = WS_VISIBLE | WS_CLIPCHILDREN;

+ 1 - 1
CamelotD3D9Renderer/Source/CmD3D9Texture.cpp

@@ -240,7 +240,7 @@ namespace CamelotEngine
 		
 		clearBufferViews();
 
-		IDestroyable::destroy();
+		CoreGpuObject::destroy_internal();
 	}
 	/****************************************************************************************/
 	D3D9Texture::TextureResources* D3D9Texture::getTextureResources(IDirect3DDevice9* d3d9Device)

+ 7 - 0
CamelotGLRenderer/Include/CmGLTexture.h

@@ -67,7 +67,14 @@ namespace CamelotEngine {
 		// Constructor
 		GLTexture(GLSupport& support);
 
+		/**
+		 * @copydoc Texture::initialize_internal()
+		 */
 		void initialize_internal();
+
+		/**
+		 * @copydoc Texture::destroy_internal()
+		 */
 		void destroy_internal();
 
 		PixelData lockImpl(GpuLockOptions options, UINT32 mipLevel, UINT32 face);

+ 1 - 1
CamelotGLRenderer/Source/CmGLTexture.cpp

@@ -207,7 +207,7 @@ namespace CamelotEngine {
 
 		clearBufferViews();
 
-		IDestroyable::destroy();
+		CoreGpuObject::destroy_internal();
 	}
 
     GLenum GLTexture::getGLTextureTarget(void) const

+ 0 - 4
CamelotGLRenderer/Source/CmWin32Window.cpp

@@ -106,10 +106,6 @@ namespace CamelotEngine {
 
 	void Win32Window::initialize(const RENDER_WINDOW_DESC& desc)
 	{
-		// destroy current window, if any
-		if (mHWnd)
-			destroy();
-
 #ifdef CM_STATIC_LIB
 		HINSTANCE hInst = GetModuleHandle( NULL );
 #else

+ 1 - 1
CamelotGLRenderer/Source/GLSL/src/CmGLSLGpuProgram.cpp

@@ -81,7 +81,7 @@ namespace CamelotEngine {
 	void GLSLGpuProgram::destroy_internal()
 	{
 		// Nothing to destroy
-		GpuProgram::destroy();
+		GpuProgram::destroy_internal();
 	}
 }
 

+ 2 - 0
CamelotRenderer/CamelotRenderer.vcxproj

@@ -191,6 +191,7 @@
     <ClInclude Include="Include\CmCommonEnums.h" />
     <ClInclude Include="Include\CmComponentRTTI.h" />
     <ClInclude Include="Include\CmConfigOptionMap.h" />
+    <ClInclude Include="Include\CmCoreGpuObject.h" />
     <ClInclude Include="Include\CmDeferredRenderContext.h" />
     <ClInclude Include="Include\CmDepthStencilStateRTTI.h" />
     <ClInclude Include="Include\CmDepthStencilState.h" />
@@ -281,6 +282,7 @@
     <ClCompile Include="Source\CmCgProgram.cpp" />
     <ClCompile Include="Source\CmCgProgramFactory.cpp" />
     <ClCompile Include="Source\CmCommandQueue.cpp" />
+    <ClCompile Include="Source\CmCoreGpuObject.cpp" />
     <ClCompile Include="Source\CmDeferredRenderContext.cpp" />
     <ClCompile Include="Source\CmDepthStencilState.cpp" />
     <ClCompile Include="Source\CmGpuBuffer.cpp" />

+ 6 - 0
CamelotRenderer/CamelotRenderer.vcxproj.filters

@@ -365,6 +365,9 @@
     <ClInclude Include="Include\CmGpuParamBlock.h">
       <Filter>Header Files\RenderSystem</Filter>
     </ClInclude>
+    <ClInclude Include="Include\CmCoreGpuObject.h">
+      <Filter>Header Files\RenderSystem</Filter>
+    </ClInclude>
   </ItemGroup>
   <ItemGroup>
     <ClCompile Include="Source\CamelotRenderer.cpp">
@@ -553,5 +556,8 @@
     <ClCompile Include="Source\CmGpuParamBlock.cpp">
       <Filter>Source Files\RenderSystem</Filter>
     </ClCompile>
+    <ClCompile Include="Source\CmCoreGpuObject.cpp">
+      <Filter>Source Files\RenderSystem</Filter>
+    </ClCompile>
   </ItemGroup>
 </Project>

+ 39 - 0
CamelotRenderer/Include/CmCoreGpuObject.h

@@ -0,0 +1,39 @@
+#pragma once
+
+#include "CmPrerequisites.h"
+
+namespace CamelotEngine
+{
+	/**
+	 * @brief	This class provides some common functionality that all low-level GPU-related objects
+	 * 			need to implement.
+	 * 			
+	 * @note	This involves initializing, keeping track of, and releasing all GPU resources.
+	 */
+	class CM_EXPORT CoreGpuObject
+	{
+	public:
+		CoreGpuObject();
+		virtual ~CoreGpuObject();
+
+		/**
+		 * @brief	Destroys this object. Make sure to call this before deleting the object.
+		 * 			
+		 * @note	Destruction is not done immediately, and is instead just scheduled on the
+		 * 			render thread. Unless called from render thread in which case it is executed right away.
+		 */
+		virtual void destroy();
+
+		bool isDestroyed() { return mDestroyed; }
+
+	protected:
+		/**
+		 * @brief	Frees all of the objects dynamically allocated memory. All derived classes that have something to free
+		 * 			should do it here instead of their destructor. All derived classes need to call this base method when they're done.
+		 */
+		virtual void destroy_internal();
+
+	private:
+		bool mDestroyed;
+	};
+}

+ 5 - 10
CamelotRenderer/Include/CmGpuBuffer.h

@@ -3,11 +3,11 @@
 #include "CmPrerequisites.h"
 #include "CmCommonEnums.h"
 #include "CmGpuBufferView.h"
-#include "CmIDestroyable.h"
+#include "CmCoreGpuObject.h"
 
 namespace CamelotEngine 
 {
-	class CM_EXPORT GpuBuffer : public IDestroyable
+	class CM_EXPORT GpuBuffer : public CoreGpuObject
     {
     public:
         GpuBuffer(UINT32 elementCount, UINT32 elementSize, GpuBufferType type, GpuBufferUsage usage, bool randomGpuWrite = false, bool useCounter = false);
@@ -32,14 +32,6 @@ namespace CamelotEngine
 		UINT32 getElementCount() const { return mElementCount; }
 		UINT32 getElementSize() const { return mElementSize; }
 
-		/**
-		 * @copydoc	IDestroyable::destroy()
-		 * 			
-		 * 	@note	Destruction is not done immediately, and is instead just scheduled on the
-		 * 			render thread. Unless called from render thread in which case it is executed right away.
-		 */
-		void destroy();
-
 	protected:
 		GpuBufferType mType;
 		GpuBufferUsage mUsage;
@@ -52,6 +44,9 @@ namespace CamelotEngine
 		virtual void destroyView(GpuBufferView* view) = 0;
 		void clearBufferViews();
 
+		/**
+		 * @copydoc CoreGpuObject::destroy_internal()
+		 */
 		virtual void destroy_internal();
 
 		struct GpuBufferReference

+ 28 - 30
CamelotRenderer/Include/CmIndexBuffer.h

@@ -31,7 +31,7 @@ THE SOFTWARE.
 // Precompiler options
 #include "CmPrerequisites.h"
 #include "CmHardwareBuffer.h"
-#include "CmIDestroyable.h"
+#include "CmCoreGpuObject.h"
 
 namespace CamelotEngine 
 {
@@ -42,39 +42,37 @@ namespace CamelotEngine
 	*  @{
 	*/
 	/** Specialisation of HardwareBuffer for vertex index buffers, still abstract. */
-    class CM_EXPORT IndexBuffer : public HardwareBuffer, public IDestroyable
+    class CM_EXPORT IndexBuffer : public HardwareBuffer, public CoreGpuObject
     {
-	    public:
-		    enum IndexType {
-			    IT_16BIT,
-			    IT_32BIT
-		    };
+	public:
+		enum IndexType {
+			IT_16BIT,
+			IT_32BIT
+		};
 
-	    protected:
-			HardwareBufferManager* mMgr;
-		    IndexType mIndexType;
-		    UINT32 mNumIndexes;
-            UINT32 mIndexSize;
+		/// Should be called by HardwareBufferManager
+		IndexBuffer(HardwareBufferManager* mgr, IndexType idxType, UINT32 numIndexes, GpuBufferUsage usage,
+			bool useSystemMemory);
+		~IndexBuffer();
+		/// Return the manager of this buffer, if any
+		HardwareBufferManager* getManager() const { return mMgr; }
+		/// Get the type of indexes used in this buffer
+		IndexType getType(void) const { return mIndexType; }
+		/// Get the number of indexes in this buffer
+		UINT32 getNumIndexes(void) const { return mNumIndexes; }
+		/// Get the size in bytes of each index
+		UINT32 getIndexSize(void) const { return mIndexSize; }
 
-			virtual void destroy_internal();
+	protected:
+		HardwareBufferManager* mMgr;
+		IndexType mIndexType;
+		UINT32 mNumIndexes;
+		UINT32 mIndexSize;
 
-	    public:
-		    /// Should be called by HardwareBufferManager
-		    IndexBuffer(HardwareBufferManager* mgr, IndexType idxType, UINT32 numIndexes, GpuBufferUsage usage,
-                bool useSystemMemory);
-            ~IndexBuffer();
-			/// Return the manager of this buffer, if any
-			HardwareBufferManager* getManager() const { return mMgr; }
-    		/// Get the type of indexes used in this buffer
-            IndexType getType(void) const { return mIndexType; }
-            /// Get the number of indexes in this buffer
-            UINT32 getNumIndexes(void) const { return mNumIndexes; }
-            /// Get the size in bytes of each index
-            UINT32 getIndexSize(void) const { return mIndexSize; }
-
-			void destroy();
-
-		    // NB subclasses should override lock, unlock, readData, writeData
+		/**
+		* @copydoc CoreGpuObject::destroy_internal()
+		*/
+		virtual void destroy_internal();
     };
 	/** @} */
 }

+ 3 - 1
CamelotRenderer/Include/CmMesh.h

@@ -55,7 +55,9 @@ namespace CamelotEngine
 		virtual void initialize_internal();
 		void throwIfNotRenderThread() const;
 
-		/** @copydoc Resource::destroy_internal(). */
+		/**
+		 * @copydoc Resource::destroy_internal()
+		 */
 		virtual void destroy_internal();
 
 		/************************************************************************/

+ 3 - 11
CamelotRenderer/Include/CmRenderTarget.h

@@ -33,7 +33,7 @@ THE SOFTWARE.
 #include "CmString.h"
 #include "CmPixelUtil.h"
 #include "CmViewport.h"
-#include "CmIDestroyable.h"
+#include "CmCoreGpuObject.h"
 
 /* Define the number of priority groups for the render system's render targets. */
 #ifndef CM_NUM_RENDERTARGET_GROUPS
@@ -61,7 +61,7 @@ namespace CamelotEngine
         @version
             1.0
      */
-    class CM_EXPORT RenderTarget : public IDestroyable
+    class CM_EXPORT RenderTarget : public CoreGpuObject
     {
     public:
 		enum FrameBuffer
@@ -232,14 +232,6 @@ namespace CamelotEngine
 		*/
 		virtual void _endUpdate();
 
-		/**
-		 * @copydoc	IDestroyable::destroy()
-		 * 			
-		 * 	@note	Destruction is not done immediately, and is instead just scheduled on the
-		 * 			render thread. Unless called from render thread in which case it is executed right away.
-		 */
-		void destroy();
-
     protected:
         /// The name of this target.
         String mName;
@@ -258,7 +250,7 @@ namespace CamelotEngine
 		String mFSAAHint;
 			
 		/**
-		 * @brief	Destroys all texture resources, but doesn't actually delete the object.
+		 * @copydoc CoreGpuObject::destroy_internal()
 		 */
 		virtual void destroy_internal();
     };

+ 4 - 12
CamelotRenderer/Include/CmResource.h

@@ -2,14 +2,14 @@
 
 #include "CmPrerequisites.h"
 #include "CmIReflectable.h"
-#include "CmIDestroyable.h"
+#include "CmCoreGpuObject.h"
 
 namespace CamelotEngine
 {
 	/**
 	 * @brief	Base class for all resources used in the engine.
 	 */
-	class CM_EXPORT Resource : public IReflectable, public IDestroyable
+	class CM_EXPORT Resource : public IReflectable, public CoreGpuObject
 	{
 	public:
 		Resource();
@@ -28,14 +28,6 @@ namespace CamelotEngine
 		 */
 		void waitUntilInitialized();
 
-		/**
-		 * @copydoc	IDestroyable::destroy()
-		 * 			
-		 * 	@note	Destruction is not done immediately, and is instead just scheduled on the
-		 * 			render thread. Unless called from render thread in which case it is executed right away.
-		 */
-		void destroy();
-
 	protected:
 		friend class Resources;
 		
@@ -47,9 +39,9 @@ namespace CamelotEngine
 		virtual void initialize_internal();
 
 		/**
-		 * @brief	Destroys all texture resources, but doesn't actually delete the object.
+		 * @copydoc CoreGpuObject::destroy_internal()
 		 */
-		virtual void destroy_internal() {} // TODO - This is temporarily non-abstract
+		virtual void destroy_internal();
 
 		/**
 		 * @brief	Marks the resource as initialized.

+ 0 - 3
CamelotRenderer/Include/CmTextureManager.h

@@ -61,9 +61,6 @@ namespace CamelotEngine {
 		virtual Texture* createTextureImpl() = 0;
 		virtual RenderTexture* createRenderTextureImpl() = 0;
 
-		void destroy(Texture* texture);
-		virtual void destroy_internal(Texture* texture);
-
     public:
 
         TextureManager(void);

+ 5 - 4
CamelotRenderer/Include/CmVertexBuffer.h

@@ -31,7 +31,7 @@ THE SOFTWARE.
 // Precompiler options
 #include "CmPrerequisites.h"
 #include "CmHardwareBuffer.h"
-#include "CmIDestroyable.h"
+#include "CmCoreGpuObject.h"
 #include "CmColor.h"
 
 namespace CamelotEngine 
@@ -43,7 +43,7 @@ namespace CamelotEngine
 	*  @{
 	*/
 	/** Specialisation of HardwareBuffer for a vertex buffer. */
-    class CM_EXPORT VertexBuffer : public HardwareBuffer, public IDestroyable
+    class CM_EXPORT VertexBuffer : public HardwareBuffer, public CoreGpuObject
     {
 	public:
 		/// Should be called by HardwareBufferManager
@@ -51,8 +51,6 @@ namespace CamelotEngine
             GpuBufferUsage usage, bool useSystemMemory);
         ~VertexBuffer();
 
-		void destroy();
-
 		/// Return the manager of this buffer, if any
 		HardwareBufferManager* getManager() const { return mMgr; }
         /// Gets the size in bytes of a single vertex in this buffer
@@ -64,6 +62,9 @@ namespace CamelotEngine
 		UINT32 mNumVertices;
 		UINT32 mVertexSize;
 
+		/**
+		 * @copydoc CoreGpuObject::destroy_internal()
+		 */
 		virtual void destroy_internal();
     };
 }

+ 16 - 14
CamelotRenderer/Include/CmVertexDeclaration.h

@@ -2,7 +2,7 @@
 
 #include "CmPrerequisites.h"
 #include "CmColor.h"
-#include "CmIDestroyable.h"
+#include "CmCoreGpuObject.h"
 
 namespace CamelotEngine
 {
@@ -242,24 +242,14 @@ namespace CamelotEngine
 	Like the other classes in this functional area, these declarations should be created and
 	destroyed using the HardwareBufferManager.
     */
-	class CM_EXPORT VertexDeclaration : public IReflectable, public IDestroyable
+	class CM_EXPORT VertexDeclaration : public IReflectable, public CoreGpuObject
     {
     public:
 		/// Defines the list of vertex elements that makes up this declaration
         typedef list<VertexElement>::type VertexElementList;
         /// Sort routine for vertex elements
         static bool vertexElementLess(const VertexElement& e1, const VertexElement& e2);
-    protected:
-        VertexElementList mElementList;
-		size_t mHash;
-
-		/**
-		 * @brief	Generates a hash value based on all elements in the declaration.
-		 */
-		void recalculateHash();
 
-		virtual void destroy_internal();
-    public:
         /// Standard constructor, not you should use HardwareBufferManager::createVertexDeclaration
         VertexDeclaration();
         virtual ~VertexDeclaration();
@@ -383,8 +373,6 @@ namespace CamelotEngine
 		*/
         virtual VertexDeclarationPtr clone(HardwareBufferManager* mgr = 0);
 
-		void destroy();
-
         inline bool operator== (const VertexDeclaration& rhs) const
         {
             if (mElementList.size() != rhs.mElementList.size())
@@ -407,6 +395,20 @@ namespace CamelotEngine
             return !(*this == rhs);
         }
 
+    protected:
+        VertexElementList mElementList;
+		size_t mHash;
+
+		/**
+		 * @brief	Generates a hash value based on all elements in the declaration.
+		 */
+		void recalculateHash();
+
+		/**
+		 * @copydoc CoreGpuObject::destroy_internal()
+		 */
+		virtual void destroy_internal();
+
 		/************************************************************************/
 		/* 								SERIALIZATION                      		*/
 		/************************************************************************/

+ 28 - 0
CamelotRenderer/Source/CmCoreGpuObject.cpp

@@ -0,0 +1,28 @@
+#include "CmCoreGpuObject.h"
+#include "CmRenderSystem.h"
+#include "CmDebug.h"
+
+namespace CamelotEngine
+{
+	CoreGpuObject::CoreGpuObject()
+		:mDestroyed(false)
+	{ }
+
+	CoreGpuObject::~CoreGpuObject() 
+	{
+		if(!mDestroyed)
+		{
+			LOGWRN("Destructor called but object is not destroyed. Object will leak.")
+		}
+	}
+
+	void CoreGpuObject::destroy()
+	{
+		RenderSystem::instancePtr()->queueCommand(boost::bind(&CoreGpuObject::destroy_internal, this));
+	}
+
+	void CoreGpuObject::destroy_internal()
+	{
+		mDestroyed = true;
+	}
+}

+ 1 - 6
CamelotRenderer/Source/CmGpuBuffer.cpp

@@ -15,16 +15,11 @@ namespace CamelotEngine
 		// I can't call it here since it needs a virtual method call
 	}
 
-	void GpuBuffer::destroy()
-	{
-		RenderSystem::instancePtr()->queueCommand(boost::bind(&GpuBuffer::destroy_internal, this));
-	}
-
 	void GpuBuffer::destroy_internal()
 	{
 		clearBufferViews();
 
-		IDestroyable::destroy();
+		CoreGpuObject::destroy_internal();
 	}
 
 	void GpuBuffer::clearBufferViews()

+ 1 - 2
CamelotRenderer/Source/CmGpuProgram.cpp

@@ -70,8 +70,7 @@ namespace CamelotEngine
 	//---------------------------------------------------------------------------
 	void GpuProgram::destroy_internal()
 	{
-		// Nothing to destroy
-		IDestroyable::destroy();
+		CoreGpuObject::destroy_internal();
 	}
     //-----------------------------------------------------------------------------
     bool GpuProgram::isSupported(void) const

+ 1 - 6
CamelotRenderer/Source/CmIndexBuffer.cpp

@@ -58,18 +58,13 @@ namespace CamelotEngine {
     {
 
     }
-	//----------------------------------------------------------------------------
-	void IndexBuffer::destroy()
-	{
-		RenderSystem::instancePtr()->queueCommand(boost::bind(&IndexBuffer::destroy_internal, this));
-	}
 	//----------------------------------------------------------------------------
 	void IndexBuffer::destroy_internal()
 	{
 		if (mMgr)
 			mMgr->_notifyIndexBufferDestroyed(this);
 
-		IDestroyable::destroy();
+		CoreGpuObject::destroy_internal();
 	}
 }
 

+ 1 - 1
CamelotRenderer/Source/CmMesh.cpp

@@ -319,7 +319,7 @@ namespace CamelotEngine
 		if(mIndexData)
 			delete mIndexData;
 
-		IDestroyable::destroy();
+		CoreGpuObject::destroy_internal();
 	}
 
 	void Mesh::throwIfNotRenderThread() const

+ 1 - 7
CamelotRenderer/Source/CmRenderTarget.cpp

@@ -45,14 +45,9 @@ namespace CamelotEngine {
     {
     }
 
-	void RenderTarget::destroy()
-	{
-		RenderSystem::instancePtr()->queueCommand(boost::bind(&RenderTarget::destroy_internal, this));
-	}
-
 	void RenderTarget::destroy_internal()
 	{
-		IDestroyable::destroy();
+		CoreGpuObject::destroy_internal();
 	}
 
     const String& RenderTarget::getName(void) const
@@ -60,7 +55,6 @@ namespace CamelotEngine {
         return mName;
     }
 
-
     void RenderTarget::getMetrics(unsigned int& width, unsigned int& height, unsigned int& colourDepth)
     {
         width = mWidth;

+ 2 - 2
CamelotRenderer/Source/CmResource.cpp

@@ -26,9 +26,9 @@ namespace CamelotEngine
 		CM_THREAD_NOTIFY_ALL(mResourceLoadedCondition);
 	}
 
-	void Resource::destroy()
+	void Resource::destroy_internal()
 	{
-		RenderSystem::instancePtr()->queueCommand(boost::bind(&Resource::destroy_internal, this));
+		CoreGpuObject::destroy_internal();
 	}
 
 	void Resource::waitUntilInitialized()

+ 2 - 12
CamelotRenderer/Source/CmTextureManager.cpp

@@ -41,22 +41,12 @@ namespace CamelotEngine {
     {
         // subclasses should unregister with resource group manager
     }
-	//-----------------------------------------------------------------------
-	void TextureManager::destroy(Texture* texture)
-	{
-		RenderSystem::instancePtr()->queueCommand(boost::bind(&TextureManager::destroy_internal, this, texture));
-	}
-	//-----------------------------------------------------------------------
-	void TextureManager::destroy_internal(Texture* texture)
-	{
-		delete texture;
-	}
     //-----------------------------------------------------------------------
     TexturePtr TextureManager::createTexture(TextureType texType, UINT32 width, UINT32 height, UINT32 depth, int numMipmaps,
         PixelFormat format, int usage, bool hwGamma, 
 		UINT32 fsaa, const String& fsaaHint)
     {
-        TexturePtr ret = TexturePtr(createTextureImpl(), boost::bind(&TextureManager::destroy, this, _1));
+        TexturePtr ret = TexturePtr(createTextureImpl());
 		ret->initialize(texType, width, height, depth, static_cast<size_t>(numMipmaps), format, usage, hwGamma, fsaa, fsaaHint);
 
 		return ret;
@@ -64,7 +54,7 @@ namespace CamelotEngine {
 	//-----------------------------------------------------------------------
 	TexturePtr TextureManager::createEmpty()
 	{
-		TexturePtr ret = TexturePtr(createTextureImpl(), boost::bind(&TextureManager::destroy, this, _1));
+		TexturePtr ret = TexturePtr(createTextureImpl());
 
 		return ret;
 	}

+ 1 - 6
CamelotRenderer/Source/CmVertexBuffer.cpp

@@ -51,16 +51,11 @@ namespace CamelotEngine
 
     }
 
-	void VertexBuffer::destroy()
-	{
-		RenderSystem::instancePtr()->queueCommand(boost::bind(&VertexBuffer::destroy_internal, this));
-	}
-
 	void VertexBuffer::destroy_internal()
 	{
 		if (mMgr)
 			mMgr->_notifyVertexBufferDestroyed(this);
 
-		IDestroyable::destroy();
+		CoreGpuObject::destroy_internal();
 	}
 }

+ 1 - 6
CamelotRenderer/Source/CmVertexDeclaration.cpp

@@ -462,14 +462,9 @@ namespace CamelotEngine
 		return ret;
 	}
 
-	void VertexDeclaration::destroy()
-	{
-		RenderSystem::instancePtr()->queueCommand(boost::bind(&VertexDeclaration::destroy_internal, this));
-	}
-
 	void VertexDeclaration::destroy_internal()
 	{
-		IDestroyable::destroy();
+		CoreGpuObject::destroy_internal();
 	}
 
 	//----------------------------------------------------------------------------

+ 3 - 3
CamelotRenderer/Source/CmWindowEventUtilities.cpp

@@ -280,7 +280,7 @@ void GLXProc( RenderWindow *win, const XEvent &event )
 
             for(index = start ; index != end; ++index)
                 (index->second)->windowClosed(win);
-			win->destroy();
+
 		}
 		break;
 	}
@@ -291,7 +291,7 @@ void GLXProc( RenderWindow *win, const XEvent &event )
 			// Window closed without window manager warning.
             for(index = start ; index != end; ++index)
                 (index->second)->windowClosed(win);
-			win->destroy();
+
 		}
 		break;
 	}
@@ -434,7 +434,7 @@ OSStatus WindowEventUtilities::_CarbonWindowHandler(EventHandlerCallRef nextHand
 			break;
 		}
         case kEventWindowClosed:
-            curWindow->destroy();
+
             for( ; start != end; ++start )
 				(start->second)->windowClosed(curWindow);
             break;

+ 0 - 2
CamelotUtility/CamelotUtility.vcxproj

@@ -161,7 +161,6 @@
   </ItemDefinitionGroup>
   <ItemGroup>
     <ClCompile Include="..\CamelotRenderer\Source\CmManagedDataBlock.cpp" />
-    <ClCompile Include="Source\CmIDestroyable.cpp" />
     <ClCompile Include="Source\CmInt2.cpp" />
     <ClCompile Include="Source\CmPixelData.cpp" />
     <ClCompile Include="Source\CmUUID.cpp" />
@@ -177,7 +176,6 @@
     <ClInclude Include="Include\CmException.h" />
     <ClInclude Include="Include\CmFileSerializer.h" />
     <ClInclude Include="Include\CmFileSystem.h" />
-    <ClInclude Include="Include\CmIDestroyable.h" />
     <ClInclude Include="Include\CmInt2.h" />
     <ClInclude Include="Include\CmIReflectable.h" />
     <ClInclude Include="Include\CmKeyValuePair.h" />

+ 0 - 6
CamelotUtility/CamelotUtility.vcxproj.filters

@@ -207,9 +207,6 @@
     <ClInclude Include="Include\CmUtil.h">
       <Filter>Header Files</Filter>
     </ClInclude>
-    <ClInclude Include="Include\CmIDestroyable.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
   </ItemGroup>
   <ItemGroup>
     <ClCompile Include="Include\CmAxisAlignedBox.cpp">
@@ -305,8 +302,5 @@
     <ClCompile Include="Source\CmPixelData.cpp">
       <Filter>Source Files</Filter>
     </ClCompile>
-    <ClCompile Include="Source\CmIDestroyable.cpp">
-      <Filter>Source Files</Filter>
-    </ClCompile>
   </ItemGroup>
 </Project>

+ 0 - 25
CamelotUtility/Include/CmIDestroyable.h

@@ -1,25 +0,0 @@
-#pragma once
-
-#include "CmPrerequisitesUtil.h"
-
-namespace CamelotEngine
-{
-	/**
-	 * @brief	Classes deriving from this interface need to be destroyed with the help of a destroy() method,
-	 * 			before their actual destructor is called.
-	 */
-	class CM_UTILITY_EXPORT IDestroyable
-	{
-	public:
-		IDestroyable();
-		virtual ~IDestroyable();
-
-		/**
-		 * @brief	Destroys this object. Make sure to call this before deleting the object.
-		 */
-		virtual void destroy();
-
-	private:
-		bool mDestroyed;
-	};
-}

+ 0 - 22
CamelotUtility/Source/CmIDestroyable.cpp

@@ -1,22 +0,0 @@
-#include "CmIDestroyable.h"
-#include "CmDebug.h"
-
-namespace CamelotEngine
-{
-	IDestroyable::IDestroyable()
-		:mDestroyed(false)
-	{ }
-
-	IDestroyable::~IDestroyable() 
-	{
-		if(!mDestroyed)
-		{
-			LOGWRN("Destructor called but object is not destroyed. Object will leak.")
-		}
-	}
-
-	void IDestroyable::destroy()
-	{
-		mDestroyed = true;
-	}
-}