Browse Source

A bunch more code ported to new alloc system

Marko Pintera 12 years ago
parent
commit
c5f46545e8
58 changed files with 247 additions and 195 deletions
  1. 7 7
      BansheeEngine/Source/BsApplication.cpp
  2. 4 4
      BansheeEngine/Source/BsGUIWindowFrame.cpp
  3. 6 6
      BansheeEngine/Source/BsImageSprite.cpp
  4. 3 3
      BansheeEngine/Source/BsSprite.cpp
  5. 6 6
      BansheeEngine/Source/BsTextSprite.cpp
  6. 2 2
      CamelotClient/CamelotClient.cpp
  7. 32 1
      CamelotCore/Include/CmCoreObject.h
  8. 6 6
      CamelotCore/Source/CmInput.cpp
  9. 2 2
      CamelotCore/Source/CmMeshData.cpp
  10. 3 3
      CamelotD3D11RenderSystem/Source/CmD3D11Driver.cpp
  11. 1 1
      CamelotD3D11RenderSystem/Source/CmD3D11DriverList.cpp
  12. 3 3
      CamelotD3D11RenderSystem/Source/CmD3D11GpuBuffer.cpp
  13. 2 2
      CamelotD3D11RenderSystem/Source/CmD3D11GpuParamBlockBuffer.cpp
  14. 1 1
      CamelotD3D11RenderSystem/Source/CmD3D11HardwareBuffer.cpp
  15. 2 1
      CamelotD3D11RenderSystem/Source/CmD3D11IndexBuffer.cpp
  16. 8 10
      CamelotD3D11RenderSystem/Source/CmD3D11InputLayoutManager.cpp
  17. 16 16
      CamelotD3D11RenderSystem/Source/CmD3D11RenderSystem.cpp
  18. 1 1
      CamelotD3D11RenderSystem/Source/CmD3D11RenderSystemFactory.cpp
  19. 1 1
      CamelotD3D11RenderSystem/Source/CmD3D11Texture.cpp
  20. 4 3
      CamelotD3D11RenderSystem/Source/CmD3D11VertexBuffer.cpp
  21. 3 3
      CamelotD3D11RenderSystem/Source/CmD3D11VideoModeList.cpp
  22. 4 4
      CamelotD3D9Renderer/Source/CmD3D9Device.cpp
  23. 1 1
      CamelotD3D9Renderer/Source/CmD3D9DeviceManager.cpp
  24. 1 1
      CamelotD3D9Renderer/Source/CmD3D9Driver.cpp
  25. 1 1
      CamelotD3D9Renderer/Source/CmD3D9IndexBuffer.cpp
  26. 1 1
      CamelotD3D9Renderer/Source/CmD3D9PixelBuffer.cpp
  27. 17 17
      CamelotD3D9Renderer/Source/CmD3D9RenderSystem.cpp
  28. 1 1
      CamelotD3D9Renderer/Source/CmD3D9RenderSystemFactory.cpp
  29. 1 1
      CamelotD3D9Renderer/Source/CmD3D9RenderWindowManager.cpp
  30. 1 1
      CamelotD3D9Renderer/Source/CmD3D9Texture.cpp
  31. 1 1
      CamelotD3D9Renderer/Source/CmD3D9VertexBuffer.cpp
  32. 2 2
      CamelotD3D9Renderer/Source/CmD3D9VertexDeclaration.cpp
  33. 1 1
      CamelotFBXImporter/Include/CmFBXImporter.h
  34. 1 1
      CamelotFontImporter/Include/CmFontImporter.h
  35. 1 1
      CamelotFreeImgImporter/Include/CmFreeImgImporter.h
  36. 1 1
      CamelotGLRenderer/Source/CmGLContext.cpp
  37. 2 2
      CamelotGLRenderer/Source/CmGLMultiRenderTexture.cpp
  38. 14 13
      CamelotGLRenderer/Source/CmGLRenderSystem.cpp
  39. 1 1
      CamelotGLRenderer/Source/CmGLRenderSystemFactory.cpp
  40. 3 3
      CamelotGLRenderer/Source/CmGLRenderTexture.cpp
  41. 1 1
      CamelotGLRenderer/Source/CmWin32GLSupport.cpp
  42. 1 1
      CamelotGLRenderer/Source/CmWin32Window.cpp
  43. 7 7
      CamelotGLRenderer/Source/GLSL/src/CmGLSLPreprocessor.cpp
  44. 2 2
      CamelotGLRenderer/Source/GLSL/src/CmGLSLProgramFactory.cpp
  45. 1 1
      CamelotGLRenderer/Source/win32/CmGLUtil.h
  46. 1 1
      CamelotGLRenderer/Source/win32/CmWin32Context.cpp
  47. 10 6
      CamelotUtility/Include/CmMemoryAllocator.h
  48. 7 7
      CamelotUtility/Include/CmRTTIType.h
  49. 20 7
      CamelotUtility/Include/CmStdHeaders.h
  50. 2 2
      CamelotUtility/Source/CmDebug.cpp
  51. 3 3
      CamelotUtility/Source/CmDynLibManager.cpp
  52. 2 2
      CamelotUtility/Source/CmFileSystem.cpp
  53. 3 3
      CamelotUtility/Source/CmLog.cpp
  54. 1 1
      CamelotUtility/Source/CmRTTIType.cpp
  55. 2 2
      CamelotUtility/Source/CmTexAtlasGenerator.cpp
  56. 2 2
      CamelotUtility/Source/CmTime.cpp
  57. 4 4
      CamelotUtility/Source/CmWorkQueue.cpp
  58. 10 7
      TODO.txt

+ 7 - 7
BansheeEngine/Source/BsApplication.cpp

@@ -32,16 +32,16 @@ namespace BansheeEngine
 		desc.importers.push_back("CamelotFBXImporter");
 		desc.importers.push_back("CamelotFBXImporter");
 		desc.importers.push_back("CamelotFontImporter");
 		desc.importers.push_back("CamelotFontImporter");
 
 
-		GUIManager::startUp(CM_NEW(GUIManager, GenAlloc) GUIManager());
-		GUIMaterialManager::startUp(CM_NEW(GUIMaterialManager, GenAlloc) GUIMaterialManager());
-		OverlayManager::startUp(CM_NEW(OverlayManager, GenAlloc) OverlayManager());
+		GUIManager::startUp(cm_new<GUIManager>());
+		GUIMaterialManager::startUp(cm_new<GUIMaterialManager>());
+		OverlayManager::startUp(cm_new<OverlayManager>());
 
 
 		CM::gApplication().startUp(desc);
 		CM::gApplication().startUp(desc);
 
 
-		BuiltinMaterialManager::startUp(CM_NEW(BuiltinMaterialManager, GenAlloc) BuiltinMaterialManager());
-		BuiltinMaterialManager::instance().addFactory(CM_NEW(D3D9BuiltinMaterialFactory, GenAlloc) D3D9BuiltinMaterialFactory());
-		BuiltinMaterialManager::instance().addFactory(CM_NEW(D3D11BuiltinMaterialFactory, GenAlloc) D3D11BuiltinMaterialFactory());
-		BuiltinMaterialManager::instance().addFactory(CM_NEW(GLBuiltinMaterialFactory, GenAlloc) GLBuiltinMaterialFactory());
+		BuiltinMaterialManager::startUp(cm_new<BuiltinMaterialManager>());
+		BuiltinMaterialManager::instance().addFactory(cm_new<D3D9BuiltinMaterialFactory>());
+		BuiltinMaterialManager::instance().addFactory(cm_new<D3D11BuiltinMaterialFactory>());
+		BuiltinMaterialManager::instance().addFactory(cm_new<GLBuiltinMaterialFactory>());
 		BuiltinMaterialManager::instance().setActive(desc.renderSystem);
 		BuiltinMaterialManager::instance().setActive(desc.renderSystem);
 
 
 		EngineGUI::startUp(new EngineGUI());
 		EngineGUI::startUp(new EngineGUI());

+ 4 - 4
BansheeEngine/Source/BsGUIWindowFrame.cpp

@@ -19,7 +19,7 @@ namespace BansheeEngine
 	GUIWindowFrame::GUIWindowFrame(GUIWidget& parent, const GUIElementStyle* style, const GUILayoutOptions& layoutOptions)
 	GUIWindowFrame::GUIWindowFrame(GUIWidget& parent, const GUIElementStyle* style, const GUILayoutOptions& layoutOptions)
 		:GUIElement(parent, style, layoutOptions)
 		:GUIElement(parent, style, layoutOptions)
 	{
 	{
-		mImageSprite = CM_NEW(ImageSprite, PoolAlloc) ImageSprite();
+		mImageSprite = cm_new<ImageSprite, PoolAlloc>();
 
 
 		mDesc.texture = mStyle->normal.texture;
 		mDesc.texture = mStyle->normal.texture;
 
 
@@ -37,7 +37,7 @@ namespace BansheeEngine
 
 
 	GUIWindowFrame::~GUIWindowFrame()
 	GUIWindowFrame::~GUIWindowFrame()
 	{
 	{
-		CM_DELETE(mImageSprite, ImageSprite, PoolAlloc);
+		cm_delete<PoolAlloc>(mImageSprite);
 	}
 	}
 
 
 	GUIWindowFrame* GUIWindowFrame::create(GUIWidget& parent, const GUIElementStyle* style)
 	GUIWindowFrame* GUIWindowFrame::create(GUIWidget& parent, const GUIElementStyle* style)
@@ -48,7 +48,7 @@ namespace BansheeEngine
 			style = skin->getStyle(getGUITypeName());
 			style = skin->getStyle(getGUITypeName());
 		}
 		}
 
 
-		return CM_NEW(GUIWindowFrame, PoolAlloc) GUIWindowFrame(parent, style, getDefaultLayoutOptions(style));
+		return new (cm_alloc<GUIWindowFrame, PoolAlloc>()) GUIWindowFrame(parent, style, getDefaultLayoutOptions(style));
 	}
 	}
 
 
 	GUIWindowFrame* GUIWindowFrame::create(GUIWidget& parent, const GUILayoutOptions& layoutOptions, const GUIElementStyle* style)
 	GUIWindowFrame* GUIWindowFrame::create(GUIWidget& parent, const GUILayoutOptions& layoutOptions, const GUIElementStyle* style)
@@ -59,7 +59,7 @@ namespace BansheeEngine
 			style = skin->getStyle(getGUITypeName());
 			style = skin->getStyle(getGUITypeName());
 		}
 		}
 
 
-		return CM_NEW(GUIWindowFrame, PoolAlloc) GUIWindowFrame(parent, style, layoutOptions);
+		return new (cm_alloc<GUIWindowFrame, PoolAlloc>()) GUIWindowFrame(parent, style, layoutOptions);
 	}
 	}
 
 
 	UINT32 GUIWindowFrame::getNumRenderElements() const
 	UINT32 GUIWindowFrame::getNumRenderElements() const

+ 6 - 6
BansheeEngine/Source/BsImageSprite.cpp

@@ -42,13 +42,13 @@ namespace BansheeEngine
 				UINT32 oldVertexCount = renderElem.numQuads * 4;
 				UINT32 oldVertexCount = renderElem.numQuads * 4;
 				UINT32 oldIndexCount = renderElem.numQuads * 6;
 				UINT32 oldIndexCount = renderElem.numQuads * 6;
 
 
-				if(renderElem.vertices != nullptr) CM_DELETE_ARRAY(renderElem.vertices, Vector2, oldVertexCount, ScratchAlloc);
-				if(renderElem.uvs != nullptr) CM_DELETE_ARRAY(renderElem.uvs, Vector2, oldVertexCount, ScratchAlloc);
-				if(renderElem.indexes != nullptr) CM_DELETE_ARRAY(renderElem.indexes, UINT32, oldIndexCount, ScratchAlloc);
+				if(renderElem.vertices != nullptr) cm_deleteN<ScratchAlloc>(renderElem.vertices, oldVertexCount);
+				if(renderElem.uvs != nullptr) cm_deleteN<ScratchAlloc>(renderElem.uvs, oldVertexCount);
+				if(renderElem.indexes != nullptr) cm_deleteN<ScratchAlloc>(renderElem.indexes, oldIndexCount);
 
 
-				renderElem.vertices = CM_NEW_ARRAY(Vector2, newNumQuads * 4, ScratchAlloc);
-				renderElem.uvs = CM_NEW_ARRAY(Vector2, newNumQuads * 4, ScratchAlloc);
-				renderElem.indexes = CM_NEW_ARRAY(UINT32, newNumQuads * 6, ScratchAlloc);
+				renderElem.vertices = cm_newN<Vector2, ScratchAlloc>(newNumQuads * 4);
+				renderElem.uvs = cm_newN<Vector2, ScratchAlloc>(newNumQuads * 4);
+				renderElem.indexes = cm_newN<UINT32, ScratchAlloc>(newNumQuads * 6);
 				renderElem.numQuads = newNumQuads;
 				renderElem.numQuads = newNumQuads;
 			}
 			}
 
 

+ 3 - 3
BansheeEngine/Source/BsSprite.cpp

@@ -132,13 +132,13 @@ namespace BansheeEngine
 			UINT32 indexCount = renderElem.numQuads * 6;
 			UINT32 indexCount = renderElem.numQuads * 6;
 
 
 			if(renderElem.vertices != nullptr)
 			if(renderElem.vertices != nullptr)
-				CM_DELETE_ARRAY(renderElem.vertices, Vector2, vertexCount, ScratchAlloc);
+				cm_deleteN<ScratchAlloc>(renderElem.vertices, vertexCount);
 
 
 			if(renderElem.uvs != nullptr)
 			if(renderElem.uvs != nullptr)
-				CM_DELETE_ARRAY(renderElem.uvs, Vector2, vertexCount, ScratchAlloc);
+				cm_deleteN<ScratchAlloc>(renderElem.uvs, vertexCount);
 
 
 			if(renderElem.indexes != nullptr)
 			if(renderElem.indexes != nullptr)
-				CM_DELETE_ARRAY(renderElem.indexes, UINT32, indexCount, ScratchAlloc);
+				cm_deleteN<ScratchAlloc>(renderElem.indexes, indexCount);
 
 
 			if(renderElem.material != nullptr)
 			if(renderElem.material != nullptr)
 			{
 			{

+ 6 - 6
BansheeEngine/Source/BsTextSprite.cpp

@@ -59,13 +59,13 @@ namespace BansheeEngine
 				UINT32 oldVertexCount = cachedElem.numQuads * 4;
 				UINT32 oldVertexCount = cachedElem.numQuads * 4;
 				UINT32 oldIndexCount = cachedElem.numQuads * 6;
 				UINT32 oldIndexCount = cachedElem.numQuads * 6;
 
 
-				if(cachedElem.vertices != nullptr) CM_DELETE_ARRAY(cachedElem.vertices, Vector2, oldVertexCount, ScratchAlloc);
-				if(cachedElem.uvs != nullptr) CM_DELETE_ARRAY(cachedElem.uvs, Vector2, oldVertexCount, ScratchAlloc);
-				if(cachedElem.indexes != nullptr) CM_DELETE_ARRAY(cachedElem.indexes, UINT32, oldIndexCount, ScratchAlloc);
+				if(cachedElem.vertices != nullptr) cm_deleteN<ScratchAlloc>(cachedElem.vertices, oldVertexCount);
+				if(cachedElem.uvs != nullptr) cm_deleteN<ScratchAlloc>(cachedElem.uvs, oldVertexCount);
+				if(cachedElem.indexes != nullptr) cm_deleteN<ScratchAlloc>(cachedElem.indexes, oldIndexCount);
 
 
-				cachedElem.vertices = CM_NEW_ARRAY(Vector2, newNumQuads * 4, ScratchAlloc);
-				cachedElem.uvs = CM_NEW_ARRAY(Vector2, newNumQuads * 4, ScratchAlloc);
-				cachedElem.indexes = CM_NEW_ARRAY(UINT32, newNumQuads * 6, ScratchAlloc);
+				cachedElem.vertices = cm_newN<Vector2, ScratchAlloc>(newNumQuads * 4);
+				cachedElem.uvs = cm_newN<Vector2, ScratchAlloc>(newNumQuads * 4);
+				cachedElem.indexes = cm_newN<UINT32, ScratchAlloc>(newNumQuads * 6);
 				cachedElem.numQuads = newNumQuads;
 				cachedElem.numQuads = newNumQuads;
 			}
 			}
 
 

+ 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;

+ 32 - 1
CamelotCore/Include/CmCoreObject.h

@@ -2,7 +2,8 @@
 
 
 #include "CmPrerequisites.h"
 #include "CmPrerequisites.h"
 #include "CmAsyncOp.h"
 #include "CmAsyncOp.h"
-#include "boost/function.hpp"
+#include <boost/function.hpp>
+#include <boost/preprocessor.hpp>
 
 
 namespace CamelotFramework
 namespace CamelotFramework
 {
 {
@@ -156,4 +157,34 @@ o		 *
 		static void executeGpuCommand(std::shared_ptr<CoreObject>& obj, boost::function<void()> func);
 		static void executeGpuCommand(std::shared_ptr<CoreObject>& obj, boost::function<void()> func);
 		static void executeReturnGpuCommand(std::shared_ptr<CoreObject>& obj, boost::function<void(AsyncOp&)> func, AsyncOp& op); 
 		static void executeReturnGpuCommand(std::shared_ptr<CoreObject>& obj, boost::function<void(AsyncOp&)> func, AsyncOp& op); 
 	};
 	};
+
+#define MAKE_CM_NEW_CORE(z, n, unused)                                     \
+	template<class Type, class MainAlloc, class PtrDataAlloc BOOST_PP_ENUM_TRAILING_PARAMS(n, class T)>     \
+	std::shared_ptr<Type> cm_new_core(BOOST_PP_ENUM_BINARY_PARAMS(n, T, t) ) { \
+	return std::shared_ptr<Type, void(CoreObject*), StdAlloc<PtrDataAlloc>>(cm_new<Type, MainAlloc>(BOOST_PP_ENUM_PARAMS (n, t)), &CoreObject::_deleteDelayed<Type, MainAlloc>, StdAlloc<PtrDataAlloc>());     \
+	}
+
+	BOOST_PP_REPEAT(9, MAKE_CM_NEW_CORE, ~)
+
+#undef MAKE_CM_NEW_CORE
+
+#define MAKE_CM_NEW_CORE(z, n, unused)                                     \
+	template<class Type, class MainAlloc BOOST_PP_ENUM_TRAILING_PARAMS(n, class T)>     \
+	std::shared_ptr<Type> cm_new_core(BOOST_PP_ENUM_BINARY_PARAMS(n, T, t) ) { \
+	return std::shared_ptr<Type, void(CoreObject*), StdAlloc<GenAlloc>>(cm_new<Type, MainAlloc>(BOOST_PP_ENUM_PARAMS (n, t)), &CoreObject::_deleteDelayed<Type, MainAlloc>, StdAlloc<GenAlloc>());     \
+	}
+
+	BOOST_PP_REPEAT(9, MAKE_CM_NEW_CORE, ~)
+
+#undef MAKE_CM_NEW_CORE
+
+#define MAKE_CM_NEW_CORE(z, n, unused)                                     \
+	template<class Type BOOST_PP_ENUM_TRAILING_PARAMS(n, class T)>     \
+	std::shared_ptr<Type> cm_new_core(BOOST_PP_ENUM_BINARY_PARAMS(n, T, t) ) { \
+	return std::shared_ptr<Type, void(CoreObject*), StdAlloc<GenAlloc>>(cm_new<Type, GenAlloc>(BOOST_PP_ENUM_PARAMS (n, t)), &CoreObject::_deleteDelayed<Type, GenAlloc>, StdAlloc<GenAlloc>());     \
+	}
+
+	BOOST_PP_REPEAT(9, MAKE_CM_NEW_CORE, ~)
+
+#undef MAKE_CM_NEW_CORE
 }
 }

+ 6 - 6
CamelotCore/Source/CmInput.cpp

@@ -15,9 +15,9 @@ namespace CamelotFramework
 		:mSmoothHorizontalAxis(0.0f), mSmoothVerticalAxis(0.0f), mCurrentBufferIdx(0), mMouseLastRel(0, 0),
 		:mSmoothHorizontalAxis(0.0f), mSmoothVerticalAxis(0.0f), mCurrentBufferIdx(0), mMouseLastRel(0, 0),
 		mUsingClipRect(false), mClipRect(0, 0, 0, 0), mInputHandler(nullptr)
 		mUsingClipRect(false), mClipRect(0, 0, 0, 0), mInputHandler(nullptr)
 	{ 
 	{ 
-		mHorizontalHistoryBuffer = CM_NEW_ARRAY(float, HISTORY_BUFFER_SIZE, GenAlloc);
-		mVerticalHistoryBuffer = CM_NEW_ARRAY(float, HISTORY_BUFFER_SIZE, GenAlloc);
-		mTimesHistoryBuffer = CM_NEW_ARRAY(float, HISTORY_BUFFER_SIZE, GenAlloc);
+		mHorizontalHistoryBuffer = cm_newN<float>(HISTORY_BUFFER_SIZE);
+		mVerticalHistoryBuffer = cm_newN<float>(HISTORY_BUFFER_SIZE);
+		mTimesHistoryBuffer = cm_newN<float>(HISTORY_BUFFER_SIZE);
 
 
 		for(int i = 0; i < HISTORY_BUFFER_SIZE; i++)
 		for(int i = 0; i < HISTORY_BUFFER_SIZE; i++)
 		{
 		{
@@ -35,9 +35,9 @@ namespace CamelotFramework
 
 
 	Input::~Input()
 	Input::~Input()
 	{
 	{
-		CM_DELETE_ARRAY(mHorizontalHistoryBuffer, float, HISTORY_BUFFER_SIZE, GenAlloc);
-		CM_DELETE_ARRAY(mVerticalHistoryBuffer, float, HISTORY_BUFFER_SIZE, GenAlloc);
-		CM_DELETE_ARRAY(mTimesHistoryBuffer, float, HISTORY_BUFFER_SIZE, GenAlloc);
+		cm_deleteN(mHorizontalHistoryBuffer, HISTORY_BUFFER_SIZE);
+		cm_deleteN(mVerticalHistoryBuffer, HISTORY_BUFFER_SIZE);
+		cm_deleteN(mTimesHistoryBuffer, HISTORY_BUFFER_SIZE);
 	}
 	}
 
 
 	void Input::initClipRect(Rect& clipRect)
 	void Input::initClipRect(Rect& clipRect)

+ 2 - 2
CamelotCore/Source/CmMeshData.cpp

@@ -90,7 +90,7 @@ namespace CamelotFramework
 		UINT32 maxStreamIdx = getMaxStreamIdx();
 		UINT32 maxStreamIdx = getMaxStreamIdx();
 
 
 		UINT32 numStreams = maxStreamIdx + 1;
 		UINT32 numStreams = maxStreamIdx + 1;
-		UINT32* streamOffsets = CM_NEW_ARRAY(UINT32, numStreams, ScratchAlloc);
+		UINT32* streamOffsets = cm_newN<UINT32, ScratchAlloc>(numStreams);
 		for(UINT32 i = 0; i < numStreams; i++)
 		for(UINT32 i = 0; i < numStreams; i++)
 			streamOffsets[i] = 0;
 			streamOffsets[i] = 0;
 
 
@@ -101,7 +101,7 @@ namespace CamelotFramework
 			streamOffsets[streamIdx] += vertElem.getSize();
 			streamOffsets[streamIdx] += vertElem.getSize();
 		}
 		}
 
 
-		CM_DELETE_ARRAY(streamOffsets, UINT32, numStreams,ScratchAlloc);
+		cm_deleteN<ScratchAlloc>(streamOffsets, numStreams);
 
 
 		return declaration;
 		return declaration;
 	}
 	}

+ 3 - 3
CamelotD3D11RenderSystem/Source/CmD3D11Driver.cpp

@@ -42,7 +42,7 @@ namespace CamelotFramework
 		}
 		}
 
 
 		if(mVideoModeList != nullptr)
 		if(mVideoModeList != nullptr)
-			CM_DELETE_ARRAY(mVideoModeList, D3D11VideoModeList*, mNumOutputs, GenAlloc);
+			cm_deleteN(mVideoModeList, mNumOutputs);
 
 
 		SAFE_RELEASE(mDXGIAdapter);
 		SAFE_RELEASE(mDXGIAdapter);
 	}
 	}
@@ -61,9 +61,9 @@ namespace CamelotFramework
 
 
 		mNumOutputs = outputIdx;
 		mNumOutputs = outputIdx;
 
 
-		mVideoModeList = CM_NEW_ARRAY(D3D11VideoModeList*, mNumOutputs, GenAlloc);
+		mVideoModeList = cm_newN<D3D11VideoModeList*>(mNumOutputs);
 		for(UINT32 i = 0; i < mNumOutputs; i++)
 		for(UINT32 i = 0; i < mNumOutputs; i++)
-			mVideoModeList[i] = CM_NEW(D3D11VideoModeList, GenAlloc) D3D11VideoModeList(this, i);
+			mVideoModeList[i] = cm_new<D3D11VideoModeList>(this, i);
 	}
 	}
 
 
 	D3D11Driver& D3D11Driver::operator=(const D3D11Driver& ob)
 	D3D11Driver& D3D11Driver::operator=(const D3D11Driver& ob)

+ 1 - 1
CamelotD3D11RenderSystem/Source/CmD3D11DriverList.cpp

@@ -33,7 +33,7 @@ namespace CamelotFramework
 				CM_EXCEPT(InternalErrorException, "Enumerating adapters failed.");
 				CM_EXCEPT(InternalErrorException, "Enumerating adapters failed.");
 			}
 			}
 
 
-			mDriverList.push_back(CM_NEW(D3D11Driver, GenAlloc) D3D11Driver(adapterIdx, dxgiAdapter));
+			mDriverList.push_back(cm_new<D3D11Driver>(adapterIdx, dxgiAdapter));
 
 
 			SAFE_RELEASE(dxgiAdapter);
 			SAFE_RELEASE(dxgiAdapter);
 			adapterIdx++;
 			adapterIdx++;

+ 3 - 3
CamelotD3D11RenderSystem/Source/CmD3D11GpuBuffer.cpp

@@ -39,7 +39,7 @@ namespace CamelotFramework
 			CM_EXCEPT(InvalidParametersException, "Unsupported buffer type " + toString(mType));
 			CM_EXCEPT(InvalidParametersException, "Unsupported buffer type " + toString(mType));
 		}
 		}
 
 
-		mBuffer = CM_NEW(D3D11HardwareBuffer, PoolAlloc) D3D11HardwareBuffer(bufferType, mUsage, mElementCount, mElementSize, 
+		mBuffer = cm_new<D3D11HardwareBuffer, PoolAlloc>(bufferType, mUsage, mElementCount, mElementSize, 
 			d3d11rs->getPrimaryDevice(), false, false, mRandomGpuWrite, mUseCounter);
 			d3d11rs->getPrimaryDevice(), false, false, mRandomGpuWrite, mUseCounter);
 
 
 		GpuBuffer::initialize_internal();
 		GpuBuffer::initialize_internal();
@@ -87,12 +87,12 @@ namespace CamelotFramework
 
 
 	GpuBufferView* D3D11GpuBuffer::createView()
 	GpuBufferView* D3D11GpuBuffer::createView()
 	{
 	{
-		return CM_NEW(D3D11GpuBufferView, PoolAlloc) D3D11GpuBufferView();
+		return cm_new<D3D11GpuBufferView, PoolAlloc>();
 	}
 	}
 
 
 	void D3D11GpuBuffer::destroyView(GpuBufferView* view)
 	void D3D11GpuBuffer::destroyView(GpuBufferView* view)
 	{
 	{
 		if(view != nullptr)
 		if(view != nullptr)
-			CM_DELETE(view, GpuBufferView, PoolAlloc);
+			cm_delete<PoolAlloc>(view);
 	}
 	}
 }
 }

+ 2 - 2
CamelotD3D11RenderSystem/Source/CmD3D11GpuParamBlockBuffer.cpp

@@ -17,9 +17,9 @@ namespace CamelotFramework
 		D3D11Device& device = d3d11rs->getPrimaryDevice();
 		D3D11Device& device = d3d11rs->getPrimaryDevice();
 
 
 		if(mUsage == GPBU_STATIC)
 		if(mUsage == GPBU_STATIC)
-			mBuffer = CM_NEW(D3D11HardwareBuffer, PoolAlloc) D3D11HardwareBuffer(D3D11HardwareBuffer::BT_CONSTANT, GBU_STATIC, 1, mSize, device);
+			mBuffer = cm_new<D3D11HardwareBuffer, PoolAlloc>(D3D11HardwareBuffer::BT_CONSTANT, GBU_STATIC, 1, mSize, std::ref(device));
 		else if(mUsage == GPBU_DYNAMIC)
 		else if(mUsage == GPBU_DYNAMIC)
-			mBuffer = CM_NEW(D3D11HardwareBuffer, PoolAlloc) D3D11HardwareBuffer(D3D11HardwareBuffer::BT_CONSTANT, GBU_DYNAMIC, 1, mSize, device);
+			mBuffer = cm_new<D3D11HardwareBuffer, PoolAlloc>(D3D11HardwareBuffer::BT_CONSTANT, GBU_DYNAMIC, 1, mSize, std::ref(device));
 		else
 		else
 			CM_EXCEPT(InternalErrorException, "Invalid gpu param block usage.");
 			CM_EXCEPT(InternalErrorException, "Invalid gpu param block usage.");
 
 

+ 1 - 1
CamelotD3D11RenderSystem/Source/CmD3D11HardwareBuffer.cpp

@@ -188,7 +188,7 @@ namespace CamelotFramework
 			if (!mpTempStagingBuffer)
 			if (!mpTempStagingBuffer)
 			{
 			{
 				// create another buffer instance but use system memory
 				// create another buffer instance but use system memory
-				mpTempStagingBuffer = CM_NEW(D3D11HardwareBuffer, PoolAlloc) D3D11HardwareBuffer(mBufferType, mUsage, 1, mSizeInBytes, mDevice, true);
+				mpTempStagingBuffer = cm_new<D3D11HardwareBuffer, PoolAlloc>(mBufferType, mUsage, 1, mSizeInBytes, std::ref(mDevice), true);
 			}
 			}
 
 
 			// schedule a copy to the staging
 			// schedule a copy to the staging

+ 2 - 1
CamelotD3D11RenderSystem/Source/CmD3D11IndexBuffer.cpp

@@ -1,4 +1,5 @@
 #include "CmD3D11IndexBuffer.h"
 #include "CmD3D11IndexBuffer.h"
+#include "CmD3D11Device.h"
 
 
 namespace CamelotFramework
 namespace CamelotFramework
 {
 {
@@ -16,7 +17,7 @@ namespace CamelotFramework
 
 
 	void D3D11IndexBuffer::initialize_internal()
 	void D3D11IndexBuffer::initialize_internal()
 	{
 	{
-		mBuffer = CM_NEW(D3D11HardwareBuffer, PoolAlloc) D3D11HardwareBuffer(D3D11HardwareBuffer::BT_INDEX, mUsage, 1, mSizeInBytes, mDevice, mSystemMemory);
+		mBuffer = cm_new<D3D11HardwareBuffer, PoolAlloc>(D3D11HardwareBuffer::BT_INDEX, mUsage, 1, mSizeInBytes, std::ref(mDevice), mSystemMemory);
 
 
 		IndexBuffer::initialize_internal();
 		IndexBuffer::initialize_internal();
 	}
 	}

+ 8 - 10
CamelotD3D11RenderSystem/Source/CmD3D11InputLayoutManager.cpp

@@ -7,8 +7,6 @@
 #include "CmDebug.h"
 #include "CmDebug.h"
 #include "CmUtil.h"
 #include "CmUtil.h"
 
 
-#include "boost/preprocessor/comma.hpp"
-
 namespace CamelotFramework
 namespace CamelotFramework
 {
 {
 	size_t D3D11InputLayoutManager::HashFunc::operator()
 	size_t D3D11InputLayoutManager::HashFunc::operator()
@@ -57,9 +55,9 @@ namespace CamelotFramework
 		{
 		{
 			auto firstElem = mInputLayoutMap.begin();
 			auto firstElem = mInputLayoutMap.begin();
 
 
-			CM_DELETE(firstElem->first.bufferDeclElements, list<VertexElement BOOST_PP_COMMA() StdAlloc<VertexElement>>, PoolAlloc);
+			cm_delete<PoolAlloc>(firstElem->first.bufferDeclElements);
 			SAFE_RELEASE(firstElem->second->inputLayout);
 			SAFE_RELEASE(firstElem->second->inputLayout);
-			CM_DELETE(firstElem->second, InputLayoutEntry, PoolAlloc);
+			cm_delete<PoolAlloc>(firstElem->second);
 
 
 			mInputLayoutMap.erase(firstElem);
 			mInputLayoutMap.erase(firstElem);
 		}
 		}
@@ -96,7 +94,7 @@ namespace CamelotFramework
 			return; // Error was already reported, so just quit here
 			return; // Error was already reported, so just quit here
 
 
 		UINT32 numElements = vertexBufferDecl->getElementCount();
 		UINT32 numElements = vertexBufferDecl->getElementCount();
-		D3D11_INPUT_ELEMENT_DESC* declElements = CM_NEW_ARRAY(D3D11_INPUT_ELEMENT_DESC, numElements, ScratchAlloc);
+		D3D11_INPUT_ELEMENT_DESC* declElements = cm_newN<D3D11_INPUT_ELEMENT_DESC, ScratchAlloc>(numElements);
 		ZeroMemory(declElements, sizeof(D3D11_INPUT_ELEMENT_DESC) * numElements);
 		ZeroMemory(declElements, sizeof(D3D11_INPUT_ELEMENT_DESC) * numElements);
 
 
 		unsigned int idx = 0;
 		unsigned int idx = 0;
@@ -118,7 +116,7 @@ namespace CamelotFramework
 
 
 		const HLSLMicroCode& microcode = vertexProgram.getMicroCode();
 		const HLSLMicroCode& microcode = vertexProgram.getMicroCode();
 
 
-		InputLayoutEntry* newEntry = CM_NEW(InputLayoutEntry, PoolAlloc) InputLayoutEntry();
+		InputLayoutEntry* newEntry = cm_new<InputLayoutEntry, PoolAlloc>();
 		newEntry->lastUsedIdx = ++mLastUsedCounter;
 		newEntry->lastUsedIdx = ++mLastUsedCounter;
 		newEntry->inputLayout = nullptr; 
 		newEntry->inputLayout = nullptr; 
 		HRESULT hr = device.getD3D11Device()->CreateInputLayout( 
 		HRESULT hr = device.getD3D11Device()->CreateInputLayout( 
@@ -128,7 +126,7 @@ namespace CamelotFramework
 			microcode.size(),
 			microcode.size(),
 			&newEntry->inputLayout);
 			&newEntry->inputLayout);
 
 
-		//CM_DELETE_ARRAY(declElements, D3D11_INPUT_ELEMENT_DESC, numElements, ScratchAlloc);
+		cm_deleteN<ScratchAlloc>(declElements, numElements);
 
 
 		if (FAILED(hr)|| device.hasError())
 		if (FAILED(hr)|| device.hasError())
 			CM_EXCEPT(RenderingAPIException, "Unable to set D3D11 vertex declaration" + device.getErrorDescription());
 			CM_EXCEPT(RenderingAPIException, "Unable to set D3D11 vertex declaration" + device.getErrorDescription());
@@ -137,7 +135,7 @@ namespace CamelotFramework
 		VertexDeclarationKey pair;
 		VertexDeclarationKey pair;
 		pair.bufferDeclHash = vertexBufferDecl->getHash();
 		pair.bufferDeclHash = vertexBufferDecl->getHash();
 
 
-		list<VertexElement>::type* bufferDeclElements = CM_NEW(list<VertexElement>::type, PoolAlloc) list<VertexElement>::type(); 
+		list<VertexElement>::type* bufferDeclElements = cm_new<list<VertexElement>::type, PoolAlloc>(); 
 		pair.bufferDeclElements = bufferDeclElements;
 		pair.bufferDeclElements = bufferDeclElements;
 		pair.vertexProgramId = vertexProgram.getProgramId();
 		pair.vertexProgramId = vertexProgram.getProgramId();
 
 
@@ -168,9 +166,9 @@ namespace CamelotFramework
 		{
 		{
 			auto inputLayoutIter = mInputLayoutMap.find(iter->second);
 			auto inputLayoutIter = mInputLayoutMap.find(iter->second);
 
 
-			CM_DELETE(inputLayoutIter->first.bufferDeclElements, list<VertexElement BOOST_PP_COMMA() StdAlloc<VertexElement>>, PoolAlloc);
+			cm_delete<PoolAlloc>(inputLayoutIter->first.bufferDeclElements);
 			SAFE_RELEASE(inputLayoutIter->second->inputLayout);
 			SAFE_RELEASE(inputLayoutIter->second->inputLayout);
-			CM_DELETE(inputLayoutIter->second, InputLayoutEntry, PoolAlloc);
+			cm_delete<PoolAlloc>(inputLayoutIter->second);
 
 
 			mInputLayoutMap.erase(inputLayoutIter);
 			mInputLayoutMap.erase(inputLayoutIter);
 
 

+ 16 - 16
CamelotD3D11RenderSystem/Source/CmD3D11RenderSystem.cpp

@@ -67,7 +67,7 @@ namespace CamelotFramework
 		if(FAILED(hr))
 		if(FAILED(hr))
 			CM_EXCEPT(RenderingAPIException, "Failed to create Direct3D11 DXGIFactory");
 			CM_EXCEPT(RenderingAPIException, "Failed to create Direct3D11 DXGIFactory");
 
 
-		mDriverList = CM_NEW(D3D11DriverList, GenAlloc) D3D11DriverList(mDXGIFactory);
+		mDriverList = cm_new<D3D11DriverList>(mDXGIFactory);
 		mActiveD3DDriver = mDriverList->item(0); // TODO: Always get first driver, for now
 		mActiveD3DDriver = mDriverList->item(0); // TODO: Always get first driver, for now
 
 
 		IDXGIAdapter* selectedAdapter = mActiveD3DDriver->getDeviceAdapter();
 		IDXGIAdapter* selectedAdapter = mActiveD3DDriver->getDeviceAdapter();
@@ -96,7 +96,7 @@ namespace CamelotFramework
 		if(FAILED(hr))         
 		if(FAILED(hr))         
 			CM_EXCEPT(RenderingAPIException, "Failed to create Direct3D11 object. D3D11CreateDeviceN returned this error code: " + toString(hr));
 			CM_EXCEPT(RenderingAPIException, "Failed to create Direct3D11 object. D3D11CreateDeviceN returned this error code: " + toString(hr));
 
 
-		mDevice = CM_NEW(D3D11Device, GenAlloc) D3D11Device(device);
+		mDevice = cm_new<D3D11Device>(device);
 
 
 		LARGE_INTEGER driverVersion;
 		LARGE_INTEGER driverVersion;
 		if(SUCCEEDED(selectedAdapter->CheckInterfaceSupport(IID_ID3D10Device /* intentionally D3D10, not D3D11 */, &driverVersion)))
 		if(SUCCEEDED(selectedAdapter->CheckInterfaceSupport(IID_ID3D10Device /* intentionally D3D10, not D3D11 */, &driverVersion)))
@@ -108,29 +108,29 @@ namespace CamelotFramework
 		}
 		}
 
 
 		// Create the texture manager for use by others		
 		// Create the texture manager for use by others		
-		TextureManager::startUp(CM_NEW(D3D11TextureManager, GenAlloc) D3D11TextureManager());
+		TextureManager::startUp(cm_new<D3D11TextureManager>());
 
 
 		// Also create hardware buffer manager		
 		// Also create hardware buffer manager		
-		HardwareBufferManager::startUp(CM_NEW(D3D11HardwareBufferManager, GenAlloc) D3D11HardwareBufferManager(*mDevice));
+		HardwareBufferManager::startUp(cm_new<D3D11HardwareBufferManager>(std::ref(*mDevice)));
 
 
 		// Create the GPU program manager		
 		// Create the GPU program manager		
-		GpuProgramManager::startUp(CM_NEW(D3D11GpuProgramManager, GenAlloc) D3D11GpuProgramManager(*mDevice));
+		GpuProgramManager::startUp(cm_new<D3D11GpuProgramManager>(std::ref(*mDevice)));
 
 
 		// Create render window manager
 		// Create render window manager
-		RenderWindowManager::startUp(CM_NEW(D3D11RenderWindowManager, GenAlloc) D3D11RenderWindowManager(this));
+		RenderWindowManager::startUp(cm_new<D3D11RenderWindowManager>(this));
 
 
 		// Create & register HLSL factory		
 		// Create & register HLSL factory		
-		mHLSLFactory = CM_NEW(D3D11HLSLProgramFactory, GenAlloc) D3D11HLSLProgramFactory();
+		mHLSLFactory = cm_new<D3D11HLSLProgramFactory>();
 
 
 		// Create render state manager
 		// Create render state manager
-		RenderStateManager::startUp(CM_NEW(D3D11RenderStateManager, GenAlloc) D3D11RenderStateManager());
+		RenderStateManager::startUp(cm_new<D3D11RenderStateManager>());
 
 
 		mCurrentCapabilities = createRenderSystemCapabilities();
 		mCurrentCapabilities = createRenderSystemCapabilities();
 
 
 		mCurrentCapabilities->addShaderProfile("hlsl");
 		mCurrentCapabilities->addShaderProfile("hlsl");
 		HighLevelGpuProgramManager::instance().addFactory(mHLSLFactory);
 		HighLevelGpuProgramManager::instance().addFactory(mHLSLFactory);
 
 
-		mIAManager = CM_NEW(D3D11InputLayoutManager, GenAlloc) D3D11InputLayoutManager();
+		mIAManager = cm_new<D3D11InputLayoutManager>();
 
 
 		RenderWindowPtr primaryWindow = RenderWindow::create(mPrimaryWindowDesc);
 		RenderWindowPtr primaryWindow = RenderWindow::create(mPrimaryWindowDesc);
 
 
@@ -579,13 +579,13 @@ namespace CamelotFramework
 		{
 		{
 			UINT32 maxRenderTargets = mCurrentCapabilities->getNumMultiRenderTargets();
 			UINT32 maxRenderTargets = mCurrentCapabilities->getNumMultiRenderTargets();
 
 
-			ID3D11RenderTargetView** views = CM_NEW_ARRAY(ID3D11RenderTargetView*, maxRenderTargets, ScratchAlloc);
+			ID3D11RenderTargetView** views = cm_newN<ID3D11RenderTargetView*, ScratchAlloc>(maxRenderTargets);
 			memset(views, 0, sizeof(ID3D11RenderTargetView*) * maxRenderTargets);
 			memset(views, 0, sizeof(ID3D11RenderTargetView*) * maxRenderTargets);
 
 
 			target->getCustomAttribute("RTV", views);
 			target->getCustomAttribute("RTV", views);
 			if (!views[0])
 			if (!views[0])
 			{
 			{
-				CM_DELETE_ARRAY(views, ID3D11RenderTargetView*, maxRenderTargets, ScratchAlloc);
+				cm_deleteN<ScratchAlloc>(views, maxRenderTargets);
 				return;
 				return;
 			}
 			}
 
 
@@ -601,7 +601,7 @@ namespace CamelotFramework
 					mDevice->getImmediateContext()->ClearRenderTargetView(views[i], clearColor);
 					mDevice->getImmediateContext()->ClearRenderTargetView(views[i], clearColor);
 			}
 			}
 
 
-			CM_DELETE_ARRAY(views, ID3D11RenderTargetView*, maxRenderTargets, ScratchAlloc);
+			cm_deleteN<ScratchAlloc>(views, maxRenderTargets);
 		}
 		}
 
 
 		// Clear depth stencil
 		// Clear depth stencil
@@ -632,12 +632,12 @@ namespace CamelotFramework
 
 
 		// Retrieve render surfaces
 		// Retrieve render surfaces
 		UINT32 maxRenderTargets = mCurrentCapabilities->getNumMultiRenderTargets();
 		UINT32 maxRenderTargets = mCurrentCapabilities->getNumMultiRenderTargets();
-		ID3D11RenderTargetView** views = CM_NEW_ARRAY(ID3D11RenderTargetView*, maxRenderTargets, ScratchAlloc);
+		ID3D11RenderTargetView** views = cm_newN<ID3D11RenderTargetView*, ScratchAlloc>(maxRenderTargets);
 		memset(views, 0, sizeof(ID3D11RenderTargetView*) * maxRenderTargets);
 		memset(views, 0, sizeof(ID3D11RenderTargetView*) * maxRenderTargets);
 		target->getCustomAttribute("RTV", views);
 		target->getCustomAttribute("RTV", views);
 		if (!views[0])
 		if (!views[0])
 		{
 		{
-			CM_DELETE_ARRAY(views, ID3D11RenderTargetView*, maxRenderTargets, ScratchAlloc);
+			cm_deleteN<ScratchAlloc>(views, maxRenderTargets);
 			return;
 			return;
 		}
 		}
 
 
@@ -650,7 +650,7 @@ namespace CamelotFramework
 		if (mDevice->hasError())
 		if (mDevice->hasError())
 			CM_EXCEPT(RenderingAPIException, "Failed to setRenderTarget : " + mDevice->getErrorDescription());
 			CM_EXCEPT(RenderingAPIException, "Failed to setRenderTarget : " + mDevice->getErrorDescription());
 
 
-		CM_DELETE_ARRAY(views, ID3D11RenderTargetView*, maxRenderTargets, ScratchAlloc);
+		cm_deleteN<ScratchAlloc>(views, maxRenderTargets);
 	}
 	}
 
 
 	void D3D11RenderSystem::setClipPlanesImpl(const PlaneList& clipPlanes)
 	void D3D11RenderSystem::setClipPlanesImpl(const PlaneList& clipPlanes)
@@ -662,7 +662,7 @@ namespace CamelotFramework
 	{
 	{
 		THROW_IF_NOT_RENDER_THREAD;
 		THROW_IF_NOT_RENDER_THREAD;
 
 
-		RenderSystemCapabilities* rsc = CM_NEW(RenderSystemCapabilities, GenAlloc) RenderSystemCapabilities();
+		RenderSystemCapabilities* rsc = cm_new<RenderSystemCapabilities>();
 
 
 		rsc->setDriverVersion(mDriverVersion);
 		rsc->setDriverVersion(mDriverVersion);
 		rsc->setDeviceName(mActiveD3DDriver->getDriverDescription());
 		rsc->setDeviceName(mActiveD3DDriver->getDriverDescription());

+ 1 - 1
CamelotD3D11RenderSystem/Source/CmD3D11RenderSystemFactory.cpp

@@ -5,7 +5,7 @@ namespace CamelotFramework
 {
 {
 	void D3D11RenderSystemFactory::create()
 	void D3D11RenderSystemFactory::create()
 	{
 	{
-		RenderSystem::startUp(CM_NEW(D3D11RenderSystem, GenAlloc) D3D11RenderSystem());
+		RenderSystem::startUp(new (cm_alloc<D3D11RenderSystem>()) D3D11RenderSystem());
 	}
 	}
 
 
 	D3D11RenderSystemFactory::InitOnStart D3D11RenderSystemFactory::initOnStart;
 	D3D11RenderSystemFactory::InitOnStart D3D11RenderSystemFactory::initOnStart;

+ 1 - 1
CamelotD3D11RenderSystem/Source/CmD3D11Texture.cpp

@@ -532,7 +532,7 @@ namespace CamelotFramework
 		UINT32 sizeOfImage = lock.getConsecutiveSize();
 		UINT32 sizeOfImage = lock.getConsecutiveSize();
 		mLockedSubresourceIdx = D3D11CalcSubresource(mipLevel, face, getNumMipmaps()+1);
 		mLockedSubresourceIdx = D3D11CalcSubresource(mipLevel, face, getNumMipmaps()+1);
 
 
-		mStaticBuffer = CM_NEW(PixelData, PoolAlloc) PixelData(lock.getWidth(), lock.getHeight(), lock.getDepth(), lock.getFormat());
+		mStaticBuffer = cm_new<PixelData, PoolAlloc>(lock.getWidth(), lock.getHeight(), lock.getDepth(), lock.getFormat());
 		mStaticBuffer->allocateInternalBuffer();
 		mStaticBuffer->allocateInternalBuffer();
 
 
 		return mStaticBuffer->getData();
 		return mStaticBuffer->getData();

+ 4 - 3
CamelotD3D11RenderSystem/Source/CmD3D11VertexBuffer.cpp

@@ -1,4 +1,5 @@
 #include "CmD3D11VertexBuffer.h"
 #include "CmD3D11VertexBuffer.h"
+#include "CmD3D11Device.h"
 
 
 namespace CamelotFramework
 namespace CamelotFramework
 {
 {
@@ -38,8 +39,8 @@ namespace CamelotFramework
 
 
 	void D3D11VertexBuffer::initialize_internal()
 	void D3D11VertexBuffer::initialize_internal()
 	{
 	{
-		mBuffer = CM_NEW(D3D11HardwareBuffer, PoolAlloc) D3D11HardwareBuffer(D3D11HardwareBuffer::BT_VERTEX, 
-			mUsage, 1, mSizeInBytes, mDevice, mSystemMemory, mStreamOut);
+		mBuffer = cm_new<D3D11HardwareBuffer, PoolAlloc>(D3D11HardwareBuffer::BT_VERTEX, 
+			mUsage, 1, mSizeInBytes, std::ref(mDevice), mSystemMemory, mStreamOut);
 
 
 		VertexBuffer::initialize_internal();
 		VertexBuffer::initialize_internal();
 	}
 	}
@@ -47,7 +48,7 @@ namespace CamelotFramework
 	void D3D11VertexBuffer::destroy_internal()
 	void D3D11VertexBuffer::destroy_internal()
 	{
 	{
 		if(mBuffer != nullptr)
 		if(mBuffer != nullptr)
-			CM_DELETE(mBuffer, D3D11HardwareBuffer, PoolAlloc);
+			cm_delete<PoolAlloc>(mBuffer);
 
 
 		VertexBuffer::destroy_internal();
 		VertexBuffer::destroy_internal();
 	}
 	}

+ 3 - 3
CamelotD3D11RenderSystem/Source/CmD3D11VideoModeList.cpp

@@ -44,12 +44,12 @@ namespace CamelotFramework
 			CM_EXCEPT(InternalErrorException, "Error while enumerating adapter output video modes. Output index: " + toString(adapterOutput));
 			CM_EXCEPT(InternalErrorException, "Error while enumerating adapter output video modes. Output index: " + toString(adapterOutput));
 		}
 		}
 
 
-		DXGI_MODE_DESC* modeDesc = CM_NEW_ARRAY(DXGI_MODE_DESC, numModes, ScratchAlloc);
+		DXGI_MODE_DESC* modeDesc = cm_newN<DXGI_MODE_DESC, ScratchAlloc>(numModes);
 
 
 		hr = output->GetDisplayModeList(DXGI_FORMAT_R8G8B8A8_UNORM, 0, &numModes, modeDesc);
 		hr = output->GetDisplayModeList(DXGI_FORMAT_R8G8B8A8_UNORM, 0, &numModes, modeDesc);
 		if(FAILED(hr))
 		if(FAILED(hr))
 		{
 		{
-			CM_DELETE_ARRAY(modeDesc, DXGI_MODE_DESC, numModes, ScratchAlloc);
+			cm_deleteN<ScratchAlloc>(modeDesc, numModes);
 
 
 			SAFE_RELEASE(output);
 			SAFE_RELEASE(output);
 			CM_EXCEPT(InternalErrorException, "Error while enumerating adapter output video modes. Output index: " + toString(adapterOutput));
 			CM_EXCEPT(InternalErrorException, "Error while enumerating adapter output video modes. Output index: " + toString(adapterOutput));
@@ -86,7 +86,7 @@ namespace CamelotFramework
 				mModeList.push_back(D3D11VideoMode(outputDesc, displayMode));
 				mModeList.push_back(D3D11VideoMode(outputDesc, displayMode));
 		}
 		}
 
 
-		CM_DELETE_ARRAY(modeDesc, DXGI_MODE_DESC, numModes, ScratchAlloc);
+		cm_deleteN<ScratchAlloc>(modeDesc, numModes);
 	}
 	}
 
 
 	UINT32 D3D11VideoModeList::count() const
 	UINT32 D3D11VideoModeList::count() const

+ 4 - 4
CamelotD3D9Renderer/Source/CmD3D9Device.cpp

@@ -84,7 +84,7 @@ namespace CamelotFramework
 
 
 		if (it == mMapRenderWindowToResoruces.end())
 		if (it == mMapRenderWindowToResoruces.end())
 		{
 		{
-			RenderWindowResources* renderWindowResources = CM_NEW(RenderWindowResources, PoolAlloc) RenderWindowResources;
+			RenderWindowResources* renderWindowResources = cm_new<RenderWindowResources, PoolAlloc>();
 
 
 			memset(renderWindowResources, 0, sizeof(RenderWindowResources));						
 			memset(renderWindowResources, 0, sizeof(RenderWindowResources));						
 			renderWindowResources->adapterOrdinalInGroupIndex = 0;					
 			renderWindowResources->adapterOrdinalInGroupIndex = 0;					
@@ -294,7 +294,7 @@ namespace CamelotFramework
 		mD3D9DeviceCapsValid	= false;
 		mD3D9DeviceCapsValid	= false;
 
 
 		if(mPresentationParams != nullptr)
 		if(mPresentationParams != nullptr)
-			CM_DELETE_ARRAY(mPresentationParams, D3DPRESENT_PARAMETERS, mPresentationParamsCount, PoolAlloc);
+			cm_deleteN<PoolAlloc>(mPresentationParams, mPresentationParamsCount);
 
 
 		mPresentationParamsCount = 0;
 		mPresentationParamsCount = 0;
 
 
@@ -471,13 +471,13 @@ namespace CamelotFramework
 	{		
 	{		
 		// Clear old presentation parameters.
 		// Clear old presentation parameters.
 		if(mPresentationParams != nullptr)
 		if(mPresentationParams != nullptr)
-			CM_DELETE_ARRAY(mPresentationParams, D3DPRESENT_PARAMETERS, mPresentationParamsCount, PoolAlloc);
+			cm_deleteN<PoolAlloc>(mPresentationParams, mPresentationParamsCount);
 
 
 		mPresentationParamsCount = 0;		
 		mPresentationParamsCount = 0;		
 
 
 		if (mMapRenderWindowToResoruces.size() > 0)
 		if (mMapRenderWindowToResoruces.size() > 0)
 		{
 		{
-			mPresentationParams = CM_NEW_ARRAY(D3DPRESENT_PARAMETERS, (UINT32)mMapRenderWindowToResoruces.size(), PoolAlloc);
+			mPresentationParams = cm_newN<D3DPRESENT_PARAMETERS, PoolAlloc>((UINT32)mMapRenderWindowToResoruces.size());
 
 
 			RenderWindowToResorucesIterator it = mMapRenderWindowToResoruces.begin();
 			RenderWindowToResorucesIterator it = mMapRenderWindowToResoruces.begin();
 
 

+ 1 - 1
CamelotD3D9Renderer/Source/CmD3D9DeviceManager.cpp

@@ -222,7 +222,7 @@ namespace CamelotFramework
 		// No matching device found -> create new one.
 		// No matching device found -> create new one.
 		if (renderDevice == NULL)
 		if (renderDevice == NULL)
 		{
 		{
-			renderDevice = CM_NEW(D3D9Device, GenAlloc) D3D9Device(this, nAdapterOrdinal, direct3D9->GetAdapterMonitor(nAdapterOrdinal), devType, extraFlags);
+			renderDevice = cm_new<D3D9Device>(this, nAdapterOrdinal, direct3D9->GetAdapterMonitor(nAdapterOrdinal), devType, extraFlags);
 			mRenderDevices.push_back(renderDevice);
 			mRenderDevices.push_back(renderDevice);
 			if (mActiveDevice == NULL)			
 			if (mActiveDevice == NULL)			
 				setActiveDevice(renderDevice);											
 				setActiveDevice(renderDevice);											

+ 1 - 1
CamelotD3D9Renderer/Source/CmD3D9Driver.cpp

@@ -85,7 +85,7 @@ namespace CamelotFramework
 	D3D9VideoModeList* D3D9Driver::getVideoModeList()
 	D3D9VideoModeList* D3D9Driver::getVideoModeList()
 	{
 	{
 		if( !mpVideoModeList )
 		if( !mpVideoModeList )
-			mpVideoModeList = CM_NEW(D3D9VideoModeList, GenAlloc) D3D9VideoModeList( this );
+			mpVideoModeList = cm_new<D3D9VideoModeList>(this);
 
 
 		return mpVideoModeList;
 		return mpVideoModeList;
 	}	
 	}	

+ 1 - 1
CamelotD3D9Renderer/Source/CmD3D9IndexBuffer.cpp

@@ -255,7 +255,7 @@ namespace CamelotFramework {
 		}
 		}
 		else
 		else
 		{
 		{
-			bufferResources = CM_NEW(BufferResources, PoolAlloc) BufferResources;			
+			bufferResources = cm_new<BufferResources, PoolAlloc>();			
 			mMapDeviceToBufferResources[d3d9Device] = bufferResources;
 			mMapDeviceToBufferResources[d3d9Device] = bufferResources;
 		}
 		}
 
 

+ 1 - 1
CamelotD3D9Renderer/Source/CmD3D9PixelBuffer.cpp

@@ -197,7 +197,7 @@ namespace CamelotFramework
 	//-----------------------------------------------------------------------------  
 	//-----------------------------------------------------------------------------  
 	D3D9PixelBuffer::BufferResources* D3D9PixelBuffer::createBufferResources()
 	D3D9PixelBuffer::BufferResources* D3D9PixelBuffer::createBufferResources()
 	{
 	{
-		BufferResources* newResources = CM_NEW(BufferResources, PoolAlloc) BufferResources;
+		BufferResources* newResources = cm_new<BufferResources, PoolAlloc>();
 
 
 		memset(newResources, 0, sizeof(BufferResources));
 		memset(newResources, 0, sizeof(BufferResources));
 
 

+ 17 - 17
CamelotD3D9Renderer/Source/CmD3D9RenderSystem.cpp

@@ -159,34 +159,34 @@ namespace CamelotFramework
 		mDriverVersion.build = LOWORD(mActiveD3DDriver->getAdapterIdentifier().DriverVersion.LowPart);
 		mDriverVersion.build = LOWORD(mActiveD3DDriver->getAdapterIdentifier().DriverVersion.LowPart);
 
 
 		// Create the device manager.
 		// Create the device manager.
-		mDeviceManager = CM_NEW(D3D9DeviceManager, GenAlloc) D3D9DeviceManager();
-
-		// Create the texture manager for use by others		
-		TextureManager::startUp(CM_NEW(D3D9TextureManager, GenAlloc) D3D9TextureManager());
+		mDeviceManager = cm_new<D3D9DeviceManager>();
 
 
 		// Also create hardware buffer manager		
 		// Also create hardware buffer manager		
-		HardwareBufferManager::startUp(CM_NEW(D3D9HardwareBufferManager, GenAlloc) D3D9HardwareBufferManager());
+		HardwareBufferManager::startUp(cm_new<D3D9HardwareBufferManager>());
 
 
 		// Create the GPU program manager		
 		// Create the GPU program manager		
-		GpuProgramManager::startUp(CM_NEW(D3D9GpuProgramManager, GenAlloc) D3D9GpuProgramManager());
+		GpuProgramManager::startUp(cm_new<D3D9GpuProgramManager>());
 
 
 		// Create & register HLSL factory		
 		// Create & register HLSL factory		
-		mHLSLProgramFactory = CM_NEW(D3D9HLSLProgramFactory, GenAlloc) D3D9HLSLProgramFactory();
+		mHLSLProgramFactory = cm_new<D3D9HLSLProgramFactory>();
 
 
 		// Create & register Cg factory		
 		// Create & register Cg factory		
-		mCgProgramFactory = CM_NEW(CgProgramFactory, GenAlloc) CgProgramFactory();
+		mCgProgramFactory = cm_new<CgProgramFactory>();
 
 
 		// Create render window manager
 		// Create render window manager
-		RenderWindowManager::startUp(CM_NEW(D3D9RenderWindowManager, GenAlloc) D3D9RenderWindowManager(this));
+		RenderWindowManager::startUp(cm_new<D3D9RenderWindowManager>(this));
 
 
 		// Create render state manager
 		// Create render state manager
-		RenderStateManager::startUp(CM_NEW(RenderStateManager, GenAlloc) RenderStateManager());
+		RenderStateManager::startUp(cm_new<RenderStateManager>());
 
 
 		// Create primary window and finalize initialization
 		// Create primary window and finalize initialization
 		RenderWindowPtr primaryWindow = RenderWindow::create(mPrimaryWindowDesc);
 		RenderWindowPtr primaryWindow = RenderWindow::create(mPrimaryWindowDesc);
 		D3D9RenderWindow* d3d9renderWindow = static_cast<D3D9RenderWindow*>(primaryWindow.get());
 		D3D9RenderWindow* d3d9renderWindow = static_cast<D3D9RenderWindow*>(primaryWindow.get());
 		updateRenderSystemCapabilities(d3d9renderWindow);
 		updateRenderSystemCapabilities(d3d9renderWindow);
 
 
+		// Create the texture manager for use by others		
+		TextureManager::startUp(cm_new<D3D9TextureManager>());
+
 		// call superclass method
 		// call superclass method
 		RenderSystem::initialize_internal(asyncOp);
 		RenderSystem::initialize_internal(asyncOp);
 
 
@@ -197,7 +197,7 @@ namespace CamelotFramework
 	{
 	{
 		if(mTexStageDesc != nullptr)
 		if(mTexStageDesc != nullptr)
 		{
 		{
-			CM_DELETE_ARRAY(mTexStageDesc, sD3DTextureStageDesc, mNumTexStages, GenAlloc);
+			cm_deleteN(mTexStageDesc, mNumTexStages);
 			mTexStageDesc = nullptr;
 			mTexStageDesc = nullptr;
 		}
 		}
 
 
@@ -1101,12 +1101,12 @@ namespace CamelotFramework
 
 
 		// Retrieve render surfaces
 		// Retrieve render surfaces
 		UINT32 maxRenderTargets = mCurrentCapabilities->getNumMultiRenderTargets();
 		UINT32 maxRenderTargets = mCurrentCapabilities->getNumMultiRenderTargets();
-		IDirect3DSurface9** pBack = CM_NEW_ARRAY(IDirect3DSurface9*, maxRenderTargets, ScratchAlloc);
+		IDirect3DSurface9** pBack = cm_newN<IDirect3DSurface9*, ScratchAlloc>(maxRenderTargets);
 		memset(pBack, 0, sizeof(IDirect3DSurface9*) * maxRenderTargets);
 		memset(pBack, 0, sizeof(IDirect3DSurface9*) * maxRenderTargets);
 		target->getCustomAttribute( "DDBACKBUFFER", pBack );
 		target->getCustomAttribute( "DDBACKBUFFER", pBack );
 		if (!pBack[0])
 		if (!pBack[0])
 		{
 		{
-			CM_DELETE_ARRAY(pBack, IDirect3DSurface9*, maxRenderTargets, ScratchAlloc);
+			cm_deleteN<ScratchAlloc>(pBack, maxRenderTargets);
 			return;
 			return;
 		}
 		}
 
 
@@ -1126,7 +1126,7 @@ namespace CamelotFramework
 			}
 			}
 		}
 		}
 
 
-		CM_DELETE_ARRAY(pBack, IDirect3DSurface9*, maxRenderTargets, ScratchAlloc);
+		cm_deleteN<ScratchAlloc>(pBack, maxRenderTargets);
 
 
 		hr = getActiveD3D9Device()->SetDepthStencilSurface(pDepth);
 		hr = getActiveD3D9Device()->SetDepthStencilSurface(pDepth);
 		if (FAILED(hr))
 		if (FAILED(hr))
@@ -1573,7 +1573,7 @@ namespace CamelotFramework
 	D3D9DriverList* D3D9RenderSystem::getDirect3DDrivers() const
 	D3D9DriverList* D3D9RenderSystem::getDirect3DDrivers() const
 	{
 	{
 		if( !mDriverList )
 		if( !mDriverList )
-			mDriverList = CM_NEW(D3D9DriverList, GenAlloc) D3D9DriverList();
+			mDriverList = cm_new<D3D9DriverList>();
 
 
 		return mDriverList;
 		return mDriverList;
 	}
 	}
@@ -1653,7 +1653,7 @@ namespace CamelotFramework
 	{			
 	{			
 		RenderSystemCapabilities* rsc = mCurrentCapabilities;
 		RenderSystemCapabilities* rsc = mCurrentCapabilities;
 		if (rsc == NULL)
 		if (rsc == NULL)
-			rsc = CM_NEW(RenderSystemCapabilities, GenAlloc) RenderSystemCapabilities();
+			rsc = cm_new<RenderSystemCapabilities>();
 
 
 		rsc->setCategoryRelevant(CAPS_CATEGORY_D3D9, true);
 		rsc->setCategoryRelevant(CAPS_CATEGORY_D3D9, true);
 		rsc->setDriverVersion(mDriverVersion);
 		rsc->setDriverVersion(mDriverVersion);
@@ -2269,7 +2269,7 @@ namespace CamelotFramework
 			HighLevelGpuProgramManager::instance().addFactory(mCgProgramFactory);
 			HighLevelGpuProgramManager::instance().addFactory(mCgProgramFactory);
 
 
 		mNumTexStages = caps->getNumCombinedTextureUnits();
 		mNumTexStages = caps->getNumCombinedTextureUnits();
-		mTexStageDesc = CM_NEW_ARRAY(sD3DTextureStageDesc, mNumTexStages, GenAlloc);
+		mTexStageDesc = cm_newN<sD3DTextureStageDesc>(mNumTexStages);
 
 
 		// set stages desc. to defaults
 		// set stages desc. to defaults
 		for (UINT32 n = 0; n < mNumTexStages; n++)
 		for (UINT32 n = 0; n < mNumTexStages; n++)

+ 1 - 1
CamelotD3D9Renderer/Source/CmD3D9RenderSystemFactory.cpp

@@ -11,7 +11,7 @@ namespace CamelotFramework
 		HINSTANCE hInst = GetModuleHandle( "CamelotD3D9RenderSystem.dll" );
 		HINSTANCE hInst = GetModuleHandle( "CamelotD3D9RenderSystem.dll" );
 	#endif
 	#endif
 
 
-		RenderSystem::startUp(CM_NEW(D3D9RenderSystem, GenAlloc) D3D9RenderSystem(hInst));
+		RenderSystem::startUp(cm_new<D3D9RenderSystem>(hInst));
 	}
 	}
 
 
 	D3D9RenderSystemFactory::InitOnStart D3D9RenderSystemFactory::initOnStart;
 	D3D9RenderSystemFactory::InitOnStart D3D9RenderSystemFactory::initOnStart;

+ 1 - 1
CamelotD3D9Renderer/Source/CmD3D9RenderWindowManager.cpp

@@ -20,7 +20,7 @@ namespace CamelotFramework
 			desc.platformSpecific["parentWindowHandle"] = toString((unsigned long)hWnd);
 			desc.platformSpecific["parentWindowHandle"] = toString((unsigned long)hWnd);
 		}
 		}
 
 
-		D3D9RenderWindow* window = CM_NEW(D3D9RenderWindow, PoolAlloc) D3D9RenderWindow(desc, mRenderSystem->getInstanceHandle());
+		D3D9RenderWindow* window = new (cm_alloc<D3D9RenderWindow, PoolAlloc>()) D3D9RenderWindow(desc, mRenderSystem->getInstanceHandle());
 
 
 		return RenderWindowPtr(window, &CoreObject::_deleteDelayed<D3D9RenderWindow, PoolAlloc>);
 		return RenderWindowPtr(window, &CoreObject::_deleteDelayed<D3D9RenderWindow, PoolAlloc>);
 	}
 	}

+ 1 - 1
CamelotD3D9Renderer/Source/CmD3D9Texture.cpp

@@ -260,7 +260,7 @@ namespace CamelotFramework
 	{
 	{
 		assert(mMapDeviceToTextureResources.find(d3d9Device) == mMapDeviceToTextureResources.end());
 		assert(mMapDeviceToTextureResources.find(d3d9Device) == mMapDeviceToTextureResources.end());
 
 
-		TextureResources* textureResources = CM_NEW(TextureResources, PoolAlloc) TextureResources;
+		TextureResources* textureResources = cm_new<TextureResources, PoolAlloc>();
 
 
 		textureResources->pNormTex		= NULL;
 		textureResources->pNormTex		= NULL;
 		textureResources->pCubeTex		= NULL;
 		textureResources->pCubeTex		= NULL;

+ 1 - 1
CamelotD3D9Renderer/Source/CmD3D9VertexBuffer.cpp

@@ -196,7 +196,7 @@ namespace CamelotFramework {
 		}
 		}
 		else
 		else
 		{
 		{
-			bufferResources = CM_NEW(BufferResources, PoolAlloc) BufferResources;			
+			bufferResources = cm_new<BufferResources, PoolAlloc>();			
 			mMapDeviceToBufferResources[d3d9Device] = bufferResources;
 			mMapDeviceToBufferResources[d3d9Device] = bufferResources;
 		}
 		}
 
 

+ 2 - 2
CamelotD3D9Renderer/Source/CmD3D9VertexDeclaration.cpp

@@ -121,7 +121,7 @@ namespace CamelotFramework {
 		// Case we have to create the declaration for this device.
 		// Case we have to create the declaration for this device.
 		if (it == mMapDeviceToDeclaration.end() || it->second == NULL)
 		if (it == mMapDeviceToDeclaration.end() || it->second == NULL)
 		{
 		{
-			D3DVERTEXELEMENT9* d3delems = CM_NEW_ARRAY(D3DVERTEXELEMENT9, (UINT32)(mElementList.size() + 1), PoolAlloc);
+			D3DVERTEXELEMENT9* d3delems = cm_newN<D3DVERTEXELEMENT9, PoolAlloc>((UINT32)(mElementList.size() + 1));
 
 
 			VertexElementList::const_iterator i, iend;
 			VertexElementList::const_iterator i, iend;
 			unsigned int idx;
 			unsigned int idx;
@@ -164,7 +164,7 @@ namespace CamelotFramework {
 				CM_EXCEPT(InternalErrorException, "Cannot create D3D9 vertex declaration: ");
 				CM_EXCEPT(InternalErrorException, "Cannot create D3D9 vertex declaration: ");
 			}
 			}
 
 
-			CM_DELETE_ARRAY(d3delems, D3DVERTEXELEMENT9, (UINT32)(mElementList.size() + 1), PoolAlloc);
+			cm_deleteN<PoolAlloc>(d3delems, (UINT32)(mElementList.size() + 1));
 
 
 			mMapDeviceToDeclaration[pCurDevice] = lpVertDecl;
 			mMapDeviceToDeclaration[pCurDevice] = lpVertDecl;
 		}
 		}

+ 1 - 1
CamelotFBXImporter/Include/CmFBXImporter.h

@@ -23,7 +23,7 @@ namespace CamelotFramework
 			static FBXImporter* importer = nullptr;
 			static FBXImporter* importer = nullptr;
 			if(importer == nullptr)
 			if(importer == nullptr)
 			{
 			{
-				importer = CM_NEW(FBXImporter, GenAlloc) FBXImporter();
+				importer = cm_new<FBXImporter>();
 				Importer::instance().registerAssetImporter(importer);
 				Importer::instance().registerAssetImporter(importer);
 			}
 			}
 		}
 		}

+ 1 - 1
CamelotFontImporter/Include/CmFontImporter.h

@@ -20,7 +20,7 @@ namespace CamelotFramework
 			static FontImporter* importer = nullptr;
 			static FontImporter* importer = nullptr;
 			if(importer == nullptr)
 			if(importer == nullptr)
 			{
 			{
-				importer = CM_NEW(FontImporter, GenAlloc) FontImporter();
+				importer = cm_new<FontImporter>();
 				Importer::instance().registerAssetImporter(importer);
 				Importer::instance().registerAssetImporter(importer);
 			}
 			}
 		}
 		}

+ 1 - 1
CamelotFreeImgImporter/Include/CmFreeImgImporter.h

@@ -22,7 +22,7 @@ namespace CamelotFramework
 			static FreeImgImporter* importer = nullptr;
 			static FreeImgImporter* importer = nullptr;
 			if(importer == nullptr)
 			if(importer == nullptr)
 			{
 			{
-				importer = CM_NEW(FreeImgImporter, GenAlloc) FreeImgImporter();
+				importer = cm_new<FreeImgImporter>();
 				Importer::instance().registerAssetImporter(importer);
 				Importer::instance().registerAssetImporter(importer);
 			}
 			}
 		}
 		}

+ 1 - 1
CamelotGLRenderer/Source/CmGLContext.cpp

@@ -51,7 +51,7 @@ GLEWContext * glewGetContext()
 	GLEWContext * currentGLEWContextsPtr =  CM_THREAD_POINTER_GET(GLEWContextsPtr);
 	GLEWContext * currentGLEWContextsPtr =  CM_THREAD_POINTER_GET(GLEWContextsPtr);
 	if (currentGLEWContextsPtr == NULL)
 	if (currentGLEWContextsPtr == NULL)
 	{
 	{
-		currentGLEWContextsPtr = CM_NEW(GLEWContext, GenAlloc) GLEWContext();
+		currentGLEWContextsPtr = cm_new<GLEWContext>();
 		CM_THREAD_POINTER_SET(GLEWContextsPtr, currentGLEWContextsPtr);
 		CM_THREAD_POINTER_SET(GLEWContextsPtr, currentGLEWContextsPtr);
 		memset(currentGLEWContextsPtr, 0, sizeof(GLEWContext));
 		memset(currentGLEWContextsPtr, 0, sizeof(GLEWContext));
 		glewInit();
 		glewInit();

+ 2 - 2
CamelotGLRenderer/Source/CmGLMultiRenderTexture.cpp

@@ -17,9 +17,9 @@ namespace CamelotFramework
 	void GLMultiRenderTexture::initialize_internal()
 	void GLMultiRenderTexture::initialize_internal()
 	{
 	{
 		if(mFB != nullptr)
 		if(mFB != nullptr)
-			CM_DELETE(mFB, GLFrameBufferObject, GenAlloc);
+			cm_delete(mFB);
 
 
-		mFB = CM_NEW(GLFrameBufferObject, PoolAlloc) GLFrameBufferObject(mFSAA);
+		mFB = cm_new<GLFrameBufferObject, PoolAlloc>(mFSAA);
 
 
 		for(size_t i = 0; i < mColorSurfaces.size(); i++)
 		for(size_t i = 0; i < mColorSurfaces.size(); i++)
 		{
 		{

+ 14 - 13
CamelotGLRenderer/Source/CmGLRenderSystem.cpp

@@ -40,6 +40,7 @@ THE SOFTWARE.s
 #include "CmGLSLExtSupport.h"
 #include "CmGLSLExtSupport.h"
 #include "CmGLOcclusionQuery.h"
 #include "CmGLOcclusionQuery.h"
 #include "CmGLContext.h"
 #include "CmGLContext.h"
+#include "CmGLSupport.h"
 #include "CmAsyncOp.h"
 #include "CmAsyncOp.h"
 #include "CmBlendState.h"
 #include "CmBlendState.h"
 #include "CmRasterizerState.h"
 #include "CmRasterizerState.h"
@@ -114,7 +115,7 @@ namespace CamelotFramework
 		mMinFilter = FO_LINEAR;
 		mMinFilter = FO_LINEAR;
 		mMipFilter = FO_POINT;
 		mMipFilter = FO_POINT;
 
 
-		mProgramPipelineManager = CM_NEW(GLSLProgramPipelineManager, GenAlloc) GLSLProgramPipelineManager();
+		mProgramPipelineManager = cm_new<GLSLProgramPipelineManager>();
 	}
 	}
 
 
 	GLRenderSystem::~GLRenderSystem()
 	GLRenderSystem::~GLRenderSystem()
@@ -141,9 +142,9 @@ namespace CamelotFramework
 		THROW_IF_NOT_RENDER_THREAD;
 		THROW_IF_NOT_RENDER_THREAD;
 
 
 		mGLSupport->start();
 		mGLSupport->start();
-		RenderWindowManager::startUp(CM_NEW(GLRenderWindowManager, GenAlloc) GLRenderWindowManager(this));
+		RenderWindowManager::startUp(cm_new<GLRenderWindowManager>(this));
 
 
-		RenderStateManager::startUp(CM_NEW(RenderStateManager, GenAlloc) RenderStateManager());
+		RenderStateManager::startUp(cm_new<RenderStateManager>());
 
 
 		// Initialize a window so we have something to create a GL context with
 		// Initialize a window so we have something to create a GL context with
 		RenderWindowPtr primaryWindow = RenderWindow::create(mPrimaryWindowDesc);
 		RenderWindowPtr primaryWindow = RenderWindow::create(mPrimaryWindowDesc);
@@ -240,7 +241,7 @@ namespace CamelotFramework
 			CM_DELETE(mGLSupport, GLSupport, GenAlloc);
 			CM_DELETE(mGLSupport, GLSupport, GenAlloc);
 
 
 		if(mTextureTypes != nullptr)
 		if(mTextureTypes != nullptr)
-			CM_DELETE_ARRAY(mTextureTypes, GLenum, mNumTextureTypes, GenAlloc);
+			cm_deleteN(mTextureTypes, mNumTextureTypes);
 	}
 	}
 
 
 	//---------------------------------------------------------------------
 	//---------------------------------------------------------------------
@@ -1769,23 +1770,23 @@ namespace CamelotFramework
 			glUnmapBufferARB = glUnmapBuffer;
 			glUnmapBufferARB = glUnmapBuffer;
 		}
 		}
 
 
-		HardwareBufferManager::startUp(CM_NEW(GLHardwareBufferManager, GenAlloc) GLHardwareBufferManager);
+		HardwareBufferManager::startUp(cm_new<GLHardwareBufferManager>());
 		checkForErrors();
 		checkForErrors();
 
 
 		// GPU Program Manager setup
 		// GPU Program Manager setup
-		GpuProgramManager::startUp(CM_NEW(GLGpuProgramManager, GenAlloc) GLGpuProgramManager());
+		GpuProgramManager::startUp(cm_new<GLGpuProgramManager>());
 		checkForErrors();
 		checkForErrors();
 
 
 		if(caps->isShaderProfileSupported("glsl"))
 		if(caps->isShaderProfileSupported("glsl"))
 		{
 		{
-			mGLSLProgramFactory = CM_NEW(GLSLProgramFactory, GenAlloc) GLSLProgramFactory();
+			mGLSLProgramFactory = cm_new<GLSLProgramFactory>();
 			HighLevelGpuProgramManager::instance().addFactory(mGLSLProgramFactory);
 			HighLevelGpuProgramManager::instance().addFactory(mGLSLProgramFactory);
 			checkForErrors();
 			checkForErrors();
 		}
 		}
 
 
 		if(caps->isShaderProfileSupported("cg"))
 		if(caps->isShaderProfileSupported("cg"))
 		{
 		{
-			mCgProgramFactory = CM_NEW(CgProgramFactory, GenAlloc) CgProgramFactory();
+			mCgProgramFactory = cm_new<CgProgramFactory>();
 			HighLevelGpuProgramManager::instance().addFactory(mCgProgramFactory);
 			HighLevelGpuProgramManager::instance().addFactory(mCgProgramFactory);
 			checkForErrors();
 			checkForErrors();
 		}
 		}
@@ -1819,7 +1820,7 @@ namespace CamelotFramework
 			if(caps->hasCapability(RSC_HWRENDER_TO_TEXTURE))
 			if(caps->hasCapability(RSC_HWRENDER_TO_TEXTURE))
 			{
 			{
 				// Create FBO manager
 				// Create FBO manager
-				GLRTTManager::startUp(CM_NEW(GLRTTManager, GenAlloc) GLRTTManager());
+				GLRTTManager::startUp(cm_new<GLRTTManager>());
 				checkForErrors();
 				checkForErrors();
 			}
 			}
 		}
 		}
@@ -1845,7 +1846,7 @@ namespace CamelotFramework
 			CM_EXCEPT(InternalErrorException, "Number of combined texture units less than the number of individual units!?");
 			CM_EXCEPT(InternalErrorException, "Number of combined texture units less than the number of individual units!?");
 
 
 		mNumTextureTypes = numCombinedTexUnits;
 		mNumTextureTypes = numCombinedTexUnits;
-		mTextureTypes = CM_NEW_ARRAY(GLenum, mNumTextureTypes, GenAlloc);
+		mTextureTypes = cm_newN<GLenum>(mNumTextureTypes);
 		for(UINT16 i = 0; i < numCombinedTexUnits; i++)
 		for(UINT16 i = 0; i < numCombinedTexUnits; i++)
 			mTextureTypes[i] = 0;
 			mTextureTypes[i] = 0;
 
 
@@ -1867,14 +1868,14 @@ namespace CamelotFramework
 		if(totalNumUniformBlocks > numCombinedUniformBlocks)
 		if(totalNumUniformBlocks > numCombinedUniformBlocks)
 			CM_EXCEPT(InternalErrorException, "Number of combined uniform block buffers less than the number of individual per-stage buffers!?");
 			CM_EXCEPT(InternalErrorException, "Number of combined uniform block buffers less than the number of individual per-stage buffers!?");
 
 
-		/// Create the texture manager        
-		TextureManager::startUp(CM_NEW(GLTextureManager, GenAlloc) GLTextureManager(*mGLSupport)); 
+		/// Create the texture manager   
+		TextureManager::startUp(cm_new<GLTextureManager>(std::ref(*mGLSupport))); 
 		checkForErrors();
 		checkForErrors();
 	}
 	}
 
 
 	RenderSystemCapabilities* GLRenderSystem::createRenderSystemCapabilities() const
 	RenderSystemCapabilities* GLRenderSystem::createRenderSystemCapabilities() const
 	{
 	{
-		RenderSystemCapabilities* rsc = CM_NEW(RenderSystemCapabilities, GenAlloc) RenderSystemCapabilities();
+		RenderSystemCapabilities* rsc = cm_new<RenderSystemCapabilities>();
 
 
 		rsc->setCategoryRelevant(CAPS_CATEGORY_GL, true);
 		rsc->setCategoryRelevant(CAPS_CATEGORY_GL, true);
 		rsc->setDriverVersion(mDriverVersion);
 		rsc->setDriverVersion(mDriverVersion);

+ 1 - 1
CamelotGLRenderer/Source/CmGLRenderSystemFactory.cpp

@@ -5,7 +5,7 @@ namespace CamelotFramework
 {
 {
 	void GLRenderSystemFactory::create()
 	void GLRenderSystemFactory::create()
 	{
 	{
-		RenderSystem::startUp(CM_NEW(GLRenderSystem, GenAlloc) GLRenderSystem());
+		RenderSystem::startUp(cm_new<GLRenderSystem>());
 	}
 	}
 
 
 	GLRenderSystemFactory::InitOnStart GLRenderSystemFactory::initOnStart;
 	GLRenderSystemFactory::InitOnStart GLRenderSystemFactory::initOnStart;

+ 3 - 3
CamelotGLRenderer/Source/CmGLRenderTexture.cpp

@@ -45,7 +45,7 @@ namespace CamelotFramework
 	void GLRenderTexture::destroy_internal()
 	void GLRenderTexture::destroy_internal()
 	{
 	{
 		if(mFB != nullptr)
 		if(mFB != nullptr)
-			CM_DELETE(mFB, GLFrameBufferObject, PoolAlloc);
+			cm_delete<PoolAlloc>(mFB);
 
 
 		RenderTexture::destroy_internal();
 		RenderTexture::destroy_internal();
 	}
 	}
@@ -53,9 +53,9 @@ namespace CamelotFramework
 	void GLRenderTexture::initialize_internal()
 	void GLRenderTexture::initialize_internal()
 	{
 	{
 		if(mFB != nullptr)
 		if(mFB != nullptr)
-			CM_DELETE(mFB, GLFrameBufferObject, PoolAlloc);
+			cm_delete<PoolAlloc>(mFB);
 
 
-		mFB = CM_NEW(GLFrameBufferObject, PoolAlloc) GLFrameBufferObject(mFSAA);
+		mFB = cm_new<GLFrameBufferObject, PoolAlloc>(mFSAA);
 
 
 		GLSurfaceDesc surfaceDesc;
 		GLSurfaceDesc surfaceDesc;
 		surfaceDesc.numSamples = mFSAA;
 		surfaceDesc.numSamples = mFSAA;

+ 1 - 1
CamelotGLRenderer/Source/CmWin32GLSupport.cpp

@@ -65,7 +65,7 @@ namespace CamelotFramework
 			desc.platformSpecific["parentWindowHandle"] = toString((unsigned long)hWnd);
 			desc.platformSpecific["parentWindowHandle"] = toString((unsigned long)hWnd);
 		}
 		}
 
 
-		Win32Window* window = CM_NEW(Win32Window, PoolAlloc) Win32Window(desc, *this);
+		Win32Window* window = new (cm_alloc<Win32Window, PoolAlloc>()) Win32Window(desc, *this);
 		
 		
 		// TODO - Looking for monitors is disabled for now, as it should be done on the render thread and I need to port it but 
 		// TODO - Looking for monitors is disabled for now, as it should be done on the render thread and I need to port it but 
 		//  I don't feel like it at the moment. Plus I'll probably implemented a more streamlined approach to this anyway.
 		//  I don't feel like it at the moment. Plus I'll probably implemented a more streamlined approach to this anyway.

+ 1 - 1
CamelotGLRenderer/Source/CmWin32Window.cpp

@@ -365,7 +365,7 @@ namespace CamelotFramework {
 		}
 		}
 
 
 		// Create RenderSystem context
 		// Create RenderSystem context
-		mContext = CM_NEW(Win32Context, GenAlloc) Win32Context(mHDC, mGlrc);
+		mContext = cm_new<Win32Context>(mHDC, mGlrc);
 
 
 		RenderWindow::initialize_internal();
 		RenderWindow::initialize_internal();
 	}
 	}

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

@@ -245,7 +245,7 @@ CPreprocessor::ErrorHandlerFunc CPreprocessor::ErrorHandler = DefaultError;
 
 
 CPreprocessor::Macro::~Macro()
 CPreprocessor::Macro::~Macro()
 { 
 { 
-	CM_DELETE_ARRAY(Args, Token, NumArgs, ScratchAlloc); 
+	cm_deleteN<ScratchAlloc>(Args, NumArgs);
 	CM_DELETE(Next, Macro, ScratchAlloc); 
 	CM_DELETE(Next, Macro, ScratchAlloc); 
 }
 }
 
 
@@ -427,7 +427,7 @@ CPreprocessor::Token CPreprocessor::ExpandMacro (const Token &iToken)
             Token t = GetArguments (nargs, args, cur->ExpandFunc ? false : true);
             Token t = GetArguments (nargs, args, cur->ExpandFunc ? false : true);
             if (t.Type == Token::TK_ERROR)
             if (t.Type == Token::TK_ERROR)
             {
             {
-                CM_DELETE_ARRAY(args, Token, nargs, ScratchAlloc);
+                cm_deleteN<ScratchAlloc>(args, nargs);
                 return t;
                 return t;
             }
             }
 
 
@@ -456,7 +456,7 @@ CPreprocessor::Token CPreprocessor::ExpandMacro (const Token &iToken)
             cur->Expand (nargs, args, MacroList);
             cur->Expand (nargs, args, MacroList);
         t.AppendNL (Line - old_line);
         t.AppendNL (Line - old_line);
 
 
-		CM_DELETE_ARRAY(args, Token, nargs, ScratchAlloc);
+		cm_deleteN<ScratchAlloc>(args, nargs);
 
 
         return t;
         return t;
     }
     }
@@ -867,7 +867,7 @@ CPreprocessor::Token CPreprocessor::GetArguments (int &oNumArgs, Token *&oArgs,
 
 
 Done:
 Done:
     oNumArgs = nargs;
     oNumArgs = nargs;
-    oArgs = CM_NEW_ARRAY(Token, nargs, ScratchAlloc);
+    oArgs = cm_newN<Token, ScratchAlloc>(nargs);
     for (int i = 0; i < nargs; i++)
     for (int i = 0; i < nargs; i++)
         oArgs [i] = args [i];
         oArgs [i] = args [i];
     return t;
     return t;
@@ -885,7 +885,7 @@ bool CPreprocessor::HandleDefine (Token &iBody, int iLine)
         return false;
         return false;
     }
     }
 
 
-    Macro *m = CM_NEW(Macro, ScratchAlloc) Macro (t);
+    Macro *m = cm_new<Macro, ScratchAlloc>(t);
     m->Body = iBody;
     m->Body = iBody;
     t = cpp.GetArguments (m->NumArgs, m->Args, false);
     t = cpp.GetArguments (m->NumArgs, m->Args, false);
     while (t.Type == Token::TK_WHITESPACE)
     while (t.Type == Token::TK_WHITESPACE)
@@ -1153,7 +1153,7 @@ Done:
 void CPreprocessor::Define (const char *iMacroName, size_t iMacroNameLen,
 void CPreprocessor::Define (const char *iMacroName, size_t iMacroNameLen,
                             const char *iMacroValue, size_t iMacroValueLen)
                             const char *iMacroValue, size_t iMacroValueLen)
 {
 {
-    Macro *m = CM_NEW(Macro, ScratchAlloc) Macro (Token (Token::TK_KEYWORD, iMacroName, iMacroNameLen));
+    Macro *m = cm_new<Macro, ScratchAlloc>(Token (Token::TK_KEYWORD, iMacroName, iMacroNameLen));
     m->Value = Token (Token::TK_TEXT, iMacroValue, iMacroValueLen);
     m->Value = Token (Token::TK_TEXT, iMacroValue, iMacroValueLen);
     m->Next = MacroList;
     m->Next = MacroList;
     MacroList = m;
     MacroList = m;
@@ -1162,7 +1162,7 @@ void CPreprocessor::Define (const char *iMacroName, size_t iMacroNameLen,
 void CPreprocessor::Define (const char *iMacroName, size_t iMacroNameLen,
 void CPreprocessor::Define (const char *iMacroName, size_t iMacroNameLen,
                             long iMacroValue)
                             long iMacroValue)
 {
 {
-    Macro *m = CM_NEW(Macro, ScratchAlloc) Macro (Token (Token::TK_KEYWORD, iMacroName, iMacroNameLen));
+    Macro *m = cm_new<Macro, ScratchAlloc>(Token (Token::TK_KEYWORD, iMacroName, iMacroNameLen));
     m->Value.SetValue (iMacroValue);
     m->Value.SetValue (iMacroValue);
     m->Next = MacroList;
     m->Next = MacroList;
     MacroList = m;
     MacroList = m;

+ 2 - 2
CamelotGLRenderer/Source/GLSL/src/CmGLSLProgramFactory.cpp

@@ -41,14 +41,14 @@ namespace CamelotFramework {
     HighLevelGpuProgramPtr GLSLProgramFactory::create(const String& source, const String& entryPoint, 
     HighLevelGpuProgramPtr GLSLProgramFactory::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)
     {
     {
-		GLSLProgram* prog = CM_NEW(GLSLProgram, PoolAlloc) GLSLProgram(source, entryPoint, sLanguageName, gptype, profile, includes);
+		GLSLProgram* prog = new (cm_alloc<GLSLProgram, PoolAlloc>()) GLSLProgram(source, entryPoint, sLanguageName, gptype, profile, includes);
 
 
 		return HighLevelGpuProgramPtr(prog, &CoreObject::_deleteDelayed<GLSLProgram, PoolAlloc>);
 		return HighLevelGpuProgramPtr(prog, &CoreObject::_deleteDelayed<GLSLProgram, PoolAlloc>);
     }
     }
 	//-----------------------------------------------------------------------
 	//-----------------------------------------------------------------------
 	HighLevelGpuProgramPtr GLSLProgramFactory::create()
 	HighLevelGpuProgramPtr GLSLProgramFactory::create()
 	{
 	{
-		GLSLProgram* prog = CM_NEW(GLSLProgram, PoolAlloc) GLSLProgram("", "", sLanguageName, GPT_VERTEX_PROGRAM, GPP_NONE, nullptr);
+		GLSLProgram* prog = new (cm_alloc<GLSLProgram, PoolAlloc>()) GLSLProgram("", "", sLanguageName, GPT_VERTEX_PROGRAM, GPP_NONE, nullptr);
 
 
 		return HighLevelGpuProgramPtr(prog, &CoreObject::_deleteDelayed<GLSLProgram, PoolAlloc>);
 		return HighLevelGpuProgramPtr(prog, &CoreObject::_deleteDelayed<GLSLProgram, PoolAlloc>);
 	}
 	}

+ 1 - 1
CamelotGLRenderer/Source/win32/CmGLUtil.h

@@ -35,7 +35,7 @@ namespace CamelotFramework {
     
     
 inline GLSupport* getGLSupport()
 inline GLSupport* getGLSupport()
 {
 {
-    return CM_NEW(Win32GLSupport, GenAlloc) Win32GLSupport();
+    return cm_new<Win32GLSupport>();
 }
 }
 
 
 };
 };

+ 1 - 1
CamelotGLRenderer/Source/win32/CmWin32Context.cpp

@@ -77,7 +77,7 @@ WGLEWContext * wglewGetContext()
 	WGLEWContext * currentWGLEWContextsPtr = CM_THREAD_POINTER_GET(WGLEWContextsPtr);
 	WGLEWContext * currentWGLEWContextsPtr = CM_THREAD_POINTER_GET(WGLEWContextsPtr);
 	if (currentWGLEWContextsPtr == NULL)
 	if (currentWGLEWContextsPtr == NULL)
 	{
 	{
-		currentWGLEWContextsPtr = CM_NEW(WGLEWContext, GenAlloc) WGLEWContext();
+		currentWGLEWContextsPtr = cm_new<WGLEWContext>();
 		CM_THREAD_POINTER_SET(WGLEWContextsPtr, currentWGLEWContextsPtr);
 		CM_THREAD_POINTER_SET(WGLEWContextsPtr, currentWGLEWContextsPtr);
 		ZeroMemory(currentWGLEWContextsPtr, sizeof(WGLEWContext));
 		ZeroMemory(currentWGLEWContextsPtr, sizeof(WGLEWContext));
 		wglewInit();
 		wglewInit();

+ 10 - 6
CamelotUtility/Include/CmMemoryAllocator.h

@@ -106,9 +106,9 @@ namespace CamelotFramework
 	}
 	}
 
 
 	template<class T, class category> 
 	template<class T, class category> 
-	inline T* cm_new(UINT32 count)
+	inline T* cm_alloc()
 	{
 	{
-		return new (cm_alloc<category>(count)) T();
+		return (T*)MemoryAllocator<category>::allocate(sizeof(T));
 	}
 	}
 
 
 	template<class T, class category> 
 	template<class T, class category> 
@@ -128,7 +128,7 @@ namespace CamelotFramework
 		return new (cm_alloc<category>(sizeof(Type))) Type(BOOST_PP_ENUM_PARAMS (n, t));     \
 		return new (cm_alloc<category>(sizeof(Type))) Type(BOOST_PP_ENUM_PARAMS (n, t));     \
 	}
 	}
 
 
-	BOOST_PP_REPEAT(9, MAKE_CM_NEW, ~)
+	BOOST_PP_REPEAT(15, MAKE_CM_NEW, ~)
 
 
 #undef MAKE_CM_NEW
 #undef MAKE_CM_NEW
 
 
@@ -164,6 +164,12 @@ namespace CamelotFramework
 		return MemoryAllocator<GenAlloc>::allocate(count);
 		return MemoryAllocator<GenAlloc>::allocate(count);
 	}
 	}
 
 
+	template<class T> 
+	inline T* cm_alloc()
+	{
+		return (T*)MemoryAllocator<GenAlloc>::allocate(sizeof(T));
+	}
+
 	template<class T> 
 	template<class T> 
 	inline T* cm_newN(UINT32 count)
 	inline T* cm_newN(UINT32 count)
 	{
 	{
@@ -181,7 +187,7 @@ namespace CamelotFramework
 	return new (cm_alloc<GenAlloc>(sizeof(Type))) Type(BOOST_PP_ENUM_PARAMS (n, t));     \
 	return new (cm_alloc<GenAlloc>(sizeof(Type))) Type(BOOST_PP_ENUM_PARAMS (n, t));     \
 	}
 	}
 
 
-	BOOST_PP_REPEAT(9, MAKE_CM_NEW, ~)
+		BOOST_PP_REPEAT(15, MAKE_CM_NEW, ~)
 
 
 #undef MAKE_CM_NEW
 #undef MAKE_CM_NEW
 
 
@@ -209,9 +215,7 @@ namespace CamelotFramework
 }
 }
 
 
 #define CM_NEW(T, category) new (CamelotFramework::MemoryAllocator<category>::allocate(sizeof(T)))
 #define CM_NEW(T, category) new (CamelotFramework::MemoryAllocator<category>::allocate(sizeof(T)))
-#define CM_NEW_ARRAY(T, count, category) CamelotFramework::__cm_construct_array<T, category>(count)
 #define CM_DELETE(ptr, T, category) {(ptr)->~T(); CamelotFramework::MemoryAllocator<category>::free(ptr);}
 #define CM_DELETE(ptr, T, category) {(ptr)->~T(); CamelotFramework::MemoryAllocator<category>::free(ptr);}
-#define CM_DELETE_ARRAY(ptr, T, count, category) CamelotFramework::cm_deleteN<category>(ptr, count)
 
 
 namespace CamelotFramework
 namespace CamelotFramework
 {
 {

+ 7 - 7
CamelotUtility/Include/CmRTTIType.h

@@ -581,7 +581,7 @@ namespace CamelotFramework
 		void addPlainField(const std::string& name, UINT32 uniqueId, boost::any getter, boost::any setter, UINT64 flags)
 		void addPlainField(const std::string& name, UINT32 uniqueId, boost::any getter, boost::any setter, UINT64 flags)
 		{
 		{
 			RTTIPlainField<DataType, ObjectType>* newField = 
 			RTTIPlainField<DataType, ObjectType>* newField = 
-				CM_NEW(RTTIPlainField<DataType BOOST_PP_COMMA() ObjectType>, GenAlloc) RTTIPlainField<DataType, ObjectType>();
+				cm_new<RTTIPlainField<DataType, ObjectType>>();
 			newField->initSingle(name, uniqueId, getter, setter, flags);
 			newField->initSingle(name, uniqueId, getter, setter, flags);
 			addNewField(newField);
 			addNewField(newField);
 		}
 		}
@@ -593,7 +593,7 @@ namespace CamelotFramework
 				"Invalid data type for complex field. It needs to derive from CamelotFramework::IReflectable.");
 				"Invalid data type for complex field. It needs to derive from CamelotFramework::IReflectable.");
 
 
 			RTTIReflectableField<DataType, ObjectType>* newField = 
 			RTTIReflectableField<DataType, ObjectType>* newField = 
-				CM_NEW(RTTIReflectableField<DataType BOOST_PP_COMMA() ObjectType>, GenAlloc) RTTIReflectableField<DataType, ObjectType>();
+				cm_new<RTTIReflectableField<DataType, ObjectType>>();
 			newField->initSingle(name, uniqueId, getter, setter, flags);
 			newField->initSingle(name, uniqueId, getter, setter, flags);
 			addNewField(newField);
 			addNewField(newField);
 		}
 		}
@@ -608,7 +608,7 @@ namespace CamelotFramework
 				checkForCircularReferences<DataType>();
 				checkForCircularReferences<DataType>();
 
 
 			RTTIReflectablePtrField<DataType, ObjectType>* newField = 
 			RTTIReflectablePtrField<DataType, ObjectType>* newField = 
-				CM_NEW(RTTIReflectablePtrField<DataType BOOST_PP_COMMA() ObjectType>, GenAlloc) RTTIReflectablePtrField<DataType, ObjectType>();
+				cm_new<RTTIReflectablePtrField<DataType, ObjectType>>();
 			newField->initSingle(name, uniqueId, getter, setter, flags);
 			newField->initSingle(name, uniqueId, getter, setter, flags);
 			addNewField(newField);
 			addNewField(newField);
 		}
 		}
@@ -618,7 +618,7 @@ namespace CamelotFramework
 			boost::any setter, boost::any setSize, UINT64 flags)
 			boost::any setter, boost::any setSize, UINT64 flags)
 		{
 		{
 			RTTIPlainField<DataType, ObjectType>* newField = 
 			RTTIPlainField<DataType, ObjectType>* newField = 
-				CM_NEW(RTTIPlainField<DataType BOOST_PP_COMMA() ObjectType>, GenAlloc) RTTIPlainField<DataType, ObjectType>();
+				cm_new<RTTIPlainField<DataType, ObjectType>>();
 			newField->initArray(name, uniqueId, getter, getSize, setter, setSize, flags);
 			newField->initArray(name, uniqueId, getter, getSize, setter, setSize, flags);
 			addNewField(newField);
 			addNewField(newField);
 		}	
 		}	
@@ -631,7 +631,7 @@ namespace CamelotFramework
 				"Invalid data type for complex field. It needs to derive from CamelotFramework::IReflectable.");
 				"Invalid data type for complex field. It needs to derive from CamelotFramework::IReflectable.");
 
 
 			RTTIReflectableField<DataType, ObjectType>* newField = 
 			RTTIReflectableField<DataType, ObjectType>* newField = 
-				CM_NEW(RTTIReflectableField<DataType BOOST_PP_COMMA() ObjectType>, GenAlloc) RTTIReflectableField<DataType, ObjectType>();
+				cm_new<RTTIReflectableField<DataType, ObjectType>>();
 			newField->initArray(name, uniqueId, getter, getSize, setter, setSize, flags);
 			newField->initArray(name, uniqueId, getter, getSize, setter, setSize, flags);
 			addNewField(newField);
 			addNewField(newField);
 		}
 		}
@@ -647,7 +647,7 @@ namespace CamelotFramework
 				checkForCircularReferences<DataType>();
 				checkForCircularReferences<DataType>();
 
 
 			RTTIReflectablePtrField<DataType, ObjectType>* newField = 
 			RTTIReflectablePtrField<DataType, ObjectType>* newField = 
-				CM_NEW(RTTIReflectablePtrField<DataType BOOST_PP_COMMA() ObjectType>, GenAlloc) RTTIReflectablePtrField<DataType, ObjectType>();
+				cm_new<RTTIReflectablePtrField<DataType, ObjectType>>();
 			newField->initArray(name, uniqueId, getter, getSize, setter, setSize, flags);
 			newField->initArray(name, uniqueId, getter, getSize, setter, setSize, flags);
 			addNewField(newField);
 			addNewField(newField);
 		}
 		}
@@ -656,7 +656,7 @@ namespace CamelotFramework
 		void addDataBlockField(const std::string& name, UINT32 uniqueId, boost::any getter, boost::any setter, UINT64 flags, boost::any customAllocator = boost::any())
 		void addDataBlockField(const std::string& name, UINT32 uniqueId, boost::any getter, boost::any setter, UINT64 flags, boost::any customAllocator = boost::any())
 		{
 		{
 			RTTIManagedDataBlockField<ManagedDataBlock, ObjectType>* newField = 
 			RTTIManagedDataBlockField<ManagedDataBlock, ObjectType>* newField = 
-				CM_NEW(RTTIManagedDataBlockField<ManagedDataBlock BOOST_PP_COMMA() ObjectType>, GenAlloc) RTTIManagedDataBlockField<ManagedDataBlock, ObjectType>();
+				cm_new<RTTIManagedDataBlockField<ManagedDataBlock, ObjectType>>();
 			newField->initSingle(name, uniqueId, getter,  setter, flags, customAllocator);
 			newField->initSingle(name, uniqueId, getter,  setter, flags, customAllocator);
 			addNewField(newField);
 			addNewField(newField);
 		}	
 		}	

+ 20 - 7
CamelotUtility/Include/CmStdHeaders.h

@@ -28,6 +28,7 @@
 
 
 #include <memory>
 #include <memory>
 #include <boost/shared_array.hpp>
 #include <boost/shared_array.hpp>
+#include <boost/preprocessor.hpp>
 
 
 // STL containers
 // STL containers
 #include <vector>
 #include <vector>
@@ -206,13 +207,25 @@ namespace CamelotFramework
 		typedef typename std::unordered_multimap<K, V, H, C, A> type; 
 		typedef typename std::unordered_multimap<K, V, H, C, A> type; 
 	}; 
 	}; 
 
 
-//#define MAKE_CM_MAKE_SHARED(z, n, unused)                                     \
-//	template<class Type, class category BOOST_PP_ENUM_TRAILING_PARAMS(n, class T)>     \
-//	Type* cm_make_shared(BOOST_PP_ENUM_BINARY_PARAMS(n, T, t) ) { \
-//	return std::allocate_shared<Type>(StdAlloc<category> BOOST_PP_ENUM_TRAILING_PARAMS (n, t));     \
-//	}
-//
-//	BOOST_PP_REPEAT(9, MAKE_CM_MAKE_SHARED, ~)
+#define MAKE_CM_NEW_SHARED(z, n, unused)                                     \
+	template<class Type, class category BOOST_PP_ENUM_TRAILING_PARAMS(n, class T)>     \
+	std::shared_ptr<Type> cm_new_shared(BOOST_PP_ENUM_BINARY_PARAMS(n, T, t) ) { \
+	return std::allocate_shared<Type>(StdAlloc<category>() BOOST_PP_ENUM_TRAILING_PARAMS (n, t));     \
+	}
+
+	BOOST_PP_REPEAT(9, MAKE_CM_NEW_SHARED, ~)
+
+#undef MAKE_CM_NEW_SHARED
+
+#define MAKE_CM_NEW_SHARED(z, n, unused)                                     \
+	template<class Type BOOST_PP_ENUM_TRAILING_PARAMS(n, class T)>     \
+	std::shared_ptr<Type> cm_new_shared(BOOST_PP_ENUM_BINARY_PARAMS(n, T, t) ) { \
+	return std::allocate_shared<Type>(StdAlloc<GenAlloc>() BOOST_PP_ENUM_TRAILING_PARAMS (n, t));     \
+	}
+
+	BOOST_PP_REPEAT(9, MAKE_CM_NEW_SHARED, ~)
+
+#undef MAKE_CM_NEW_SHARED
 
 
 	// TODO - Once VC2012 grows up and adds proper C++11 support, uncomment this
 	// TODO - Once VC2012 grows up and adds proper C++11 support, uncomment this
 	//template <typename T, typename A = char> 
 	//template <typename T, typename A = char> 

+ 2 - 2
CamelotUtility/Source/CmDebug.cpp

@@ -45,14 +45,14 @@ namespace CamelotFramework
 		DataStreamPtr ds = FileSystem::create(filePath);
 		DataStreamPtr ds = FileSystem::create(filePath);
 
 
 		UINT32 bmpDataSize = BitmapWriter::getBMPSize(width, height, bytesPerPixel);
 		UINT32 bmpDataSize = BitmapWriter::getBMPSize(width, height, bytesPerPixel);
-		UINT8* bmpBuffer = CM_NEW_ARRAY(UINT8, bmpDataSize, ScratchAlloc);
+		UINT8* bmpBuffer = cm_newN<UINT8, ScratchAlloc>(bmpDataSize);
 
 
 		BitmapWriter::rawPixelsToBMP(rawPixels, bmpBuffer, width, height, bytesPerPixel);
 		BitmapWriter::rawPixelsToBMP(rawPixels, bmpBuffer, width, height, bytesPerPixel);
 
 
 		ds->write(bmpBuffer, bmpDataSize);
 		ds->write(bmpBuffer, bmpDataSize);
 		ds->close();
 		ds->close();
 
 
-		CM_DELETE_ARRAY(bmpBuffer, UINT8, bmpDataSize, ScratchAlloc);
+		cm_deleteN<ScratchAlloc>(bmpBuffer, bmpDataSize);
 	}
 	}
 
 
 	CM_UTILITY_EXPORT Debug& gDebug()
 	CM_UTILITY_EXPORT Debug& gDebug()

+ 3 - 3
CamelotUtility/Source/CmDynLibManager.cpp

@@ -44,7 +44,7 @@ namespace CamelotFramework
 		}
 		}
 		else
 		else
 		{
 		{
-	        DynLib* pLib = CM_NEW(DynLib, GenAlloc) DynLib(filename);
+	        DynLib* pLib = cm_new<DynLib>(filename);
 			pLib->load();        
 			pLib->load();        
         	mLibList[filename] = pLib;
         	mLibList[filename] = pLib;
 	        return pLib;
 	        return pLib;
@@ -59,7 +59,7 @@ namespace CamelotFramework
 			mLibList.erase(i);
 			mLibList.erase(i);
 		}
 		}
 		lib->unload();
 		lib->unload();
-		CM_DELETE(lib, DynLib, GenAlloc);
+		cm_delete(lib);
 	}
 	}
 	//-----------------------------------------------------------------------
 	//-----------------------------------------------------------------------
     DynLibManager::~DynLibManager()
     DynLibManager::~DynLibManager()
@@ -68,7 +68,7 @@ namespace CamelotFramework
         for( DynLibList::iterator it = mLibList.begin(); it != mLibList.end(); ++it )
         for( DynLibList::iterator it = mLibList.begin(); it != mLibList.end(); ++it )
         {
         {
             it->second->unload();
             it->second->unload();
-			CM_DELETE(it->second, DynLib, GenAlloc);
+			cm_delete(it->second);
         }
         }
 
 
         // Empty the list
         // Empty the list

+ 2 - 2
CamelotUtility/Source/CmFileSystem.cpp

@@ -67,12 +67,12 @@ namespace CamelotFramework
 		if (rwStream)
 		if (rwStream)
 		{
 		{
 			// use the writeable stream 
 			// use the writeable stream 
-			stream = CM_NEW(FileDataStream, ScratchAlloc) FileDataStream(fullPath, rwStream, (size_t)tagStat.st_size, true);
+			stream = cm_new<FileDataStream, ScratchAlloc>(fullPath, rwStream, (size_t)tagStat.st_size, true);
 		}
 		}
 		else
 		else
 		{
 		{
 			// read-only stream
 			// read-only stream
-			stream = CM_NEW(FileDataStream, ScratchAlloc) FileDataStream(fullPath, roStream, (size_t)tagStat.st_size, true);
+			stream = cm_new<FileDataStream, ScratchAlloc>(fullPath, roStream, (size_t)tagStat.st_size, true);
 		}
 		}
 		return DataStreamPtr(stream, &MemAllocDeleter<FileDataStream, ScratchAlloc>::deleter);
 		return DataStreamPtr(stream, &MemAllocDeleter<FileDataStream, ScratchAlloc>::deleter);
 	}
 	}

+ 3 - 3
CamelotUtility/Source/CmLog.cpp

@@ -17,12 +17,12 @@ namespace CamelotFramework
 		flush();
 		flush();
 
 
 		for(auto iter = mEntries.begin(); iter != mEntries.end(); ++iter)
 		for(auto iter = mEntries.begin(); iter != mEntries.end(); ++iter)
-			CM_DELETE(*iter, LogEntry, PoolAlloc);
+			cm_delete<PoolAlloc>(*iter);
 	}
 	}
 
 
 	void Log::logMsg(const String& message, const String& level)
 	void Log::logMsg(const String& message, const String& level)
 	{
 	{
-		LogEntry* newEntry = CM_NEW(LogEntry, PoolAlloc) LogEntry(message, level);
+		LogEntry* newEntry = cm_new<LogEntry, PoolAlloc>(message, level);
 		mEntries.push_back(newEntry);
 		mEntries.push_back(newEntry);
 
 
 		doOnEntryAdded(*newEntry);
 		doOnEntryAdded(*newEntry);
@@ -34,7 +34,7 @@ namespace CamelotFramework
 	void Log::clear()
 	void Log::clear()
 	{
 	{
 		for(auto iter = mEntries.begin(); iter != mEntries.end(); ++iter)
 		for(auto iter = mEntries.begin(); iter != mEntries.end(); ++iter)
-			CM_DELETE(*iter, LogEntry, PoolAlloc);
+			cm_delete<PoolAlloc>(*iter);
 
 
 		mEntries.clear();
 		mEntries.clear();
 
 

+ 1 - 1
CamelotUtility/Source/CmRTTIType.cpp

@@ -9,7 +9,7 @@ namespace CamelotFramework
 	RTTITypeBase::~RTTITypeBase() 
 	RTTITypeBase::~RTTITypeBase() 
 	{
 	{
 		for(auto iter = mFields.begin(); iter != mFields.end(); ++iter)
 		for(auto iter = mFields.begin(); iter != mFields.end(); ++iter)
-			CM_DELETE(*iter, RTTIField, GenAlloc);
+			cm_delete(*iter);
 
 
 		mFields.clear();
 		mFields.clear();
 	}
 	}

+ 2 - 2
CamelotUtility/Source/CmTexAtlasGenerator.cpp

@@ -17,7 +17,7 @@ namespace CamelotFramework
 		~TexAtlasNode()
 		~TexAtlasNode()
 		{
 		{
 			if(children != nullptr)
 			if(children != nullptr)
-				CM_DELETE_ARRAY(children, TexAtlasNode, 2, ScratchAlloc);
+				cm_deleteN<ScratchAlloc>(children, 2);
 
 
 			int myVal = *cm_new<int, GenAlloc>();
 			int myVal = *cm_new<int, GenAlloc>();
 			float myVal2 = *cm_new<float, GenAlloc>();
 			float myVal2 = *cm_new<float, GenAlloc>();
@@ -63,7 +63,7 @@ namespace CamelotFramework
 				float dw = (float)(width - element.input.width);
 				float dw = (float)(width - element.input.width);
 				float dh = (height - element.input.height) * aspect;
 				float dh = (height - element.input.height) * aspect;
 
 
-				children = CM_NEW_ARRAY(TexAtlasNode, 2, ScratchAlloc);
+				children = cm_newN<TexAtlasNode, ScratchAlloc>(2);
 
 
 				if (dw > dh)
 				if (dw > dh)
 				{
 				{

+ 2 - 2
CamelotUtility/Source/CmTime.cpp

@@ -8,13 +8,13 @@ namespace CamelotFramework
 	Time::Time()
 	Time::Time()
 		:mAppStartTime(0), mLastFrameTime(0), mFrameDelta(0.0f), mTimeSinceStart(0.0f), mCurrentFrame(0)
 		:mAppStartTime(0), mLastFrameTime(0), mFrameDelta(0.0f), mTimeSinceStart(0.0f), mCurrentFrame(0)
 	{
 	{
-		mTimer = CM_NEW(Timer, GenAlloc) Timer();
+		mTimer = cm_new<Timer>();
 		mAppStartTime = mTimer->getMicroseconds();
 		mAppStartTime = mTimer->getMicroseconds();
 	}
 	}
 
 
 	Time::~Time()
 	Time::~Time()
 	{
 	{
-		CM_DELETE(mTimer, Timer, GenAlloc);
+		cm_delete(mTimer);
 	}
 	}
 
 
 	void Time::update()
 	void Time::update()

+ 4 - 4
CamelotUtility/Source/CmWorkQueue.cpp

@@ -62,7 +62,7 @@ namespace CamelotFramework {
 
 
 		mShuttingDown = false;
 		mShuttingDown = false;
 
 
-		mWorkerFunc = CM_NEW(WorkerFunc, GenAlloc) WorkerFunc(this);
+		mWorkerFunc = cm_new<WorkerFunc>(this);
 
 
 #if CM_THREAD_SUPPORT
 #if CM_THREAD_SUPPORT
 		for (UINT8 i = 0; i < mWorkerThreadCount; ++i)
 		for (UINT8 i = 0; i < mWorkerThreadCount; ++i)
@@ -97,7 +97,7 @@ namespace CamelotFramework {
 
 
 			if (mWorkerFunc != nullptr)
 			if (mWorkerFunc != nullptr)
 			{
 			{
-				CM_DELETE(mWorkerFunc, WorkerFunc, GenAlloc);
+				cm_delete(mWorkerFunc);
 				mWorkerFunc = nullptr;
 				mWorkerFunc = nullptr;
 			}
 			}
 
 
@@ -202,7 +202,7 @@ namespace CamelotFramework {
 					return 0;
 					return 0;
 
 
 			rid = ++mRequestCount;
 			rid = ++mRequestCount;
-			req = CM_NEW(Request, ScratchAlloc) Request(channel, rData, retryCount, rid);
+			req = cm_new<Request, ScratchAlloc>(channel, rData, retryCount, rid);
 
 
 #if CM_THREAD_SUPPORT
 #if CM_THREAD_SUPPORT
 			if (!forceSynchronous)
 			if (!forceSynchronous)
@@ -229,7 +229,7 @@ namespace CamelotFramework {
 		if (mShuttingDown)
 		if (mShuttingDown)
 			return;
 			return;
 
 
-		Request* req = CM_NEW(Request, ScratchAlloc) Request(channel, rData, retryCount, rid);
+		Request* req = cm_new<Request, ScratchAlloc>(channel, rData, retryCount, rid);
 
 
 #if CM_THREAD_SUPPORT
 #if CM_THREAD_SUPPORT
 		mRequestQueue.push_back(req);
 		mRequestQueue.push_back(req);

+ 10 - 7
TODO.txt

@@ -36,16 +36,19 @@ IMMEDIATE:
   - Add support for bold (and maybe italic) fonts in Font importer
   - Add support for bold (and maybe italic) fonts in Font importer
   - Add support to disable aliasing when importing font
   - Add support to disable aliasing when importing font
 
 
-std::shared_ptr
-std::vector, map, set, unordered_map, unordered_set should all use an allocator. 
- - Primarily so I can track allocations
+  fix up cm_new and cm_newN so they don't use placement new and instead manually call constructor through a func ptr so I can call
+   methods with private constructors. HOWEVER this defeats the purpsoe of a private constructor...So maybe just use macro CM_NEW for those objects?
 
 
+port remaining CM_NEW/CM_DELETE calls
+port std::shared_ptr. Make specialized versions that call CoreObject deleter and MemAlloc deleter.
+ - Make sure it uses a custom allocator
 
 
-make sure to find all std:: calls and replace them with my own
+ get rid of BOOST_PP_COMMA (remove headers referencing it as well)
+ get rid of MemAllocDeleter::deleter
+
+ maybe also add cm_stack_alloc, cm_stack_freeAll
+and cm_pool_new, cm_pool_delete
 
 
-  Make CM_NEW more friendly?
- Maybe a template instead of macro, with default allocation type?
- Also CM_DELETE so I don't have to use BOOST_PP_COMMA and specify templates exactly when calling delete
 
 
 And when I'm adding allocators to SharedPtr attempt to get rid of ugly-ass custom deleters and make just one easier to use shared_ptr wrapper.
 And when I'm adding allocators to SharedPtr attempt to get rid of ugly-ass custom deleters and make just one easier to use shared_ptr wrapper.