2
0
Marko Pintera 12 жил өмнө
parent
commit
c1aeb526d6

+ 0 - 7
CamelotCore/Include/CmIndexData.h

@@ -20,13 +20,6 @@ namespace CamelotEngine
 		/// The number of indexes to use from the buffer
 		UINT32 indexCount;
 
-		/** Clones this index data, potentially including replicating the index buffer.
-		@param copyData Whether to create new buffers too or just reference the existing ones
-		@param mgr If supplied, the buffer manager through which copies should be made
-		@remarks The caller is expected to delete the returned pointer when finished
-		*/
-		IndexData* clone(bool copyData = true, HardwareBufferManager* mgr = 0) const;
-
 		/** Re-order the indexes in this index data structure to be more
 			vertex cache friendly; that is to re-use the same vertices as close
 			together as possible. 

+ 0 - 7
CamelotCore/Include/CmVertexData.h

@@ -77,13 +77,6 @@ namespace CamelotEngine {
 		UINT32 getBufferCount(void) const { return (UINT32)mVertexBuffers.size(); }
 		UINT32 getMaxBufferIndex(void) const { return (UINT32)mVertexBuffers.size(); }
 
-		/** Clones this vertex data, potentially including replicating any vertex buffers.
-		@param copyData Whether to create new vertex buffers too or just reference the existing ones
-		@param mgr If supplied, the buffer manager through which copies should be made
-		@remarks The caller is expected to delete the returned pointer when ready
-		*/
-		VertexData* clone(bool copyData = true, HardwareBufferManager* mgr = 0) const;
-
 		/** Convert all packed colour values (VET_COLOUR_*) in buffers used to
 			another type.
 		@param srcType The source colour type to assume if the ambiguous VET_COLOUR

+ 2 - 1
CamelotCore/Source/CmCamera.cpp

@@ -87,7 +87,8 @@ namespace CamelotEngine {
     }
 	void Camera::init(RenderTargetPtr target, float left, float top, float width, float height, int ZOrder)
 	{
-		mViewport = ViewportPtr(new Viewport(target, left, top, width, height, ZOrder));
+		mViewport = ViewportPtr(CM_NEW(Viewport, PoolAlloc) Viewport(target, left, top, width, height, ZOrder),
+			&MemAllocDeleter<Viewport, PoolAlloc>::deleter);
 	}
 	//-----------------------------------------------------------------------
 	void Camera::setFOVy(const Radian& fov)

+ 5 - 5
CamelotCore/Source/CmCommandQueue.cpp

@@ -10,7 +10,7 @@ namespace CamelotEngine
 	CommandQueue::CommandQueue(CM_THREAD_ID_TYPE threadId, bool allowAllThreads)
 		:mMyThreadId(threadId), mAllowAllThreads(allowAllThreads), mMaxDebugIdx(0)
 	{
-		mCommands = new std::queue<Command>();
+		mCommands = CM_NEW(std::queue<Command>, PoolAlloc) std::queue<Command>();
 
 		{
 			CM_LOCK_MUTEX(CommandQueueBreakpointMutex);
@@ -22,7 +22,7 @@ namespace CamelotEngine
 	CommandQueue::CommandQueue(CM_THREAD_ID_TYPE threadId, bool allowAllThreads)
 		:mMyThreadId(threadId), mAllowAllThreads(allowAllThreads)
 	{
-		mCommands = new std::queue<Command>();
+		mCommands = CM_NEW(std::queue<Command>, PoolAlloc) std::queue<Command>();
 	}
 #endif
 
@@ -38,7 +38,7 @@ namespace CamelotEngine
 #endif
 
 		if(mCommands != nullptr)
-			delete mCommands;
+			CM_DELETE(mCommands, std::queue<Command>, PoolAlloc);
 	}
 
 	AsyncOp CommandQueue::queueReturn(boost::function<void(AsyncOp&)> commandCallback, bool _notifyWhenComplete, UINT32 _callbackId)
@@ -104,7 +104,7 @@ namespace CamelotEngine
 			CM_LOCK_MUTEX(mCommandBufferMutex);
 
 			oldCommands = mCommands;
-			mCommands = new std::queue<Command>();
+			mCommands = CM_NEW(std::queue<Command>, PoolAlloc) std::queue<Command>();
 		}
 
 		return oldCommands;
@@ -150,7 +150,7 @@ namespace CamelotEngine
 			commands->pop();
 		}
 
-		delete commands;
+		CM_DELETE(commands, std::queue<Command>, PoolAlloc);
 	}
 
 	void CommandQueue::playback(std::queue<Command>* commands)

+ 2 - 2
CamelotCore/Source/CmDeferredRenderContext.cpp

@@ -9,7 +9,7 @@
 namespace CamelotEngine
 {
 	DeferredRenderContext::DeferredRenderContext(RenderSystem* rs, CM_THREAD_ID_TYPE threadId)
-		:mCommandQueue(new CommandQueue(threadId))
+		:mCommandQueue(CM_NEW(CommandQueue, GenAlloc) CommandQueue(threadId))
 		, mRenderSystem(rs)
 	{
 		assert(mRenderSystem != nullptr);
@@ -17,7 +17,7 @@ namespace CamelotEngine
 
 	DeferredRenderContext::~DeferredRenderContext()
 	{
-		delete mCommandQueue;
+		CM_DELETE(mCommandQueue, CommandQueue, GenAlloc);
 	}
 
 	void DeferredRenderContext::setViewport(ViewportPtr& vp)

+ 2 - 2
CamelotCore/Source/CmGUILabel.cpp

@@ -11,12 +11,12 @@ namespace CamelotEngine
 		// This is calling a virtual method but it's okay because we always want the one
 		// existing on this class.
 		mStyle = skin->getStyle(getGUITypeName());
-		mTextSprite = new TextSprite(text, mStyle->font, mStyle->fontSize);
+		mTextSprite = CM_NEW(TextSprite, PoolAlloc) TextSprite(text, mStyle->font, mStyle->fontSize);
 	}
 
 	GUILabel::~GUILabel()
 	{
-		delete mTextSprite;
+		CM_DELETE(mTextSprite, TextSprite, PoolAlloc);
 	}
 
 	UINT32 GUILabel::getNumRenderElements() const

+ 2 - 1
CamelotCore/Source/CmGUIWidget.cpp

@@ -93,7 +93,8 @@ namespace CamelotEngine
 		UINT32 numMeshes = 0;
 		for(auto& renderElem : meshDataPerRenderElement)
 		{
-			renderElem.second.meshData = std::shared_ptr<MeshData>(new MeshData());
+			renderElem.second.meshData = std::shared_ptr<MeshData>(CM_NEW(MeshData, PoolAlloc) MeshData(),
+				&MemAllocDeleter<MeshData, PoolAlloc>::deleter);
 			renderElem.second.vertices = renderElem.second.meshData->addPositionsVec2(renderElem.second.numQuads * 4);
 			renderElem.second.uvs = renderElem.second.meshData->addUV0(renderElem.second.numQuads * 4);
 			renderElem.second.indices = renderElem.second.meshData->addIndices32(renderElem.second.numQuads * 6);

+ 3 - 3
CamelotCore/Source/CmGpuBuffer.cpp

@@ -27,7 +27,7 @@ namespace CamelotEngine
 		for(auto iter = mBufferViews.begin(); iter != mBufferViews.end(); ++iter)
 		{
 			destroyView(iter->second->view);
-			delete iter->second;
+			CM_DELETE(iter->second, GpuBufferReference, PoolAlloc);
 		}
 
 		mBufferViews.clear();
@@ -47,7 +47,7 @@ namespace CamelotEngine
 		{
 			GpuBufferView* newView = buffer->createView();
 			newView->initialize(buffer, key);
-			buffer->mBufferViews[key] = new GpuBufferReference(newView);
+			buffer->mBufferViews[key] = CM_NEW(GpuBufferReference, PoolAlloc) GpuBufferReference(newView);
 
 			iterFind = buffer->mBufferViews.find(key);
 		}
@@ -75,7 +75,7 @@ namespace CamelotEngine
 			buffer->mBufferViews.erase(iterFind);
 
 			buffer->destroyView(toRemove->view);
-			delete toRemove;
+			CM_DELETE(toRemove, GpuBufferReference, PoolAlloc);
 		}
 	}
 }

+ 6 - 6
CamelotCore/Source/CmGpuParamBlock.cpp

@@ -6,7 +6,7 @@
 namespace CamelotEngine
 {
 	GpuParamBlockBuffer::GpuParamBlockBuffer(UINT32 size, GpuParamBlockUsage usage)
-		:mData(new UINT8[size]), mSize(size), mUsage(usage)
+		:mData(CM_NEW_BYTES(size, ScratchAlloc)), mSize(size), mUsage(usage)
 	{
 		memset(mData, 0, mSize);
 	}
@@ -14,7 +14,7 @@ namespace CamelotEngine
 	GpuParamBlockBuffer::~GpuParamBlockBuffer()
 	{
 		if(mData != nullptr)
-			delete[] mData;
+			CM_DELETE_BYTES(mData, ScratchAlloc);
 	}
 
 	void GpuParamBlockBuffer::writeAll(const void* data)
@@ -44,13 +44,13 @@ namespace CamelotEngine
 	GpuParamBlock::~GpuParamBlock()
 	{
 		if(mData != nullptr)
-			delete [] mData;
+			CM_DELETE_BYTES(mData, ScratchAlloc);
 	}
 
 	void GpuParamBlock::initialize(const GpuParamBlockDesc& desc, GpuParamBlockUsage usage)
 	{
 		mSize = desc.blockSize * sizeof(UINT32);
-		mData = new UINT8[mSize];
+		mData = CM_NEW_BYTES(mSize, ScratchAlloc);
 		memset(mData, 0, mSize);
 
 		mUsage = usage;
@@ -119,7 +119,7 @@ namespace CamelotEngine
 			// Need to copy the data, as non-render threads might modify
 			// the data before render thread has a chance to process it
 			// TODO - Use an allocator
-			UINT8* dataCopy = new UINT8[mSize];
+			UINT8* dataCopy = CM_NEW_BYTES(mSize, ScratchAlloc);
 			memcpy(dataCopy, mData, mSize);
 
 			queueGpuCommand(getThisPtr(), boost::bind(&GpuParamBlock::updateBuffer_internal, this, dataCopy));
@@ -132,7 +132,7 @@ namespace CamelotEngine
 
 		mBuffer->writeAll(data);
 
-		delete[] data;
+		CM_DELETE_BYTES(data, ScratchAlloc);
 	}
 
 	GpuParamBlockPtr GpuParamBlock::create(const GpuParamBlockDesc& desc)

+ 2 - 1
CamelotCore/Source/CmGpuProgram.cpp

@@ -92,7 +92,8 @@ namespace CamelotEngine
 	//---------------------------------------------------------------------
 	GpuParamsPtr GpuProgram::createParameters(void)
 	{
-		return GpuParamsPtr(new GpuParams(mParametersDesc));
+		return GpuParamsPtr(CM_NEW(GpuParams, PoolAlloc) GpuParams(mParametersDesc),
+			&MemAllocDeleter<GpuParams, PoolAlloc>::deleter);
 	}
     //-----------------------------------------------------------------------
     const String& GpuProgram::getLanguage(void) const

+ 2 - 1
CamelotCore/Source/CmGpuProgramImporter.cpp

@@ -45,6 +45,7 @@ namespace CamelotEngine
 
 	ImportOptionsPtr GpuProgramImporter::createImportOptions() const
 	{
-		return ImportOptionsPtr(new GpuProgramImportOptions());
+		return ImportOptionsPtr(CM_NEW(GpuProgramImportOptions, PoolAlloc) GpuProgramImportOptions(),
+			&MemAllocDeleter<GpuProgramImportOptions, PoolAlloc>::deleter);
 	}
 }

+ 0 - 22
CamelotCore/Source/CmIndexData.cpp

@@ -19,28 +19,6 @@ namespace CamelotEngine
 	{
 	}
 
-	IndexData* IndexData::clone(bool copyData, HardwareBufferManager* mgr) const
-	{
-		HardwareBufferManager* pManager = mgr ? mgr : HardwareBufferManager::instancePtr();
-		IndexData* dest = new IndexData();
-		if (indexBuffer.get())
-		{
-            if (copyData)
-            {
-			    dest->indexBuffer = pManager->createIndexBuffer(indexBuffer->getType(), indexBuffer->getNumIndexes(),
-				    indexBuffer->getUsage());
-			    dest->indexBuffer->copyData(*indexBuffer, 0, 0, indexBuffer->getSizeInBytes(), true);
-            }
-            else
-            {
-                dest->indexBuffer = indexBuffer;
-            }
-        }
-		dest->indexCount = indexCount;
-		dest->indexStart = indexStart;
-		return dest;
-	}
-
 	// Local Utility class for vertex cache optimizer
 	class Triangle
     {

+ 2 - 1
CamelotCore/Source/CmMaterialRTTI.cpp

@@ -37,7 +37,8 @@ namespace CamelotEngine
 	void MaterialRTTI::onSerializationStarted(IReflectable* obj)
 	{
 		Material* material = static_cast<Material*>(obj);
-		std::shared_ptr<MaterialParams> params = std::shared_ptr<MaterialParams>(new MaterialParams());
+		std::shared_ptr<MaterialParams> params = std::shared_ptr<MaterialParams>(CM_NEW(MaterialParams, ScratchAlloc) MaterialParams(),
+			&MemAllocDeleter<MaterialParams, ScratchAlloc>::deleter);
 
 		ShaderPtr shader = material->getShader();
 		if(shader != nullptr)

+ 2 - 1
CamelotCore/Source/CmResourceHandle.cpp

@@ -11,7 +11,8 @@ namespace CamelotEngine
 
 	ResourceHandleBase::ResourceHandleBase()
 	{
-		mData = std::shared_ptr<ResourceHandleData>(new ResourceHandleData());
+		mData = std::shared_ptr<ResourceHandleData>(CM_NEW(ResourceHandleData, PoolAlloc) ResourceHandleData(),
+			&MemAllocDeleter<ResourceHandleData, PoolAlloc>::deleter);
 	}
 
 	bool ResourceHandleBase::isLoaded() const 

+ 2 - 1
CamelotCore/Source/CmShader.cpp

@@ -14,7 +14,8 @@ namespace CamelotEngine
 
 	TechniquePtr Shader::addTechnique(const String& renderSystem, const String& renderer)
 	{
-		TechniquePtr technique = TechniquePtr(new Technique(renderSystem, renderer));
+		TechniquePtr technique = TechniquePtr(CM_NEW(Technique, PoolAlloc) Technique(renderSystem, renderer),
+			&MemAllocDeleter<Technique, PoolAlloc>::deleter);
 		mTechniques.push_back(technique);
 
 		return technique;

+ 2 - 1
CamelotCore/Source/CmSpecificImporter.cpp

@@ -6,7 +6,8 @@ namespace CamelotEngine
 {
 	ImportOptionsPtr SpecificImporter::createImportOptions() const
 	{
-		return ImportOptionsPtr(new ImportOptions());
+		return ImportOptionsPtr(CM_NEW(ImportOptions, PoolAlloc) ImportOptions(),
+			&MemAllocDeleter<ImportOptions, PoolAlloc>::deleter);
 	}
 
 	ConstImportOptionsPtr SpecificImporter::getDefaultImportOptions() const

+ 1 - 1
CamelotCore/Source/CmTechnique.cpp

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

+ 4 - 3
CamelotCore/Source/CmTexture.cpp

@@ -138,7 +138,8 @@ namespace CamelotEngine {
 			if(depth != 1) depth /= 2;
 		}
 
-		PixelDataPtr dst(new PixelData(width, height, depth, getFormat()));
+		PixelDataPtr dst(CM_NEW(PixelData, PoolAlloc) PixelData(width, height, depth, getFormat()),
+			&MemAllocDeleter<PixelData, PoolAlloc>::deleter);
 		UINT8* buffer = (UINT8*)dst->allocData(totalSize);
 
 		PixelData myData = lock(GBL_READ_ONLY, mip, face);
@@ -245,7 +246,7 @@ namespace CamelotEngine {
 		{
 			TextureViewPtr newView = texture->createView();
 			newView->initialize(texture, key);
-			texture->mTextureViews[key] = new TextureViewReference(newView);
+			texture->mTextureViews[key] = CM_NEW(TextureViewReference, PoolAlloc) TextureViewReference(newView);
 
 			iterFind = texture->mTextureViews.find(key);
 		}
@@ -274,7 +275,7 @@ namespace CamelotEngine {
 
 			texture->mTextureViews.erase(iterFind);
 
-			delete toRemove;
+			CM_DELETE(toRemove, TextureViewReference, PoolAlloc);
 		}
 	}
 

+ 0 - 50
CamelotCore/Source/CmVertexData.cpp

@@ -86,56 +86,6 @@ namespace CamelotEngine
 		return false;
 	}
 
-	VertexData* VertexData::clone(bool copyData, HardwareBufferManager* mgr) const
-	{
-		HardwareBufferManager* pManager = mgr ? mgr : mMgr;
-
-		VertexData* dest = new VertexData(mgr);
-
-		// Copy vertex buffers in turn
-		for (auto iter = mVertexBuffers.begin(); iter != mVertexBuffers.end(); ++iter)
-		{
-			VertexBufferPtr srcbuf = iter->second;
-            VertexBufferPtr dstBuf;
-            if (copyData)
-            {
-			    // create new buffer with the same settings
-			    dstBuf = pManager->createVertexBuffer(
-					    srcbuf->getVertexSize(), srcbuf->getNumVertices(), srcbuf->getUsage());
-
-			    // copy data
-			    dstBuf->copyData(*srcbuf, 0, 0, srcbuf->getSizeInBytes(), true);
-            }
-            else
-            {
-                // don't copy, point at existing buffer
-                dstBuf = srcbuf;
-            }
-
-			// Copy binding
-			dest->setBuffer(iter->first, dstBuf);
-        }
-
-        // Basic vertex info
-		dest->vertexCount = this->vertexCount;
-        // Copy elements
-        const VertexDeclaration::VertexElementList elems = 
-            this->vertexDeclaration->getElements();
-        VertexDeclaration::VertexElementList::const_iterator ei, eiend;
-        eiend = elems.end();
-        for (ei = elems.begin(); ei != eiend; ++ei)
-        {
-            dest->vertexDeclaration->addElement(
-                ei->getSource(),
-                ei->getOffset(),
-                ei->getType(),
-                ei->getSemantic(),
-                ei->getIndex() );
-        }
-
-        return dest;
-	}
-
 	void VertexData::convertPackedColour(
 		VertexElementType srcType, VertexElementType destType)
 	{