Ver Fonte

Updated how are GpuParamBlocks handled on the core thread and compile fixes

Marko Pintera há 11 anos atrás
pai
commit
5f6fe3b27f
33 ficheiros alterados com 113 adições e 386 exclusões
  1. 0 6
      BansheeCore/BansheeCore.vcxproj
  2. 0 18
      BansheeCore/BansheeCore.vcxproj.filters
  3. 0 9
      BansheeCore/Include/BsBindableGpuParamBlock.h
  4. 4 5
      BansheeCore/Include/BsCorePrerequisites.h
  5. 3 3
      BansheeCore/Include/BsGpuParam.h
  6. 7 6
      BansheeCore/Include/BsGpuParamBlockBuffer.h
  7. 0 16
      BansheeCore/Include/BsGpuParamBlockBufferProxy.h
  8. 5 5
      BansheeCore/Include/BsGpuParams.h
  9. 0 62
      BansheeCore/Include/BsGpuParamsProxy.h
  10. 1 1
      BansheeCore/Include/BsGpuResource.h
  11. 1 1
      BansheeCore/Include/BsMaterial.h
  12. 3 3
      BansheeCore/Include/BsMeshBase.h
  13. 1 1
      BansheeCore/Include/BsMeshProxy.h
  14. 1 1
      BansheeCore/Include/BsSceneObject.h
  15. 0 0
      BansheeCore/Source/BsBindableGpuParamBlock.cpp
  16. 1 1
      BansheeCore/Source/BsCoreThreadAccessor.cpp
  17. 3 3
      BansheeCore/Source/BsGpuParam.cpp
  18. 3 13
      BansheeCore/Source/BsGpuParamBlockBuffer.cpp
  19. 0 14
      BansheeCore/Source/BsGpuParamBlockBufferProxy.cpp
  20. 47 16
      BansheeCore/Source/BsGpuParams.cpp
  21. 0 179
      BansheeCore/Source/BsGpuParamsProxy.cpp
  22. 8 8
      BansheeCore/Source/BsMaterial.cpp
  23. 1 1
      BansheeCore/Source/BsMesh.cpp
  24. 1 1
      BansheeCore/Source/BsTransientMesh.cpp
  25. 2 0
      BansheeEngine/BansheeEngine.vcxproj
  26. 6 0
      BansheeEngine/BansheeEngine.vcxproj.filters
  27. 2 0
      BansheeEngine/Include/BsPrerequisites.h
  28. 3 5
      BansheeEngine/Include/BsRenderableProxy.h
  29. 1 1
      BansheeEngine/Source/BsRenderable.cpp
  30. 0 0
      BansheeEngine/Source/BsRenderableProxy.cpp
  31. 5 5
      BansheeRenderer/Source/BsBansheeRenderer.cpp
  32. 2 2
      BansheeUtility/Include/BsFrameAlloc.h
  33. 2 0
      Renderer.txt

+ 0 - 6
BansheeCore/BansheeCore.vcxproj

@@ -272,13 +272,10 @@
     </Link>
   </ItemDefinitionGroup>
   <ItemGroup>
-    <ClInclude Include="Include\BsGpuParamBlockBufferProxy.h" />
-    <ClInclude Include="Include\BsGpuParamsProxy.h" />
     <ClInclude Include="Include\BsCameraProxy.h" />
     <ClInclude Include="Include\BsDrawList.h" />
     <ClInclude Include="Include\BsMaterialProxy.h" />
     <ClInclude Include="Include\BsMeshProxy.h" />
-    <ClInclude Include="Include\BsRenderableProxy.h" />
     <ClInclude Include="Include\BsRendererParams.h" />
     <ClInclude Include="Include\BsRenderStats.h" />
     <ClInclude Include="Include\BsCoreThread.h" />
@@ -420,8 +417,6 @@
     <ClInclude Include="Source\BsMeshRTTI.h" />
   </ItemGroup>
   <ItemGroup>
-    <ClCompile Include="Source\BsGpuParamBlockBufferProxy.cpp" />
-    <ClCompile Include="Source\BsGpuParamsProxy.cpp" />
     <ClCompile Include="Source\BsCameraProxy.cpp" />
     <ClCompile Include="Source\BsCoreThread.cpp" />
     <ClCompile Include="Source\BsDrawList.cpp" />
@@ -472,7 +467,6 @@
     <ClCompile Include="Source\BsPlatform.cpp" />
     <ClCompile Include="Source\BsProfilingManager.cpp" />
     <ClCompile Include="Source\BsQueryManager.cpp" />
-    <ClCompile Include="Source\BsRenderableProxy.cpp" />
     <ClCompile Include="Source\BsRenderer.cpp" />
     <ClCompile Include="Source\BsRendererParams.cpp" />
     <ClCompile Include="Source\BsRenderQueue.cpp" />

+ 0 - 18
BansheeCore/BansheeCore.vcxproj.filters

@@ -504,9 +504,6 @@
     <ClInclude Include="Include\BsProfilingManager.h">
       <Filter>Header Files</Filter>
     </ClInclude>
-    <ClInclude Include="Include\BsRenderableProxy.h">
-      <Filter>Header Files\Renderer</Filter>
-    </ClInclude>
     <ClInclude Include="Include\BsCameraProxy.h">
       <Filter>Header Files\Renderer</Filter>
     </ClInclude>
@@ -522,12 +519,6 @@
     <ClInclude Include="Include\BsMaterialProxy.h">
       <Filter>Header Files\Renderer</Filter>
     </ClInclude>
-    <ClInclude Include="Include\BsGpuParamsProxy.h">
-      <Filter>Header Files\Renderer</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\BsGpuParamBlockBufferProxy.h">
-      <Filter>Header Files\Renderer</Filter>
-    </ClInclude>
   </ItemGroup>
   <ItemGroup>
     <ClCompile Include="Source\BsCoreApplication.cpp">
@@ -818,9 +809,6 @@
     <ClCompile Include="Source\BsProfilingManager.cpp">
       <Filter>Source Files</Filter>
     </ClCompile>
-    <ClCompile Include="Source\BsRenderableProxy.cpp">
-      <Filter>Source Files\Renderer</Filter>
-    </ClCompile>
     <ClCompile Include="Source\BsDrawList.cpp">
       <Filter>Source Files\Renderer</Filter>
     </ClCompile>
@@ -830,11 +818,5 @@
     <ClCompile Include="Source\BsRendererParams.cpp">
       <Filter>Source Files\Renderer</Filter>
     </ClCompile>
-    <ClCompile Include="Source\BsGpuParamsProxy.cpp">
-      <Filter>Source Files\Renderer</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\BsGpuParamBlockBufferProxy.cpp">
-      <Filter>Source Files\Renderer</Filter>
-    </ClCompile>
   </ItemGroup>
 </Project>

+ 0 - 9
BansheeCore/Include/BsBindableGpuParamBlock.h

@@ -1,9 +0,0 @@
-#pragma once
-
-#include "BsCorePrerequisites.h"
-#include "BsCoreObject.h"
-
-namespace BansheeEngine
-{
-
-}

+ 4 - 5
BansheeCore/Include/BsCorePrerequisites.h

@@ -128,12 +128,11 @@ namespace BansheeEngine
 	class VideoMode;
 	class VideoOutputInfo;
 	class VideoModeInfo;
-	class RenderableProxy;
 	class RenderableElement;
 	class CameraProxy;
-	class MaterialProxy;
-	class MaterialProxyPass;
-	class MeshProxy;
+	struct MaterialProxy;
+	struct MaterialProxyPass;
+	struct MeshProxy;
 	class GpuParamBlockBufferProxy;
 	class GpuParamsProxy;
 	class DrawList;
@@ -234,7 +233,7 @@ namespace BansheeEngine
 	typedef std::shared_ptr<CameraProxy> CameraProxyPtr;
 	typedef std::shared_ptr<MaterialProxy> MaterialProxyPtr;
 	typedef std::shared_ptr<MeshProxy> MeshProxyPtr;
-	typedef std::shared_ptr<GpuParams> GpuParamsPtr;
+	typedef std::shared_ptr<GpuParamsProxy> GpuParamsProxyPtr;
 	typedef std::shared_ptr<GpuParamBlockBufferProxy> GpuParamBlockBufferProxyPtr;
 }
 

+ 3 - 3
BansheeCore/Include/BsGpuParam.h

@@ -32,7 +32,7 @@ namespace BansheeEngine
 		/**
 		 * @brief	Gets a parameter block at the specified slot index.
 		 */
-		GpuParamBlock* getParamBlock(UINT32 slotIdx) const;
+		GpuParamBlockPtr getParamBlock(UINT32 slotIdx) const;
 
 		/**
 		 * @brief	Returns true if matrices need to be transposed when reading/writing them.
@@ -132,7 +132,7 @@ namespace BansheeEngine
 
 			UINT32 elementSizeBytes = mParamDesc->elementSize * sizeof(UINT32);
 			UINT32 sizeBytes = std::min(elementSizeBytes, (UINT32)sizeof(T)); // Truncate if it doesn't fit within parameter size
-			GpuParamBlock* paramBlock = getParamBlock(mParamDesc->paramBlockSlot);
+			GpuParamBlockPtr paramBlock = getParamBlock(mParamDesc->paramBlockSlot);
 
 			if (TransposePolicy<T>::transposeEnabled(getTransposeMatrices()))
 			{
@@ -173,7 +173,7 @@ namespace BansheeEngine
 
 			UINT32 elementSizeBytes = mParamDesc->elementSize * sizeof(UINT32);
 			UINT32 sizeBytes = std::min(elementSizeBytes, (UINT32)sizeof(T));
-			GpuParamBlock* paramBlock = getParamBlock(mParamDesc->paramBlockSlot);
+			GpuParamBlockPtr paramBlock = getParamBlock(mParamDesc->paramBlockSlot);
 
 			T value;
 			paramBlock->read((mParamDesc->cpuMemOffset + arrayIdx * mParamDesc->arrayElementStride) * sizeof(UINT32), &value, sizeBytes);

+ 7 - 6
BansheeCore/Include/BsGpuParamBlockBuffer.h

@@ -59,19 +59,20 @@ namespace BansheeEngine
 		 *
 		 * @note	Sim thread only.
 		 */
-		GpuParamBlock* getParamBlock() const { return mParamBlock; }
+		GpuParamBlockPtr getParamBlock() const { return mParamBlock; }
 
 		// TODO UNDOCUMENTED
-		GpuParamBlockBufferProxyPtr _createProxy() const;
-		void _setActiveProxy(const GpuParamBlockBufferProxyPtr& activeProxy) { mActiveProxy = activeProxy; }
-		GpuParamBlockBufferProxyPtr _getActiveProxy() const { return mActiveProxy; }
+		// TODO - Keeping a core param block along with a sim param block is redundant in some cases,
+		// as it might not be used (e.g. if gpu param block buffer is only accessed from core thread)
+		GpuParamBlockPtr getCoreParamBlock() const { return mCoreParamBlock; }
+		void setCoreParamBlock(const GpuParamBlockPtr& paramBlock) { mCoreParamBlock = paramBlock; }
 
 	protected:
 		GpuParamBlockUsage mUsage;
 		UINT32 mSize;
 
-		GpuParamBlock* mParamBlock;
-		GpuParamBlockBufferProxyPtr mActiveProxy;
+		GpuParamBlockPtr mParamBlock;
+		GpuParamBlockPtr mCoreParamBlock;
 	};
 
 	/**

+ 0 - 16
BansheeCore/Include/BsGpuParamBlockBufferProxy.h

@@ -1,16 +0,0 @@
-#pragma once
-
-#include "BsCorePrerequisites.h"
-#include "BsGpuParamBlock.h"
-
-namespace BansheeEngine
-{
-	// TODO UNDOCUMENTED
-	struct BS_CORE_EXPORT GpuParamBlockBufferProxy
-	{
-		GpuParamBlockBufferProxy(UINT32 size);
-		~GpuParamBlockBufferProxy();
-
-		GpuParamBlock* block;
-	};
-}

+ 5 - 5
BansheeCore/Include/BsGpuParams.h

@@ -230,12 +230,13 @@ namespace BansheeEngine
 		HSamplerState getSamplerState(UINT32 slot);
 
 		/**
-		 * @brief	Returns an exact copy of this object.
+		 * @brief	Returns an exact copy of this object. Cloned object will have a core copy of the GPU
+		 *			param blocks, so it should only be used on the core thread.
 		 *
 		 * @note	Optional frame allocator to allocate the returned data with. If not specified
 		 *			allocation will be done using normal means.
 		 */
-		GpuParamsPtr clone(FrameAlloc* frameAlloc = nullptr) const;
+		GpuParamsPtr cloneForCore(FrameAlloc* frameAlloc = nullptr) const;
 
 		/**
 		 * @brief	Checks is the core dirty flag set. This is used by external systems 
@@ -253,8 +254,6 @@ namespace BansheeEngine
 		void _markCoreClean();
 
 	private:
-		friend class GpuParamsProxy;
-
 		GpuParamDesc& mParamDesc;
 		std::shared_ptr<GpuParamsInternalData> mInternalData;
 
@@ -267,7 +266,7 @@ namespace BansheeEngine
 		 * @brief	Calculates size and offsets used when splitting a large memory chunk into separate buffers.
 		 *			Parameter counts must have been previously assigned.
 		 */
-		void getInternalBufferData(UINT32& bufferSize, UINT32& paramBlockBufferOffset,
+		void getInternalBufferData(UINT32& bufferSize, UINT32& paramBlockOffset, UINT32& paramBlockBufferOffset,
 			UINT32& textureOffset, UINT32& samplerStateOffset) const;
 
 		/**
@@ -289,6 +288,7 @@ namespace BansheeEngine
 		UINT32 mNumTextures;
 		UINT32 mNumSamplerStates;
 
+		GpuParamBlockPtr* mParamBlocks;
 		GpuParamBlockBufferPtr* mParamBlockBuffers;
 		HTexture* mTextures;
 		HSamplerState* mSamplerStates;

+ 0 - 62
BansheeCore/Include/BsGpuParamsProxy.h

@@ -1,62 +0,0 @@
-#pragma once
-
-#include "BsCorePrerequisites.h"
-
-namespace BansheeEngine
-{
-	/**
-	 * @brief	Contains a snapshot of GpuParams data. It can be used for
-	 *			creating a temporary or permanent copy of GpuParams data for use
-	 *			on another thread.
-	**/
-	class BS_CORE_EXPORT GpuParamsProxy
-	{
-	public:
-		GpuParamsProxy(const GpuParamsPtr& sourceParams, FrameAlloc* allocator);
-		~GpuParamsProxy();
-
-		/**
-		 * @brief	Uploads all CPU stored parameter buffer data to the GPU buffers.
-		 */
-		void updateHardwareBuffers();
-
-		/**
-		 * @brief	Gets a parameter block buffer from the specified slot.
-		 */
-		GpuParamBlockBufferPtr getParamBlockBuffer(UINT32 slot) const;
-
-		/**
-		 * @brief	Gets a parameter block buffer by name.
-		 */
-		GpuParamBlockBufferPtr getParamBlockBuffer(const String& name) const;
-
-		/**
-		 * @brief	Gets a texture bound to the specified slot.
-		 */
-		HTexture getTexture(UINT32 slot);
-
-		/**
-		 * @brief	Gets a sampler state bound to the specified slot.
-		 */
-		HSamplerState getSamplerState(UINT32 slot);
-
-		/**
-		 * @brief	Gets a description of all parameters stored in this class.
-		 */
-		const GpuParamDesc& getParamDesc() const { return mParamDesc; }
-
-	private:
-		const GpuParamDesc& mParamDesc;
-		UINT8* mData;
-
-		UINT32 mNumParamBlocks;
-		UINT32 mNumTextures;
-		UINT32 mNumSamplerStates;
-
-		FrameAlloc* mAllocator;
-		GpuParamsBlockProxy** mParamBlocks;
-		GpuParamBlockBufferPtr* mParamBlockBuffers;
-		HTexture* mTextures;
-		HSamplerState* mSamplerStates;
-	};
-}

+ 1 - 1
BansheeCore/Include/BsGpuResource.h

@@ -19,7 +19,7 @@ namespace BansheeEngine
 		 *
 		 * @note	Sim thread only.
 		 */
-		virtual void _writeSubresourceSim(UINT32 subresourceIdx, const GpuResourceData& data, bool discardEntireBuffer);
+		virtual void _writeSubresourceSim(UINT32 subresourceIdx, const GpuResourceData& data, bool discardEntireBuffer) { }
 
 		/**
 		 * @brief	Updates a part of the current resource with the provided data. Specific resource

+ 1 - 1
BansheeCore/Include/BsMaterial.h

@@ -15,7 +15,7 @@ namespace BansheeEngine
 	/**
 	 * @brief	Type of material dirty flags
 	 */
-	enum MaterialDirtyFlag
+	enum class MaterialDirtyFlag
 	{
 		Material = 0x01, /**< Internal material data is dirty. */
 		Proxy = 0x02, /**< Active proxy needs to be updated. */

+ 3 - 3
BansheeCore/Include/BsMeshBase.h

@@ -12,7 +12,7 @@ namespace BansheeEngine
 	/**
 	 * @brief	Type of mesh dirty flags
 	 */
-	enum MeshDirtyFlag
+	enum class MeshDirtyFlag
 	{
 		Mesh = 0x01, /**< Internal mesh data is dirty. */
 		Proxy = 0x02 /**< Active proxy needs to be updated. */
@@ -148,14 +148,14 @@ namespace BansheeEngine
 		 *
 		 * @note	Sim thread only.
 		 */
-		bool _isCoreDirty(MeshDirtyFlag flag) const { (mCoreDirtyFlags & flag) != 0; }
+		bool _isCoreDirty(MeshDirtyFlag flag) const { return (mCoreDirtyFlags & (UINT32)flag) != 0; }
 
 		/**
 		 * @brief	Marks the core dirty flag as clean.
 		 *
 		 * @note	Sim thread only.
 		 */
-		void _markCoreClean(MeshDirtyFlag flag) { mCoreDirtyFlags &= ~flag; }
+		void _markCoreClean(MeshDirtyFlag flag) { mCoreDirtyFlags &= ~(UINT32)flag; }
 
 		/**
 		 * @brief	Gets the currently active proxy of this material.

+ 1 - 1
BansheeCore/Include/BsMeshProxy.h

@@ -11,7 +11,7 @@ namespace BansheeEngine
 	 */
 	struct BS_CORE_EXPORT MeshProxy
 	{
-		MeshPtr mesh;
+		MeshBasePtr mesh;
 		SubMesh subMesh;
 		Bounds bounds;
 	};

+ 1 - 1
BansheeCore/Include/BsSceneObject.h

@@ -199,7 +199,7 @@ namespace BansheeEngine
 		 * @brief	Checks is the core dirty flag set. This is used by external systems 
 		 *			to know when internal data has changed and core thread potentially needs to be notified.
 		 */
-		bool _isCoreDirty() const { mIsCoreDirtyFlags != 0; }
+		bool _isCoreDirty() const { return mIsCoreDirtyFlags != 0; }
 
 		/**
 		 * @brief	Marks the core dirty flag as clean.

+ 0 - 0
BansheeCore/Source/BsBindableGpuParamBlock.cpp


+ 1 - 1
BansheeCore/Source/BsCoreThreadAccessor.cpp

@@ -101,7 +101,7 @@ namespace BansheeEngine
 
 	void CoreThreadAccessorBase::bindGpuParams(GpuProgramType gptype, const GpuParamsPtr& params)
 	{
-		mCommandQueue->queue(std::bind(&RenderSystem::bindGpuParams, RenderSystem::instancePtr(), gptype, params->clone(gCoreThread().getFrameAlloc())));
+		mCommandQueue->queue(std::bind(&RenderSystem::bindGpuParams, RenderSystem::instancePtr(), gptype, params->cloneForCore(gCoreThread().getFrameAlloc())));
 	}
 
 	void CoreThreadAccessorBase::beginRender()

+ 3 - 3
BansheeCore/Source/BsGpuParam.cpp

@@ -16,7 +16,7 @@ namespace BansheeEngine
 		return mInternalData->mIsDestroyed;
 	}
 
-	GpuParamBlock* GpuDataParamBase::getParamBlock(UINT32 slotIdx) const
+	GpuParamBlockPtr GpuDataParamBase::getParamBlock(UINT32 slotIdx) const
 	{
 		return mInternalData->mParamBlocks[slotIdx];
 	}
@@ -66,7 +66,7 @@ namespace BansheeEngine
 
 		sizeBytes = std::min(elementSizeBytes, sizeBytes);
 
-		GpuParamBlock* paramBlock = mInternalData->mParamBlocks[mParamDesc->paramBlockSlot];
+		GpuParamBlockPtr paramBlock = mInternalData->mParamBlocks[mParamDesc->paramBlockSlot];
 		paramBlock->write((mParamDesc->cpuMemOffset + arrayIdx * mParamDesc->arrayElementStride) * sizeof(UINT32), value, sizeBytes);
 
 		// Set unused bytes to 0
@@ -101,7 +101,7 @@ namespace BansheeEngine
 #endif
 		sizeBytes = std::min(elementSizeBytes, sizeBytes);
 
-		GpuParamBlock* paramBlock = mInternalData->mParamBlocks[mParamDesc->paramBlockSlot];
+		GpuParamBlockPtr paramBlock = mInternalData->mParamBlocks[mParamDesc->paramBlockSlot];
 		paramBlock->read((mParamDesc->cpuMemOffset + arrayIdx * mParamDesc->arrayElementStride) * sizeof(UINT32), value, sizeBytes);
 	}
 

+ 3 - 13
BansheeCore/Source/BsGpuParamBlockBuffer.cpp

@@ -1,19 +1,17 @@
 #include "BsGpuParamBlockBuffer.h"
 #include "BsGpuParamBlock.h"
-#include "BsGpuParamBlockBufferProxy.h"
 
 namespace BansheeEngine
 {
 	GpuParamBlockBuffer::GpuParamBlockBuffer()
-		:mSize(0), mUsage(GPBU_DYNAMIC), mParamBlock(nullptr)
+		:mSize(0), mUsage(GPBU_DYNAMIC), mParamBlock(nullptr), mCoreParamBlock(nullptr)
 	{
 
 	}
 
 	GpuParamBlockBuffer::~GpuParamBlockBuffer()
 	{
-		if(mParamBlock != nullptr)
-			bs_delete(mParamBlock);
+
 	}
 
 	void GpuParamBlockBuffer::initialize(UINT32 size, GpuParamBlockUsage usage)
@@ -21,19 +19,11 @@ namespace BansheeEngine
 		mSize = size;
 		mUsage = usage;
 
-		mParamBlock = bs_new<GpuParamBlock, PoolAlloc>(size);
+		mParamBlock = bs_shared_ptr<GpuParamBlock>(size);
 
 		CoreObject::initialize();
 	}
 
-	GpuParamBlockBufferProxyPtr GpuParamBlockBuffer::_createProxy() const
-	{
-		GpuParamBlockBufferProxyPtr proxy = bs_shared_ptr<GpuParamBlockBufferProxy>(mSize);
-		memcpy(proxy->block->getData(), mParamBlock->getData(), mSize);
-		
-		return proxy;
-	}
-
 	void GenericGpuParamBlockBuffer::writeData(const UINT8* data)
 	{
 		memcpy(mData, data, mSize);

+ 0 - 14
BansheeCore/Source/BsGpuParamBlockBufferProxy.cpp

@@ -1,14 +0,0 @@
-#include "BsGpuParamBlockBufferProxy.h"
-
-namespace BansheeEngine
-{
-	GpuParamBlockBufferProxy::GpuParamBlockBufferProxy(UINT32 size)
-	{
-		block = bs_new<GpuParamBlock>(size);
-	}
-
-	GpuParamBlockBufferProxy::~GpuParamBlockBufferProxy()
-	{
-		bs_delete(block);
-	}
-}

+ 47 - 16
BansheeCore/Source/BsGpuParams.cpp

@@ -11,7 +11,7 @@ namespace BansheeEngine
 {
 	GpuParamsInternalData::GpuParamsInternalData()
 		:mTransposeMatrices(false), mData(nullptr), mNumParamBlocks(0), mNumTextures(0), mNumSamplerStates(0), mFrameAlloc(nullptr),
-		mParamBlockBuffers(nullptr), mTextures(nullptr), mSamplerStates(nullptr), mCoreDirtyFlags(0xFFFFFFFF)
+		mParamBlocks(nullptr), mParamBlockBuffers(nullptr), mTextures(nullptr), mSamplerStates(nullptr), mCoreDirtyFlags(0xFFFFFFFF)
 	{ }
 
 	GpuParams::GpuParams(GpuParamDesc& paramDesc, bool transposeMatrices)
@@ -40,13 +40,15 @@ namespace BansheeEngine
 
 		// Allocate everything in a single block of memory to get rid of extra memory allocations
 		UINT32 bufferSize = 0;
+		UINT32 paramBlockOffset = 0;
 		UINT32 paramBlockBufferOffset = 0;
 		UINT32 textureOffset = 0;
 		UINT32 samplerStateOffset = 0;
 
-		getInternalBufferData(bufferSize, paramBlockBufferOffset, textureOffset, samplerStateOffset);
+		getInternalBufferData(bufferSize, paramBlockOffset, paramBlockBufferOffset, textureOffset, samplerStateOffset);
 
 		mInternalData->mData = (UINT8*)bs_alloc(bufferSize);
+		mInternalData->mParamBlocks = (GpuParamBlockPtr*)(mInternalData->mData + paramBlockOffset);
 		mInternalData->mParamBlockBuffers = (GpuParamBlockBufferPtr*)(mInternalData->mData + paramBlockBufferOffset);
 		mInternalData->mTextures = (HTexture*)(mInternalData->mData + textureOffset);
 		mInternalData->mSamplerStates = (HSamplerState*)(mInternalData->mData + samplerStateOffset);
@@ -54,8 +56,15 @@ namespace BansheeEngine
 		// Ensure everything is constructed
 		for (UINT32 i = 0; i < mInternalData->mNumParamBlocks; i++)
 		{
-			GpuParamBlockBufferPtr* ptrToIdx = (&mInternalData->mParamBlockBuffers[i]);
-			ptrToIdx = new (&mInternalData->mParamBlockBuffers[i]) GpuParamBlockBufferPtr(nullptr);
+			{
+				GpuParamBlockPtr* ptrToIdx = (&mInternalData->mParamBlocks[i]);
+				ptrToIdx = new (&mInternalData->mParamBlocks[i]) GpuParamBlockPtr(nullptr);
+			}
+
+			{
+				GpuParamBlockBufferPtr* ptrToIdx = (&mInternalData->mParamBlockBuffers[i]);
+				ptrToIdx = new (&mInternalData->mParamBlockBuffers[i]) GpuParamBlockBufferPtr(nullptr);
+			}
 		}
 
 		for (UINT32 i = 0; i < mInternalData->mNumTextures; i++)
@@ -84,6 +93,7 @@ namespace BansheeEngine
 		// Ensure everything is destructed
 		for (UINT32 i = 0; i < mInternalData->mNumParamBlocks; i++)
 		{
+			mInternalData->mParamBlocks[i].~shared_ptr();
 			mInternalData->mParamBlockBuffers[i].~shared_ptr();
 		}
 
@@ -108,6 +118,7 @@ namespace BansheeEngine
 		}
 
 		mInternalData->mParamBlockBuffers[slot] = paramBlockBuffer;
+		mInternalData->mParamBlocks[slot] = paramBlockBuffer->getParamBlock();
 
 		markCoreDirty();
 	}
@@ -123,6 +134,7 @@ namespace BansheeEngine
 		}
 
 		mInternalData->mParamBlockBuffers[iterFind->second.slot] = paramBlockBuffer;
+		mInternalData->mParamBlocks[iterFind->second.slot] = paramBlockBuffer->getParamBlock();
 
 		markCoreDirty();
 	}
@@ -244,23 +256,23 @@ namespace BansheeEngine
 	{
 		for (UINT32 i = 0; i < mInternalData->mNumParamBlocks; i++)
 		{
-			if (mInternalData->mParamBlockBuffers[i] != nullptr)
+			if (mInternalData->mParamBlocks[i] != nullptr && mInternalData->mParamBlockBuffers[i] != nullptr)
 			{
-				GpuParamBlock* block = mInternalData->mParamBlockBuffers[i]->getParamBlock();
-				if (block->isDirty())
-					block->uploadToBuffer(mInternalData->mParamBlockBuffers[i]);
+				if (mInternalData->mParamBlocks[i]->isDirty())
+					mInternalData->mParamBlocks[i]->uploadToBuffer(mInternalData->mParamBlockBuffers[i]);
 			}
 		}
 	}
 
-	GpuParamsPtr GpuParams::clone(FrameAlloc* frameAlloc) const
+	GpuParamsPtr GpuParams::cloneForCore(FrameAlloc* frameAlloc) const
 	{
 		UINT32 bufferSize = 0;
+		UINT32 paramBlockOffset = 0;
 		UINT32 paramBlockBufferOffset = 0;
 		UINT32 textureOffset = 0;
 		UINT32 samplerStateOffset = 0;
 
-		getInternalBufferData(bufferSize, paramBlockBufferOffset, textureOffset, samplerStateOffset);
+		getInternalBufferData(bufferSize, paramBlockOffset, paramBlockBufferOffset, textureOffset, samplerStateOffset);
 
 		GpuParamsPtr myClone = nullptr;
 		
@@ -285,13 +297,30 @@ namespace BansheeEngine
 		myClone->mInternalData->mNumTextures = mInternalData->mNumTextures;
 		myClone->mInternalData->mNumSamplerStates = mInternalData->mNumSamplerStates;
 
+		myClone->mInternalData->mParamBlocks = (GpuParamBlockPtr*)(myClone->mInternalData->mData + paramBlockOffset);
 		myClone->mInternalData->mParamBlockBuffers = (GpuParamBlockBufferPtr*)(myClone->mInternalData->mData + paramBlockBufferOffset);
 		myClone->mInternalData->mTextures = (HTexture*)(myClone->mInternalData->mData + textureOffset);
 		myClone->mInternalData->mSamplerStates = (HSamplerState*)(myClone->mInternalData->mData + samplerStateOffset);
 
 		for (UINT32 i = 0; i < mInternalData->mNumParamBlocks; i++)
 		{
-			myClone->mInternalData->mParamBlockBuffers[i] = mInternalData->mParamBlockBuffers[i];
+			GpuParamBlockBufferPtr buffer = mInternalData->mParamBlockBuffers[i];
+			if (buffer != nullptr)
+			{
+				if (buffer->getParamBlock()->isDirty())
+				{
+					GpuParamBlockPtr newBlock = bs_shared_ptr<GpuParamBlock>(buffer->getSize());
+					memcpy(newBlock->getData(), buffer->getParamBlock()->getData(), buffer->getSize());
+					buffer->setCoreParamBlock(newBlock);
+					buffer->getParamBlock()->setDirty(false);
+				}
+
+				myClone->mInternalData->mParamBlocks[i] = buffer->getCoreParamBlock();
+			}
+			else
+				myClone->mInternalData->mParamBlocks[i] = nullptr;
+
+			myClone->mInternalData->mParamBlockBuffers[i] = buffer;
 		}
 
 		for (UINT32 i = 0; i < mInternalData->mNumTextures; i++)
@@ -307,15 +336,17 @@ namespace BansheeEngine
 		return myClone;
 	}
 
-	void GpuParams::getInternalBufferData(UINT32& bufferSize, UINT32& paramBlockBufferOffset,
+	void GpuParams::getInternalBufferData(UINT32& bufferSize, UINT32& paramBlockOffset, UINT32& paramBlockBufferOffset,
 		UINT32& textureOffset, UINT32& samplerStateOffset) const
 	{
+		UINT32 paramBlockBufferSize = mInternalData->mNumParamBlocks * sizeof(GpuParamBlock*);
 		UINT32 paramBlockBuffersBufferSize = mInternalData->mNumParamBlocks * sizeof(GpuParamBlockBufferPtr);
 		UINT32 textureBufferSize = mInternalData->mNumTextures * sizeof(HTexture);
 		UINT32 samplerStateBufferSize = mInternalData->mNumSamplerStates * sizeof(HSamplerState);
 
-		bufferSize = paramBlockBuffersBufferSize + textureBufferSize + samplerStateBufferSize;
-		paramBlockBufferOffset = 0;
+		bufferSize = paramBlockBufferSize + paramBlockBuffersBufferSize + textureBufferSize + samplerStateBufferSize;
+		paramBlockOffset = 0;
+		paramBlockBufferOffset = paramBlockOffset + paramBlockBufferSize;
 		textureOffset = paramBlockBufferOffset + paramBlockBuffersBufferSize;
 		samplerStateOffset = textureOffset + textureBufferSize;
 	}
@@ -331,8 +362,8 @@ namespace BansheeEngine
 
 		for (UINT32 i = 0; i < mInternalData->mNumParamBlocks; i++)
 		{
-			if (mInternalData->mParamBlockBuffers[i] != nullptr)
-				mInternalData->mParamBlockBuffers[i]->getParamBlock()->setDirty(false);
+			if (mInternalData->mParamBlocks[i] != nullptr)
+				mInternalData->mParamBlocks[i]->setDirty(false);
 		}
 	}
 

+ 0 - 179
BansheeCore/Source/BsGpuParamsProxy.cpp

@@ -1,179 +0,0 @@
-#include "BsGpuParamsProxy.h"
-#include "BsGpuParams.h"
-#include "BsGpuParamDesc.h"
-#include "BsBindableGpuParamBlock.h"
-#include "BsGpuParamBlockBuffer.h"
-#include "BsDebug.h"
-#include "BsFrameAlloc.h"
-
-namespace BansheeEngine
-{
-	/**
-	* @brief	Specialized class for send GPU parameters to the core thread. Represents a single
-	* 			parameter block buffer and is used for temporary storage of GPU parameters.
-	*
-	* @note		Due to the way allocation is handled, this class is not allowed to have a destructor.
-	*
-	* @see		BindableGpuParams
-	*/
-	class BS_CORE_EXPORT GpuParamsBlockProxy
-	{
-	public:
-		GpuParamsBlockProxy()
-			:mDirty(true), mData(nullptr), mSize(0)
-		{ }
-
-		/**
-		* @brief	Uploads the current data to the specified buffer, and marks the block a non-dirty.
-		*
-		* @note	Core thread only.
-		*/
-		void uploadToBuffer(GpuParamBlockBufferPtr buffer)
-		{
-			buffer->writeData(mData);
-			mDirty = false;
-		}
-
-		/**
-		* @brief	Query if this object is dirty. If dirty the data of this block
-		* 			will need to be uploaded to a GPU buffer.
-		*
-		* @note	Core thread only.
-		*/
-		bool isDirty() const { return mDirty; }
-	protected:
-		friend class GpuParams;
-		friend class GpuParamsProxy;
-
-		UINT8* mData;
-		UINT32 mSize;
-		bool mDirty;
-	};
-
-	GpuParamsProxy::GpuParamsProxy(const GpuParamsPtr& params, FrameAlloc* allocator)
-		:mParamDesc(params->getParamDesc()), mData(nullptr), mNumParamBlocks(0), mAllocator(allocator),
-		mNumTextures(0), mNumSamplerStates(0),mParamBlocks(nullptr), mParamBlockBuffers(nullptr), mTextures(nullptr), mSamplerStates(nullptr)
-	{
-		// Allocate everything in a single block of memory to get rid of extra memory allocations
-		UINT32 paramBlockBufferSize = params->mInternalData->mNumParamBlocks * sizeof(GpuParamsBlockProxy*);
-		UINT32 paramBlockBuffersBufferSize = params->mInternalData->mNumParamBlocks * sizeof(GpuParamBlockBufferPtr);
-		UINT32 textureBufferSize = params->mInternalData->mNumTextures * sizeof(HTexture);
-		UINT32 samplerStateBufferSize = params->mInternalData->mNumSamplerStates * sizeof(HSamplerState);
-
-		UINT32 bufferSize = paramBlockBufferSize + paramBlockBuffersBufferSize + textureBufferSize + samplerStateBufferSize;
-		for (UINT32 i = 0; i < params->mInternalData->mNumParamBlocks; i++)
-		{
-			if (params->mInternalData->mParamBlockBuffers[i] != nullptr)
-				bufferSize += sizeof(GpuParamsBlockProxy)+params->mInternalData->mParamBlockBuffers[i]->getSize();
-		}
-
-		mData = (UINT8*)allocator->alloc(bufferSize);
-		mNumParamBlocks = params->mInternalData->mNumParamBlocks;
-		mNumTextures = params->mInternalData->mNumTextures;
-		mNumSamplerStates = params->mInternalData->mNumSamplerStates;
-
-		UINT8* dataIter = mData;
-		mParamBlocks = (GpuParamsBlockProxy**)dataIter;
-		dataIter += paramBlockBufferSize;
-
-		mParamBlockBuffers = (GpuParamBlockBufferPtr*)dataIter;
-		dataIter += paramBlockBuffersBufferSize;
-
-		mTextures = (HTexture*)dataIter;
-		dataIter += textureBufferSize;
-
-		mSamplerStates = (HSamplerState*)dataIter;
-		dataIter += samplerStateBufferSize;
-
-		// Copy data
-		memcpy(mParamBlockBuffers, params->mInternalData->mParamBlockBuffers, paramBlockBuffersBufferSize);
-		memcpy(mTextures, params->mInternalData->mTextures, textureBufferSize);
-		memcpy(mSamplerStates, params->mInternalData->mSamplerStates, samplerStateBufferSize);
-
-		for (UINT32 i = 0; i < params->mInternalData->mNumParamBlocks; i++)
-		{
-			if (params->mInternalData->mParamBlockBuffers[i] != nullptr)
-			{
-				GpuParamBlock* paramBlock = params->mInternalData->mParamBlockBuffers[i]->getParamBlock();
-
-				UINT32 bufferSize = paramBlock->getSize();
-				mParamBlocks[i] = (GpuParamsBlockProxy*)dataIter;
-
-				dataIter += sizeof(GpuParamsBlockProxy);
-				mParamBlocks[i]->mData = dataIter;
-
-				dataIter += bufferSize;
-				memcpy(mParamBlocks[i]->mData, paramBlock->getData(), bufferSize);
-
-				mParamBlocks[i]->mSize = bufferSize;
-				mParamBlocks[i]->mDirty = paramBlock->isDirty();
-			}
-		}
-	}
-
-	GpuParamsProxy::~GpuParamsProxy()
-	{
-		if(mData != nullptr)
-		{
-			mAllocator->dealloc(mData);
-		}
-	}
-
-	GpuParamBlockBufferPtr GpuParamsProxy::getParamBlockBuffer(UINT32 slot) const
-	{
-		if(slot < 0 || slot >= mNumParamBlocks)
-		{
-			BS_EXCEPT(InvalidParametersException, "Index out of range: Valid range: 0 .. " + 
-				toString(mNumParamBlocks - 1) + ". Requested: " + toString(slot));
-		}
-
-		return mParamBlockBuffers[slot];
-	}
-
-	GpuParamBlockBufferPtr GpuParamsProxy::getParamBlockBuffer(const String& name) const
-	{
-		auto iterFind = mParamDesc.paramBlocks.find(name);
-
-		if(iterFind == mParamDesc.paramBlocks.end())
-		{
-			LOGWRN("Cannot find parameter block with the name: " + name);
-			return nullptr;
-		}
-
-		return mParamBlockBuffers[iterFind->second.slot];
-	}
-
-	HTexture GpuParamsProxy::getTexture(UINT32 slot)
-	{
-		if(slot < 0 || slot >= mNumTextures)
-		{
-			BS_EXCEPT(InvalidParametersException, "Index out of range: Valid range: 0 .. " + 
-				toString(mNumTextures - 1) + ". Requested: " + toString(slot));
-		}
-
-		return mTextures[slot];
-	}
-
-	HSamplerState GpuParamsProxy::getSamplerState(UINT32 slot)
-	{
-		if(slot < 0 || slot >= mNumSamplerStates)
-		{
-			BS_EXCEPT(InvalidParametersException, "Index out of range: Valid range: 0 .. " + 
-				toString(mNumSamplerStates - 1) + ". Requested: " + toString(slot));
-		}
-
-		return mSamplerStates[slot];
-	}
-
-	void GpuParamsProxy::updateHardwareBuffers()
-	{
-		for(size_t i = 0; i < mNumParamBlocks; i++)
-		{
-			if(mParamBlocks[i] != nullptr && mParamBlockBuffers[i] != nullptr)
-			{
-				if(mParamBlocks[i]->isDirty())
-					mParamBlocks[i]->uploadToBuffer(mParamBlockBuffers[i]);
-			}
-		}
-	}
-}

+ 8 - 8
BansheeCore/Source/BsMaterial.cpp

@@ -716,12 +716,12 @@ namespace BansheeEngine
 			return false;
 		}
 		else
-			return (mCoreDirtyFlags & flag) != 0 || (mShader != nullptr && mShader->_isCoreDirty());
+			return (mCoreDirtyFlags & (UINT32)flag) != 0 || (mShader != nullptr && mShader->_isCoreDirty());
 	}
 
 	void Material::_markCoreClean(MaterialDirtyFlag flag)
 	{ 
-		mCoreDirtyFlags &= ~flag;
+		mCoreDirtyFlags &= ~(UINT32)flag;
 
 		if (flag == MaterialDirtyFlag::Material)
 		{
@@ -762,37 +762,37 @@ namespace BansheeEngine
 			if (pass->hasVertexProgram())
 			{
 				passData.vertexProg = pass->getVertexProgram();
-				passData.vertexProgParams = params->mVertParams->clone();
+				passData.vertexProgParams = params->mVertParams->cloneForCore();
 			}
 
 			if (pass->hasFragmentProgram())
 			{
 				passData.fragmentProg = pass->getFragmentProgram();
-				passData.fragmentProgParams = params->mFragParams->clone();
+				passData.fragmentProgParams = params->mFragParams->cloneForCore();
 			}
 
 			if (pass->hasGeometryProgram())
 			{
 				passData.geometryProg = pass->getGeometryProgram();
-				passData.geometryProgParams = params->mGeomParams->clone();
+				passData.geometryProgParams = params->mGeomParams->cloneForCore();
 			}
 
 			if (pass->hasHullProgram())
 			{
 				passData.hullProg = pass->getHullProgram();
-				passData.hullProgParams = params->mHullParams->clone();
+				passData.hullProgParams = params->mHullParams->cloneForCore();
 			}
 
 			if (pass->hasDomainProgram())
 			{
 				passData.domainProg = pass->getDomainProgram();
-				passData.domainProgParams = params->mDomainParams->clone();
+				passData.domainProgParams = params->mDomainParams->cloneForCore();
 			}
 
 			if (pass->hasComputeProgram())
 			{
 				passData.computeProg = pass->getComputeProgram();
-				passData.computeProgParams = params->mComputeParams->clone();
+				passData.computeProgParams = params->mComputeParams->cloneForCore();
 			}
 
 			passData.blendState = pass->getBlendState();

+ 1 - 1
BansheeCore/Source/BsMesh.cpp

@@ -365,7 +365,7 @@ namespace BansheeEngine
 	MeshProxyPtr Mesh::_createProxy(UINT32 subMeshIdx)
 	{
 		MeshProxyPtr coreProxy = bs_shared_ptr<MeshProxy>();
-		coreProxy->mesh = getThisPtr();
+		coreProxy->mesh = std::static_pointer_cast<MeshBase>(getThisPtr());
 		coreProxy->bounds = mBounds;
 		coreProxy->subMesh = getSubMesh(subMeshIdx);
 

+ 1 - 1
BansheeCore/Source/BsTransientMesh.cpp

@@ -58,7 +58,7 @@ namespace BansheeEngine
 	MeshProxyPtr TransientMesh::_createProxy(UINT32 subMeshIdx)
 	{
 		MeshProxyPtr coreProxy = bs_shared_ptr<MeshProxy>();
-		coreProxy->mesh = getThisPtr();
+		coreProxy->mesh = std::static_pointer_cast<MeshBase>(getThisPtr());
 		coreProxy->subMesh = mSubMeshes[0];
 
 		// Note: Not calculating bounds for transient meshes yet

+ 2 - 0
BansheeEngine/BansheeEngine.vcxproj

@@ -228,6 +228,7 @@
   <ItemGroup>
     <ClCompile Include="Source\BsCursor.cpp" />
     <ClCompile Include="Source\BsInputConfiguration.cpp" />
+    <ClCompile Include="Source\BsRenderableProxy.cpp" />
     <ClCompile Include="Source\BsVirtualInput.cpp" />
     <ClInclude Include="Include\BsApplication.h" />
     <ClInclude Include="Include\BsCursor.h" />
@@ -287,6 +288,7 @@
     <ClInclude Include="Include\BsImageSprite.h" />
     <ClInclude Include="Include\BsProfilerOverlay.h" />
     <ClInclude Include="Include\BsRectOffset.h" />
+    <ClInclude Include="Include\BsRenderableProxy.h" />
     <ClInclude Include="Include\BsSceneManager.h" />
     <ClInclude Include="Include\BsGUIScrollArea.h" />
     <ClInclude Include="Include\BsScriptManager.h" />

+ 6 - 0
BansheeEngine/BansheeEngine.vcxproj.filters

@@ -273,6 +273,9 @@
     <ClInclude Include="Include\BsRectOffset.h">
       <Filter>Header Files</Filter>
     </ClInclude>
+    <ClInclude Include="Include\BsRenderableProxy.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
   </ItemGroup>
   <ItemGroup>
     <ClCompile Include="Source\BsGUIElement.cpp">
@@ -470,5 +473,8 @@
     <ClCompile Include="Source\BsBuiltinResources.cpp">
       <Filter>Source Files</Filter>
     </ClCompile>
+    <ClCompile Include="Source\BsRenderableProxy.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
   </ItemGroup>
 </Project>

+ 2 - 0
BansheeEngine/Include/BsPrerequisites.h

@@ -68,6 +68,7 @@ namespace BansheeEngine
 	class GUIContent;
 	class GUIContextMenu;
 	class GUIDropDownHitBox;
+	class RenderableProxy;
 
 	// 2D
 	class TextSprite;
@@ -86,6 +87,7 @@ namespace BansheeEngine
 	typedef std::shared_ptr<Camera> CameraPtr;
 	typedef std::shared_ptr<Renderable> RenderablePtr;
 	typedef std::shared_ptr<GUIToggleGroup> GUIToggleGroupPtr;
+	typedef std::shared_ptr<RenderableProxy> RenderableProxyPtr;
 
 	typedef GameObjectHandle<GUIWidget> HGUIWidget;
 	typedef GameObjectHandle<Camera> HCamera;

+ 3 - 5
BansheeCore/Include/BsRenderableProxy.h → BansheeEngine/Include/BsRenderableProxy.h

@@ -1,6 +1,6 @@
 #pragma once
 
-#include "BsCorePrerequisites.h"
+#include "BsPrerequisites.h"
 #include "BsMaterialProxy.h"
 #include "BsMeshProxy.h"
 #include "BsBounds.h"
@@ -9,7 +9,7 @@
 namespace BansheeEngine
 {
 	// TODO UNDOCUMENTED
-	class BS_CORE_EXPORT RenderableElement
+	class BS_EXPORT RenderableElement
 	{
 	public:
 		RenderableElement();
@@ -28,7 +28,7 @@ namespace BansheeEngine
 		bool mBoundsDirty;
 	};
 
-	class BS_CORE_EXPORT RenderableProxy
+	class BS_EXPORT RenderableProxy
 	{
 	public:
 		~RenderableProxy();
@@ -36,6 +36,4 @@ namespace BansheeEngine
 		Vector<RenderableElement*> renderableElements;
 		RenderableType renderableType;
 	};
-
-	typedef std::shared_ptr<RenderableProxy> RenderableProxyPtr;
 }

+ 1 - 1
BansheeEngine/Source/BsRenderable.cpp

@@ -80,7 +80,7 @@ namespace BansheeEngine
 		if (mMeshData.mesh != nullptr && mMeshData.mesh.isLoaded() && mMeshData.mesh->_isCoreDirty(MeshDirtyFlag::Mesh))
 			return true;
 
-		return mCoreDirtyFlags; 
+		return mCoreDirtyFlags != 0; 
 	}
 
 	void Renderable::_markCoreClean()

+ 0 - 0
BansheeCore/Source/BsRenderableProxy.cpp → BansheeEngine/Source/BsRenderableProxy.cpp


+ 5 - 5
BansheeRenderer/Source/BsBansheeRenderer.cpp

@@ -170,7 +170,7 @@ namespace BansheeEngine
 	void BansheeRenderer::addCameraProxy(CameraProxyPtr proxy)
 	{
 		RenderTargetPtr renderTarget = proxy->viewport.getTarget();
-		auto findIter = std::find(mRenderTargets.begin(), mRenderTargets.end(), renderTarget);
+		auto findIter = std::find_if(mRenderTargets.begin(), mRenderTargets.end(), [&](const RenderTargetData& x) { return x.target == renderTarget; });
 
 		if (findIter != mRenderTargets.end())
 		{
@@ -203,7 +203,7 @@ namespace BansheeEngine
 	void BansheeRenderer::removeCameraProxy(CameraProxyPtr proxy)
 	{
 		RenderTargetPtr renderTarget = proxy->viewport.getTarget();
-		auto findIter = std::find(mRenderTargets.begin(), mRenderTargets.end(), renderTarget);
+		auto findIter = std::find_if(mRenderTargets.begin(), mRenderTargets.end(), [&](const RenderTargetData& x) { return x.target == renderTarget; });
 
 		if (findIter != mRenderTargets.end())
 		{
@@ -307,7 +307,7 @@ namespace BansheeEngine
 								GpuParamsPtr params = passParams->getParamByIdx(k);
 								if (params != nullptr && params->_isCoreDirty())
 								{
-									dirtyParams.setParamByIdx(k, params->clone());
+									dirtyParams.setParamByIdx(k, params->cloneForCore());
 
 									params->_markCoreClean();
 								}
@@ -395,7 +395,7 @@ namespace BansheeEngine
 			for (auto& callback : callbacksForViewport)
 				callback(viewportRawPtr, *drawList);
 
-			gCoreAccessor().queueCommand(std::bind(&BansheeRenderer::setDrawList, camera->_getActiveProxy(), drawList));
+			gCoreAccessor().queueCommand(std::bind(&BansheeRenderer::setDrawList, this, camera->_getActiveProxy(), drawList));
 		}
 
 		gCoreAccessor().queueCommand(std::bind(&BansheeRenderer::renderAllCore, this));
@@ -604,7 +604,7 @@ namespace BansheeEngine
 		THROW_IF_NOT_CORE_THREAD;
 
 		RenderSystem& rs = RenderSystem::instance();
-		MeshPtr mesh = meshProxy.mesh;
+		MeshBasePtr mesh = meshProxy.mesh;
 		std::shared_ptr<VertexData> vertexData = mesh->_getVertexData();
 
 		rs.setVertexDeclaration(vertexData->vertexDeclaration);

+ 2 - 2
BansheeUtility/Include/BsFrameAlloc.h

@@ -72,7 +72,7 @@ namespace BansheeEngine
 	 * @brief	Allocator for the standard library that internally uses a
 	 * 			frame allocator.
 	 */
-	template <class Tc>
+	template <class T>
 	class StdFrameAlloc
 	{
 	public:
@@ -141,7 +141,7 @@ namespace BansheeEngine
 		 */
 		pointer allocate(size_type num, const void* = 0)
 		{
-			pointer ret = (pointer)(mFrameAlloc->alloc((size_t)num*sizeof(T)));
+			pointer ret = (pointer)(mFrameAlloc->alloc((UINT32)num*sizeof(T)));
 			return ret;
 		}
 

+ 2 - 0
Renderer.txt

@@ -14,6 +14,8 @@ ISSUE - GpuParamBlock is tied to the hardware buffer. But I need separate param
 IMPORTANT - Renderer now requires GpuparamBuffers to exist. Separate for each renderer semantic. Add
 GpuParamBlockBuffer emulation to DX9 (they can be user-specified via import settings or something).
 
+GpuParamBlockBuffer and GpuParams::cloneForCore are very clumsy in how they deal in keeping two separate param blocks. Rethink this a bit.
+
 Make sure to update param buffers in bulk before doing any rendering:
  - They're updated when material proxies are first created
  - When material proxies are updated