소스 검색

Ported remaining new/delete calls to the new system

Marko Pintera 12 년 전
부모
커밋
df225bbba5
66개의 변경된 파일170개의 추가작업 그리고 204개의 파일을 삭제
  1. 1 2
      BansheeEngine/Include/BsGUIElement.h
  2. 1 1
      BansheeEngine/Source/BsBuiltinMaterialManager.cpp
  3. 2 2
      BansheeEngine/Source/BsGUIElement.cpp
  4. 1 1
      BansheeEngine/Source/BsGUILayout.cpp
  5. 2 2
      CamelotClient/CamelotClient.cpp
  6. 1 1
      CamelotCore/Include/CmCoreObject.h
  7. 10 20
      CamelotCore/Include/CmMaterialRTTI.h
  8. 1 2
      CamelotCore/Include/CmMeshDataRTTI.h
  9. 1 2
      CamelotCore/Include/CmResourceHandleRTTI.h
  10. 2 3
      CamelotCore/Include/CmTextureRTTI.h
  11. 2 2
      CamelotCore/Source/CmCommandQueue.cpp
  12. 2 2
      CamelotCore/Source/CmGpuBuffer.cpp
  13. 2 2
      CamelotCore/Source/CmGpuParams.cpp
  14. 1 1
      CamelotCore/Source/CmImporter.cpp
  15. 4 4
      CamelotCore/Source/CmMesh.cpp
  16. 3 3
      CamelotCore/Source/CmRenderSystem.cpp
  17. 3 3
      CamelotCore/Source/CmResources.cpp
  18. 2 3
      CamelotCore/Source/CmShader.cpp
  19. 1 1
      CamelotCore/Source/CmTechnique.cpp
  20. 1 1
      CamelotCore/Source/CmTexture.cpp
  21. 1 2
      CamelotD3D11RenderSystem/Include/CmD3D11RenderSystemFactory.h
  22. 1 1
      CamelotD3D11RenderSystem/Source/CmD3D11Driver.cpp
  23. 1 1
      CamelotD3D11RenderSystem/Source/CmD3D11DriverList.cpp
  24. 1 1
      CamelotD3D11RenderSystem/Source/CmD3D11GpuBuffer.cpp
  25. 1 1
      CamelotD3D11RenderSystem/Source/CmD3D11GpuParamBlockBuffer.cpp
  26. 5 10
      CamelotD3D11RenderSystem/Source/CmD3D11GpuProgramManager.cpp
  27. 1 2
      CamelotD3D11RenderSystem/Source/CmD3D11HLSLProgram.cpp
  28. 4 4
      CamelotD3D11RenderSystem/Source/CmD3D11HLSLProgramFactory.cpp
  29. 2 2
      CamelotD3D11RenderSystem/Source/CmD3D11HardwareBuffer.cpp
  30. 8 8
      CamelotD3D11RenderSystem/Source/CmD3D11HardwareBufferManager.cpp
  31. 1 1
      CamelotD3D11RenderSystem/Source/CmD3D11IndexBuffer.cpp
  32. 4 4
      CamelotD3D11RenderSystem/Source/CmD3D11RenderStateManager.cpp
  33. 4 4
      CamelotD3D11RenderSystem/Source/CmD3D11RenderSystem.cpp
  34. 2 2
      CamelotD3D11RenderSystem/Source/CmD3D11RenderWindowManager.cpp
  35. 2 2
      CamelotD3D11RenderSystem/Source/CmD3D11Texture.cpp
  36. 6 6
      CamelotD3D11RenderSystem/Source/CmD3D11TextureManager.cpp
  37. 1 2
      CamelotD3D9Renderer/Include/CmD3D9RenderSystemFactory.h
  38. 2 2
      CamelotD3D9Renderer/Source/CmD3D9Device.cpp
  39. 1 1
      CamelotD3D9Renderer/Source/CmD3D9DeviceManager.cpp
  40. 1 1
      CamelotD3D9Renderer/Source/CmD3D9Driver.cpp
  41. 1 2
      CamelotD3D9Renderer/Source/CmD3D9GpuProgram.cpp
  42. 4 4
      CamelotD3D9Renderer/Source/CmD3D9GpuProgramManager.cpp
  43. 1 2
      CamelotD3D9Renderer/Source/CmD3D9HLSLProgram.cpp
  44. 4 4
      CamelotD3D9Renderer/Source/CmD3D9HLSLProgramFactory.cpp
  45. 10 10
      CamelotD3D9Renderer/Source/CmD3D9HardwareBufferManager.cpp
  46. 2 2
      CamelotD3D9Renderer/Source/CmD3D9IndexBuffer.cpp
  47. 2 2
      CamelotD3D9Renderer/Source/CmD3D9PixelBuffer.cpp
  48. 6 6
      CamelotD3D9Renderer/Source/CmD3D9RenderSystem.cpp
  49. 4 6
      CamelotD3D9Renderer/Source/CmD3D9Texture.cpp
  50. 6 6
      CamelotD3D9Renderer/Source/CmD3D9TextureManager.cpp
  51. 2 2
      CamelotD3D9Renderer/Source/CmD3D9VertexBuffer.cpp
  52. 2 2
      CamelotFBXImporter/Source/CmFBXImporter.cpp
  53. 1 2
      CamelotFontImporter/Source/CmFontImporter.cpp
  54. 1 2
      CamelotFreeImgImporter/Source/CmFreeImgImporter.cpp
  55. 1 2
      CamelotGLRenderer/Include/CmGLRenderSystemFactory.h
  56. 2 2
      CamelotGLRenderer/Source/CmGLGpuProgramManager.cpp
  57. 4 8
      CamelotGLRenderer/Source/CmGLHardwareBufferManager.cpp
  58. 1 1
      CamelotGLRenderer/Source/CmGLMultiRenderTexture.cpp
  59. 4 4
      CamelotGLRenderer/Source/CmGLRenderSystem.cpp
  60. 2 2
      CamelotGLRenderer/Source/CmGLTexture.cpp
  61. 6 6
      CamelotGLRenderer/Source/CmGLTextureManager.cpp
  62. 1 1
      CamelotGLRenderer/Source/CmWin32Window.cpp
  63. 4 4
      CamelotGLRenderer/Source/GLSL/src/CmGLSLPreprocessor.cpp
  64. 1 1
      CamelotOISInput/Source/CmOISPlugin.cpp
  65. 1 1
      CamelotUtility/Include/CmModule.h
  66. 5 5
      CamelotUtility/Source/CmWorkQueue.cpp

+ 1 - 2
BansheeEngine/Include/BsGUIElement.h

@@ -11,6 +11,7 @@ namespace BansheeEngine
 	{
 	{
 	public:
 	public:
 		GUIElement(GUIWidget& parent, const GUIElementStyle* style, const GUILayoutOptions& layoutOptions);
 		GUIElement(GUIWidget& parent, const GUIElementStyle* style, const GUILayoutOptions& layoutOptions);
+		virtual ~GUIElement();
 
 
 		/**
 		/**
 		 * @brief	Returns the number of separate render elements in the GUI element.
 		 * @brief	Returns the number of separate render elements in the GUI element.
@@ -112,8 +113,6 @@ namespace BansheeEngine
 		//	onKeyPressed
 		//	onKeyPressed
 		//	onKeyReleased
 		//	onKeyReleased
 	protected:
 	protected:
-		virtual ~GUIElement();
-
 		virtual void updateRenderElementsInternal() = 0;
 		virtual void updateRenderElementsInternal() = 0;
 
 
 		void setLayoutOptions(const GUILayoutOptions& layoutOptions);
 		void setLayoutOptions(const GUILayoutOptions& layoutOptions);

+ 1 - 1
BansheeEngine/Source/BsBuiltinMaterialManager.cpp

@@ -15,7 +15,7 @@ namespace BansheeEngine
 		for(auto& iter : mAvailableFactories)
 		for(auto& iter : mAvailableFactories)
 		{
 		{
 			iter.second->shutDown();
 			iter.second->shutDown();
-			CM_DELETE(iter.second, BuiltinMaterialFactory, GenAlloc)
+			cm_delete(iter.second);
 		}
 		}
 	}
 	}
 
 

+ 2 - 2
BansheeEngine/Source/BsGUIElement.cpp

@@ -126,13 +126,13 @@ namespace BansheeEngine
 
 
 	void GUIElement::_destroyInternal(GUIElement* element)
 	void GUIElement::_destroyInternal(GUIElement* element)
 	{
 	{
-		CM_DELETE(element, GUIElement, PoolAlloc);
+		cm_delete<PoolAlloc>(element);
 	}
 	}
 
 
 	void GUIElement::destroy(GUIElement* element)
 	void GUIElement::destroy(GUIElement* element)
 	{
 	{
 		element->mParent.unregisterElement(element);
 		element->mParent.unregisterElement(element);
 
 
-		CM_DELETE(element, GUIElement, PoolAlloc);
+		cm_delete<PoolAlloc>(element);
 	}
 	}
 }
 }

+ 1 - 1
BansheeEngine/Source/BsGUILayout.cpp

@@ -119,7 +119,7 @@ namespace BansheeEngine
 
 
 			if(child.isLayout() && child.layout == &layout)
 			if(child.isLayout() && child.layout == &layout)
 			{
 			{
-				CM_DELETE(child.layout, GUILayout, PoolAlloc);
+				cm_delete<PoolAlloc>(child.layout);
 
 
 				mChildren.erase(iter);
 				mChildren.erase(iter);
 				foundElem = true;
 				foundElem = true;

+ 2 - 2
CamelotClient/CamelotClient.cpp

@@ -30,9 +30,9 @@
 #include "CmRTTIType.h"
 #include "CmRTTIType.h"
 #include "CmCursor.h"
 #include "CmCursor.h"
 
 
-#define DX11
+//#define DX11
 //#define DX9
 //#define DX9
-//#define GL
+#define GL
 
 
 using namespace CamelotFramework;
 using namespace CamelotFramework;
 using namespace BansheeEditor;
 using namespace BansheeEditor;

+ 1 - 1
CamelotCore/Include/CmCoreObject.h

@@ -89,7 +89,7 @@ o		 *
 			}
 			}
 			else
 			else
 			{
 			{
-				CM_DELETE((T*)obj, T, MemAlloc);
+				cm_delete<MemAlloc, T>((T*)obj);
 			}
 			}
 		}
 		}
 
 

+ 10 - 20
CamelotCore/Include/CmMaterialRTTI.h

@@ -178,8 +178,7 @@ namespace CamelotFramework
 		virtual UINT32 getRTTIId() { return TID_MaterialParamFloat; }
 		virtual UINT32 getRTTIId() { return TID_MaterialParamFloat; }
 		virtual std::shared_ptr<IReflectable> newRTTIObject() 
 		virtual std::shared_ptr<IReflectable> newRTTIObject() 
 		{ 
 		{ 
-			return std::shared_ptr<IReflectable>(CM_NEW(MaterialFloatParam, ScratchAlloc) MaterialFloatParam(),
-				&MemAllocDeleter<MaterialFloatParam, ScratchAlloc>::deleter); 
+			return cm_shared_ptr<MaterialFloatParam, ScratchAlloc>(); 
 		}
 		}
 	};
 	};
 
 
@@ -211,8 +210,7 @@ namespace CamelotFramework
 		virtual UINT32 getRTTIId() { return TID_MaterialParamVec2; }
 		virtual UINT32 getRTTIId() { return TID_MaterialParamVec2; }
 		virtual std::shared_ptr<IReflectable> newRTTIObject() 
 		virtual std::shared_ptr<IReflectable> newRTTIObject() 
 		{ 
 		{ 
-			return std::shared_ptr<IReflectable>(CM_NEW(MaterialVec2Param, ScratchAlloc) MaterialVec2Param(),
-				&MemAllocDeleter<MaterialVec2Param, ScratchAlloc>::deleter); 
+			return cm_shared_ptr<MaterialVec2Param, ScratchAlloc>(); 
 		}
 		}
 	};
 	};
 
 
@@ -244,8 +242,7 @@ namespace CamelotFramework
 		virtual UINT32 getRTTIId() { return TID_MaterialParamVec3; }
 		virtual UINT32 getRTTIId() { return TID_MaterialParamVec3; }
 		virtual std::shared_ptr<IReflectable> newRTTIObject() 
 		virtual std::shared_ptr<IReflectable> newRTTIObject() 
 		{ 
 		{ 
-			return std::shared_ptr<IReflectable>(CM_NEW(MaterialVec3Param, ScratchAlloc) MaterialVec3Param(),
-				&MemAllocDeleter<MaterialVec3Param, ScratchAlloc>::deleter); 
+			return cm_shared_ptr<MaterialVec3Param, ScratchAlloc>(); 
 		}
 		}
 	};
 	};
 
 
@@ -277,8 +274,7 @@ namespace CamelotFramework
 		virtual UINT32 getRTTIId() { return TID_MaterialParamVec4; }
 		virtual UINT32 getRTTIId() { return TID_MaterialParamVec4; }
 		virtual std::shared_ptr<IReflectable> newRTTIObject() 
 		virtual std::shared_ptr<IReflectable> newRTTIObject() 
 		{
 		{
-			return std::shared_ptr<IReflectable>(CM_NEW(MaterialVec4Param, ScratchAlloc) MaterialVec4Param(),
-				&MemAllocDeleter<MaterialVec4Param, ScratchAlloc>::deleter); 
+			return cm_shared_ptr<MaterialVec4Param, ScratchAlloc>();
 		}
 		}
 	};
 	};
 
 
@@ -310,8 +306,7 @@ namespace CamelotFramework
 		virtual UINT32 getRTTIId() { return TID_MaterialParamMat3; }
 		virtual UINT32 getRTTIId() { return TID_MaterialParamMat3; }
 		virtual std::shared_ptr<IReflectable> newRTTIObject() 
 		virtual std::shared_ptr<IReflectable> newRTTIObject() 
 		{ 
 		{ 
-			return std::shared_ptr<IReflectable>(CM_NEW(MaterialMat3Param, ScratchAlloc) MaterialMat3Param(),
-				&MemAllocDeleter<MaterialMat3Param, ScratchAlloc>::deleter); 
+			return cm_shared_ptr<MaterialMat3Param, ScratchAlloc>();
 		}
 		}
 	};
 	};
 
 
@@ -343,8 +338,7 @@ namespace CamelotFramework
 		virtual UINT32 getRTTIId() { return TID_MaterialParamMat4; }
 		virtual UINT32 getRTTIId() { return TID_MaterialParamMat4; }
 		virtual std::shared_ptr<IReflectable> newRTTIObject() 
 		virtual std::shared_ptr<IReflectable> newRTTIObject() 
 		{ 
 		{ 
-			return std::shared_ptr<IReflectable>(CM_NEW(MaterialMat4Param, ScratchAlloc) MaterialMat4Param(),
-				&MemAllocDeleter<MaterialMat4Param, ScratchAlloc>::deleter); 
+			return cm_shared_ptr<MaterialMat4Param, ScratchAlloc>();
 		}
 		}
 	};
 	};
 
 
@@ -392,8 +386,7 @@ namespace CamelotFramework
 		virtual UINT32 getRTTIId() { return TID_MaterialParamStruct; }
 		virtual UINT32 getRTTIId() { return TID_MaterialParamStruct; }
 		virtual std::shared_ptr<IReflectable> newRTTIObject() 
 		virtual std::shared_ptr<IReflectable> newRTTIObject() 
 		{ 
 		{ 
-			return std::shared_ptr<IReflectable>(CM_NEW(MaterialStructParam, ScratchAlloc) MaterialStructParam(),
-				&MemAllocDeleter<MaterialStructParam, ScratchAlloc>::deleter);
+			return cm_shared_ptr<MaterialStructParam, ScratchAlloc>();
 		}
 		}
 	};
 	};
 
 
@@ -421,8 +414,7 @@ namespace CamelotFramework
 		virtual UINT32 getRTTIId() { return TID_MaterialParamTexture; }
 		virtual UINT32 getRTTIId() { return TID_MaterialParamTexture; }
 		virtual std::shared_ptr<IReflectable> newRTTIObject() 
 		virtual std::shared_ptr<IReflectable> newRTTIObject() 
 		{ 
 		{ 
-			return std::shared_ptr<IReflectable>(CM_NEW(MaterialTextureParam, ScratchAlloc) MaterialTextureParam(),
-				&MemAllocDeleter<MaterialTextureParam, ScratchAlloc>::deleter);
+			return cm_shared_ptr<MaterialTextureParam, ScratchAlloc>();
 		}
 		}
 	};
 	};
 
 
@@ -450,8 +442,7 @@ namespace CamelotFramework
 		virtual UINT32 getRTTIId() { return TID_MaterialParamSamplerState; }
 		virtual UINT32 getRTTIId() { return TID_MaterialParamSamplerState; }
 		virtual std::shared_ptr<IReflectable> newRTTIObject() 
 		virtual std::shared_ptr<IReflectable> newRTTIObject() 
 		{ 
 		{ 
-			return std::shared_ptr<IReflectable>(CM_NEW(MaterialSamplerStateParam, ScratchAlloc) MaterialSamplerStateParam(),
-				&MemAllocDeleter<MaterialSamplerStateParam, ScratchAlloc>::deleter);
+			return cm_shared_ptr<MaterialSamplerStateParam, ScratchAlloc>();
 		}
 		}
 	};
 	};
 
 
@@ -542,8 +533,7 @@ namespace CamelotFramework
 		virtual UINT32 getRTTIId() { return TID_MaterialParams; }
 		virtual UINT32 getRTTIId() { return TID_MaterialParams; }
 		virtual std::shared_ptr<IReflectable> newRTTIObject() 
 		virtual std::shared_ptr<IReflectable> newRTTIObject() 
 		{ 
 		{ 
-			return std::shared_ptr<IReflectable>(CM_NEW(MaterialParams, ScratchAlloc) MaterialParams(),
-				&MemAllocDeleter<MaterialParams, ScratchAlloc>::deleter);
+			return cm_shared_ptr<MaterialParams, ScratchAlloc>();
 		}
 		}
 	};
 	};
 
 

+ 1 - 2
CamelotCore/Include/CmMeshDataRTTI.h

@@ -110,8 +110,7 @@ namespace CamelotFramework
 
 
 		virtual std::shared_ptr<IReflectable> newRTTIObject() 
 		virtual std::shared_ptr<IReflectable> newRTTIObject() 
 		{
 		{
-			return std::shared_ptr<MeshData>(CM_NEW(MeshData, PoolAlloc) MeshData(),
-				&MemAllocDeleter<MeshData, PoolAlloc>::deleter);
+			return cm_shared_ptr<MeshData, PoolAlloc>(new (cm_alloc<MeshData, PoolAlloc>()) MeshData());
 		}
 		}
 
 
 		virtual const String& getRTTIName() 
 		virtual const String& getRTTIName() 

+ 1 - 2
CamelotCore/Include/CmResourceHandleRTTI.h

@@ -46,8 +46,7 @@ namespace CamelotFramework
 
 
 		virtual std::shared_ptr<IReflectable> newRTTIObject()
 		virtual std::shared_ptr<IReflectable> newRTTIObject()
 		{
 		{
-			return std::shared_ptr<ResourceHandleBase>(CM_NEW(ResourceHandleBase, PoolAlloc) ResourceHandleBase(),
-				&MemAllocDeleter<ResourceHandleBase, PoolAlloc>::deleter);
+			return cm_shared_ptr<ResourceHandleBase, PoolAlloc>(new (cm_alloc<ResourceHandleBase, PoolAlloc>()) ResourceHandleBase());
 		}
 		}
 	};
 	};
 }
 }

+ 2 - 3
CamelotCore/Include/CmTextureRTTI.h

@@ -7,7 +7,6 @@
 #include "CmMath.h"
 #include "CmMath.h"
 #include "CmApplication.h"
 #include "CmApplication.h"
 #include "CmDeferredRenderContext.h"
 #include "CmDeferredRenderContext.h"
-#include <boost/preprocessor/comma.hpp>
 
 
 // DEBUG ONLY
 // DEBUG ONLY
 #include "CmTextureManager.h"
 #include "CmTextureManager.h"
@@ -89,7 +88,7 @@ namespace CamelotFramework
 		{
 		{
 			Texture* texture = static_cast<Texture*>(obj);
 			Texture* texture = static_cast<Texture*>(obj);
 
 
-			texture->mRTTIData = CM_NEW(vector<PixelDataPtr>::type, PoolAlloc) vector<PixelDataPtr>::type();
+			texture->mRTTIData = cm_new<vector<PixelDataPtr>::type, PoolAlloc>();
 		}
 		}
 
 
 		virtual void onDeserializationEnded(IReflectable* obj)
 		virtual void onDeserializationEnded(IReflectable* obj)
@@ -119,7 +118,7 @@ namespace CamelotFramework
 
 
 			gMainSyncedRC().submitToGpu(true); // TODO - Possibly we can avoid this. I don't see a reason we need to wait for the update to complete.
 			gMainSyncedRC().submitToGpu(true); // TODO - Possibly we can avoid this. I don't see a reason we need to wait for the update to complete.
 
 
-			CM_DELETE(pixelData, vector<PixelDataPtr BOOST_PP_COMMA() StdAlloc<PixelDataPtr>>, PoolAlloc);
+			cm_delete<PoolAlloc>(pixelData);
 			texture->mRTTIData = nullptr;	
 			texture->mRTTIData = nullptr;	
 		}
 		}
 
 

+ 2 - 2
CamelotCore/Source/CmCommandQueue.cpp

@@ -118,7 +118,7 @@ namespace CamelotFramework
 			commands->pop();
 			commands->pop();
 		}
 		}
 
 
-		CM_DELETE(commands, queue<QueuedCommand>, PoolAlloc);
+		cm_delete<PoolAlloc>(commands);
 	}
 	}
 
 
 	void CommandQueueBase::playback(std::queue<QueuedCommand>* commands)
 	void CommandQueueBase::playback(std::queue<QueuedCommand>* commands)
@@ -129,7 +129,7 @@ namespace CamelotFramework
 	void CommandQueueBase::cancelAll()
 	void CommandQueueBase::cancelAll()
 	{
 	{
 		std::queue<QueuedCommand>* commands = flush();
 		std::queue<QueuedCommand>* commands = flush();
-		CM_DELETE(commands, queue<QueuedCommand>, PoolAlloc);
+		cm_delete<PoolAlloc>(commands);
 	}
 	}
 
 
 	bool CommandQueueBase::isEmpty()
 	bool CommandQueueBase::isEmpty()

+ 2 - 2
CamelotCore/Source/CmGpuBuffer.cpp

@@ -27,7 +27,7 @@ namespace CamelotFramework
 		for(auto iter = mBufferViews.begin(); iter != mBufferViews.end(); ++iter)
 		for(auto iter = mBufferViews.begin(); iter != mBufferViews.end(); ++iter)
 		{
 		{
 			destroyView(iter->second->view);
 			destroyView(iter->second->view);
-			CM_DELETE(iter->second, GpuBufferReference, PoolAlloc);
+			cm_delete<PoolAlloc>(iter->second);
 		}
 		}
 
 
 		mBufferViews.clear();
 		mBufferViews.clear();
@@ -75,7 +75,7 @@ namespace CamelotFramework
 			buffer->mBufferViews.erase(iterFind);
 			buffer->mBufferViews.erase(iterFind);
 
 
 			buffer->destroyView(toRemove->view);
 			buffer->destroyView(toRemove->view);
-			CM_DELETE(toRemove, GpuBufferReference, PoolAlloc);
+			cm_delete<PoolAlloc>(toRemove);
 		}
 		}
 	}
 	}
 }
 }

+ 2 - 2
CamelotCore/Source/CmGpuParams.cpp

@@ -98,7 +98,7 @@ namespace CamelotFramework
 		}
 		}
 
 
 		if(mParamBlocks[iterFind->second.slot] != nullptr)
 		if(mParamBlocks[iterFind->second.slot] != nullptr)
-			CM_DELETE(mParamBlocks[iterFind->second.slot], GpuParamBlock, PoolAlloc);
+			cm_delete<PoolAlloc>(mParamBlocks[iterFind->second.slot]);
 
 
 		mParamBlocks[iterFind->second.slot] = cm_new<GpuParamBlock, PoolAlloc>(paramBlockBuffer->getSize());
 		mParamBlocks[iterFind->second.slot] = cm_new<GpuParamBlock, PoolAlloc>(paramBlockBuffer->getSize());
 		mParamBlockBuffers[iterFind->second.slot] = paramBlockBuffer;
 		mParamBlockBuffers[iterFind->second.slot] = paramBlockBuffer;
@@ -336,7 +336,7 @@ namespace CamelotFramework
 
 
 	void GpuParams::releaseBindableCopy(BindableGpuParams& bindableParams)
 	void GpuParams::releaseBindableCopy(BindableGpuParams& bindableParams)
 	{
 	{
-		CM_DELETE(bindableParams.mParams, GpuParams, ScratchAlloc);
+		cm_delete<ScratchAlloc>(bindableParams.mParams);
 	}
 	}
 
 
 	BindableGpuParams::BindableGpuParams(GpuParams* params)
 	BindableGpuParams::BindableGpuParams(GpuParams* params)

+ 1 - 1
CamelotCore/Source/CmImporter.cpp

@@ -23,7 +23,7 @@ namespace CamelotFramework
 		for(auto i = mAssetImporters.begin(); i != mAssetImporters.end(); ++i)
 		for(auto i = mAssetImporters.begin(); i != mAssetImporters.end(); ++i)
 		{
 		{
 			if((*i) != nullptr)
 			if((*i) != nullptr)
-				CM_DELETE(*i, SpecificImporter, GenAlloc);
+				cm_delete(*i);
 		}
 		}
 
 
 		mAssetImporters.clear();
 		mAssetImporters.clear();

+ 4 - 4
CamelotCore/Source/CmMesh.cpp

@@ -39,10 +39,10 @@ namespace CamelotFramework
 		mSubMeshes.clear();
 		mSubMeshes.clear();
 
 
 		if(mVertexData != nullptr)
 		if(mVertexData != nullptr)
-			CM_DELETE(mVertexData, VertexData, PoolAlloc);
+			cm_delete<PoolAlloc>(mVertexData);
 
 
 		if(mIndexData != nullptr)
 		if(mIndexData != nullptr)
-			CM_DELETE(mIndexData, IndexData, PoolAlloc);
+			cm_delete<PoolAlloc>(mIndexData);
 
 
 		// Submeshes
 		// Submeshes
 		for(UINT32 i = 0; i < meshData.getNumSubmeshes(); i++)
 		for(UINT32 i = 0; i < meshData.getNumSubmeshes(); i++)
@@ -240,10 +240,10 @@ namespace CamelotFramework
 		THROW_IF_NOT_RENDER_THREAD;
 		THROW_IF_NOT_RENDER_THREAD;
 
 
 		if(mVertexData != nullptr)
 		if(mVertexData != nullptr)
-			CM_DELETE(mVertexData, VertexData, PoolAlloc);
+			cm_delete<PoolAlloc>(mVertexData);
 
 
 		if(mIndexData != nullptr)
 		if(mIndexData != nullptr)
-			CM_DELETE(mIndexData, IndexData, PoolAlloc);
+			cm_delete<PoolAlloc>(mIndexData);
 
 
 		Resource::destroy_internal();
 		Resource::destroy_internal();
 	}
 	}

+ 3 - 3
CamelotCore/Source/CmRenderSystem.cpp

@@ -80,11 +80,11 @@ namespace CamelotFramework {
 
 
 		if(mCommandQueue != nullptr)
 		if(mCommandQueue != nullptr)
 		{
 		{
-			CM_DELETE(mCommandQueue, CommandQueue<CommandQueueSync>, GenAlloc);
+			cm_delete(mCommandQueue);
 			mCommandQueue = nullptr;
 			mCommandQueue = nullptr;
 		}
 		}
 
 
-		CM_DELETE(mCurrentCapabilities, RenderSystemCapabilities, GenAlloc);
+		cm_delete(mCurrentCapabilities);
 		mCurrentCapabilities = nullptr;
 		mCurrentCapabilities = nullptr;
     }
     }
 
 
@@ -375,7 +375,7 @@ namespace CamelotFramework {
 
 
 		if(mRenderThreadFunc != nullptr)
 		if(mRenderThreadFunc != nullptr)
 		{
 		{
-			CM_DELETE(mRenderThreadFunc, RenderWorkerFunc, GenAlloc);
+			cm_delete(mRenderThreadFunc);
 			mRenderThreadFunc = nullptr;
 			mRenderThreadFunc = nullptr;
 		}
 		}
 #endif
 #endif

+ 3 - 3
CamelotCore/Source/CmResources.cpp

@@ -100,14 +100,14 @@ namespace CamelotFramework
 
 
 			mWorkQueue->shutdown();
 			mWorkQueue->shutdown();
 
 
-			CM_DELETE(mWorkQueue, WorkQueue, GenAlloc);
+			cm_delete(mWorkQueue);
 		}
 		}
 
 
 		if(mRequestHandler != nullptr)
 		if(mRequestHandler != nullptr)
-			CM_DELETE(mRequestHandler, ResourceRequestHandler, GenAlloc);
+			cm_delete(mRequestHandler);
 
 
 		if(mResponseHandler != nullptr)
 		if(mResponseHandler != nullptr)
-			CM_DELETE(mResponseHandler, ResourceResponseHandler, GenAlloc);
+			cm_delete(mResponseHandler);
 	}
 	}
 
 
 	HResource Resources::load(const String& filePath)
 	HResource Resources::load(const String& filePath)

+ 2 - 3
CamelotCore/Source/CmShader.cpp

@@ -14,8 +14,7 @@ namespace CamelotFramework
 
 
 	TechniquePtr Shader::addTechnique(const String& renderSystem, const String& renderer)
 	TechniquePtr Shader::addTechnique(const String& renderSystem, const String& renderer)
 	{
 	{
-		TechniquePtr technique = TechniquePtr(CM_NEW(Technique, PoolAlloc) Technique(renderSystem, renderer),
-			&MemAllocDeleter<Technique, PoolAlloc>::deleter);
+		TechniquePtr technique = cm_shared_ptr<Technique, PoolAlloc>(renderSystem, renderer);
 		mTechniques.push_back(technique);
 		mTechniques.push_back(technique);
 
 
 		return technique;
 		return technique;
@@ -207,7 +206,7 @@ namespace CamelotFramework
 
 
 	ShaderPtr Shader::create(const String& name)
 	ShaderPtr Shader::create(const String& name)
 	{
 	{
-		ShaderPtr newShader(CM_NEW(Shader, PoolAlloc) Shader(name), &CoreObject::_deleteDelayed<Shader, PoolAlloc>);
+		ShaderPtr newShader = cm_core_ptr<Shader, PoolAlloc>(new (cm_alloc<Shader, PoolAlloc>()) Shader(name));
 		newShader->setThisPtr(newShader);
 		newShader->setThisPtr(newShader);
 		newShader->initialize();
 		newShader->initialize();
 
 

+ 1 - 1
CamelotCore/Source/CmTechnique.cpp

@@ -16,7 +16,7 @@ namespace CamelotFramework
 
 
 	PassPtr Technique::addPass()
 	PassPtr Technique::addPass()
 	{
 	{
-		PassPtr newPass(CM_NEW(Pass, PoolAlloc) Pass(), &MemAllocDeleter<Pass, PoolAlloc>::deleter);
+		PassPtr newPass = cm_shared_ptr<Pass, PoolAlloc>();
 
 
 		mPasses.push_back(newPass);
 		mPasses.push_back(newPass);
 		return newPass;
 		return newPass;

+ 1 - 1
CamelotCore/Source/CmTexture.cpp

@@ -297,7 +297,7 @@ namespace CamelotFramework {
 
 
 			texture->mTextureViews.erase(iterFind);
 			texture->mTextureViews.erase(iterFind);
 
 
-			CM_DELETE(toRemove, TextureViewReference, PoolAlloc);
+			cm_delete<PoolAlloc>(toRemove);
 		}
 		}
 	}
 	}
 
 

+ 1 - 2
CamelotD3D11RenderSystem/Include/CmD3D11RenderSystemFactory.h

@@ -24,8 +24,7 @@ namespace CamelotFramework
 				static RenderSystemFactoryPtr newFactory;
 				static RenderSystemFactoryPtr newFactory;
 				if(newFactory == nullptr)
 				if(newFactory == nullptr)
 				{
 				{
-					newFactory = RenderSystemFactoryPtr(CM_NEW(D3D11RenderSystemFactory, GenAlloc) D3D11RenderSystemFactory(),
-						&MemAllocDeleter<D3D11RenderSystemFactory, GenAlloc>::deleter);
+					newFactory = cm_shared_ptr<D3D11RenderSystemFactory>();
 					RenderSystemManager::instance().registerRenderSystemFactory(newFactory);
 					RenderSystemManager::instance().registerRenderSystemFactory(newFactory);
 				}
 				}
 			}
 			}

+ 1 - 1
CamelotD3D11RenderSystem/Source/CmD3D11Driver.cpp

@@ -38,7 +38,7 @@ namespace CamelotFramework
 		for(UINT32 i = 0; i < mNumOutputs; i++)
 		for(UINT32 i = 0; i < mNumOutputs; i++)
 		{
 		{
 			if(mVideoModeList[i] != nullptr)
 			if(mVideoModeList[i] != nullptr)
-				CM_DELETE(mVideoModeList[i], D3D11VideoModeList, GenAlloc);
+				cm_delete(mVideoModeList[i]);
 		}
 		}
 
 
 		if(mVideoModeList != nullptr)
 		if(mVideoModeList != nullptr)

+ 1 - 1
CamelotD3D11RenderSystem/Source/CmD3D11DriverList.cpp

@@ -13,7 +13,7 @@ namespace CamelotFramework
 	{
 	{
 		for(size_t i = 0; i < mDriverList.size(); i++)
 		for(size_t i = 0; i < mDriverList.size(); i++)
 		{
 		{
-			CM_DELETE(mDriverList[i], D3D11Driver, GenAlloc);
+			cm_delete(mDriverList[i]);
 		}
 		}
 
 
 		mDriverList.clear();
 		mDriverList.clear();

+ 1 - 1
CamelotD3D11RenderSystem/Source/CmD3D11GpuBuffer.cpp

@@ -47,7 +47,7 @@ namespace CamelotFramework
 
 
 	void D3D11GpuBuffer::destroy_internal()
 	void D3D11GpuBuffer::destroy_internal()
 	{
 	{
-		CM_DELETE(mBuffer, D3D11HardwareBuffer, PoolAlloc);
+		cm_delete<PoolAlloc>(mBuffer);
 
 
 		GpuBuffer::destroy_internal();
 		GpuBuffer::destroy_internal();
 	}
 	}

+ 1 - 1
CamelotD3D11RenderSystem/Source/CmD3D11GpuParamBlockBuffer.cpp

@@ -29,7 +29,7 @@ namespace CamelotFramework
 	void D3D11GpuParamBlockBuffer::destroy_internal()
 	void D3D11GpuParamBlockBuffer::destroy_internal()
 	{
 	{
 		if(mBuffer != nullptr)
 		if(mBuffer != nullptr)
-			CM_DELETE(mBuffer, D3D11HardwareBuffer, PoolAlloc);
+			cm_delete<PoolAlloc>(mBuffer);
 
 
 		GpuParamBlockBuffer::destroy_internal();
 		GpuParamBlockBuffer::destroy_internal();
 	}
 	}

+ 5 - 10
CamelotD3D11RenderSystem/Source/CmD3D11GpuProgramManager.cpp

@@ -16,20 +16,15 @@ namespace CamelotFramework
 		switch(gptype)
 		switch(gptype)
 		{
 		{
 		case GPT_VERTEX_PROGRAM:
 		case GPT_VERTEX_PROGRAM:
-			return GpuProgramPtr(CM_NEW(D3D11GpuVertexProgram, PoolAlloc) D3D11GpuVertexProgram(language), 
-				&CoreObject::_deleteDelayed<D3D11GpuVertexProgram, PoolAlloc>);
+			return cm_core_ptr<D3D11GpuVertexProgram, PoolAlloc>(new (cm_alloc<D3D11GpuVertexProgram, PoolAlloc>()) D3D11GpuVertexProgram(language));
 		case GPT_FRAGMENT_PROGRAM:
 		case GPT_FRAGMENT_PROGRAM:
-			return GpuProgramPtr(CM_NEW(D3D11GpuFragmentProgram, PoolAlloc) D3D11GpuFragmentProgram(language), 
-				&CoreObject::_deleteDelayed<D3D11GpuFragmentProgram, PoolAlloc>);
+			return cm_core_ptr<D3D11GpuFragmentProgram, PoolAlloc>(new (cm_alloc<D3D11GpuFragmentProgram, PoolAlloc>()) D3D11GpuFragmentProgram(language));
 		case GPT_HULL_PROGRAM:
 		case GPT_HULL_PROGRAM:
-			return GpuProgramPtr(CM_NEW(D3D11GpuHullProgram, PoolAlloc) D3D11GpuHullProgram(language), 
-				&CoreObject::_deleteDelayed<D3D11GpuHullProgram, PoolAlloc>);
+			return cm_core_ptr<D3D11GpuHullProgram, PoolAlloc>(new (cm_alloc<D3D11GpuHullProgram, PoolAlloc>()) D3D11GpuHullProgram(language));
 		case GPT_DOMAIN_PROGRAM:
 		case GPT_DOMAIN_PROGRAM:
-			return GpuProgramPtr(CM_NEW(D3D11GpuDomainProgram, PoolAlloc) D3D11GpuDomainProgram(language), 
-				&CoreObject::_deleteDelayed<D3D11GpuDomainProgram, PoolAlloc>);
+			return cm_core_ptr<D3D11GpuDomainProgram, PoolAlloc>(new (cm_alloc<D3D11GpuDomainProgram, PoolAlloc>()) D3D11GpuDomainProgram(language));
 		case GPT_GEOMETRY_PROGRAM:
 		case GPT_GEOMETRY_PROGRAM:
-			return GpuProgramPtr(CM_NEW(D3D11GpuGeometryProgram, PoolAlloc) D3D11GpuGeometryProgram(language), 
-				&CoreObject::_deleteDelayed<D3D11GpuGeometryProgram, PoolAlloc>);
+			return cm_core_ptr<D3D11GpuGeometryProgram, PoolAlloc>(new (cm_alloc<D3D11GpuGeometryProgram, PoolAlloc>()) D3D11GpuGeometryProgram(language));
 		}
 		}
 		
 		
 		return nullptr;
 		return nullptr;

+ 1 - 2
CamelotD3D11RenderSystem/Source/CmD3D11HLSLProgram.cpp

@@ -169,8 +169,7 @@ namespace CamelotFramework
 
 
 	GpuParamsPtr D3D11HLSLProgram::createParameters()
 	GpuParamsPtr D3D11HLSLProgram::createParameters()
 	{
 	{
-		GpuParamsPtr params(CM_NEW(GpuParams, PoolAlloc) GpuParams(mParametersDesc),
-			&MemAllocDeleter<GpuParams, PoolAlloc>::deleter);
+		GpuParamsPtr params = cm_shared_ptr<GpuParams, PoolAlloc>(std::ref(mParametersDesc));
 		params->setTransposeMatrices(mColumnMajorMatrices);
 		params->setTransposeMatrices(mColumnMajorMatrices);
 
 
 		return params;
 		return params;

+ 4 - 4
CamelotD3D11RenderSystem/Source/CmD3D11HLSLProgramFactory.cpp

@@ -21,15 +21,15 @@ namespace CamelotFramework
 	HighLevelGpuProgramPtr D3D11HLSLProgramFactory::create(const String& source, const String& entryPoint, 
 	HighLevelGpuProgramPtr D3D11HLSLProgramFactory::create(const String& source, const String& entryPoint, 
 		GpuProgramType gptype, GpuProgramProfile profile, const vector<HGpuProgInclude>::type* includes)
 		GpuProgramType gptype, GpuProgramProfile profile, const vector<HGpuProgInclude>::type* includes)
     {
     {
-		D3D11HLSLProgram* prog = CM_NEW(D3D11HLSLProgram, PoolAlloc) D3D11HLSLProgram(source, entryPoint, sLanguageName, gptype, profile, includes);
+		D3D11HLSLProgram* prog = new (cm_alloc<D3D11HLSLProgram, PoolAlloc>()) D3D11HLSLProgram(source, entryPoint, sLanguageName, gptype, profile, includes);
 
 
-        return HighLevelGpuProgramPtr(prog, &CoreObject::_deleteDelayed<D3D11HLSLProgram, PoolAlloc>);
+        return cm_core_ptr<D3D11HLSLProgram, PoolAlloc>(prog);
     }
     }
 
 
 	HighLevelGpuProgramPtr D3D11HLSLProgramFactory::create()
 	HighLevelGpuProgramPtr D3D11HLSLProgramFactory::create()
 	{
 	{
-		D3D11HLSLProgram* prog = CM_NEW(D3D11HLSLProgram, PoolAlloc) D3D11HLSLProgram("", "", sLanguageName, GPT_VERTEX_PROGRAM, GPP_NONE, nullptr);
+		D3D11HLSLProgram* prog = new (cm_alloc<D3D11HLSLProgram, PoolAlloc>()) D3D11HLSLProgram("", "", sLanguageName, GPT_VERTEX_PROGRAM, GPP_NONE, nullptr);
 
 
-		return HighLevelGpuProgramPtr(prog, &CoreObject::_deleteDelayed<D3D11HLSLProgram, PoolAlloc>);
+		return cm_core_ptr<D3D11HLSLProgram, PoolAlloc>(prog);
 	}
 	}
 }
 }

+ 2 - 2
CamelotD3D11RenderSystem/Source/CmD3D11HardwareBuffer.cpp

@@ -92,7 +92,7 @@ namespace CamelotFramework
 		SAFE_RELEASE(mD3DBuffer);
 		SAFE_RELEASE(mD3DBuffer);
 
 
 		if(mpTempStagingBuffer != nullptr)
 		if(mpTempStagingBuffer != nullptr)
-			CM_DELETE(mpTempStagingBuffer, D3D11HardwareBuffer, PoolAlloc);
+			cm_delete<PoolAlloc>(mpTempStagingBuffer);
 	}
 	}
 
 
 	void* D3D11HardwareBuffer::lockImpl(UINT32 offset, 
 	void* D3D11HardwareBuffer::lockImpl(UINT32 offset, 
@@ -220,7 +220,7 @@ namespace CamelotFramework
 			// not that efficient, but we should not be locking often
 			// not that efficient, but we should not be locking often
 			if(mpTempStagingBuffer != nullptr)
 			if(mpTempStagingBuffer != nullptr)
 			{
 			{
-				CM_DELETE(mpTempStagingBuffer, D3D11HardwareBuffer, PoolAlloc);
+				cm_delete<PoolAlloc>(mpTempStagingBuffer);
 				mpTempStagingBuffer = nullptr;
 				mpTempStagingBuffer = nullptr;
 			}
 			}
 		}
 		}

+ 8 - 8
CamelotD3D11RenderSystem/Source/CmD3D11HardwareBufferManager.cpp

@@ -19,31 +19,31 @@ namespace CamelotFramework
 	VertexBufferPtr D3D11HardwareBufferManager::createVertexBufferImpl(UINT32 vertexSize, 
 	VertexBufferPtr D3D11HardwareBufferManager::createVertexBufferImpl(UINT32 vertexSize, 
 		UINT32 numVerts, GpuBufferUsage usage, bool streamOut)
 		UINT32 numVerts, GpuBufferUsage usage, bool streamOut)
 	{
 	{
-		D3D11VertexBuffer* buffer = CM_NEW(D3D11VertexBuffer, PoolAlloc) D3D11VertexBuffer(mDevice, this, vertexSize, numVerts, usage, false, streamOut);
+		D3D11VertexBuffer* buffer = new (cm_alloc<D3D11VertexBuffer, PoolAlloc>()) D3D11VertexBuffer(mDevice, this, vertexSize, numVerts, usage, false, streamOut);
 
 
-		return VertexBufferPtr(buffer, &CoreObject::_deleteDelayed<D3D11VertexBuffer, PoolAlloc>);
+		return cm_core_ptr<D3D11VertexBuffer, PoolAlloc>(buffer);
 	}
 	}
 
 
 	IndexBufferPtr D3D11HardwareBufferManager::createIndexBufferImpl(IndexBuffer::IndexType itype, 
 	IndexBufferPtr D3D11HardwareBufferManager::createIndexBufferImpl(IndexBuffer::IndexType itype, 
 		UINT32 numIndexes, GpuBufferUsage usage)
 		UINT32 numIndexes, GpuBufferUsage usage)
 	{
 	{
-		D3D11IndexBuffer* buffer = CM_NEW(D3D11IndexBuffer, PoolAlloc) D3D11IndexBuffer(mDevice, this, itype, numIndexes, usage, false);
+		D3D11IndexBuffer* buffer = new (cm_alloc<D3D11IndexBuffer, PoolAlloc>()) D3D11IndexBuffer(mDevice, this, itype, numIndexes, usage, false);
 
 
-		return IndexBufferPtr(buffer, &CoreObject::_deleteDelayed<D3D11IndexBuffer, PoolAlloc>);
+		return cm_core_ptr<D3D11IndexBuffer, PoolAlloc>(buffer);
 	}
 	}
 
 
 	GpuParamBlockBufferPtr D3D11HardwareBufferManager::createGpuParamBlockBufferImpl()
 	GpuParamBlockBufferPtr D3D11HardwareBufferManager::createGpuParamBlockBufferImpl()
 	{
 	{
-		D3D11GpuParamBlockBuffer* paramBlockBuffer = CM_NEW(D3D11GpuParamBlockBuffer, PoolAlloc) D3D11GpuParamBlockBuffer();
+		D3D11GpuParamBlockBuffer* paramBlockBuffer = new (cm_alloc<D3D11GpuParamBlockBuffer, PoolAlloc>()) D3D11GpuParamBlockBuffer();
 
 
-		return GpuParamBlockBufferPtr(paramBlockBuffer, &CoreObject::_deleteDelayed<D3D11GpuParamBlockBuffer, PoolAlloc>);
+		return cm_core_ptr<D3D11GpuParamBlockBuffer, PoolAlloc>(paramBlockBuffer);
 	}
 	}
 
 
 	GpuBufferPtr D3D11HardwareBufferManager::createGpuBufferImpl(UINT32 elementCount, UINT32 elementSize, 
 	GpuBufferPtr D3D11HardwareBufferManager::createGpuBufferImpl(UINT32 elementCount, UINT32 elementSize, 
 		GpuBufferType type, GpuBufferUsage usage, bool randomGpuWrite, bool useCounter)
 		GpuBufferType type, GpuBufferUsage usage, bool randomGpuWrite, bool useCounter)
 	{
 	{
-		D3D11GpuBuffer* buffer = CM_NEW(D3D11GpuBuffer, PoolAlloc) D3D11GpuBuffer(elementCount, elementSize, type, usage, randomGpuWrite, useCounter);
+		D3D11GpuBuffer* buffer = new (cm_alloc<D3D11GpuBuffer, PoolAlloc>()) D3D11GpuBuffer(elementCount, elementSize, type, usage, randomGpuWrite, useCounter);
 
 
-		return GpuBufferPtr(buffer, &CoreObject::_deleteDelayed<D3D11GpuBuffer, PoolAlloc>);
+		return cm_core_ptr<D3D11GpuBuffer, PoolAlloc>(buffer);
 	}
 	}
 }
 }

+ 1 - 1
CamelotD3D11RenderSystem/Source/CmD3D11IndexBuffer.cpp

@@ -25,7 +25,7 @@ namespace CamelotFramework
 	void D3D11IndexBuffer::destroy_internal()
 	void D3D11IndexBuffer::destroy_internal()
 	{
 	{
 		if(mBuffer != nullptr)
 		if(mBuffer != nullptr)
-			CM_DELETE(mBuffer, D3D11HardwareBuffer, PoolAlloc) ;
+			cm_delete<PoolAlloc>(mBuffer) ;
 
 
 		IndexBuffer::destroy_internal();
 		IndexBuffer::destroy_internal();
 	}
 	}

+ 4 - 4
CamelotD3D11RenderSystem/Source/CmD3D11RenderStateManager.cpp

@@ -8,25 +8,25 @@ namespace CamelotFramework
 {
 {
 	SamplerStatePtr D3D11RenderStateManager::createSamplerStateImpl() const
 	SamplerStatePtr D3D11RenderStateManager::createSamplerStateImpl() const
 	{
 	{
-		SamplerStatePtr samplerState = SamplerStatePtr(CM_NEW(D3D11SamplerState, PoolAlloc) D3D11SamplerState(), &CoreObject::_deleteDelayed<D3D11SamplerState, PoolAlloc>);
+		SamplerStatePtr samplerState = cm_core_ptr<D3D11SamplerState, PoolAlloc>(new (cm_alloc<D3D11SamplerState, PoolAlloc>()) D3D11SamplerState());
 		return samplerState;
 		return samplerState;
 	}
 	}
 
 
 	BlendStatePtr D3D11RenderStateManager::createBlendStateImpl() const
 	BlendStatePtr D3D11RenderStateManager::createBlendStateImpl() const
 	{
 	{
-		BlendStatePtr blendState = BlendStatePtr(CM_NEW(D3D11BlendState, PoolAlloc) D3D11BlendState(), &CoreObject::_deleteDelayed<D3D11BlendState, PoolAlloc>);
+		BlendStatePtr blendState = cm_core_ptr<D3D11BlendState, PoolAlloc>(new (cm_alloc<D3D11BlendState, PoolAlloc>()) D3D11BlendState());
 		return blendState;
 		return blendState;
 	}
 	}
 
 
 	RasterizerStatePtr D3D11RenderStateManager::createRasterizerStateImpl() const
 	RasterizerStatePtr D3D11RenderStateManager::createRasterizerStateImpl() const
 	{
 	{
-		RasterizerStatePtr rasterizerState = RasterizerStatePtr(CM_NEW(D3D11RasterizerState, PoolAlloc) D3D11RasterizerState(), &CoreObject::_deleteDelayed<D3D11RasterizerState, PoolAlloc>);
+		RasterizerStatePtr rasterizerState = cm_core_ptr<D3D11RasterizerState, PoolAlloc>(new (cm_alloc<D3D11RasterizerState, PoolAlloc>()) D3D11RasterizerState());
 		return rasterizerState;
 		return rasterizerState;
 	}
 	}
 
 
 	DepthStencilStatePtr D3D11RenderStateManager::createDepthStencilStateImpl() const
 	DepthStencilStatePtr D3D11RenderStateManager::createDepthStencilStateImpl() const
 	{
 	{
-		DepthStencilStatePtr depthStencilState = DepthStencilStatePtr(CM_NEW(D3D11DepthStencilState, PoolAlloc) D3D11DepthStencilState(), &CoreObject::_deleteDelayed<D3D11DepthStencilState, PoolAlloc>);
+		DepthStencilStatePtr depthStencilState = cm_core_ptr<D3D11DepthStencilState, PoolAlloc>(new (cm_alloc<D3D11DepthStencilState, PoolAlloc>()) D3D11DepthStencilState());
 		return depthStencilState;
 		return depthStencilState;
 	}
 	}
 }
 }

+ 4 - 4
CamelotD3D11RenderSystem/Source/CmD3D11RenderSystem.cpp

@@ -145,13 +145,13 @@ namespace CamelotFramework
 
 
 		if(mIAManager != nullptr)
 		if(mIAManager != nullptr)
 		{
 		{
-			CM_DELETE(mIAManager, D3D11InputLayoutManager, GenAlloc);
+			cm_delete(mIAManager);
 			mIAManager = nullptr;
 			mIAManager = nullptr;
 		}
 		}
 
 
 		if(mHLSLFactory != nullptr)
 		if(mHLSLFactory != nullptr)
 		{
 		{
-			CM_DELETE(mHLSLFactory, D3D11HLSLProgramFactory, GenAlloc);
+			cm_delete(mHLSLFactory);
 			mHLSLFactory = nullptr;
 			mHLSLFactory = nullptr;
 		}
 		}
 
 
@@ -168,13 +168,13 @@ namespace CamelotFramework
 
 
 		if(mDevice != nullptr)
 		if(mDevice != nullptr)
 		{
 		{
-			CM_DELETE(mDevice, D3D11Device, GenAlloc);
+			cm_delete(mDevice);
 			mDevice = nullptr;
 			mDevice = nullptr;
 		}
 		}
 
 
 		if(mDriverList != nullptr)
 		if(mDriverList != nullptr)
 		{
 		{
-			CM_DELETE(mDriverList, D3D11DriverList, GenAlloc);
+			cm_delete(mDriverList);
 			mDriverList = nullptr;
 			mDriverList = nullptr;
 		}
 		}
 
 

+ 2 - 2
CamelotD3D11RenderSystem/Source/CmD3D11RenderWindowManager.cpp

@@ -24,7 +24,7 @@ namespace CamelotFramework
 		}
 		}
 
 
 		// Create the window
 		// Create the window
-		D3D11RenderWindow* renderWindow = CM_NEW(D3D11RenderWindow, PoolAlloc) D3D11RenderWindow(desc, d3d11rs->getPrimaryDevice(), d3d11rs->getDXGIFactory());
-		return RenderWindowPtr(renderWindow, &CoreObject::_deleteDelayed<D3D11RenderWindow, PoolAlloc>);
+		D3D11RenderWindow* renderWindow = new (cm_alloc<D3D11RenderWindow, PoolAlloc>()) D3D11RenderWindow(desc, d3d11rs->getPrimaryDevice(), d3d11rs->getDXGIFactory());
+		return cm_core_ptr<D3D11RenderWindow, PoolAlloc>(renderWindow);
 	}
 	}
 }
 }

+ 2 - 2
CamelotD3D11RenderSystem/Source/CmD3D11Texture.cpp

@@ -554,7 +554,7 @@ namespace CamelotFramework
 		}
 		}
 
 
 		if(mStaticBuffer != nullptr)
 		if(mStaticBuffer != nullptr)
-			CM_DELETE(mStaticBuffer, PixelData, PoolAlloc);
+			cm_delete<PoolAlloc>(mStaticBuffer);
 	}
 	}
 
 
 	void D3D11Texture::_createStagingBuffer()
 	void D3D11Texture::_createStagingBuffer()
@@ -608,7 +608,7 @@ namespace CamelotFramework
 
 
 	TextureViewPtr D3D11Texture::createView()
 	TextureViewPtr D3D11Texture::createView()
 	{
 	{
-		TextureViewPtr viewPtr(CM_NEW(D3D11TextureView, PoolAlloc) D3D11TextureView(), &CoreObject::_deleteDelayed<D3D11TextureView, PoolAlloc>);
+		TextureViewPtr viewPtr = cm_core_ptr<D3D11TextureView, PoolAlloc>(new (cm_alloc<D3D11TextureView, PoolAlloc>()) D3D11TextureView());
 		viewPtr->setThisPtr(viewPtr);
 		viewPtr->setThisPtr(viewPtr);
 
 
 		return viewPtr;
 		return viewPtr;

+ 6 - 6
CamelotD3D11RenderSystem/Source/CmD3D11TextureManager.cpp

@@ -16,23 +16,23 @@ namespace CamelotFramework
 
 
 	TexturePtr D3D11TextureManager::createTextureImpl()
 	TexturePtr D3D11TextureManager::createTextureImpl()
 	{
 	{
-		D3D11Texture* tex = CM_NEW(D3D11Texture, PoolAlloc) D3D11Texture(); 
+		D3D11Texture* tex = new (cm_alloc<D3D11Texture, PoolAlloc>()) D3D11Texture(); 
 
 
-		return TexturePtr(tex, &CoreObject::_deleteDelayed<D3D11Texture, PoolAlloc>);
+		return cm_core_ptr<D3D11Texture, PoolAlloc>(tex);
 	}
 	}
 
 
 	RenderTexturePtr D3D11TextureManager::createRenderTextureImpl()
 	RenderTexturePtr D3D11TextureManager::createRenderTextureImpl()
 	{
 	{
-		D3D11RenderTexture* tex = CM_NEW(D3D11RenderTexture, PoolAlloc) D3D11RenderTexture();
+		D3D11RenderTexture* tex = new (cm_alloc<D3D11RenderTexture, PoolAlloc>()) D3D11RenderTexture();
 
 
-		return RenderTexturePtr(tex, &CoreObject::_deleteDelayed<D3D11RenderTexture, PoolAlloc>);
+		return cm_core_ptr<D3D11RenderTexture, PoolAlloc>(tex);
 	}
 	}
 
 
 	MultiRenderTexturePtr D3D11TextureManager::createMultiRenderTextureImpl()
 	MultiRenderTexturePtr D3D11TextureManager::createMultiRenderTextureImpl()
 	{
 	{
-		D3D11MultiRenderTexture* tex = CM_NEW(D3D11MultiRenderTexture, PoolAlloc) D3D11MultiRenderTexture();
+		D3D11MultiRenderTexture* tex = new (cm_alloc<D3D11MultiRenderTexture, PoolAlloc>()) D3D11MultiRenderTexture();
 
 
-		return MultiRenderTexturePtr(tex, &CoreObject::_deleteDelayed<D3D11MultiRenderTexture, PoolAlloc>);
+		return cm_core_ptr<D3D11MultiRenderTexture, PoolAlloc>(tex);
 	}
 	}
 
 
 	PixelFormat D3D11TextureManager::getNativeFormat(TextureType ttype, PixelFormat format, int usage)
 	PixelFormat D3D11TextureManager::getNativeFormat(TextureType ttype, PixelFormat format, int usage)

+ 1 - 2
CamelotD3D9Renderer/Include/CmD3D9RenderSystemFactory.h

@@ -24,8 +24,7 @@ namespace CamelotFramework
 						static RenderSystemFactoryPtr newFactory;
 						static RenderSystemFactoryPtr newFactory;
 						if(newFactory == nullptr)
 						if(newFactory == nullptr)
 						{
 						{
-							newFactory = RenderSystemFactoryPtr(CM_NEW(D3D9RenderSystemFactory, GenAlloc) D3D9RenderSystemFactory(),
-								&MemAllocDeleter<D3D9RenderSystemFactory, GenAlloc>::deleter);
+							newFactory = cm_shared_ptr<D3D9RenderSystemFactory>();
 							RenderSystemManager::instance().registerRenderSystemFactory(newFactory);
 							RenderSystemManager::instance().registerRenderSystemFactory(newFactory);
 						}
 						}
 					}
 					}

+ 2 - 2
CamelotD3D9Renderer/Source/CmD3D9Device.cpp

@@ -117,7 +117,7 @@ namespace CamelotFramework
 			releaseRenderWindowResources(renderWindowResources);
 			releaseRenderWindowResources(renderWindowResources);
 
 
 			if(renderWindowResources != nullptr)
 			if(renderWindowResources != nullptr)
-				CM_DELETE(renderWindowResources, RenderWindowResources, PoolAlloc);
+				cm_delete<PoolAlloc>(renderWindowResources);
 			
 			
 			mMapRenderWindowToResoruces.erase(it);		
 			mMapRenderWindowToResoruces.erase(it);		
 		}
 		}
@@ -283,7 +283,7 @@ namespace CamelotFramework
 				setSharedWindowHandle(NULL);
 				setSharedWindowHandle(NULL);
 
 
 			if(it->second != nullptr)
 			if(it->second != nullptr)
-				CM_DELETE(it->second, RenderWindowResources, PoolAlloc);
+				cm_delete<PoolAlloc>(it->second);
 
 
 			++it;
 			++it;
 		}
 		}

+ 1 - 1
CamelotD3D9Renderer/Source/CmD3D9DeviceManager.cpp

@@ -273,7 +273,7 @@ namespace CamelotFramework
 				if (*itDevice == device)
 				if (*itDevice == device)
 				{					
 				{					
 					if(device != nullptr)
 					if(device != nullptr)
-						CM_DELETE(device, D3D9Device, GenAlloc);
+						cm_delete(device);
 
 
 					mRenderDevices.erase(itDevice);
 					mRenderDevices.erase(itDevice);
 					break;
 					break;

+ 1 - 1
CamelotD3D9Renderer/Source/CmD3D9Driver.cpp

@@ -64,7 +64,7 @@ namespace CamelotFramework
 	D3D9Driver::~D3D9Driver()
 	D3D9Driver::~D3D9Driver()
 	{
 	{
 		if(mpVideoModeList != nullptr)
 		if(mpVideoModeList != nullptr)
-			CM_DELETE(mpVideoModeList, D3D9VideoModeList, GenAlloc);
+			cm_delete(mpVideoModeList);
 	}
 	}
 
 
 	String D3D9Driver::DriverName() const
 	String D3D9Driver::DriverName() const

+ 1 - 2
CamelotD3D9Renderer/Source/CmD3D9GpuProgram.cpp

@@ -136,8 +136,7 @@ namespace CamelotFramework {
     //-----------------------------------------------------------------------
     //-----------------------------------------------------------------------
 	GpuParamsPtr D3D9GpuProgram::createParameters()
 	GpuParamsPtr D3D9GpuProgram::createParameters()
 	{
 	{
-		GpuParamsPtr params(CM_NEW(GpuParams, PoolAlloc) GpuParams(mParametersDesc), 
-			&MemAllocDeleter<GpuParams, PoolAlloc>::deleter);
+		GpuParamsPtr params = cm_shared_ptr<GpuParams, PoolAlloc>(std::ref(mParametersDesc));
 		params->setTransposeMatrices(mColumnMajorMatrices);
 		params->setTransposeMatrices(mColumnMajorMatrices);
 
 
 		return params;
 		return params;

+ 4 - 4
CamelotD3D9Renderer/Source/CmD3D9GpuProgramManager.cpp

@@ -46,15 +46,15 @@ namespace CamelotFramework {
     {
     {
         if (gptype == GPT_VERTEX_PROGRAM)
         if (gptype == GPT_VERTEX_PROGRAM)
         {
         {
-            D3D9GpuVertexProgram* prog = CM_NEW(D3D9GpuVertexProgram, PoolAlloc) D3D9GpuVertexProgram(source, entryPoint, language, gptype, profile);
+            D3D9GpuVertexProgram* prog = new (cm_alloc<D3D9GpuVertexProgram, PoolAlloc>()) D3D9GpuVertexProgram(source, entryPoint, language, gptype, profile);
 
 
-			return GpuProgramPtr(prog, &CoreObject::_deleteDelayed<D3D9GpuVertexProgram, PoolAlloc>);
+			return cm_core_ptr<D3D9GpuVertexProgram, PoolAlloc>(prog);
         }
         }
         else
         else
         {
         {
-            D3D9GpuFragmentProgram* prog = CM_NEW(D3D9GpuFragmentProgram, PoolAlloc) D3D9GpuFragmentProgram(source, entryPoint, language, gptype, profile);
+            D3D9GpuFragmentProgram* prog = new (cm_alloc<D3D9GpuFragmentProgram, PoolAlloc>()) D3D9GpuFragmentProgram(source, entryPoint, language, gptype, profile);
 
 
-			return GpuProgramPtr(prog, &CoreObject::_deleteDelayed<D3D9GpuFragmentProgram, PoolAlloc>);
+			return cm_core_ptr<D3D9GpuFragmentProgram, PoolAlloc>(prog);
         }
         }
     }
     }
 }
 }

+ 1 - 2
CamelotD3D9Renderer/Source/CmD3D9HLSLProgram.cpp

@@ -243,8 +243,7 @@ namespace CamelotFramework {
 	//-----------------------------------------------------------------------
 	//-----------------------------------------------------------------------
 	GpuParamsPtr D3D9HLSLProgram::createParameters()
 	GpuParamsPtr D3D9HLSLProgram::createParameters()
 	{
 	{
-		GpuParamsPtr params(CM_NEW(GpuParams, PoolAlloc) GpuParams(mParametersDesc),
-			&MemAllocDeleter<GpuParams, PoolAlloc>::deleter);
+		GpuParamsPtr params = cm_shared_ptr<GpuParams, PoolAlloc>(std::ref(mParametersDesc));
 		params->setTransposeMatrices(mColumnMajorMatrices);
 		params->setTransposeMatrices(mColumnMajorMatrices);
 
 
 		return params;
 		return params;

+ 4 - 4
CamelotD3D9Renderer/Source/CmD3D9HLSLProgramFactory.cpp

@@ -50,15 +50,15 @@ namespace CamelotFramework {
 	HighLevelGpuProgramPtr D3D9HLSLProgramFactory::create(const String& source, const String& entryPoint, 
 	HighLevelGpuProgramPtr D3D9HLSLProgramFactory::create(const String& source, const String& entryPoint, 
 		GpuProgramType gptype, GpuProgramProfile profile, const vector<HGpuProgInclude>::type* includes)
 		GpuProgramType gptype, GpuProgramProfile profile, const vector<HGpuProgInclude>::type* includes)
     {
     {
-		D3D9HLSLProgram* prog = CM_NEW(D3D9HLSLProgram, PoolAlloc) D3D9HLSLProgram(source, entryPoint, sLanguageName, gptype, profile, includes);
+		D3D9HLSLProgram* prog = new (cm_alloc<D3D9HLSLProgram, PoolAlloc>()) D3D9HLSLProgram(source, entryPoint, sLanguageName, gptype, profile, includes);
 
 
-        return HighLevelGpuProgramPtr(prog, &CoreObject::_deleteDelayed<D3D9HLSLProgram, PoolAlloc>);
+        return cm_core_ptr<D3D9HLSLProgram, PoolAlloc>(prog);
     }
     }
 	//-----------------------------------------------------------------------
 	//-----------------------------------------------------------------------
 	HighLevelGpuProgramPtr D3D9HLSLProgramFactory::create()
 	HighLevelGpuProgramPtr D3D9HLSLProgramFactory::create()
 	{
 	{
-		D3D9HLSLProgram* prog = CM_NEW(D3D9HLSLProgram, PoolAlloc) D3D9HLSLProgram("", "", sLanguageName, GPT_VERTEX_PROGRAM, GPP_NONE, nullptr);
+		D3D9HLSLProgram* prog = new (cm_alloc<D3D9HLSLProgram, PoolAlloc>()) D3D9HLSLProgram("", "", sLanguageName, GPT_VERTEX_PROGRAM, GPP_NONE, nullptr);
 
 
-		return HighLevelGpuProgramPtr(prog, &CoreObject::_deleteDelayed<D3D9HLSLProgram, PoolAlloc>);
+		return cm_core_ptr<D3D9HLSLProgram, PoolAlloc>(prog);
 	}
 	}
 }
 }

+ 10 - 10
CamelotD3D9Renderer/Source/CmD3D9HardwareBufferManager.cpp

@@ -48,34 +48,34 @@ namespace CamelotFramework
     {
     {
 		assert (numVerts > 0);
 		assert (numVerts > 0);
 
 
-        D3D9VertexBuffer* buffer = CM_NEW(D3D9VertexBuffer, PoolAlloc) D3D9VertexBuffer(this, vertexSize, numVerts, usage, false);
-		return VertexBufferPtr(buffer, &CoreObject::_deleteDelayed<D3D9VertexBuffer, PoolAlloc>);
+        D3D9VertexBuffer* buffer = new (cm_alloc<D3D9VertexBuffer, PoolAlloc>()) D3D9VertexBuffer(this, vertexSize, numVerts, usage, false);
+		return cm_core_ptr<D3D9VertexBuffer, PoolAlloc>(buffer);
     }
     }
     //-----------------------------------------------------------------------
     //-----------------------------------------------------------------------
 	IndexBufferPtr D3D9HardwareBufferManager::createIndexBufferImpl(IndexBuffer::IndexType itype, UINT32 numIndexes, GpuBufferUsage usage)
 	IndexBufferPtr D3D9HardwareBufferManager::createIndexBufferImpl(IndexBuffer::IndexType itype, UINT32 numIndexes, GpuBufferUsage usage)
     {
     {
 		assert (numIndexes > 0);
 		assert (numIndexes > 0);
 
 
-		D3D9IndexBuffer* buffer = CM_NEW(D3D9IndexBuffer, PoolAlloc) D3D9IndexBuffer(this, itype, numIndexes, usage, false);
-		return IndexBufferPtr(buffer, &CoreObject::_deleteDelayed<D3D9IndexBuffer, PoolAlloc>);
+		D3D9IndexBuffer* buffer = new (cm_alloc<D3D9IndexBuffer, PoolAlloc>()) D3D9IndexBuffer(this, itype, numIndexes, usage, false);
+		return cm_core_ptr<D3D9IndexBuffer, PoolAlloc>(buffer);
     }
     }
 	//-----------------------------------------------------------------------
 	//-----------------------------------------------------------------------
 	GpuParamBlockBufferPtr D3D9HardwareBufferManager::createGpuParamBlockBufferImpl()
 	GpuParamBlockBufferPtr D3D9HardwareBufferManager::createGpuParamBlockBufferImpl()
 	{
 	{
-		GpuParamBlockBuffer* paramBlockBuffer = CM_NEW(GenericGpuParamBlockBuffer, PoolAlloc) GenericGpuParamBlockBuffer();
-		return GpuParamBlockBufferPtr(paramBlockBuffer, &CoreObject::_deleteDelayed<GpuParamBlockBuffer, PoolAlloc>);
+		GpuParamBlockBuffer* paramBlockBuffer = new (cm_alloc<GenericGpuParamBlockBuffer, PoolAlloc>()) GenericGpuParamBlockBuffer();
+		return cm_core_ptr<GpuParamBlockBuffer, PoolAlloc>(paramBlockBuffer);
 	}
 	}
 	//-----------------------------------------------------------------------
 	//-----------------------------------------------------------------------
 	GpuBufferPtr D3D9HardwareBufferManager::createGpuBufferImpl(UINT32 elementCount, UINT32 elementSize, 
 	GpuBufferPtr D3D9HardwareBufferManager::createGpuBufferImpl(UINT32 elementCount, UINT32 elementSize, 
 		GpuBufferType type, GpuBufferUsage usage, bool randomGpuWrite, bool useCounter)
 		GpuBufferType type, GpuBufferUsage usage, bool randomGpuWrite, bool useCounter)
 	{
 	{
-		D3D9GpuBuffer* buffer = CM_NEW(D3D9GpuBuffer, PoolAlloc) D3D9GpuBuffer(elementCount, elementSize, type, usage, randomGpuWrite, useCounter);
-		return GpuBufferPtr(buffer, &CoreObject::_deleteDelayed<D3D9GpuBuffer, PoolAlloc>);
+		D3D9GpuBuffer* buffer = new (cm_alloc<D3D9GpuBuffer, PoolAlloc>()) D3D9GpuBuffer(elementCount, elementSize, type, usage, randomGpuWrite, useCounter);
+		return cm_core_ptr<D3D9GpuBuffer, PoolAlloc>(buffer);
 	}
 	}
     //-----------------------------------------------------------------------
     //-----------------------------------------------------------------------
     VertexDeclarationPtr D3D9HardwareBufferManager::createVertexDeclarationImpl(void)
     VertexDeclarationPtr D3D9HardwareBufferManager::createVertexDeclarationImpl(void)
     {
     {
-        D3D9VertexDeclaration* decl = CM_NEW(D3D9VertexDeclaration, PoolAlloc) D3D9VertexDeclaration();
-		return VertexDeclarationPtr(decl, &CoreObject::_deleteDelayed<D3D9VertexDeclaration, PoolAlloc>);
+        D3D9VertexDeclaration* decl = new (cm_alloc<D3D9VertexDeclaration, PoolAlloc>()) D3D9VertexDeclaration();
+		return cm_core_ptr<D3D9VertexDeclaration, PoolAlloc>(decl);
     }
     }
 }
 }

+ 2 - 2
CamelotD3D9Renderer/Source/CmD3D9IndexBuffer.cpp

@@ -91,7 +91,7 @@ namespace CamelotFramework {
 			SAFE_RELEASE(it->second->mBuffer);
 			SAFE_RELEASE(it->second->mBuffer);
 
 
 			if(it->second != nullptr)
 			if(it->second != nullptr)
-				CM_DELETE(it->second, BufferResources, PoolAlloc);
+				cm_delete<PoolAlloc>(it->second);
 
 
 			++it;
 			++it;
 		}	
 		}	
@@ -208,7 +208,7 @@ namespace CamelotFramework {
 			SAFE_RELEASE(it->second->mBuffer);
 			SAFE_RELEASE(it->second->mBuffer);
 
 
 			if(it->second != nullptr)
 			if(it->second != nullptr)
-				CM_DELETE(it->second, BufferResources, PoolAlloc);
+				cm_delete<PoolAlloc>(it->second);
 
 
 			mMapDeviceToBufferResources.erase(it);
 			mMapDeviceToBufferResources.erase(it);
 		}
 		}

+ 2 - 2
CamelotD3D9Renderer/Source/CmD3D9PixelBuffer.cpp

@@ -55,7 +55,7 @@ namespace CamelotFramework
 			SAFE_RELEASE(it->second->volume);
 			SAFE_RELEASE(it->second->volume);
 
 
 			if(it->second != nullptr)
 			if(it->second != nullptr)
-				CM_DELETE(it->second, BufferResources, PoolAlloc);
+				cm_delete<PoolAlloc>(it->second);
 
 
 			DeviceToBufferResourcesIterator deadi = it++;
 			DeviceToBufferResourcesIterator deadi = it++;
 			mMapDeviceToBufferResources.erase(deadi);
 			mMapDeviceToBufferResources.erase(deadi);
@@ -217,7 +217,7 @@ namespace CamelotFramework
 			SAFE_RELEASE(it->second->volume);	
 			SAFE_RELEASE(it->second->volume);	
 
 
 			if(it->second != nullptr)
 			if(it->second != nullptr)
-				CM_DELETE(it->second, BufferResources, PoolAlloc);
+				cm_delete<PoolAlloc>(it->second);
 
 
 			mMapDeviceToBufferResources.erase(it);
 			mMapDeviceToBufferResources.erase(it);
 		}
 		}

+ 6 - 6
CamelotD3D9Renderer/Source/CmD3D9RenderSystem.cpp

@@ -138,7 +138,7 @@ namespace CamelotFramework
 		THROW_IF_NOT_RENDER_THREAD;
 		THROW_IF_NOT_RENDER_THREAD;
 
 
 		// Create the resource manager.
 		// Create the resource manager.
-		mResourceManager = CM_NEW(D3D9ResourceManager, GenAlloc) D3D9ResourceManager();
+		mResourceManager = cm_new<D3D9ResourceManager>();
 
 
 		// Create our Direct3D object
 		// Create our Direct3D object
 		if( NULL == (mpD3D = Direct3DCreate9(D3D_SDK_VERSION)) )
 		if( NULL == (mpD3D = Direct3DCreate9(D3D_SDK_VERSION)) )
@@ -205,13 +205,13 @@ namespace CamelotFramework
 
 
 		if(mDeviceManager != nullptr)
 		if(mDeviceManager != nullptr)
 		{
 		{
-			CM_DELETE(mDeviceManager, D3D9DeviceManager, GenAlloc);
+			cm_delete(mDeviceManager);
 			mDeviceManager = nullptr;
 			mDeviceManager = nullptr;
 		}
 		}
 
 
 		if(mDriverList != nullptr)
 		if(mDriverList != nullptr)
 		{
 		{
-			CM_DELETE(mDriverList, D3D9DriverList, GenAlloc);
+			cm_delete(mDriverList);
 			mDriverList = nullptr;
 			mDriverList = nullptr;
 		}
 		}
 		mActiveD3DDriver = NULL;	
 		mActiveD3DDriver = NULL;	
@@ -226,14 +226,14 @@ namespace CamelotFramework
 		if (mHLSLProgramFactory)
 		if (mHLSLProgramFactory)
 		{
 		{
 			HighLevelGpuProgramManager::instance().removeFactory(mHLSLProgramFactory);
 			HighLevelGpuProgramManager::instance().removeFactory(mHLSLProgramFactory);
-			CM_DELETE(mHLSLProgramFactory, D3D9HLSLProgramFactory, GenAlloc);
+			cm_delete(mHLSLProgramFactory);
 			mHLSLProgramFactory = 0;
 			mHLSLProgramFactory = 0;
 		}
 		}
 
 
 		if(mCgProgramFactory)
 		if(mCgProgramFactory)
 		{
 		{
 			HighLevelGpuProgramManager::instance().removeFactory(mCgProgramFactory);
 			HighLevelGpuProgramManager::instance().removeFactory(mCgProgramFactory);
-			CM_DELETE(mCgProgramFactory, CgProgramFactory, GenAlloc);
+			cm_delete(mCgProgramFactory);
 			mCgProgramFactory = 0;
 			mCgProgramFactory = 0;
 		}
 		}
 
 
@@ -241,7 +241,7 @@ namespace CamelotFramework
 
 
 		if(mResourceManager != nullptr)
 		if(mResourceManager != nullptr)
 		{
 		{
-			CM_DELETE(mResourceManager, D3D9ResourceManager, GenAlloc);
+			cm_delete(mResourceManager);
 			mResourceManager = nullptr;
 			mResourceManager = nullptr;
 		}
 		}
 
 

+ 4 - 6
CamelotD3D9Renderer/Source/CmD3D9Texture.cpp

@@ -232,7 +232,7 @@ namespace CamelotFramework
 			TextureResources* textureResource = it->second;
 			TextureResources* textureResource = it->second;
 
 
 			if(textureResource != nullptr)
 			if(textureResource != nullptr)
-				CM_DELETE(textureResource, TextureResources, PoolAlloc);
+				cm_delete<PoolAlloc>(textureResource);
 
 
 			++it;
 			++it;
 		}		
 		}		
@@ -942,8 +942,7 @@ namespace CamelotFramework
 	void D3D9Texture::_createSurfaceList(IDirect3DDevice9* d3d9Device, TextureResources* textureResources)
 	void D3D9Texture::_createSurfaceList(IDirect3DDevice9* d3d9Device, TextureResources* textureResources)
 	{
 	{
 		IDirect3DSurface9 *surface;
 		IDirect3DSurface9 *surface;
-		IDirect3DVolume9 *volume;
-		D3D9PixelBuffer *buffer;				
+		IDirect3DVolume9 *volume;				
 		UINT32 mip, face;
 		UINT32 mip, face;
 
 
 		
 		
@@ -987,8 +986,7 @@ namespace CamelotFramework
 			{
 			{
 				for(UINT32 mip=0; mip<=mNumMipmaps; ++mip)
 				for(UINT32 mip=0; mip<=mNumMipmaps; ++mip)
 				{
 				{
-					buffer = CM_NEW(D3D9PixelBuffer, PoolAlloc) D3D9PixelBuffer((GpuBufferUsage)bufusage, this);
-					mSurfaceList.push_back(PixelBufferPtr(buffer, &MemAllocDeleter<D3D9PixelBuffer, PoolAlloc>::deleter));
+					mSurfaceList.push_back(cm_shared_ptr<D3D9PixelBuffer, PoolAlloc>((GpuBufferUsage)bufusage, this));
 				}
 				}
 			}
 			}
 		}
 		}
@@ -1147,7 +1145,7 @@ namespace CamelotFramework
 			freeTextureResources(d3d9Device, textureResource);
 			freeTextureResources(d3d9Device, textureResource);
 
 
 			if(textureResource != nullptr)
 			if(textureResource != nullptr)
-				CM_DELETE(textureResource, TextureResources, PoolAlloc);
+				cm_delete<PoolAlloc>(textureResource);
 
 
 			mMapDeviceToTextureResources.erase(it);
 			mMapDeviceToTextureResources.erase(it);
 		}	
 		}	

+ 6 - 6
CamelotD3D9Renderer/Source/CmD3D9TextureManager.cpp

@@ -44,23 +44,23 @@ namespace CamelotFramework
 
 
     TexturePtr D3D9TextureManager::createTextureImpl()
     TexturePtr D3D9TextureManager::createTextureImpl()
     {
     {
-		D3D9Texture* tex = CM_NEW(D3D9Texture, PoolAlloc) D3D9Texture();
+		D3D9Texture* tex = new (cm_alloc<D3D9Texture, PoolAlloc>()) D3D9Texture();
 
 
-		return TexturePtr(tex, &CoreObject::_deleteDelayed<D3D9Texture, PoolAlloc>);
+		return cm_core_ptr<D3D9Texture, PoolAlloc>(tex);
     }
     }
 
 
 	RenderTexturePtr D3D9TextureManager::createRenderTextureImpl()
 	RenderTexturePtr D3D9TextureManager::createRenderTextureImpl()
 	{
 	{
-		D3D9RenderTexture* tex = CM_NEW(D3D9RenderTexture, PoolAlloc) D3D9RenderTexture();
+		D3D9RenderTexture* tex = new (cm_alloc<D3D9RenderTexture, PoolAlloc>()) D3D9RenderTexture();
 
 
-		return RenderTexturePtr(tex, &CoreObject::_deleteDelayed<D3D9RenderTexture, PoolAlloc>);
+		return cm_core_ptr<D3D9RenderTexture, PoolAlloc>(tex);
 	}
 	}
 
 
 	MultiRenderTexturePtr D3D9TextureManager::createMultiRenderTextureImpl()
 	MultiRenderTexturePtr D3D9TextureManager::createMultiRenderTextureImpl()
 	{
 	{
-		D3D9MultiRenderTexture* tex = CM_NEW(D3D9MultiRenderTexture, PoolAlloc) D3D9MultiRenderTexture();
+		D3D9MultiRenderTexture* tex = new (cm_alloc<D3D9MultiRenderTexture, PoolAlloc>()) D3D9MultiRenderTexture();
 
 
-		return MultiRenderTexturePtr(tex, &CoreObject::_deleteDelayed<D3D9MultiRenderTexture, PoolAlloc>);
+		return cm_core_ptr<D3D9MultiRenderTexture, PoolAlloc>(tex);
 	}
 	}
 
 
 	PixelFormat D3D9TextureManager::getNativeFormat(TextureType ttype, PixelFormat format, int usage)
 	PixelFormat D3D9TextureManager::getNativeFormat(TextureType ttype, PixelFormat format, int usage)

+ 2 - 2
CamelotD3D9Renderer/Source/CmD3D9VertexBuffer.cpp

@@ -149,7 +149,7 @@ namespace CamelotFramework {
 			SAFE_RELEASE(it->second->mBuffer);
 			SAFE_RELEASE(it->second->mBuffer);
 
 
 			if(it->second != nullptr)
 			if(it->second != nullptr)
-				CM_DELETE(it->second, BufferResources, PoolAlloc);
+				cm_delete<PoolAlloc>(it->second);
 
 
 			mMapDeviceToBufferResources.erase(it);
 			mMapDeviceToBufferResources.erase(it);
 		}	
 		}	
@@ -344,7 +344,7 @@ namespace CamelotFramework {
 			SAFE_RELEASE(it->second->mBuffer);
 			SAFE_RELEASE(it->second->mBuffer);
 
 
 			if(it->second != nullptr)
 			if(it->second != nullptr)
-				CM_DELETE(it->second, BufferResources, PoolAlloc);
+				cm_delete<PoolAlloc>(it->second);
 
 
 			++it;
 			++it;
 		}	
 		}	

+ 2 - 2
CamelotFBXImporter/Source/CmFBXImporter.cpp

@@ -178,7 +178,7 @@ namespace CamelotFramework
 	MeshDataPtr FBXImporter::parseMesh(FbxMesh* mesh, bool createTangentsIfMissing)
 	MeshDataPtr FBXImporter::parseMesh(FbxMesh* mesh, bool createTangentsIfMissing)
 	{
 	{
 		if (!mesh->GetNode())
 		if (!mesh->GetNode())
-			return MeshDataPtr(CM_NEW(MeshData, ScratchAlloc) MeshData(0), &MemAllocDeleter<MeshData, ScratchAlloc>::deleter);
+			return cm_shared_ptr<MeshData, ScratchAlloc>(0);
 
 
 		// Find out which vertex attributes exist
 		// Find out which vertex attributes exist
 		bool allByControlPoint = true;
 		bool allByControlPoint = true;
@@ -284,7 +284,7 @@ namespace CamelotFramework
 
 
 		UINT32 vertexCount = lPolygonVertexCount;
 		UINT32 vertexCount = lPolygonVertexCount;
 
 
-		MeshDataPtr meshData = MeshDataPtr(CM_NEW(MeshData, ScratchAlloc) MeshData(vertexCount), &MemAllocDeleter<MeshData, ScratchAlloc>::deleter);
+		MeshDataPtr meshData = cm_shared_ptr<MeshData, ScratchAlloc>(vertexCount);
 		
 		
 		meshData->beginDesc();
 		meshData->beginDesc();
 		meshData->addVertElem(VET_FLOAT3, VES_POSITION);
 		meshData->addVertElem(VET_FLOAT3, VES_POSITION);

+ 1 - 2
CamelotFontImporter/Source/CmFontImporter.cpp

@@ -42,8 +42,7 @@ namespace CamelotFramework
 
 
 	ImportOptionsPtr FontImporter::createImportOptions() const
 	ImportOptionsPtr FontImporter::createImportOptions() const
 	{
 	{
-		return ImportOptionsPtr(CM_NEW(FontImportOptions, ScratchAlloc) FontImportOptions(),
-			&MemAllocDeleter<FontImportOptions, ScratchAlloc>::deleter);
+		return cm_shared_ptr<FontImportOptions, ScratchAlloc>();
 	}
 	}
 
 
 	HResource FontImporter::import(const String& filePath, ConstImportOptionsPtr importOptions)
 	HResource FontImporter::import(const String& filePath, ConstImportOptionsPtr importOptions)

+ 1 - 2
CamelotFreeImgImporter/Source/CmFreeImgImporter.cpp

@@ -301,8 +301,7 @@ namespace CamelotFramework
 		UINT32 size = dstPitch * height;
 		UINT32 size = dstPitch * height;
 
 
 		// Bind output buffer
 		// Bind output buffer
-		TextureDataPtr texData(CM_NEW(TextureData, ScratchAlloc) TextureData(width, height, size, format, 1, 0, 0),
-			&MemAllocDeleter<TextureData, ScratchAlloc>::deleter);
+		TextureDataPtr texData = cm_shared_ptr<TextureData, ScratchAlloc>(width, height, size, format, 1, 0, 0);
 		UINT8* output = texData->getData();
 		UINT8* output = texData->getData();
 
 
 		UINT8* pSrc;
 		UINT8* pSrc;

+ 1 - 2
CamelotGLRenderer/Include/CmGLRenderSystemFactory.h

@@ -24,8 +24,7 @@ namespace CamelotFramework
 				static RenderSystemFactoryPtr newFactory;
 				static RenderSystemFactoryPtr newFactory;
 				if(newFactory == nullptr)
 				if(newFactory == nullptr)
 				{
 				{
-					newFactory = RenderSystemFactoryPtr(CM_NEW(GLRenderSystemFactory, GenAlloc) GLRenderSystemFactory(),
-						&MemAllocDeleter<GLRenderSystemFactory, GenAlloc>::deleter);
+					newFactory = cm_shared_ptr<GLRenderSystemFactory>();
 					RenderSystemManager::instance().registerRenderSystemFactory(newFactory);
 					RenderSystemManager::instance().registerRenderSystemFactory(newFactory);
 				}
 				}
 			}
 			}

+ 2 - 2
CamelotGLRenderer/Source/CmGLGpuProgramManager.cpp

@@ -43,8 +43,8 @@ namespace CamelotFramework
 
 
 	GpuProgramPtr GLGpuProgramManager::create(const String& source, const String& entryPoint, const String& language, GpuProgramType gptype, GpuProgramProfile profile)
 	GpuProgramPtr GLGpuProgramManager::create(const String& source, const String& entryPoint, const String& language, GpuProgramType gptype, GpuProgramProfile profile)
 	{
 	{
-		GLSLGpuProgram* prog = CM_NEW(GLSLGpuProgram, PoolAlloc) GLSLGpuProgram(source, entryPoint, language, gptype, profile, nullptr);
+		GLSLGpuProgram* prog = new (cm_alloc<GLSLGpuProgram, PoolAlloc>()) GLSLGpuProgram(source, entryPoint, language, gptype, profile, nullptr);
 
 
-		return GpuProgramPtr(prog, &CoreObject::_deleteDelayed<GLSLGpuProgram, PoolAlloc>);
+		return cm_core_ptr<GLSLGpuProgram, PoolAlloc>(prog);
 	}
 	}
 }
 }

+ 4 - 8
CamelotGLRenderer/Source/CmGLHardwareBufferManager.cpp

@@ -83,8 +83,7 @@ namespace CamelotFramework {
     VertexBufferPtr GLHardwareBufferManager::createVertexBufferImpl(
     VertexBufferPtr GLHardwareBufferManager::createVertexBufferImpl(
         UINT32 vertexSize, UINT32 numVerts, GpuBufferUsage usage, bool streamOut)
         UINT32 vertexSize, UINT32 numVerts, GpuBufferUsage usage, bool streamOut)
     {
     {
-		return VertexBufferPtr(CM_NEW(GLVertexBuffer, PoolAlloc) GLVertexBuffer(this, vertexSize, numVerts, usage),
-			&CoreObject::_deleteDelayed<GLVertexBuffer, PoolAlloc>);
+		return cm_core_ptr<GLVertexBuffer, PoolAlloc>(new (cm_alloc<GLVertexBuffer, PoolAlloc>()) GLVertexBuffer(this, vertexSize, numVerts, usage));
     }
     }
     //-----------------------------------------------------------------------
     //-----------------------------------------------------------------------
     IndexBufferPtr 
     IndexBufferPtr 
@@ -92,21 +91,18 @@ namespace CamelotFramework {
         IndexBuffer::IndexType itype, UINT32 numIndexes, 
         IndexBuffer::IndexType itype, UINT32 numIndexes, 
         GpuBufferUsage usage)
         GpuBufferUsage usage)
     {
     {
-		return IndexBufferPtr(CM_NEW(GLIndexBuffer, PoolAlloc) GLIndexBuffer(this, itype, numIndexes, usage),
-			&CoreObject::_deleteDelayed<GLIndexBuffer, PoolAlloc>);
+		return cm_core_ptr<GLIndexBuffer, PoolAlloc>(new (cm_alloc<GLIndexBuffer, PoolAlloc>()) GLIndexBuffer(this, itype, numIndexes, usage));
     }
     }
 	//---------------------------------------------------------------------
 	//---------------------------------------------------------------------
 	GpuParamBlockBufferPtr GLHardwareBufferManager::createGpuParamBlockBufferImpl()
 	GpuParamBlockBufferPtr GLHardwareBufferManager::createGpuParamBlockBufferImpl()
 	{
 	{
-		return GpuParamBlockBufferPtr(CM_NEW(GLGpuParamBlockBuffer, PoolAlloc) GLGpuParamBlockBuffer(),
-			&CoreObject::_deleteDelayed<GLGpuParamBlockBuffer, PoolAlloc>);
+		return cm_core_ptr<GLGpuParamBlockBuffer, PoolAlloc>(new (cm_alloc<GLGpuParamBlockBuffer, PoolAlloc>()) GLGpuParamBlockBuffer());
 	}
 	}
 	//---------------------------------------------------------------------
 	//---------------------------------------------------------------------
 	GpuBufferPtr GLHardwareBufferManager::createGpuBufferImpl(UINT32 elementCount, UINT32 elementSize, 
 	GpuBufferPtr GLHardwareBufferManager::createGpuBufferImpl(UINT32 elementCount, UINT32 elementSize, 
 		GpuBufferType type, GpuBufferUsage usage, bool randomGpuWrite, bool useCounter)
 		GpuBufferType type, GpuBufferUsage usage, bool randomGpuWrite, bool useCounter)
 	{
 	{
-		return GpuBufferPtr(CM_NEW(GLGpuBuffer, PoolAlloc) GLGpuBuffer(elementCount, elementSize, type, usage, randomGpuWrite, useCounter), 
-			&CoreObject::_deleteDelayed<GLGpuBuffer, PoolAlloc>);
+		return cm_core_ptr<GLGpuBuffer, PoolAlloc>(new (cm_alloc<GLGpuBuffer, PoolAlloc>()) GLGpuBuffer(elementCount, elementSize, type, usage, randomGpuWrite, useCounter));
 	}
 	}
     //---------------------------------------------------------------------
     //---------------------------------------------------------------------
     GLenum GLHardwareBufferManager::getGLUsage(unsigned int usage)
     GLenum GLHardwareBufferManager::getGLUsage(unsigned int usage)

+ 1 - 1
CamelotGLRenderer/Source/CmGLMultiRenderTexture.cpp

@@ -61,7 +61,7 @@ namespace CamelotFramework
 	void GLMultiRenderTexture::destroy_internal()
 	void GLMultiRenderTexture::destroy_internal()
 	{
 	{
 		if(mFB != nullptr)
 		if(mFB != nullptr)
-			CM_DELETE(mFB, GLFrameBufferObject, GenAlloc);
+			cm_delete(mFB);
 
 
 		MultiRenderTexture::destroy_internal();
 		MultiRenderTexture::destroy_internal();
 	}
 	}

+ 4 - 4
CamelotGLRenderer/Source/CmGLRenderSystem.cpp

@@ -195,7 +195,7 @@ namespace CamelotFramework
 		{
 		{
 			// Remove from manager safely
 			// Remove from manager safely
 			HighLevelGpuProgramManager::instance().removeFactory(mGLSLProgramFactory);
 			HighLevelGpuProgramManager::instance().removeFactory(mGLSLProgramFactory);
-			CM_DELETE(mGLSLProgramFactory, GLSLProgramFactory, GenAlloc);
+			cm_delete(mGLSLProgramFactory);
 			mGLSLProgramFactory = nullptr;
 			mGLSLProgramFactory = nullptr;
 		}
 		}
 
 
@@ -204,7 +204,7 @@ namespace CamelotFramework
 		{
 		{
 			// Remove from manager safely
 			// Remove from manager safely
 			HighLevelGpuProgramManager::instance().removeFactory(mCgProgramFactory);
 			HighLevelGpuProgramManager::instance().removeFactory(mCgProgramFactory);
-			CM_DELETE(mCgProgramFactory, CgProgramFactory, GenAlloc);
+			cm_delete(mCgProgramFactory);
 			mCgProgramFactory = nullptr;
 			mCgProgramFactory = nullptr;
 		}
 		}
 
 
@@ -235,10 +235,10 @@ namespace CamelotFramework
 		mGLInitialised = 0;
 		mGLInitialised = 0;
 
 
 		if(mProgramPipelineManager != nullptr)
 		if(mProgramPipelineManager != nullptr)
-			CM_DELETE(mProgramPipelineManager, GLSLProgramPipelineManager, GenAlloc);
+			cm_delete(mProgramPipelineManager);
 
 
 		if(mGLSupport)
 		if(mGLSupport)
-			CM_DELETE(mGLSupport, GLSupport, GenAlloc);
+			cm_delete(mGLSupport);
 
 
 		if(mTextureTypes != nullptr)
 		if(mTextureTypes != nullptr)
 			cm_deleteN(mTextureTypes, mNumTextureTypes);
 			cm_deleteN(mTextureTypes, mNumTextureTypes);

+ 2 - 2
CamelotGLRenderer/Source/CmGLTexture.cpp

@@ -287,9 +287,9 @@ namespace CamelotFramework {
 		{
 		{
 			for(UINT32 mip=0; mip<=getNumMipmaps(); mip++)
 			for(UINT32 mip=0; mip<=getNumMipmaps(); mip++)
 			{
 			{
-                GLPixelBuffer *buf = CM_NEW(GLTextureBuffer, PoolAlloc) GLTextureBuffer("", getGLTextureTarget(), mTextureID, face, mip,
+                GLPixelBuffer *buf = cm_new<GLTextureBuffer, PoolAlloc>("", getGLTextureTarget(), mTextureID, face, mip,
 						static_cast<GpuBufferUsage>(mUsage), false, mHwGamma, mFSAA);
 						static_cast<GpuBufferUsage>(mUsage), false, mHwGamma, mFSAA);
-				mSurfaceList.push_back(PixelBufferPtr(buf, &MemAllocDeleter<GLPixelBuffer, PoolAlloc>::deleter));
+				mSurfaceList.push_back(cm_shared_ptr<GLPixelBuffer, PoolAlloc>(buf));
                 
                 
                 /// Check for error
                 /// Check for error
                 if(buf->getWidth()==0 || buf->getHeight()==0 || buf->getDepth()==0)
                 if(buf->getWidth()==0 || buf->getHeight()==0 || buf->getDepth()==0)

+ 6 - 6
CamelotGLRenderer/Source/CmGLTextureManager.cpp

@@ -46,23 +46,23 @@ namespace CamelotFramework
 
 
     TexturePtr GLTextureManager::createTextureImpl()
     TexturePtr GLTextureManager::createTextureImpl()
     {
     {
-        GLTexture* tex = CM_NEW(GLTexture, PoolAlloc) GLTexture(mGLSupport);
+        GLTexture* tex = new (cm_alloc<GLTexture, PoolAlloc>()) GLTexture(mGLSupport);
 
 
-		return TexturePtr(tex, &CoreObject::_deleteDelayed<GLTexture, PoolAlloc>);
+		return cm_core_ptr<GLTexture, PoolAlloc>(tex);
     }
     }
 
 
 	RenderTexturePtr GLTextureManager::createRenderTextureImpl()
 	RenderTexturePtr GLTextureManager::createRenderTextureImpl()
 	{
 	{
-		GLRenderTexture* tex = CM_NEW(GLRenderTexture, PoolAlloc) GLRenderTexture();
+		GLRenderTexture* tex = new (cm_alloc<GLRenderTexture, PoolAlloc>()) GLRenderTexture();
 
 
-		return RenderTexturePtr(tex, &CoreObject::_deleteDelayed<GLRenderTexture, PoolAlloc>);
+		return cm_core_ptr<GLRenderTexture, PoolAlloc>(tex);
 	}
 	}
 
 
 	MultiRenderTexturePtr GLTextureManager::createMultiRenderTextureImpl()
 	MultiRenderTexturePtr GLTextureManager::createMultiRenderTextureImpl()
 	{
 	{
-		GLMultiRenderTexture* tex = CM_NEW(GLMultiRenderTexture, PoolAlloc) GLMultiRenderTexture();
+		GLMultiRenderTexture* tex = new (cm_alloc<GLMultiRenderTexture, PoolAlloc>()) GLMultiRenderTexture();
 
 
-		return MultiRenderTexturePtr(tex, &CoreObject::_deleteDelayed<GLMultiRenderTexture, PoolAlloc>);
+		return cm_core_ptr<GLMultiRenderTexture, PoolAlloc>(tex);
 	}
 	}
 
 
 	PixelFormat GLTextureManager::getNativeFormat(TextureType ttype, PixelFormat format, int usage)
 	PixelFormat GLTextureManager::getNativeFormat(TextureType ttype, PixelFormat format, int usage)

+ 1 - 1
CamelotGLRenderer/Source/CmWin32Window.cpp

@@ -376,7 +376,7 @@ namespace CamelotFramework {
 			return;
 			return;
 
 
 		// Unregister and destroy GLContext
 		// Unregister and destroy GLContext
-		CM_DELETE(mContext, Win32Context, GenAlloc);
+		cm_delete(mContext);
 
 
 		if (!mIsExternalGLContext && mGlrc)
 		if (!mIsExternalGLContext && mGlrc)
 		{
 		{

+ 4 - 4
CamelotGLRenderer/Source/GLSL/src/CmGLSLPreprocessor.cpp

@@ -246,7 +246,7 @@ CPreprocessor::ErrorHandlerFunc CPreprocessor::ErrorHandler = DefaultError;
 CPreprocessor::Macro::~Macro()
 CPreprocessor::Macro::~Macro()
 { 
 { 
 	cm_deleteN<ScratchAlloc>(Args, NumArgs);
 	cm_deleteN<ScratchAlloc>(Args, NumArgs);
-	CM_DELETE(Next, Macro, ScratchAlloc); 
+	cm_delete<ScratchAlloc>(Next); 
 }
 }
 
 
 CPreprocessor::CPreprocessor (const Token &iToken, int iLine) : MacroList (NULL)
 CPreprocessor::CPreprocessor (const Token &iToken, int iLine) : MacroList (NULL)
@@ -261,7 +261,7 @@ CPreprocessor::CPreprocessor (const Token &iToken, int iLine) : MacroList (NULL)
 CPreprocessor::~CPreprocessor ()
 CPreprocessor::~CPreprocessor ()
 {
 {
 	if(MacroList != nullptr)
 	if(MacroList != nullptr)
-		CM_DELETE(MacroList, Macro, ScratchAlloc);
+		cm_delete<ScratchAlloc>(MacroList);
 }
 }
 
 
 void CPreprocessor::Error (int iLine, const char *iError, const Token *iToken)
 void CPreprocessor::Error (int iLine, const char *iError, const Token *iToken)
@@ -900,7 +900,7 @@ bool CPreprocessor::HandleDefine (Token &iBody, int iLine)
             break;
             break;
 
 
         case Token::TK_ERROR:
         case Token::TK_ERROR:
-            CM_DELETE(m, Macro, ScratchAlloc);
+            cm_delete<ScratchAlloc>(m);
             return false;
             return false;
 
 
         default:
         default:
@@ -1178,7 +1178,7 @@ bool CPreprocessor::Undef (const char *iMacroName, size_t iMacroNameLen)
         {
         {
             Macro *next = (*cur)->Next;
             Macro *next = (*cur)->Next;
             (*cur)->Next = NULL;
             (*cur)->Next = NULL;
-            CM_DELETE((*cur), Macro, ScratchAlloc);
+            cm_delete<ScratchAlloc>(*cur);
             *cur = next;
             *cur = next;
             return true;
             return true;
         }
         }

+ 1 - 1
CamelotOISInput/Source/CmOISPlugin.cpp

@@ -16,7 +16,7 @@ namespace CamelotFramework
 		// TODO - Window handles in Windows are 64 bits when compiled as x64, but OIS only accepts a 32bit value. Is this okay?
 		// TODO - Window handles in Windows are 64 bits when compiled as x64, but OIS only accepts a 32bit value. Is this okay?
 		UINT32 windowId = (UINT32)gApplication().getAppWindowId();
 		UINT32 windowId = (UINT32)gApplication().getAppWindowId();
 
 
-		InputHandlerPtr inputHandler = InputHandlerPtr(CM_NEW(InputHandlerOIS, GenAlloc) InputHandlerOIS(windowId), &MemAllocDeleter<InputHandlerOIS, GenAlloc>::deleter);
+		InputHandlerPtr inputHandler = cm_shared_ptr<InputHandlerOIS>(windowId);
 
 
 		gInput().registerInputHandler(inputHandler);
 		gInput().registerInputHandler(inputHandler);
 
 

+ 1 - 1
CamelotUtility/Include/CmModule.h

@@ -79,7 +79,7 @@ namespace CamelotFramework
 
 
 			((Module*)_instance)->onShutDown();
 			((Module*)_instance)->onShutDown();
 
 
-			CM_DELETE(_instance, T, GenAlloc);
+			cm_delete(_instance);
 			isShutDown = true;
 			isShutDown = true;
 		}
 		}
 
 

+ 5 - 5
CamelotUtility/Source/CmWorkQueue.cpp

@@ -45,7 +45,7 @@ namespace CamelotFramework {
 
 
 		for (RequestQueue::iterator i = mRequestQueue.begin(); i != mRequestQueue.end(); ++i)
 		for (RequestQueue::iterator i = mRequestQueue.begin(); i != mRequestQueue.end(); ++i)
 		{
 		{
-			CM_DELETE(*i, Request, ScratchAlloc);
+			cm_delete<ScratchAlloc>(*i);
 		}
 		}
 		mRequestQueue.clear();
 		mRequestQueue.clear();
 	}
 	}
@@ -385,13 +385,13 @@ namespace CamelotFramework {
 					addRequestWithRID(req->getID(), req->getChannel(), req->getData(), 
 					addRequestWithRID(req->getID(), req->getChannel(), req->getData(), 
 						req->getRetryCount() - 1);
 						req->getRetryCount() - 1);
 					// discard response (this also deletes request)
 					// discard response (this also deletes request)
-					CM_DELETE(response, Response, ScratchAlloc);
+					cm_delete<ScratchAlloc>(response);
 					return;
 					return;
 				}
 				}
 			}
 			}
 
 
 			processResponse(response);
 			processResponse(response);
-			CM_DELETE(response, Response, ScratchAlloc);
+			cm_delete<ScratchAlloc>(response);
 		}
 		}
 		else
 		else
 		{
 		{
@@ -399,7 +399,7 @@ namespace CamelotFramework {
 			gDebug().logWarning("warning: no handler processed request "
 			gDebug().logWarning("warning: no handler processed request "
 				+ toString(r->getID()) + ", channel " + toString(r->getChannel()));
 				+ toString(r->getID()) + ", channel " + toString(r->getChannel()));
 
 
-			CM_DELETE(r, Request, ScratchAlloc);
+			cm_delete<ScratchAlloc>(r);
 		}
 		}
 
 
 	}
 	}
@@ -533,7 +533,7 @@ namespace CamelotFramework {
 	//---------------------------------------------------------------------
 	//---------------------------------------------------------------------
 	WorkQueue::Response::~Response()
 	WorkQueue::Response::~Response()
 	{
 	{
-		CM_DELETE(mRequest, Request, ScratchAlloc);
+		cm_delete<ScratchAlloc>(mRequest);
 	}
 	}
 	//---------------------------------------------------------------------
 	//---------------------------------------------------------------------
 	void WorkQueue::WorkerFunc::operator()()
 	void WorkQueue::WorkerFunc::operator()()