Quellcode durchsuchen

Massive refactor: Moving all the core thread objects into their own namespace, so I can rename them into something neater and get rid of the Core suffix

BearishSun vor 9 Jahren
Ursprung
Commit
4e57b50514
100 geänderte Dateien mit 2521 neuen und 2317 gelöschten Zeilen
  1. 7 3
      Source/BansheeCore/Include/BsBlendState.h
  2. 35 31
      Source/BansheeCore/Include/BsCamera.h
  3. 2 2
      Source/BansheeCore/Include/BsCommandBuffer.h
  4. 2 2
      Source/BansheeCore/Include/BsCommandBufferManager.h
  5. 3 3
      Source/BansheeCore/Include/BsCommonTypes.h
  6. 10 9
      Source/BansheeCore/Include/BsCoreObject.h
  7. 3 0
      Source/BansheeCore/Include/BsCoreObjectCore.h
  8. 2 2
      Source/BansheeCore/Include/BsCoreObjectManager.h
  9. 49 47
      Source/BansheeCore/Include/BsCorePrerequisites.h
  10. 8 6
      Source/BansheeCore/Include/BsCoreRenderer.h
  11. 6 3
      Source/BansheeCore/Include/BsDepthStencilState.h
  12. 2 2
      Source/BansheeCore/Include/BsEventQuery.h
  13. 5 2
      Source/BansheeCore/Include/BsGpuBuffer.h
  14. 26 26
      Source/BansheeCore/Include/BsGpuParam.h
  15. 62 59
      Source/BansheeCore/Include/BsGpuParamBlockBuffer.h
  16. 60 56
      Source/BansheeCore/Include/BsGpuParams.h
  17. 4 1
      Source/BansheeCore/Include/BsGpuParamsSet.h
  18. 24 21
      Source/BansheeCore/Include/BsGpuPipelineParamInfo.h
  19. 16 14
      Source/BansheeCore/Include/BsGpuPipelineState.h
  20. 5 2
      Source/BansheeCore/Include/BsGpuProgram.h
  21. 20 18
      Source/BansheeCore/Include/BsGpuProgramManager.h
  22. 4 0
      Source/BansheeCore/Include/BsHardwareBufferManager.h
  23. 6 3
      Source/BansheeCore/Include/BsIndexBuffer.h
  24. 40 37
      Source/BansheeCore/Include/BsMaterial.h
  25. 23 29
      Source/BansheeCore/Include/BsMaterialParam.h
  26. 32 32
      Source/BansheeCore/Include/BsMaterialParams.h
  27. 5 2
      Source/BansheeCore/Include/BsMesh.h
  28. 62 59
      Source/BansheeCore/Include/BsMeshBase.h
  29. 2 2
      Source/BansheeCore/Include/BsMeshData.h
  30. 73 69
      Source/BansheeCore/Include/BsMeshHeap.h
  31. 2 2
      Source/BansheeCore/Include/BsOcclusionQuery.h
  32. 2 2
      Source/BansheeCore/Include/BsParamBlocks.h
  33. 50 43
      Source/BansheeCore/Include/BsPass.h
  34. 4 4
      Source/BansheeCore/Include/BsPlatform.h
  35. 6 6
      Source/BansheeCore/Include/BsProfilerGPU.h
  36. 2 2
      Source/BansheeCore/Include/BsQueryManager.h
  37. 6 3
      Source/BansheeCore/Include/BsRasterizerState.h
  38. 4 0
      Source/BansheeCore/Include/BsRenderAPI.h
  39. 3 0
      Source/BansheeCore/Include/BsRenderStateManager.h
  40. 9 3
      Source/BansheeCore/Include/BsRenderTarget.h
  41. 7 4
      Source/BansheeCore/Include/BsRenderTexture.h
  42. 6 3
      Source/BansheeCore/Include/BsRenderWindow.h
  43. 10 7
      Source/BansheeCore/Include/BsRenderWindowManager.h
  44. 2 2
      Source/BansheeCore/Include/BsRendererExtension.h
  45. 1 1
      Source/BansheeCore/Include/BsRendererFactory.h
  46. 2 2
      Source/BansheeCore/Include/BsRendererManager.h
  47. 1 1
      Source/BansheeCore/Include/BsRendererMeshData.h
  48. 7 4
      Source/BansheeCore/Include/BsSamplerState.h
  49. 32 19
      Source/BansheeCore/Include/BsShader.h
  50. 29 25
      Source/BansheeCore/Include/BsTechnique.h
  51. 5 2
      Source/BansheeCore/Include/BsTexture.h
  52. 3 0
      Source/BansheeCore/Include/BsTextureManager.h
  53. 3 0
      Source/BansheeCore/Include/BsTextureView.h
  54. 2 2
      Source/BansheeCore/Include/BsTimerQuery.h
  55. 8 5
      Source/BansheeCore/Include/BsTransientMesh.h
  56. 6 3
      Source/BansheeCore/Include/BsVertexBuffer.h
  57. 2 2
      Source/BansheeCore/Include/BsVertexData.h
  58. 2 2
      Source/BansheeCore/Include/BsVertexDataDesc.h
  59. 5 2
      Source/BansheeCore/Include/BsVertexDeclaration.h
  60. 6 3
      Source/BansheeCore/Include/BsViewport.h
  61. 1 1
      Source/BansheeCore/Include/Win32/BSWin32PlatformData.h
  62. 44 41
      Source/BansheeCore/Source/BsBlendState.cpp
  63. 90 87
      Source/BansheeCore/Source/BsCamera.cpp
  64. 2 2
      Source/BansheeCore/Source/BsCommandBuffer.cpp
  65. 2 2
      Source/BansheeCore/Source/BsCommandBufferManager.cpp
  66. 6 6
      Source/BansheeCore/Source/BsCoreApplication.cpp
  67. 10 9
      Source/BansheeCore/Source/BsCoreObject.cpp
  68. 3 0
      Source/BansheeCore/Source/BsCoreObjectCore.cpp
  69. 5 5
      Source/BansheeCore/Source/BsCoreObjectManager.cpp
  70. 3 3
      Source/BansheeCore/Source/BsCoreRenderer.cpp
  71. 44 41
      Source/BansheeCore/Source/BsDepthStencilState.cpp
  72. 2 2
      Source/BansheeCore/Source/BsEventQuery.cpp
  73. 23 20
      Source/BansheeCore/Source/BsGpuBuffer.cpp
  74. 2 2
      Source/BansheeCore/Source/BsGpuParam.cpp
  75. 44 41
      Source/BansheeCore/Source/BsGpuParamBlockBuffer.cpp
  76. 119 116
      Source/BansheeCore/Source/BsGpuParams.cpp
  77. 9 9
      Source/BansheeCore/Source/BsGpuParamsSet.cpp
  78. 17 14
      Source/BansheeCore/Source/BsGpuPipelineParamInfo.cpp
  79. 63 60
      Source/BansheeCore/Source/BsGpuPipelineState.cpp
  80. 32 29
      Source/BansheeCore/Source/BsGpuProgram.cpp
  81. 26 23
      Source/BansheeCore/Source/BsGpuProgramManager.cpp
  82. 4 0
      Source/BansheeCore/Source/BsHardwareBufferManager.cpp
  83. 16 13
      Source/BansheeCore/Source/BsIndexBuffer.cpp
  84. 83 80
      Source/BansheeCore/Source/BsMaterial.cpp
  85. 131 128
      Source/BansheeCore/Source/BsMaterialParams.cpp
  86. 392 389
      Source/BansheeCore/Source/BsMesh.cpp
  87. 14 12
      Source/BansheeCore/Source/BsMeshBase.cpp
  88. 67 64
      Source/BansheeCore/Source/BsMeshHeap.cpp
  89. 2 2
      Source/BansheeCore/Source/BsOcclusionQuery.cpp
  90. 2 2
      Source/BansheeCore/Source/BsParamBlocks.cpp
  91. 74 71
      Source/BansheeCore/Source/BsPass.cpp
  92. 6 6
      Source/BansheeCore/Source/BsProfilerGPU.cpp
  93. 2 2
      Source/BansheeCore/Source/BsQueryManager.cpp
  94. 44 41
      Source/BansheeCore/Source/BsRasterizerState.cpp
  95. 28 25
      Source/BansheeCore/Source/BsRenderAPI.cpp
  96. 3 3
      Source/BansheeCore/Source/BsRenderAPIManager.cpp
  97. 3 0
      Source/BansheeCore/Source/BsRenderStateManager.cpp
  98. 28 26
      Source/BansheeCore/Source/BsRenderTarget.cpp
  99. 76 73
      Source/BansheeCore/Source/BsRenderTexture.cpp
  100. 174 171
      Source/BansheeCore/Source/BsRenderWindow.cpp

+ 7 - 3
Source/BansheeCore/Include/BsBlendState.h

@@ -139,7 +139,7 @@ namespace bs
 
 
 	protected:
 	protected:
 		friend class BlendState;
 		friend class BlendState;
-		friend class BlendStateCore;
+		friend class ct::BlendStateCore;
 		friend class BlendStateRTTI;
 		friend class BlendStateRTTI;
 
 
 		BLEND_STATE_DESC mData;
 		BLEND_STATE_DESC mData;
@@ -161,7 +161,7 @@ namespace bs
 		const BlendProperties& getProperties() const;
 		const BlendProperties& getProperties() const;
 
 
 		/** Retrieves a core implementation of the sampler state usable only from the core thread. */
 		/** Retrieves a core implementation of the sampler state usable only from the core thread. */
-		SPtr<BlendStateCore> getCore() const;
+		SPtr<ct::BlendStateCore> getCore() const;
 
 
 		/**	Creates a new blend state using the specified blend state description structure. */
 		/**	Creates a new blend state using the specified blend state description structure. */
 		static SPtr<BlendState> create(const BLEND_STATE_DESC& desc);
 		static SPtr<BlendState> create(const BLEND_STATE_DESC& desc);
@@ -178,7 +178,7 @@ namespace bs
 		BlendState(const BLEND_STATE_DESC& desc);
 		BlendState(const BLEND_STATE_DESC& desc);
 
 
 		/** @copydoc CoreObject::createCore */
 		/** @copydoc CoreObject::createCore */
-		SPtr<CoreObjectCore> createCore() const override;
+		SPtr<ct::CoreObjectCore> createCore() const override;
 
 
 		BlendProperties mProperties;
 		BlendProperties mProperties;
 		mutable UINT32 mId;
 		mutable UINT32 mId;
@@ -194,6 +194,9 @@ namespace bs
 	};
 	};
 
 
 	/** @} */
 	/** @} */
+
+	namespace ct
+	{
 	/** @addtogroup RenderAPI-Internal
 	/** @addtogroup RenderAPI-Internal
 	 *  @{
 	 *  @{
 	 */
 	 */
@@ -236,6 +239,7 @@ namespace bs
 	};
 	};
 
 
 	/** @} */
 	/** @} */
+	}
 }
 }
 
 
 /** @cond STDLIB */
 /** @cond STDLIB */

+ 35 - 31
Source/BansheeCore/Include/BsCamera.h

@@ -527,39 +527,11 @@ namespace bs
 	 };
 	 };
 
 
 	/** @} */
 	/** @} */
+
 	/** @addtogroup Renderer-Engine-Internal
 	/** @addtogroup Renderer-Engine-Internal
 	 *  @{
 	 *  @{
 	 */
 	 */
 
 
-	/** @copydoc CameraBase */
-	class BS_CORE_EXPORT CameraCore : public CoreObjectCore, public TCamera<true>
-	{
-	public:
-		~CameraCore();
-
-		/**	Returns the viewport used by the camera. */	
-		SPtr<ViewportCore> getViewport() const { return mViewport; }
-
-	protected:
-		friend class Camera;
-
-		CameraCore(SPtr<RenderTargetCore> target = nullptr,
-			float left = 0.0f, float top = 0.0f, float width = 1.0f, float height = 1.0f);
-
-		CameraCore(const SPtr<ViewportCore>& viewport);
-
-		/** @copydoc CoreObjectCore::initialize */
-		void initialize() override;
-
-		/** @copydoc CameraBase */
-		Rect2I getViewportRect() const override;
-
-		/** @copydoc CoreObject::syncToCore */
-		void syncToCore(const CoreSyncData& data) override;
-
-		SPtr<ViewportCore> mViewport;
-	};
-
 	/** @copydoc CameraBase */
 	/** @copydoc CameraBase */
 	class BS_CORE_EXPORT Camera : public IReflectable, public CoreObject, public TCamera<false>
 	class BS_CORE_EXPORT Camera : public IReflectable, public CoreObject, public TCamera<false>
     {
     {
@@ -580,7 +552,7 @@ namespace bs
 		void setMain(bool main) { mMain = main; }
 		void setMain(bool main) { mMain = main; }
 
 
 		/** Retrieves an implementation of a camera handler usable only from the core thread. */
 		/** Retrieves an implementation of a camera handler usable only from the core thread. */
-		SPtr<CameraCore> getCore() const;
+		SPtr<ct::CameraCore> getCore() const;
 
 
 		/**	Creates a new camera that renders to the specified portion of the provided render target. */
 		/**	Creates a new camera that renders to the specified portion of the provided render target. */
 		static SPtr<Camera> create(SPtr<RenderTarget> target = nullptr,
 		static SPtr<Camera> create(SPtr<RenderTarget> target = nullptr,
@@ -606,7 +578,7 @@ namespace bs
 		Rect2I getViewportRect() const override;
 		Rect2I getViewportRect() const override;
 
 
 		/** @copydoc CoreObject::createCore */
 		/** @copydoc CoreObject::createCore */
-		SPtr<CoreObjectCore> createCore() const override;
+		SPtr<ct::CoreObjectCore> createCore() const override;
 
 
 		/** @copydoc CameraBase::_markCoreDirty */
 		/** @copydoc CameraBase::_markCoreDirty */
 		void _markCoreDirty(CameraDirtyFlag flag = CameraDirtyFlag::Everything) override;
 		void _markCoreDirty(CameraDirtyFlag flag = CameraDirtyFlag::Everything) override;
@@ -633,5 +605,37 @@ namespace bs
 		RTTITypeBase* getRTTI() const override;
 		RTTITypeBase* getRTTI() const override;
      };
      };
 
 
+	namespace ct
+	{
+	/** @copydoc CameraBase */
+	class BS_CORE_EXPORT CameraCore : public CoreObjectCore, public TCamera<true>
+	{
+	public:
+		~CameraCore();
+
+		/**	Returns the viewport used by the camera. */	
+		SPtr<ViewportCore> getViewport() const { return mViewport; }
+
+	protected:
+		friend class Camera;
+
+		CameraCore(SPtr<RenderTargetCore> target = nullptr,
+			float left = 0.0f, float top = 0.0f, float width = 1.0f, float height = 1.0f);
+
+		CameraCore(const SPtr<ViewportCore>& viewport);
+
+		/** @copydoc CoreObjectCore::initialize */
+		void initialize() override;
+
+		/** @copydoc CameraBase */
+		Rect2I getViewportRect() const override;
+
+		/** @copydoc CoreObject::syncToCore */
+		void syncToCore(const CoreSyncData& data) override;
+
+		SPtr<ViewportCore> mViewport;
+	};
+	}
+
 	/** @} */
 	/** @} */
 }
 }

+ 2 - 2
Source/BansheeCore/Include/BsCommandBuffer.h

@@ -4,7 +4,7 @@
 
 
 #include "BsCorePrerequisites.h"
 #include "BsCorePrerequisites.h"
 
 
-namespace bs
+namespace bs { namespace ct
 {
 {
 	/** @addtogroup RenderAPI
 	/** @addtogroup RenderAPI
 	 *  @{
 	 *  @{
@@ -89,4 +89,4 @@ namespace bs
 	};
 	};
 
 
 	/** @} */
 	/** @} */
-}
+}}

+ 2 - 2
Source/BansheeCore/Include/BsCommandBufferManager.h

@@ -5,7 +5,7 @@
 #include "BsCorePrerequisites.h"
 #include "BsCorePrerequisites.h"
 #include "BsModule.h"
 #include "BsModule.h"
 
 
-namespace bs
+namespace bs { namespace ct 
 {
 {
 	/** @addtogroup RenderAPI-Internal
 	/** @addtogroup RenderAPI-Internal
 	 *  @{
 	 *  @{
@@ -34,4 +34,4 @@ namespace bs
 	};
 	};
 
 
 	/** @} */
 	/** @} */
-}
+}}

+ 3 - 3
Source/BansheeCore/Include/BsCommonTypes.h

@@ -603,15 +603,15 @@ namespace bs
 
 
 	template<bool Core> struct TMeshType {};
 	template<bool Core> struct TMeshType {};
 	template<> struct TMeshType < false > { typedef HMesh Type; };
 	template<> struct TMeshType < false > { typedef HMesh Type; };
-	template<> struct TMeshType < true > { typedef SPtr<MeshCore> Type; };
+	template<> struct TMeshType < true > { typedef SPtr<ct::MeshCore> Type; };
 
 
 	template<bool Core> struct TMaterialPtrType {};
 	template<bool Core> struct TMaterialPtrType {};
 	template<> struct TMaterialPtrType < false > { typedef HMaterial Type; };
 	template<> struct TMaterialPtrType < false > { typedef HMaterial Type; };
-	template<> struct TMaterialPtrType < true > { typedef SPtr<MaterialCore> Type; };
+	template<> struct TMaterialPtrType < true > { typedef SPtr<ct::MaterialCore> Type; };
 
 
 	template<bool Core> struct TTextureType {};
 	template<bool Core> struct TTextureType {};
 	template<> struct TTextureType < false > { typedef HTexture Type; };
 	template<> struct TTextureType < false > { typedef HTexture Type; };
-	template<> struct TTextureType < true > { typedef SPtr<TextureCore> Type; };
+	template<> struct TTextureType < true > { typedef SPtr<ct::TextureCore> Type; };
 
 
 	/** @cond SPECIALIZATIONS */
 	/** @cond SPECIALIZATIONS */
 	BS_ALLOW_MEMCPY_SERIALIZATION(TextureSurface);
 	BS_ALLOW_MEMCPY_SERIALIZATION(TextureSurface);

+ 10 - 9
Source/BansheeCore/Include/BsCoreObject.h

@@ -76,7 +76,7 @@ namespace bs
 		 *
 		 *
 		 * @note	Thread safe to retrieve, but its data is only valid on the core thread.
 		 * @note	Thread safe to retrieve, but its data is only valid on the core thread.
 		 */
 		 */
-		SPtr<CoreObjectCore> getCore() const { return mCoreSpecific; }
+		SPtr<ct::CoreObjectCore> getCore() const { return mCoreSpecific; }
 
 
 		/**
 		/**
 		 * Ensures all dirty syncable data is send to the core thread counterpart of this object (if any).
 		 * Ensures all dirty syncable data is send to the core thread counterpart of this object (if any).
@@ -129,7 +129,7 @@ namespace bs
 		 * Requires a shared pointer to the object this function will be executed on, in order to make sure the object is 
 		 * Requires a shared pointer to the object this function will be executed on, in order to make sure the object is 
 		 * not deleted before the command executes. Can be null if the function is static or global.
 		 * not deleted before the command executes. Can be null if the function is static or global.
 		 */
 		 */
-		static void queueGpuCommand(const SPtr<CoreObjectCore>& obj, std::function<void()> func);
+		static void queueGpuCommand(const SPtr<ct::CoreObjectCore>& obj, std::function<void()> func);
 
 
 		/**
 		/**
 		 * Queues a command to be executed on the core thread, with a return value in the form of AsyncOp.
 		 * Queues a command to be executed on the core thread, with a return value in the form of AsyncOp.
@@ -140,7 +140,7 @@ namespace bs
 		 * Requires a shared pointer to the object this function will be executed on, in order to make sure the object is 
 		 * Requires a shared pointer to the object this function will be executed on, in order to make sure the object is 
 		 * not deleted before the command executes. Can be null if the function is static or global.
 		 * not deleted before the command executes. Can be null if the function is static or global.
 		 */
 		 */
-		static AsyncOp queueReturnGpuCommand(const SPtr<CoreObjectCore>& obj, std::function<void(AsyncOp&)> func);
+		static AsyncOp queueReturnGpuCommand(const SPtr<ct::CoreObjectCore>& obj, std::function<void(AsyncOp&)> func);
 
 
 		bool requiresInitOnCoreThread() const { return (mFlags & CGO_INIT_ON_CORE_THREAD) != 0; }
 		bool requiresInitOnCoreThread() const { return (mFlags & CGO_INIT_ON_CORE_THREAD) != 0; }
 		void setIsDestroyed(bool destroyed) { mFlags = destroyed ? mFlags | CGO_DESTROYED : mFlags & ~CGO_DESTROYED; }
 		void setIsDestroyed(bool destroyed) { mFlags = destroyed ? mFlags | CGO_DESTROYED : mFlags & ~CGO_DESTROYED; }
@@ -156,7 +156,7 @@ namespace bs
 		 * Queues object initialization command on the core thread. The command is added to the primary core thread queue 
 		 * Queues object initialization command on the core thread. The command is added to the primary core thread queue 
 		 * and will be executed as soon as the core thread is ready.
 		 * and will be executed as soon as the core thread is ready.
 		 */
 		 */
-		static void queueInitializeGpuCommand(const SPtr<CoreObjectCore>& obj);
+		static void queueInitializeGpuCommand(const SPtr<ct::CoreObjectCore>& obj);
 
 
 		/**
 		/**
 		 * Queues object destruction command on the core thread. The command is added to the core thread queue of this 
 		 * Queues object destruction command on the core thread. The command is added to the core thread queue of this 
@@ -164,13 +164,14 @@ namespace bs
 		 *
 		 *
 		 * @note	It is up to the caller to ensure no other threads attempt to use this object.
 		 * @note	It is up to the caller to ensure no other threads attempt to use this object.
 		 */
 		 */
-		static void queueDestroyGpuCommand(const SPtr<CoreObjectCore>& obj);
+		static void queueDestroyGpuCommand(const SPtr<ct::CoreObjectCore>& obj);
 
 
 		/** Helper wrapper method used for queuing commands with no return value on the core thread. */
 		/** Helper wrapper method used for queuing commands with no return value on the core thread. */
-		static void executeGpuCommand(const SPtr<CoreObjectCore>& obj, std::function<void()> func);
+		static void executeGpuCommand(const SPtr<ct::CoreObjectCore>& obj, std::function<void()> func);
 
 
 		/**	Helper wrapper method used for queuing commands with a return value on the core thread. */
 		/**	Helper wrapper method used for queuing commands with a return value on the core thread. */
-		static void executeReturnGpuCommand(const SPtr<CoreObjectCore>& obj, std::function<void(AsyncOp&)> func, AsyncOp& op);
+		static void executeReturnGpuCommand(const SPtr<ct::CoreObjectCore>& obj, std::function<void(AsyncOp&)> func, 
+			AsyncOp& op);
 
 
 	protected:
 	protected:
 		/************************************************************************/
 		/************************************************************************/
@@ -181,7 +182,7 @@ namespace bs
 		 * Creates an object that contains core thread specific data and methods for this CoreObject. Can be null if such 
 		 * Creates an object that contains core thread specific data and methods for this CoreObject. Can be null if such 
 		 * object is not required.
 		 * object is not required.
 		 */
 		 */
-		virtual SPtr<CoreObjectCore> createCore() const { return nullptr; }
+		virtual SPtr<ct::CoreObjectCore> createCore() const { return nullptr; }
 
 
 		/**
 		/**
 		 * Marks the core data as dirty. This causes the syncToCore() method to trigger the next time objects are synced 
 		 * Marks the core data as dirty. This causes the syncToCore() method to trigger the next time objects are synced 
@@ -232,7 +233,7 @@ namespace bs
 		virtual void getCoreDependencies(Vector<CoreObject*>& dependencies) { }
 		virtual void getCoreDependencies(Vector<CoreObject*>& dependencies) { }
 
 
 	protected:
 	protected:
-		SPtr<CoreObjectCore> mCoreSpecific;
+		SPtr<ct::CoreObjectCore> mCoreSpecific;
 	};
 	};
 
 
 	/**
 	/**

+ 3 - 0
Source/BansheeCore/Include/BsCoreObjectCore.h

@@ -7,6 +7,8 @@
 
 
 namespace bs
 namespace bs
 {
 {
+	namespace ct
+	{
 	/** @addtogroup CoreThread
 	/** @addtogroup CoreThread
 	 *  @{
 	 *  @{
 	 */
 	 */
@@ -90,5 +92,6 @@ namespace bs
 	};
 	};
 
 
 	/** @} */
 	/** @} */
+	}
 }
 }
 
 

+ 2 - 2
Source/BansheeCore/Include/BsCoreObjectManager.h

@@ -33,11 +33,11 @@ namespace bs
 				:internalId(0)
 				:internalId(0)
 			{ }
 			{ }
 
 
-			CoreStoredSyncObjData(const SPtr<CoreObjectCore> destObj, UINT64 internalId, const CoreSyncData& syncData)
+			CoreStoredSyncObjData(const SPtr<ct::CoreObjectCore> destObj, UINT64 internalId, const CoreSyncData& syncData)
 				:destinationObj(destObj), syncData(syncData), internalId(internalId)
 				:destinationObj(destObj), syncData(syncData), internalId(internalId)
 			{ }
 			{ }
 
 
-			SPtr<CoreObjectCore> destinationObj;
+			SPtr<ct::CoreObjectCore> destinationObj;
 			CoreSyncData syncData;
 			CoreSyncData syncData;
 			UINT64 internalId;
 			UINT64 internalId;
 		};
 		};

+ 49 - 47
Source/BansheeCore/Include/BsCorePrerequisites.h

@@ -226,12 +226,8 @@ namespace bs
     class GpuProgram;
     class GpuProgram;
     class GpuProgramManager;
     class GpuProgramManager;
     class IndexBuffer;
     class IndexBuffer;
-	class IndexBufferCore;
-    class OcclusionQuery;
     class VertexBuffer;
     class VertexBuffer;
-	class VertexBufferCore;
 	class GpuBuffer;
 	class GpuBuffer;
-	class HighLevelGpuProgram;
 	class GpuProgramManager;
 	class GpuProgramManager;
 	class GpuProgramFactory;
 	class GpuProgramFactory;
     class IndexData;
     class IndexData;
@@ -239,38 +235,26 @@ namespace bs
 	class Technique;
 	class Technique;
 	class Shader;
 	class Shader;
 	class Material;
 	class Material;
-    class RenderAPICore;
     class RenderAPICapabilities;
     class RenderAPICapabilities;
     class RenderTarget;
     class RenderTarget;
-	class RenderTargetCore;
     class RenderTexture;
     class RenderTexture;
-	class RenderTextureCore;
     class RenderWindow;
     class RenderWindow;
-	class RenderWindowCore;
 	class RenderTargetProperties;
 	class RenderTargetProperties;
-    struct RenderOpMesh;
-    class StringInterface;
     class SamplerState;
     class SamplerState;
-	class SamplerStateCore;
     class TextureManager;
     class TextureManager;
     class Viewport;
     class Viewport;
-    class VertexData;
     class VertexDeclaration;
     class VertexDeclaration;
 	class Input;
 	class Input;
 	struct PointerEvent;
 	struct PointerEvent;
 	class RawInputHandler;
 	class RawInputHandler;
-	class CoreRenderer;
 	class RendererFactory;
 	class RendererFactory;
 	class AsyncOp;
 	class AsyncOp;
 	class HardwareBufferManager;
 	class HardwareBufferManager;
 	class FontManager;
 	class FontManager;
 	class DepthStencilState;
 	class DepthStencilState;
-	class DepthStencilStateCore;
 	class RenderStateManager;
 	class RenderStateManager;
 	class RasterizerState;
 	class RasterizerState;
-	class RasterizerStateCore;
 	class BlendState;
 	class BlendState;
-	class BlendStateCore;
 	class GpuParamBlock;
 	class GpuParamBlock;
 	class GpuParamBlockBuffer;
 	class GpuParamBlockBuffer;
 	class GpuParams;
 	class GpuParams;
@@ -279,9 +263,7 @@ namespace bs
 	struct GpuParamObjectDesc;
 	struct GpuParamObjectDesc;
 	struct GpuParamBlockDesc;
 	struct GpuParamBlockDesc;
 	class ShaderInclude;
 	class ShaderInclude;
-	class TextureView;
 	class CoreObject;
 	class CoreObject;
-	class CoreObjectCore;
 	class ImportOptions;
 	class ImportOptions;
 	class TextureImportOptions;
 	class TextureImportOptions;
 	class FontImportOptions;
 	class FontImportOptions;
@@ -294,40 +276,18 @@ namespace bs
 	class RenderQueue;
 	class RenderQueue;
 	struct ProfilerReport;
 	struct ProfilerReport;
 	class VertexDataDesc;
 	class VertexDataDesc;
-	class EventQuery;
-	class TimerQuery;
-	class OcclusionQuery;
 	class FrameAlloc;
 	class FrameAlloc;
 	class FolderMonitor;
 	class FolderMonitor;
 	class VideoMode;
 	class VideoMode;
 	class VideoOutputInfo;
 	class VideoOutputInfo;
 	class VideoModeInfo;
 	class VideoModeInfo;
-	class RenderableElement;
-	class CameraCore;
-	class MeshCoreBase;
-	class MeshCore;
 	struct SubMesh;
 	struct SubMesh;
-	class TransientMeshCore;
-	class TextureCore;
-	class MeshHeapCore;
-	class VertexDeclarationCore;
-	class GpuBufferCore;
-	class GpuParamBlockBufferCore;
-	class GpuParamsCore;
-	class ShaderCore;
-	class ViewportCore;
-	class PassCore;
-	class GpuParamsSetCore;
-	class TechniqueCore;
-	class MaterialCore;
-	class GpuProgramCore;
 	class IResourceListener;
 	class IResourceListener;
 	class TextureProperties;
 	class TextureProperties;
 	class IShaderIncludeHandler;
 	class IShaderIncludeHandler;
 	class Prefab;
 	class Prefab;
 	class PrefabDiff;
 	class PrefabDiff;
 	class RendererMeshData;
 	class RendererMeshData;
-	class LightCore;
 	class Light;
 	class Light;
 	class Win32Window;
 	class Win32Window;
 	class RenderAPIFactory;
 	class RenderAPIFactory;
@@ -373,24 +333,18 @@ namespace bs
 	class AnimationClip;
 	class AnimationClip;
 	class CCamera;
 	class CCamera;
 	class GpuPipelineParamInfo;
 	class GpuPipelineParamInfo;
-	class GpuPipelineParamInfoCore;
+	class MaterialParams;
 	template <class T> class TAnimationCurve;
 	template <class T> class TAnimationCurve;
 	struct AnimationCurves;
 	struct AnimationCurves;
 	class Skeleton;
 	class Skeleton;
 	class Animation;
 	class Animation;
 	class GpuParamsSet;
 	class GpuParamsSet;
-	class GpuParamsSetCore;
-	class MaterialParamsCore;
 	class Camera;
 	class Camera;
-	class CameraCore;
 	class MorphShapes;
 	class MorphShapes;
 	class MorphShape;
 	class MorphShape;
 	class MorphChannel;
 	class MorphChannel;
-	class CommandBuffer;
 	class GraphicsPipelineState;
 	class GraphicsPipelineState;
-	class GraphicsPipelineStateCore;
 	class ComputePipelineState;
 	class ComputePipelineState;
-	class ComputePipelineStateCore;
 	// Asset import
 	// Asset import
 	class SpecificImporter;
 	class SpecificImporter;
 	class Importer;
 	class Importer;
@@ -410,6 +364,7 @@ namespace bs
 	class PhysicsMaterial;
 	class PhysicsMaterial;
 	class PhysicsMesh;
 	class PhysicsMesh;
 	class AudioClip;
 	class AudioClip;
+	class CoreObjectManager;
 	struct CollisionData;
 	struct CollisionData;
 	// Scene
 	// Scene
 	class SceneObject;
 	class SceneObject;
@@ -440,6 +395,53 @@ namespace bs
 	class TCoreThreadQueue;
 	class TCoreThreadQueue;
 	class CommandQueueNoSync;
 	class CommandQueueNoSync;
 	class CommandQueueSync;
 	class CommandQueueSync;
+
+	namespace ct
+	{
+		class CoreRenderer;
+		class VertexData;
+		class SamplerStateCore;
+		class IndexBufferCore;
+		class VertexBufferCore;
+		class RenderAPICore;
+		class RenderTargetCore;
+		class RenderTextureCore;
+		class RenderWindowCore;
+		class DepthStencilStateCore;
+		class RasterizerStateCore;
+		class BlendStateCore;
+		class CoreObjectCore;
+		class CameraCore;
+		class MeshCoreBase;
+		class MeshCore;
+		class TransientMeshCore;
+		class TextureCore;
+		class MeshHeapCore;
+		class VertexDeclarationCore;
+		class GpuBufferCore;
+		class GpuParamBlockBufferCore;
+		class GpuParamsCore;
+		class ShaderCore;
+		class ViewportCore;
+		class PassCore;
+		class GpuParamsSetCore;
+		class TechniqueCore;
+		class MaterialCore;
+		class GpuProgramCore;
+		class LightCore;
+		class ComputePipelineStateCore;
+		class GraphicsPipelineStateCore;
+		class CameraCore;
+		class GpuParamsSetCore;
+		class MaterialParamsCore;
+		class GpuPipelineParamInfoCore;
+		class CommandBuffer;
+		class EventQuery;
+		class TimerQuery;
+		class OcclusionQuery;
+		class TextureView;
+		class RenderableElement;
+	}
 }
 }
 
 
 /************************************************************************/
 /************************************************************************/

+ 8 - 6
Source/BansheeCore/Include/BsCoreRenderer.h

@@ -6,11 +6,13 @@
 #include "BsStringID.h"
 #include "BsStringID.h"
 #include "BsRendererMeshData.h"
 #include "BsRendererMeshData.h"
 
 
-namespace bs
-{
+namespace bs 
+{ 
 	class RendererExtension;
 	class RendererExtension;
 	struct PostProcessSettings;
 	struct PostProcessSettings;
 
 
+	namespace ct
+	{
 	/** @addtogroup Renderer-Internal
 	/** @addtogroup Renderer-Internal
 	 *  @{
 	 *  @{
 	 */
 	 */
@@ -81,7 +83,7 @@ namespace bs
 		 *
 		 *
 		 * @note	Core thread.
 		 * @note	Core thread.
 		 */
 		 */
-		virtual void notifyCameraAdded(const CameraCore* camera) { }
+		virtual void notifyCameraAdded(const ct::CameraCore* camera) { }
 
 
 		/**
 		/**
 		 * Called whenever a camera's position or rotation is updated.
 		 * Called whenever a camera's position or rotation is updated.
@@ -91,14 +93,14 @@ namespace bs
 		 *
 		 *
 		 * @note	Core thread.
 		 * @note	Core thread.
 		 */
 		 */
-		virtual void notifyCameraUpdated(const CameraCore* camera, UINT32 updateFlag) { }
+		virtual void notifyCameraUpdated(const ct::CameraCore* camera, UINT32 updateFlag) { }
 
 
 		/**
 		/**
 		 * Called whenever a camera is destroyed.
 		 * Called whenever a camera is destroyed.
 		 *
 		 *
 		 * @note	Core thread.
 		 * @note	Core thread.
 		 */
 		 */
-		virtual void notifyCameraRemoved(const CameraCore* camera) { }
+		virtual void notifyCameraRemoved(const ct::CameraCore* camera) { }
 
 
 		/**
 		/**
 		 * Creates a new empty renderer mesh data.
 		 * Creates a new empty renderer mesh data.
@@ -157,4 +159,4 @@ namespace bs
 	};
 	};
 
 
 	/** @} */
 	/** @} */
-}
+}}

+ 6 - 3
Source/BansheeCore/Include/BsDepthStencilState.h

@@ -152,7 +152,7 @@ namespace bs
 		const DepthStencilProperties& getProperties() const;
 		const DepthStencilProperties& getProperties() const;
 
 
 		/**	Retrieves a core implementation of a sampler state usable only from the core thread. */
 		/**	Retrieves a core implementation of a sampler state usable only from the core thread. */
-		SPtr<DepthStencilStateCore> getCore() const;
+		SPtr<ct::DepthStencilStateCore> getCore() const;
 
 
 		/**	Creates a new depth stencil state using the specified depth stencil state description structure. */
 		/**	Creates a new depth stencil state using the specified depth stencil state description structure. */
 		static SPtr<DepthStencilState> create(const DEPTH_STENCIL_STATE_DESC& desc);
 		static SPtr<DepthStencilState> create(const DEPTH_STENCIL_STATE_DESC& desc);
@@ -169,7 +169,7 @@ namespace bs
 		DepthStencilState(const DEPTH_STENCIL_STATE_DESC& desc);
 		DepthStencilState(const DEPTH_STENCIL_STATE_DESC& desc);
 
 
 		/** @copydoc CoreObject::createCore */
 		/** @copydoc CoreObject::createCore */
-		SPtr<CoreObjectCore> createCore() const override;
+		SPtr<ct::CoreObjectCore> createCore() const override;
 
 
 		DepthStencilProperties mProperties;
 		DepthStencilProperties mProperties;
 		mutable UINT32 mId;
 		mutable UINT32 mId;
@@ -181,11 +181,13 @@ namespace bs
 	public:
 	public:
 		friend class DepthStencilStateRTTI;
 		friend class DepthStencilStateRTTI;
 		static RTTITypeBase* getRTTIStatic();
 		static RTTITypeBase* getRTTIStatic();
-		virtual RTTITypeBase* getRTTI() const override;	
+		RTTITypeBase* getRTTI() const override;	
 	};
 	};
 
 
 	/** @} */
 	/** @} */
 
 
+	namespace ct
+	{
 	/** @addtogroup RenderAPI-Internal
 	/** @addtogroup RenderAPI-Internal
 	 *  @{
 	 *  @{
 	 */
 	 */
@@ -228,6 +230,7 @@ namespace bs
 	};
 	};
 
 
 	/** @} */
 	/** @} */
+	}
 }
 }
 
 
 /** @cond STDLIB */
 /** @cond STDLIB */

+ 2 - 2
Source/BansheeCore/Include/BsEventQuery.h

@@ -4,7 +4,7 @@
 
 
 #include "BsCorePrerequisites.h"
 #include "BsCorePrerequisites.h"
 
 
-namespace bs
+namespace bs { namespace ct
 {
 {
 	/** @addtogroup RenderAPI-Internal
 	/** @addtogroup RenderAPI-Internal
 	 *  @{
 	 *  @{
@@ -64,4 +64,4 @@ namespace bs
 	};
 	};
 
 
 	/** @} */
 	/** @} */
-}
+}}

+ 5 - 2
Source/BansheeCore/Include/BsGpuBuffer.h

@@ -108,7 +108,7 @@ namespace bs
 		const GpuBufferProperties& getProperties() const { return mProperties; }
 		const GpuBufferProperties& getProperties() const { return mProperties; }
 
 
 		/** Retrieves a core implementation of a GPU buffer usable only from the core thread. */
 		/** Retrieves a core implementation of a GPU buffer usable only from the core thread. */
-		SPtr<GpuBufferCore> getCore() const;
+		SPtr<ct::GpuBufferCore> getCore() const;
 
 
 		/** Returns the size of a single element in the buffer, of the provided format, in bytes. */
 		/** Returns the size of a single element in the buffer, of the provided format, in bytes. */
 		static UINT32 getFormatSize(GpuBufferFormat format);
 		static UINT32 getFormatSize(GpuBufferFormat format);
@@ -122,13 +122,15 @@ namespace bs
 		GpuBuffer(const GPU_BUFFER_DESC& desc);
 		GpuBuffer(const GPU_BUFFER_DESC& desc);
 
 
 		/** @copydoc CoreObject::createCore */
 		/** @copydoc CoreObject::createCore */
-		SPtr<CoreObjectCore> createCore() const override;
+		SPtr<ct::CoreObjectCore> createCore() const override;
 
 
 		GpuBufferProperties mProperties;
 		GpuBufferProperties mProperties;
     };
     };
 
 
 	/** @} */
 	/** @} */
 
 
+	namespace ct
+	{
 	/** @addtogroup RenderAPI-Internal
 	/** @addtogroup RenderAPI-Internal
 	 *  @{
 	 *  @{
 	 */
 	 */
@@ -156,4 +158,5 @@ namespace bs
 	};
 	};
 
 
 	/** @} */
 	/** @} */
+	}
 }
 }

+ 26 - 26
Source/BansheeCore/Include/BsGpuParam.h

@@ -20,23 +20,23 @@ namespace bs
 
 
 	template<bool Core> struct TGpuParamsPtrType { };
 	template<bool Core> struct TGpuParamsPtrType { };
 	template<> struct TGpuParamsPtrType<false> { typedef SPtr<GpuParams> Type; };
 	template<> struct TGpuParamsPtrType<false> { typedef SPtr<GpuParams> Type; };
-	template<> struct TGpuParamsPtrType<true> { typedef SPtr<GpuParamsCore> Type; };
+	template<> struct TGpuParamsPtrType<true> { typedef SPtr<ct::GpuParamsCore> Type; };
 
 
 	template<bool Core> struct TGpuParamTextureType { };
 	template<bool Core> struct TGpuParamTextureType { };
 	template<> struct TGpuParamTextureType < false > { typedef HTexture Type; };
 	template<> struct TGpuParamTextureType < false > { typedef HTexture Type; };
-	template<> struct TGpuParamTextureType < true > { typedef SPtr<TextureCore> Type; };
+	template<> struct TGpuParamTextureType < true > { typedef SPtr<ct::TextureCore> Type; };
 
 
 	template<bool Core> struct TGpuParamSamplerStateType { };
 	template<bool Core> struct TGpuParamSamplerStateType { };
 	template<> struct TGpuParamSamplerStateType < false > { typedef SPtr<SamplerState> Type; };
 	template<> struct TGpuParamSamplerStateType < false > { typedef SPtr<SamplerState> Type; };
-	template<> struct TGpuParamSamplerStateType < true > { typedef SPtr<SamplerStateCore> Type; };
+	template<> struct TGpuParamSamplerStateType < true > { typedef SPtr<ct::SamplerStateCore> Type; };
 
 
 	template<bool Core> struct TGpuParamBufferType { };
 	template<bool Core> struct TGpuParamBufferType { };
 	template<> struct TGpuParamBufferType < false > { typedef SPtr<GpuParamBlockBuffer> Type; };
 	template<> struct TGpuParamBufferType < false > { typedef SPtr<GpuParamBlockBuffer> Type; };
-	template<> struct TGpuParamBufferType < true > { typedef SPtr<GpuParamBlockBufferCore> Type; };
+	template<> struct TGpuParamBufferType < true > { typedef SPtr<ct::GpuParamBlockBufferCore> Type; };
 
 
 	template<bool Core> struct TGpuBufferType { };
 	template<bool Core> struct TGpuBufferType { };
 	template<> struct TGpuBufferType < false > { typedef SPtr<GpuBuffer> Type; };
 	template<> struct TGpuBufferType < false > { typedef SPtr<GpuBuffer> Type; };
-	template<> struct TGpuBufferType < true > { typedef SPtr<GpuBufferCore> Type; };
+	template<> struct TGpuBufferType < true > { typedef SPtr<ct::GpuBufferCore> Type; };
 
 
 	/**
 	/**
 	 * Policy class that allows us to re-use this template class for matrices which might need transposing, and other 
 	 * Policy class that allows us to re-use this template class for matrices which might need transposing, and other 
@@ -324,32 +324,32 @@ namespace bs
 	typedef TGpuDataParam<Matrix4, false> GpuParamMat4;
 	typedef TGpuDataParam<Matrix4, false> GpuParamMat4;
 	typedef TGpuDataParam<Color, false> GpuParamColor;
 	typedef TGpuDataParam<Color, false> GpuParamColor;
 
 
-	typedef TGpuDataParam<float, true> GpuParamFloatCore;
-	typedef TGpuDataParam<Vector2, true> GpuParamVec2Core;
-	typedef TGpuDataParam<Vector3, true> GpuParamVec3Core;
-	typedef TGpuDataParam<Vector4, true> GpuParamVec4Core;
-	typedef TGpuDataParam<int, true> GpuParamIntCore;
-	typedef TGpuDataParam<Vector2I, true> GpuParamVec2ICore;
-	typedef TGpuDataParam<Vector3I, true> GpuParamVec3ICore;
-	typedef TGpuDataParam<Vector4I, true> GpuParamVec4ICore;
-	typedef TGpuDataParam<Matrix3, true> GpuParamMat3Core;
-	typedef TGpuDataParam<Matrix4, true> GpuParamMat4Core;
-	typedef TGpuDataParam<Color, true> GpuParamColorCore;
-
 	typedef TGpuParamStruct<false> GpuParamStruct;
 	typedef TGpuParamStruct<false> GpuParamStruct;
-	typedef TGpuParamStruct<true> GpuParamStructCore;
-
 	typedef TGpuParamTexture<false> GpuParamTexture;
 	typedef TGpuParamTexture<false> GpuParamTexture;
-	typedef TGpuParamTexture<true> GpuParamTextureCore;
-	
 	typedef TGpuParamBuffer<false> GpuParamBuffer;
 	typedef TGpuParamBuffer<false> GpuParamBuffer;
-	typedef TGpuParamBuffer<true> GpuParamBufferCore;
-
 	typedef TGpuParamSampState<false> GpuParamSampState;
 	typedef TGpuParamSampState<false> GpuParamSampState;
-	typedef TGpuParamSampState<true> GpuParamSampStateCore;
-
 	typedef TGpuParamLoadStoreTexture<false> GpuParamLoadStoreTexture;
 	typedef TGpuParamLoadStoreTexture<false> GpuParamLoadStoreTexture;
-	typedef TGpuParamLoadStoreTexture<true> GpuParamLoadStoreTextureCore;
+
+	namespace ct
+	{
+		typedef TGpuDataParam<float, true> GpuParamFloatCore;
+		typedef TGpuDataParam<Vector2, true> GpuParamVec2Core;
+		typedef TGpuDataParam<Vector3, true> GpuParamVec3Core;
+		typedef TGpuDataParam<Vector4, true> GpuParamVec4Core;
+		typedef TGpuDataParam<int, true> GpuParamIntCore;
+		typedef TGpuDataParam<Vector2I, true> GpuParamVec2ICore;
+		typedef TGpuDataParam<Vector3I, true> GpuParamVec3ICore;
+		typedef TGpuDataParam<Vector4I, true> GpuParamVec4ICore;
+		typedef TGpuDataParam<Matrix3, true> GpuParamMat3Core;
+		typedef TGpuDataParam<Matrix4, true> GpuParamMat4Core;
+		typedef TGpuDataParam<Color, true> GpuParamColorCore;
+
+		typedef TGpuParamStruct<true> GpuParamStructCore;
+		typedef TGpuParamTexture<true> GpuParamTextureCore;
+		typedef TGpuParamBuffer<true> GpuParamBufferCore;
+		typedef TGpuParamSampState<true> GpuParamSampStateCore;
+		typedef TGpuParamLoadStoreTexture<true> GpuParamLoadStoreTextureCore;
+	}
 
 
 	/** @} */
 	/** @} */
 }
 }

+ 62 - 59
Source/BansheeCore/Include/BsGpuParamBlockBuffer.h

@@ -7,141 +7,144 @@
 
 
 namespace bs
 namespace bs
 {
 {
-	/** @addtogroup RenderAPI-Internal
+	/** @addtogroup RenderAPI
 	 *  @{
 	 *  @{
 	 */
 	 */
 
 
 	/**
 	/**
-	 * Core thread version of a GpuParamBlockBuffer.
+	 * Represents a GPU parameter block buffer. Parameter block buffers are bound to GPU programs which then fetch 
+	 * parameters from those buffers.
 	 *
 	 *
-	 * @note	Core thread only.
+	 * Writing or reading from this buffer will translate directly to API calls that update the GPU.
+	 * 			
+	 * @note	Sim thread only.
 	 */
 	 */
-	class BS_CORE_EXPORT GpuParamBlockBufferCore : public CoreObjectCore
+	class BS_CORE_EXPORT GpuParamBlockBuffer : public CoreObject
 	{
 	{
 	public:
 	public:
-		GpuParamBlockBufferCore(UINT32 size, GpuParamBlockUsage usage, GpuDeviceFlags deviceMask);
-		virtual ~GpuParamBlockBufferCore();
-
-		/** 
-		 * Writes all of the specified data to the buffer. Data size must be the same size as the buffer. 
-		 *
-		 * @param[in]	data		Data to write. Must match the size of the buffer.
-		 * @param[in]	queueIdx	Device queue to perform the write operation on. See @ref queuesDoc.
-		 */
-		virtual void writeToGPU(const UINT8* data, UINT32 queueIdx = 0) = 0;
-
-		/** 
-		 * Flushes any cached data into the actual GPU buffer. 
-		 *
-		 * @param[in]	queueIdx	Device queue to perform the write operation on. See @ref queuesDoc.
-		 */
-		void flushToGPU(UINT32 queueIdx = 0);
+		GpuParamBlockBuffer(UINT32 size, GpuParamBlockUsage usage);
+		virtual ~GpuParamBlockBuffer();
 
 
 		/**
 		/**
 		 * Write some data to the specified offset in the buffer. 
 		 * Write some data to the specified offset in the buffer. 
 		 *
 		 *
-		 * @note	All values are in bytes. Actual hardware buffer update is delayed until rendering or until 
-		 *			flushToGPU() is called.
+		 * @note	All values are in bytes. Actual hardware buffer update is delayed until rendering.
 		 */
 		 */
 		void write(UINT32 offset, const void* data, UINT32 size);
 		void write(UINT32 offset, const void* data, UINT32 size);
 
 
 		/**
 		/**
 		 * Read some data from the specified offset in the buffer.
 		 * Read some data from the specified offset in the buffer.
 		 *			
 		 *			
-		 * @note	All values are in bytes. This reads from the cached CPU buffer and not directly from the GPU.
+		 * @note	All values are in bytes. This reads from the cached CPU buffer and not from the GPU.
 		 */
 		 */
 		void read(UINT32 offset, void* data, UINT32 size);
 		void read(UINT32 offset, void* data, UINT32 size);
 
 
 		/**
 		/**
 		 * Clear specified section of the buffer to zero.
 		 * Clear specified section of the buffer to zero.
 		 *
 		 *
-		 * @note	All values are in bytes. Actual hardware buffer update is delayed until rendering or until 
-		 *			flushToGPU() is called.
+		 * @note	All values are in bytes. Actual hardware buffer update is delayed until rendering.
 		 */
 		 */
 		void zeroOut(UINT32 offset, UINT32 size);
 		void zeroOut(UINT32 offset, UINT32 size);
 
 
+		/** Returns internal cached data of the buffer. */
+		const UINT8* getCachedData() const { return mCachedData; }
+
 		/**	Returns the size of the buffer in bytes. */
 		/**	Returns the size of the buffer in bytes. */
 		UINT32 getSize() const { return mSize; }
 		UINT32 getSize() const { return mSize; }
 
 
-		/** @copydoc HardwareBufferCoreManager::createGpuParamBlockBuffer */
-		static SPtr<GpuParamBlockBufferCore> create(UINT32 size, GpuParamBlockUsage usage = GPBU_DYNAMIC,
-			GpuDeviceFlags deviceMask = GDF_DEFAULT);
+		/**	Retrieves a core implementation of a GPU param block buffer usable only from the core thread. */
+		SPtr<ct::GpuParamBlockBufferCore> getCore() const;
+
+		/** @copydoc HardwareBufferManager::createGpuParamBlockBuffer */
+		static SPtr<GpuParamBlockBuffer> create(UINT32 size, GpuParamBlockUsage usage = GPBU_DYNAMIC);
 
 
 	protected:
 	protected:
-		/** @copydoc CoreObjectCore::syncToCore */
-		void syncToCore(const CoreSyncData& data)  override;
+		/** @copydoc CoreObject::createCore */
+		SPtr<ct::CoreObjectCore> createCore() const override;
+
+		/** @copydoc CoreObject::syncToCore */
+		CoreSyncData syncToCore(FrameAlloc* allocator) override;
 
 
 		GpuParamBlockUsage mUsage;
 		GpuParamBlockUsage mUsage;
 		UINT32 mSize;
 		UINT32 mSize;
-
 		UINT8* mCachedData;
 		UINT8* mCachedData;
-		bool mGPUBufferDirty;
 	};
 	};
 
 
 	/** @} */
 	/** @} */
-	/** @addtogroup RenderAPI
+
+	namespace ct
+	{
+	/** @addtogroup RenderAPI-Internal
 	 *  @{
 	 *  @{
 	 */
 	 */
 
 
 	/**
 	/**
-	 * Represents a GPU parameter block buffer. Parameter block buffers are bound to GPU programs which then fetch 
-	 * parameters from those buffers.
+	 * Core thread version of a GpuParamBlockBuffer.
 	 *
 	 *
-	 * Writing or reading from this buffer will translate directly to API calls that update the GPU.
-	 * 			
-	 * @note	Sim thread only.
+	 * @note	Core thread only.
 	 */
 	 */
-	class BS_CORE_EXPORT GpuParamBlockBuffer : public CoreObject
+	class BS_CORE_EXPORT GpuParamBlockBufferCore : public CoreObjectCore
 	{
 	{
 	public:
 	public:
-		GpuParamBlockBuffer(UINT32 size, GpuParamBlockUsage usage);
-		virtual ~GpuParamBlockBuffer();
+		GpuParamBlockBufferCore(UINT32 size, GpuParamBlockUsage usage, GpuDeviceFlags deviceMask);
+		virtual ~GpuParamBlockBufferCore();
+
+		/** 
+		 * Writes all of the specified data to the buffer. Data size must be the same size as the buffer. 
+		 *
+		 * @param[in]	data		Data to write. Must match the size of the buffer.
+		 * @param[in]	queueIdx	Device queue to perform the write operation on. See @ref queuesDoc.
+		 */
+		virtual void writeToGPU(const UINT8* data, UINT32 queueIdx = 0) = 0;
+
+		/** 
+		 * Flushes any cached data into the actual GPU buffer. 
+		 *
+		 * @param[in]	queueIdx	Device queue to perform the write operation on. See @ref queuesDoc.
+		 */
+		void flushToGPU(UINT32 queueIdx = 0);
 
 
 		/**
 		/**
 		 * Write some data to the specified offset in the buffer. 
 		 * Write some data to the specified offset in the buffer. 
 		 *
 		 *
-		 * @note	All values are in bytes. Actual hardware buffer update is delayed until rendering.
+		 * @note	All values are in bytes. Actual hardware buffer update is delayed until rendering or until 
+		 *			flushToGPU() is called.
 		 */
 		 */
 		void write(UINT32 offset, const void* data, UINT32 size);
 		void write(UINT32 offset, const void* data, UINT32 size);
 
 
 		/**
 		/**
 		 * Read some data from the specified offset in the buffer.
 		 * Read some data from the specified offset in the buffer.
 		 *			
 		 *			
-		 * @note	All values are in bytes. This reads from the cached CPU buffer and not from the GPU.
+		 * @note	All values are in bytes. This reads from the cached CPU buffer and not directly from the GPU.
 		 */
 		 */
 		void read(UINT32 offset, void* data, UINT32 size);
 		void read(UINT32 offset, void* data, UINT32 size);
 
 
 		/**
 		/**
 		 * Clear specified section of the buffer to zero.
 		 * Clear specified section of the buffer to zero.
 		 *
 		 *
-		 * @note	All values are in bytes. Actual hardware buffer update is delayed until rendering.
+		 * @note	All values are in bytes. Actual hardware buffer update is delayed until rendering or until 
+		 *			flushToGPU() is called.
 		 */
 		 */
 		void zeroOut(UINT32 offset, UINT32 size);
 		void zeroOut(UINT32 offset, UINT32 size);
 
 
-		/** Returns internal cached data of the buffer. */
-		const UINT8* getCachedData() const { return mCachedData; }
-
 		/**	Returns the size of the buffer in bytes. */
 		/**	Returns the size of the buffer in bytes. */
 		UINT32 getSize() const { return mSize; }
 		UINT32 getSize() const { return mSize; }
 
 
-		/**	Retrieves a core implementation of a GPU param block buffer usable only from the core thread. */
-		SPtr<GpuParamBlockBufferCore> getCore() const;
-
-		/** @copydoc HardwareBufferManager::createGpuParamBlockBuffer */
-		static SPtr<GpuParamBlockBuffer> create(UINT32 size, GpuParamBlockUsage usage = GPBU_DYNAMIC);
+		/** @copydoc HardwareBufferCoreManager::createGpuParamBlockBuffer */
+		static SPtr<GpuParamBlockBufferCore> create(UINT32 size, GpuParamBlockUsage usage = GPBU_DYNAMIC,
+			GpuDeviceFlags deviceMask = GDF_DEFAULT);
 
 
 	protected:
 	protected:
-		/** @copydoc CoreObject::createCore */
-		SPtr<CoreObjectCore> createCore() const override;
-
-		/** @copydoc CoreObject::syncToCore */
-		CoreSyncData syncToCore(FrameAlloc* allocator) override;
+		/** @copydoc CoreObjectCore::syncToCore */
+		void syncToCore(const CoreSyncData& data)  override;
 
 
 		GpuParamBlockUsage mUsage;
 		GpuParamBlockUsage mUsage;
 		UINT32 mSize;
 		UINT32 mSize;
+
 		UINT8* mCachedData;
 		UINT8* mCachedData;
+		bool mGPUBufferDirty;
 	};
 	};
 
 
-	/** @endcond */
 	/** @} */
 	/** @} */
+	}
 }
 }

+ 60 - 56
Source/BansheeCore/Include/BsGpuParams.h

@@ -108,11 +108,11 @@ namespace bs
 
 
 	template<> struct TGpuParamsTypes < true >
 	template<> struct TGpuParamsTypes < true >
 	{
 	{
-		typedef GpuParamsCore GpuParamsType;
-		typedef SPtr<TextureCore> TextureType;
-		typedef SPtr<GpuBufferCore> BufferType;
-		typedef SPtr<SamplerStateCore> SamplerType;
-		typedef SPtr<GpuParamBlockBufferCore> ParamsBufferType;
+		typedef ct::GpuParamsCore GpuParamsType;
+		typedef SPtr<ct::TextureCore> TextureType;
+		typedef SPtr<ct::GpuBufferCore> BufferType;
+		typedef SPtr<ct::SamplerStateCore> SamplerType;
+		typedef SPtr<ct::GpuParamBlockBufferCore> ParamsBufferType;
 	};
 	};
 
 
 	/** Templated version of GpuParams that contains functionality for both sim and core thread versions of stored data. */
 	/** Templated version of GpuParams that contains functionality for both sim and core thread versions of stored data. */
@@ -226,55 +226,6 @@ namespace bs
 
 
 	/** @} */
 	/** @} */
 
 
-	/** @addtogroup RenderAPI-Internal
-	 *  @{
-	 */
-
-	/**
-	 * Core thread version of GpuParams.
-	 *
-	 * @note	Core thread only.
-	 */
-	class BS_CORE_EXPORT GpuParamsCore : public CoreObjectCore, public TGpuParams<true>
-	{
-	public:
-		virtual ~GpuParamsCore() { }
-
-		/** 
-		 * @copydoc GpuParams::create(const SPtr<GraphicsPipelineState>&)
-		 * @param[in]	deviceMask		Mask that determines on which GPU devices should the buffer be created on.
-		 */
-		static SPtr<GpuParamsCore> create(const SPtr<GraphicsPipelineStateCore>& pipelineState,
-										  GpuDeviceFlags deviceMask = GDF_DEFAULT);
-
-		/** 
-		 * @copydoc GpuParams::create(const SPtr<ComputePipelineState>&) 
-		 * @param[in]	deviceMask		Mask that determines on which GPU devices should the buffer be created on.
-		 */
-		static SPtr<GpuParamsCore> create(const SPtr<ComputePipelineStateCore>& pipelineState,
-										  GpuDeviceFlags deviceMask = GDF_DEFAULT);
-
-		/** 
-		 * @copydoc GpuParams::create(const SPtr<GpuPipelineParamInfo>&)
-		 * @param[in]	deviceMask		Mask that determines on which GPU devices should the buffer be created on.
-		 */
-		static SPtr<GpuParamsCore> create(const SPtr<GpuPipelineParamInfoCore>& paramInfo,
-										  GpuDeviceFlags deviceMask = GDF_DEFAULT);
-
-	protected:
-		friend class GpuParams;
-		friend class HardwareBufferCoreManager;
-
-		GpuParamsCore(const SPtr<GpuPipelineParamInfoCore>& paramInfo, GpuDeviceFlags deviceMask);
-
-		/** @copydoc CoreObject::getThisPtr */
-		SPtr<GpuParamsCore> _getThisPtr() const override;
-
-		/** @copydoc CoreObjectCore::syncToCore */
-		void syncToCore(const CoreSyncData& data) override;
-	};
-
-	/** @} */
 	/** @addtogroup RenderAPI
 	/** @addtogroup RenderAPI
 	 *  @{
 	 *  @{
 	 */
 	 */
@@ -292,7 +243,7 @@ namespace bs
 		~GpuParams() { }
 		~GpuParams() { }
 
 
 		/** Retrieves a core implementation of a mesh usable only from the core thread. */
 		/** Retrieves a core implementation of a mesh usable only from the core thread. */
-		SPtr<GpuParamsCore> getCore() const;
+		SPtr<ct::GpuParamsCore> getCore() const;
 
 
 		/**
 		/**
 		 * Creates new GpuParams object that can serve for changing the GPU program parameters on the specified pipeline.
 		 * Creates new GpuParams object that can serve for changing the GPU program parameters on the specified pipeline.
@@ -335,7 +286,7 @@ namespace bs
 		SPtr<GpuParams> _getThisPtr() const override;
 		SPtr<GpuParams> _getThisPtr() const override;
 
 
 		/** @copydoc CoreObject::createCore */
 		/** @copydoc CoreObject::createCore */
-		SPtr<CoreObjectCore> createCore() const override;
+		SPtr<ct::CoreObjectCore> createCore() const override;
 
 
 		/** @copydoc CoreObject::syncToCore */
 		/** @copydoc CoreObject::syncToCore */
 		CoreSyncData syncToCore(FrameAlloc* allocator) override;
 		CoreSyncData syncToCore(FrameAlloc* allocator) override;
@@ -351,4 +302,57 @@ namespace bs
 	};
 	};
 
 
 	/** @} */
 	/** @} */
+
+	namespace ct
+	{
+	/** @addtogroup RenderAPI-Internal
+	 *  @{
+	 */
+
+	/**
+	 * Core thread version of GpuParams.
+	 *
+	 * @note	Core thread only.
+	 */
+	class BS_CORE_EXPORT GpuParamsCore : public CoreObjectCore, public TGpuParams<true>
+	{
+	public:
+		virtual ~GpuParamsCore() { }
+
+		/** 
+		 * @copydoc GpuParams::create(const SPtr<GraphicsPipelineState>&)
+		 * @param[in]	deviceMask		Mask that determines on which GPU devices should the buffer be created on.
+		 */
+		static SPtr<GpuParamsCore> create(const SPtr<GraphicsPipelineStateCore>& pipelineState,
+										  GpuDeviceFlags deviceMask = GDF_DEFAULT);
+
+		/** 
+		 * @copydoc GpuParams::create(const SPtr<ComputePipelineState>&) 
+		 * @param[in]	deviceMask		Mask that determines on which GPU devices should the buffer be created on.
+		 */
+		static SPtr<GpuParamsCore> create(const SPtr<ComputePipelineStateCore>& pipelineState,
+										  GpuDeviceFlags deviceMask = GDF_DEFAULT);
+
+		/** 
+		 * @copydoc GpuParams::create(const SPtr<GpuPipelineParamInfo>&)
+		 * @param[in]	deviceMask		Mask that determines on which GPU devices should the buffer be created on.
+		 */
+		static SPtr<GpuParamsCore> create(const SPtr<GpuPipelineParamInfoCore>& paramInfo,
+										  GpuDeviceFlags deviceMask = GDF_DEFAULT);
+
+	protected:
+		friend class GpuParams;
+		friend class HardwareBufferCoreManager;
+
+		GpuParamsCore(const SPtr<GpuPipelineParamInfoCore>& paramInfo, GpuDeviceFlags deviceMask);
+
+		/** @copydoc CoreObject::getThisPtr */
+		SPtr<GpuParamsCore> _getThisPtr() const override;
+
+		/** @copydoc CoreObjectCore::syncToCore */
+		void syncToCore(const CoreSyncData& data) override;
+	};
+
+	/** @} */
+	}
 }
 }

+ 4 - 1
Source/BansheeCore/Include/BsGpuParamsSet.h

@@ -15,7 +15,7 @@ namespace bs
 
 
 	template<bool Core> struct TGpuParamsType { };
 	template<bool Core> struct TGpuParamsType { };
 	template<> struct TGpuParamsType<false> { typedef GpuParams Type; };
 	template<> struct TGpuParamsType<false> { typedef GpuParams Type; };
-	template<> struct TGpuParamsType<true> { typedef GpuParamsCore Type; };
+	template<> struct TGpuParamsType<true> { typedef ct::GpuParamsCore Type; };
 
 
 	/** Contains a set of GpuParams used for a single technique within a Material. */
 	/** Contains a set of GpuParams used for a single technique within a Material. */
 	template<bool Core>
 	template<bool Core>
@@ -193,6 +193,8 @@ namespace bs
 		{ }
 		{ }
 	};
 	};
 
 
+	namespace ct
+	{
 	/** Core thread version of TGpuParamsSet<Core>. */
 	/** Core thread version of TGpuParamsSet<Core>. */
 	class BS_CORE_EXPORT GpuParamsSetCore : public TGpuParamsSet<true>
 	class BS_CORE_EXPORT GpuParamsSetCore : public TGpuParamsSet<true>
 	{
 	{
@@ -203,6 +205,7 @@ namespace bs
 			:TGpuParamsSet(technique, shader, params)
 			:TGpuParamsSet(technique, shader, params)
 		{ }
 		{ }
 	};
 	};
+	}
 
 
 	/** @} */
 	/** @} */
 }
 }

+ 24 - 21
Source/BansheeCore/Include/BsGpuPipelineParamInfo.h

@@ -88,25 +88,6 @@ namespace bs
 		GroupAlloc mAlloc;
 		GroupAlloc mAlloc;
 	};
 	};
 
 
-	/** Core thread version of a GpuPipelineParamInfo. */
-	class BS_CORE_EXPORT GpuPipelineParamInfoCore : public CoreObjectCore, public GpuPipelineParamInfoBase
-	{
-	public:
-		virtual ~GpuPipelineParamInfoCore() { }
-
-		/** 
-		 * @copydoc GpuPipelineParamInfo::create 
-		 * @param[in]	deviceMask		Mask that determines on which GPU devices should the buffer be created on.
-		 */
-		static SPtr<GpuPipelineParamInfoCore> create(const GPU_PIPELINE_PARAMS_DESC& desc,
-													 GpuDeviceFlags deviceMask = GDF_DEFAULT);
-
-	protected:
-		friend class RenderStateCoreManager;
-
-		GpuPipelineParamInfoCore(const GPU_PIPELINE_PARAMS_DESC& desc, GpuDeviceFlags deviceMask);
-	};
-
 	/** Holds meta-data about a set of GPU parameters used by a single pipeline state. */
 	/** Holds meta-data about a set of GPU parameters used by a single pipeline state. */
 	class BS_CORE_EXPORT GpuPipelineParamInfo : public CoreObject, public GpuPipelineParamInfoBase
 	class BS_CORE_EXPORT GpuPipelineParamInfo : public CoreObject, public GpuPipelineParamInfoBase
 	{
 	{
@@ -118,7 +99,7 @@ namespace bs
 		 *
 		 *
 		 * @note	Core thread only.
 		 * @note	Core thread only.
 		 */
 		 */
-		SPtr<GpuPipelineParamInfoCore> getCore() const;
+		SPtr<ct::GpuPipelineParamInfoCore> getCore() const;
 
 
 		/** 
 		/** 
 		 * Constructs the object using the provided GPU parameter descriptors. 
 		 * Constructs the object using the provided GPU parameter descriptors. 
@@ -131,8 +112,30 @@ namespace bs
 		GpuPipelineParamInfo(const GPU_PIPELINE_PARAMS_DESC& desc);
 		GpuPipelineParamInfo(const GPU_PIPELINE_PARAMS_DESC& desc);
 
 
 		/** @copydoc CoreObject::createCore */
 		/** @copydoc CoreObject::createCore */
-		SPtr<CoreObjectCore> createCore() const override;
+		SPtr<ct::CoreObjectCore> createCore() const override;
+	};
+
+	namespace ct
+	{
+	/** Core thread version of a GpuPipelineParamInfo. */
+	class BS_CORE_EXPORT GpuPipelineParamInfoCore : public CoreObjectCore, public GpuPipelineParamInfoBase
+	{
+	public:
+		virtual ~GpuPipelineParamInfoCore() { }
+
+		/** 
+		 * @copydoc GpuPipelineParamInfo::create 
+		 * @param[in]	deviceMask		Mask that determines on which GPU devices should the buffer be created on.
+		 */
+		static SPtr<GpuPipelineParamInfoCore> create(const GPU_PIPELINE_PARAMS_DESC& desc,
+													 GpuDeviceFlags deviceMask = GDF_DEFAULT);
+
+	protected:
+		friend class RenderStateCoreManager;
+
+		GpuPipelineParamInfoCore(const GPU_PIPELINE_PARAMS_DESC& desc, GpuDeviceFlags deviceMask);
 	};
 	};
+	}
 
 
 	/** @} */
 	/** @} */
 }
 }

+ 16 - 14
Source/BansheeCore/Include/BsGpuPipelineState.h

@@ -27,6 +27,8 @@ namespace bs
 
 
 	/** @} */
 	/** @} */
 
 
+	namespace ct
+	{
 	/** @addtogroup RenderAPI-Internal
 	/** @addtogroup RenderAPI-Internal
 	 *  @{
 	 *  @{
 	 */
 	 */
@@ -46,6 +48,7 @@ namespace bs
 	};
 	};
 
 
 	/** @} */
 	/** @} */
+	}
 
 
 	/** @addtogroup Implementation
 	/** @addtogroup Implementation
 	 *  @{
 	 *  @{
@@ -70,12 +73,12 @@ namespace bs
 	template<>
 	template<>
 	struct TGpuPipelineStateTypes < true >
 	struct TGpuPipelineStateTypes < true >
 	{
 	{
-		typedef SPtr<BlendStateCore> BlendStateType;
-		typedef SPtr<RasterizerStateCore> RasterizerStateType;
-		typedef SPtr<DepthStencilStateCore> DepthStencilStateType;
-		typedef SPtr<GpuProgramCore> GpuProgramType;
-		typedef GpuPipelineParamInfoCore GpuPipelineParamInfoType;
-		typedef PIPELINE_STATE_CORE_DESC StateDescType;
+		typedef SPtr<ct::BlendStateCore> BlendStateType;
+		typedef SPtr<ct::RasterizerStateCore> RasterizerStateType;
+		typedef SPtr<ct::DepthStencilStateCore> DepthStencilStateType;
+		typedef SPtr<ct::GpuProgramCore> GpuProgramType;
+		typedef ct::GpuPipelineParamInfoCore GpuPipelineParamInfoType;
+		typedef ct::PIPELINE_STATE_CORE_DESC StateDescType;
 	};
 	};
 
 
 	/** 
 	/** 
@@ -154,8 +157,6 @@ namespace bs
 	 *  @{
 	 *  @{
 	 */
 	 */
 
 
-	class GraphicsPipelineStateCore;
-
 	/**
 	/**
 	 * Describes the state of the GPU pipeline that determines how are primitives rendered. It consists of programmable
 	 * Describes the state of the GPU pipeline that determines how are primitives rendered. It consists of programmable
 	 * states (vertex, fragment, geometry, etc. GPU programs), as well as a set of fixed states (blend, rasterizer, 
 	 * states (vertex, fragment, geometry, etc. GPU programs), as well as a set of fixed states (blend, rasterizer, 
@@ -171,7 +172,7 @@ namespace bs
 		 *
 		 *
 		 * @note	Core thread only.
 		 * @note	Core thread only.
 		 */
 		 */
-		SPtr<GraphicsPipelineStateCore> getCore() const;
+		SPtr<ct::GraphicsPipelineStateCore> getCore() const;
 
 
 		/** @copydoc RenderStateManager::createGraphicsPipelineState */
 		/** @copydoc RenderStateManager::createGraphicsPipelineState */
 		static SPtr<GraphicsPipelineState> create(const PIPELINE_STATE_DESC& desc);
 		static SPtr<GraphicsPipelineState> create(const PIPELINE_STATE_DESC& desc);
@@ -181,11 +182,9 @@ namespace bs
 		GraphicsPipelineState(const PIPELINE_STATE_DESC& desc);
 		GraphicsPipelineState(const PIPELINE_STATE_DESC& desc);
 
 
 		/** @copydoc CoreObject::createCore */
 		/** @copydoc CoreObject::createCore */
-		virtual SPtr<CoreObjectCore> createCore() const;
+		virtual SPtr<ct::CoreObjectCore> createCore() const;
     };
     };
 
 
-	class ComputePipelineStateCore;
-
 	/**
 	/**
 	 * Describes the state of the GPU pipeline that determines how are compute programs executed. It consists of 
 	 * Describes the state of the GPU pipeline that determines how are compute programs executed. It consists of 
 	 * of a single programmable state (GPU program). Once created the state is immutable, and can be bound to RenderAPI for
 	 * of a single programmable state (GPU program). Once created the state is immutable, and can be bound to RenderAPI for
@@ -201,7 +200,7 @@ namespace bs
 		 *
 		 *
 		 * @note	Core thread only.
 		 * @note	Core thread only.
 		 */
 		 */
-		SPtr<ComputePipelineStateCore> getCore() const;
+		SPtr<ct::ComputePipelineStateCore> getCore() const;
 
 
 		/** @copydoc RenderStateManager::createComputePipelineState */
 		/** @copydoc RenderStateManager::createComputePipelineState */
 		static SPtr<ComputePipelineState> create(const SPtr<GpuProgram>& program);
 		static SPtr<ComputePipelineState> create(const SPtr<GpuProgram>& program);
@@ -211,11 +210,13 @@ namespace bs
 		ComputePipelineState(const SPtr<GpuProgram>& program);
 		ComputePipelineState(const SPtr<GpuProgram>& program);
 
 
 		/** @copydoc CoreObject::createCore */
 		/** @copydoc CoreObject::createCore */
-		virtual SPtr<CoreObjectCore> createCore() const;
+		virtual SPtr<ct::CoreObjectCore> createCore() const;
     };
     };
 
 
 	/** @} */
 	/** @} */
 
 
+	namespace ct
+	{
 	/** @addtogroup RenderAPI-Internal
 	/** @addtogroup RenderAPI-Internal
 	 *  @{
 	 *  @{
 	 */
 	 */
@@ -257,4 +258,5 @@ namespace bs
 	};
 	};
 
 
 	/** @} */
 	/** @} */
+	}
 }
 }

+ 5 - 2
Source/BansheeCore/Include/BsGpuProgram.h

@@ -112,7 +112,7 @@ namespace bs
 		SPtr<GpuParamDesc> getParamDesc() const;
 		SPtr<GpuParamDesc> getParamDesc() const;
 
 
 		/** Retrieves a core implementation of a gpu program usable only from the core thread. */
 		/** Retrieves a core implementation of a gpu program usable only from the core thread. */
-		SPtr<GpuProgramCore> getCore() const;
+		SPtr<ct::GpuProgramCore> getCore() const;
 
 
 		/** Returns properties that contain information about the GPU program. */
 		/** Returns properties that contain information about the GPU program. */
 		const GpuProgramProperties& getProperties() const { return mProperties; }
 		const GpuProgramProperties& getProperties() const { return mProperties; }
@@ -131,7 +131,7 @@ namespace bs
 		GpuProgram(const GPU_PROGRAM_DESC& desc);
 		GpuProgram(const GPU_PROGRAM_DESC& desc);
 
 
 		/** @copydoc CoreObject::createCore */
 		/** @copydoc CoreObject::createCore */
-		SPtr<CoreObjectCore> createCore() const override;
+		SPtr<ct::CoreObjectCore> createCore() const override;
 
 
 	protected:
 	protected:
 		bool mNeedsAdjacencyInfo;
 		bool mNeedsAdjacencyInfo;
@@ -149,6 +149,8 @@ namespace bs
 
 
 	/** @} */
 	/** @} */
 
 
+	namespace ct
+	{
 	/** @addtogroup RenderAPI-Internal
 	/** @addtogroup RenderAPI-Internal
 	 *  @{
 	 *  @{
 	 */
 	 */
@@ -218,4 +220,5 @@ namespace bs
 	};
 	};
 
 
 	/** @} */
 	/** @} */
+		}
 }
 }

+ 20 - 18
Source/BansheeCore/Include/BsGpuProgramManager.h

@@ -13,23 +13,6 @@ namespace bs
 	 *  @{
 	 *  @{
 	 */
 	 */
 
 
-	/** Factory responsible for creating GPU programs of a certain type. */
-	class BS_CORE_EXPORT GpuProgramFactory
-	{
-	public:
-        GpuProgramFactory() {}
-		virtual ~GpuProgramFactory() { }
-
-		/**	Returns GPU program language this factory is capable creating GPU programs from. */
-		virtual const String& getLanguage() const = 0;
-
-		/** @copydoc GpuProgramCore::create */
-		virtual SPtr<GpuProgramCore> create(const GPU_PROGRAM_DESC& desc, GpuDeviceFlags deviceMask = GDF_DEFAULT) = 0;
-
-		/** @copydoc GpuProgramManager::createEmpty */
-		virtual SPtr<GpuProgramCore> create(GpuProgramType type, GpuDeviceFlags deviceMask = GDF_DEFAULT) = 0;
-	};
-
 	/**
 	/**
 	 * Manager responsible for creating GPU programs. It will automatically try to find the appropriate handler for a 
 	 * Manager responsible for creating GPU programs. It will automatically try to find the appropriate handler for a 
 	 * specific GPU program language and create the program if possible.
 	 * specific GPU program language and create the program if possible.
@@ -49,6 +32,25 @@ namespace bs
 		SPtr<GpuProgram> createEmpty(const String& language, GpuProgramType type);
 		SPtr<GpuProgram> createEmpty(const String& language, GpuProgramType type);
 	};
 	};
 
 
+	namespace ct
+	{
+	/** Factory responsible for creating GPU programs of a certain type. */
+	class BS_CORE_EXPORT GpuProgramFactory
+	{
+	public:
+        GpuProgramFactory() {}
+		virtual ~GpuProgramFactory() { }
+
+		/**	Returns GPU program language this factory is capable creating GPU programs from. */
+		virtual const String& getLanguage() const = 0;
+
+		/** @copydoc GpuProgramCore::create */
+		virtual SPtr<GpuProgramCore> create(const GPU_PROGRAM_DESC& desc, GpuDeviceFlags deviceMask = GDF_DEFAULT) = 0;
+
+		/** @copydoc GpuProgramManager::createEmpty */
+		virtual SPtr<GpuProgramCore> create(GpuProgramType type, GpuDeviceFlags deviceMask = GDF_DEFAULT) = 0;
+	};
+
 	/**
 	/**
 	 * Manager responsible for creating GPU programs. It will automatically	try to find the appropriate handler for a 
 	 * Manager responsible for creating GPU programs. It will automatically	try to find the appropriate handler for a 
 	 * specific GPU program language and create the program if possible.
 	 * specific GPU program language and create the program if possible.
@@ -98,6 +100,6 @@ namespace bs
 		FactoryMap mFactories;
 		FactoryMap mFactories;
 		GpuProgramFactory* mNullFactory; /**< Factory for dealing with GPU programs that can't be created. */
 		GpuProgramFactory* mNullFactory; /**< Factory for dealing with GPU programs that can't be created. */
 	};
 	};
-
+	}
 	/** @} */
 	/** @} */
 }
 }

+ 4 - 0
Source/BansheeCore/Include/BsHardwareBufferManager.h

@@ -73,6 +73,9 @@ namespace bs
 		SPtr<GpuParams> createGpuParams(const SPtr<GpuPipelineParamInfo>& paramInfo);
 		SPtr<GpuParams> createGpuParams(const SPtr<GpuPipelineParamInfo>& paramInfo);
 	};
 	};
 
 
+	namespace ct
+	{
+
 	/**
 	/**
 	 * Handles creation of various hardware buffers.
 	 * Handles creation of various hardware buffers.
 	 *
 	 *
@@ -186,6 +189,7 @@ namespace bs
 
 
 		DeclarationMap mCachedDeclarations;
 		DeclarationMap mCachedDeclarations;
 	};
 	};
+	}
 
 
 	/** @} */
 	/** @} */
 }
 }

+ 6 - 3
Source/BansheeCore/Include/BsIndexBuffer.h

@@ -37,7 +37,7 @@ namespace bs
 
 
 	protected:
 	protected:
 		friend class IndexBuffer;
 		friend class IndexBuffer;
-		friend class IndexBufferCore;
+		friend class ct::IndexBufferCore;
 
 
 		IndexType mIndexType;
 		IndexType mIndexType;
 		UINT32 mNumIndices;
 		UINT32 mNumIndices;
@@ -58,7 +58,7 @@ namespace bs
 		 *
 		 *
 		 * @note	Core thread only.
 		 * @note	Core thread only.
 		 */
 		 */
-		SPtr<IndexBufferCore> getCore() const;
+		SPtr<ct::IndexBufferCore> getCore() const;
 
 
 		/** @copydoc HardwareBufferManager::createIndexBuffer */
 		/** @copydoc HardwareBufferManager::createIndexBuffer */
 		static SPtr<IndexBuffer> create(const INDEX_BUFFER_DESC& desc);
 		static SPtr<IndexBuffer> create(const INDEX_BUFFER_DESC& desc);
@@ -69,7 +69,7 @@ namespace bs
 		IndexBuffer(const INDEX_BUFFER_DESC& desc);
 		IndexBuffer(const INDEX_BUFFER_DESC& desc);
 
 
 		/** @copydoc CoreObject::createCore */
 		/** @copydoc CoreObject::createCore */
-		virtual SPtr<CoreObjectCore> createCore() const;
+		virtual SPtr<ct::CoreObjectCore> createCore() const;
 
 
 		IndexBufferProperties mProperties;
 		IndexBufferProperties mProperties;
 		GpuBufferUsage mUsage;
 		GpuBufferUsage mUsage;
@@ -77,6 +77,8 @@ namespace bs
 
 
 	/** @} */
 	/** @} */
 
 
+	namespace ct
+	{
 	/** @addtogroup RenderAPI-Internal
 	/** @addtogroup RenderAPI-Internal
 	 *  @{
 	 *  @{
 	 */
 	 */
@@ -99,4 +101,5 @@ namespace bs
 	};
 	};
 
 
 	/** @} */
 	/** @} */
+		}
 }
 }

+ 40 - 37
Source/BansheeCore/Include/BsMaterial.h

@@ -22,23 +22,23 @@ namespace bs
 
 
 	template<bool Core> struct TGpuParamBlockBufferPtrType { };
 	template<bool Core> struct TGpuParamBlockBufferPtrType { };
 	template<> struct TGpuParamBlockBufferPtrType<false> { typedef SPtr<GpuParamBlockBuffer> Type; };
 	template<> struct TGpuParamBlockBufferPtrType<false> { typedef SPtr<GpuParamBlockBuffer> Type; };
-	template<> struct TGpuParamBlockBufferPtrType<true> { typedef SPtr<GpuParamBlockBufferCore> Type; };
+	template<> struct TGpuParamBlockBufferPtrType<true> { typedef SPtr<ct::GpuParamBlockBufferCore> Type; };
 
 
 	template<bool Core> struct TGpuProgramType { };
 	template<bool Core> struct TGpuProgramType { };
 	template<> struct TGpuProgramType<false> { typedef SPtr<GpuProgram> Type; };
 	template<> struct TGpuProgramType<false> { typedef SPtr<GpuProgram> Type; };
-	template<> struct TGpuProgramType<true> { typedef SPtr<GpuProgramCore> Type; };
+	template<> struct TGpuProgramType<true> { typedef SPtr<ct::GpuProgramCore> Type; };
 
 
 	template<bool Core> struct TShaderType {};
 	template<bool Core> struct TShaderType {};
 	template<> struct TShaderType < false > { typedef HShader Type; };
 	template<> struct TShaderType < false > { typedef HShader Type; };
-	template<> struct TShaderType < true > { typedef SPtr<ShaderCore> Type; };
+	template<> struct TShaderType < true > { typedef SPtr<ct::ShaderCore> Type; };
 
 
 	template<bool Core> struct TGpuParamBlockBufferType {};
 	template<bool Core> struct TGpuParamBlockBufferType {};
 	template<> struct TGpuParamBlockBufferType < false > { typedef GpuParamBlockBuffer Type; };
 	template<> struct TGpuParamBlockBufferType < false > { typedef GpuParamBlockBuffer Type; };
-	template<> struct TGpuParamBlockBufferType < true > { typedef GpuParamBlockBufferCore Type; };
+	template<> struct TGpuParamBlockBufferType < true > { typedef ct::GpuParamBlockBufferCore Type; };
 	
 	
 	template<bool Core> struct TGpuParamsSetType {};
 	template<bool Core> struct TGpuParamsSetType {};
 	template<> struct TGpuParamsSetType < false > { typedef GpuParamsSet Type; };
 	template<> struct TGpuParamsSetType < false > { typedef GpuParamsSet Type; };
-	template<> struct TGpuParamsSetType < true > { typedef GpuParamsSetCore Type; };
+	template<> struct TGpuParamsSetType < true > { typedef ct::GpuParamsSetCore Type; };
 
 
 	/**
 	/**
 	 * Material that controls how objects are rendered. It is represented by a shader and parameters used to set up that
 	 * Material that controls how objects are rendered. It is represented by a shader and parameters used to set up that
@@ -540,36 +540,6 @@ namespace bs
 
 
 	/** @} */
 	/** @} */
 
 
-	/** @addtogroup Material-Internal
-	 *  @{
-	 */
-
-	/** @copydoc MaterialBase */
-	class BS_CORE_EXPORT MaterialCore : public CoreObjectCore, public TMaterial<true>
-	{
-	public:
-		~MaterialCore() { }
-
-		/** @copydoc Material::setShader */
-		void setShader(const SPtr<ShaderCore>& shader);
-
-		/** Creates a new material with the specified shader. */
-		static SPtr<MaterialCore> create(const SPtr<ShaderCore>& shader);
-
-	private:
-		friend class Material;
-
-		MaterialCore() { }
-		MaterialCore(const SPtr<ShaderCore>& shader);
-		MaterialCore(const SPtr<ShaderCore>& shader, const Vector<SPtr<TechniqueCore>>& techniques,
-			const SPtr<MaterialParamsCore>& materialParams);
-
-		/** @copydoc CoreObjectCore::syncToCore */
-		void syncToCore(const CoreSyncData& data) override;
-	};
-
-	/** @} */
-
 	/** @addtogroup Material
 	/** @addtogroup Material
 	 *  @{
 	 *  @{
 	 */
 	 */
@@ -594,7 +564,7 @@ namespace bs
 		void setShader(const HShader& shader);
 		void setShader(const HShader& shader);
 
 
 		/** Retrieves an implementation of a material usable only from the core thread. */
 		/** Retrieves an implementation of a material usable only from the core thread. */
-		SPtr<MaterialCore> getCore() const;
+		SPtr<ct::MaterialCore> getCore() const;
 
 
 		/** @copydoc CoreObject::initialize */
 		/** @copydoc CoreObject::initialize */
 		void initialize() override;
 		void initialize() override;
@@ -630,7 +600,7 @@ namespace bs
 		Material(const HShader& shader);
 		Material(const HShader& shader);
 
 
 		/** @copydoc CoreObject::createCore */
 		/** @copydoc CoreObject::createCore */
-		SPtr<CoreObjectCore> createCore() const override;
+		SPtr<ct::CoreObjectCore> createCore() const override;
 
 
 		/** @copydoc CoreObject::syncToCore */
 		/** @copydoc CoreObject::syncToCore */
 		CoreSyncData syncToCore(FrameAlloc* allocator) override;
 		CoreSyncData syncToCore(FrameAlloc* allocator) override;
@@ -678,4 +648,37 @@ namespace bs
 	};
 	};
 
 
 	/** @} */
 	/** @} */
+
+	namespace ct
+	{
+	/** @addtogroup Material-Internal
+	 *  @{
+	 */
+
+	/** @copydoc MaterialBase */
+	class BS_CORE_EXPORT MaterialCore : public CoreObjectCore, public TMaterial<true>
+	{
+	public:
+		~MaterialCore() { }
+
+		/** @copydoc Material::setShader */
+		void setShader(const SPtr<ShaderCore>& shader);
+
+		/** Creates a new material with the specified shader. */
+		static SPtr<MaterialCore> create(const SPtr<ShaderCore>& shader);
+
+	private:
+		friend class Material;
+
+		MaterialCore() { }
+		MaterialCore(const SPtr<ShaderCore>& shader);
+		MaterialCore(const SPtr<ShaderCore>& shader, const Vector<SPtr<TechniqueCore>>& techniques,
+			const SPtr<MaterialParamsCore>& materialParams);
+
+		/** @copydoc CoreObjectCore::syncToCore */
+		void syncToCore(const CoreSyncData& data) override;
+	};
+
+	/** @} */	
+	}
 }
 }

+ 23 - 29
Source/BansheeCore/Include/BsMaterialParam.h

@@ -11,19 +11,13 @@ namespace bs
 	 *  @{
 	 *  @{
 	 */
 	 */
 
 
-	class Material;
-	class MaterialCore;
-
 	template<bool Core> struct TMaterialType { };
 	template<bool Core> struct TMaterialType { };
 	template<> struct TMaterialType<false> { typedef SPtr<Material> Type; };
 	template<> struct TMaterialType<false> { typedef SPtr<Material> Type; };
-	template<> struct TMaterialType<true> { typedef SPtr<MaterialCore> Type; };
-
-	class MaterialParams;
-	class MaterialParamsCore;
+	template<> struct TMaterialType<true> { typedef SPtr<ct::MaterialCore> Type; };
 
 
 	template<bool Core> struct TMaterialParamsType { };
 	template<bool Core> struct TMaterialParamsType { };
 	template<> struct TMaterialParamsType<false> { typedef MaterialParams Type; };
 	template<> struct TMaterialParamsType<false> { typedef MaterialParams Type; };
-	template<> struct TMaterialParamsType<true> { typedef MaterialParamsCore Type; };
+	template<> struct TMaterialParamsType<true> { typedef ct::MaterialParamsCore Type; };
 
 
 	/**
 	/**
 	 * A handle that allows you to set a Material parameter. Internally keeps a reference to the material parameters so that
 	 * A handle that allows you to set a Material parameter. Internally keeps a reference to the material parameters so that
@@ -235,32 +229,32 @@ namespace bs
 	typedef TMaterialDataParam<Matrix4, false> MaterialParamMat4;
 	typedef TMaterialDataParam<Matrix4, false> MaterialParamMat4;
 	typedef TMaterialDataParam<Color, false> MaterialParamColor;
 	typedef TMaterialDataParam<Color, false> MaterialParamColor;
 
 
-	typedef TMaterialDataParam<float, true> MaterialParamFloatCore;
-	typedef TMaterialDataParam<Vector2, true> MaterialParamVec2Core;
-	typedef TMaterialDataParam<Vector3, true> MaterialParamVec3Core;
-	typedef TMaterialDataParam<Vector4, true> MaterialParamVec4Core;
-	typedef TMaterialDataParam<int, true> MaterialParamIntCore;
-	typedef TMaterialDataParam<Vector2I, true> MaterialParamVec2ICore;
-	typedef TMaterialDataParam<Vector3I, true> MaterialParamVec3ICore;
-	typedef TMaterialDataParam<Vector4I, true> MaterialParamVec4ICore;
-	typedef TMaterialDataParam<Matrix3, true> MaterialParamMat3Core;
-	typedef TMaterialDataParam<Matrix4, true> MaterialParamMat4Core;
-	typedef TMaterialDataParam<Color, true> MaterialParamColorCore;
-
 	typedef TMaterialParamStruct<false> MaterialParamStruct;
 	typedef TMaterialParamStruct<false> MaterialParamStruct;
-	typedef TMaterialParamStruct<true> MaterialParamStructCore;
-
 	typedef TMaterialParamTexture<false> MaterialParamTexture;
 	typedef TMaterialParamTexture<false> MaterialParamTexture;
-	typedef TMaterialParamTexture<true> MaterialParamTextureCore;
-
 	typedef TMaterialParamLoadStoreTexture<false> MaterialParamLoadStoreTexture;
 	typedef TMaterialParamLoadStoreTexture<false> MaterialParamLoadStoreTexture;
-	typedef TMaterialParamLoadStoreTexture<true> MaterialParamLoadStoreTextureCore;
-
 	typedef TMaterialParamBuffer<false> MaterialParamBuffer;
 	typedef TMaterialParamBuffer<false> MaterialParamBuffer;
-	typedef TMaterialParamBuffer<true> MaterialParamBufferCore;
-
 	typedef TMaterialParamSampState<false> MaterialParamSampState;
 	typedef TMaterialParamSampState<false> MaterialParamSampState;
-	typedef TMaterialParamSampState<true> MaterialParamSampStateCore;
+
+	namespace ct
+	{
+		typedef TMaterialDataParam<float, true> MaterialParamFloatCore;
+		typedef TMaterialDataParam<Vector2, true> MaterialParamVec2Core;
+		typedef TMaterialDataParam<Vector3, true> MaterialParamVec3Core;
+		typedef TMaterialDataParam<Vector4, true> MaterialParamVec4Core;
+		typedef TMaterialDataParam<int, true> MaterialParamIntCore;
+		typedef TMaterialDataParam<Vector2I, true> MaterialParamVec2ICore;
+		typedef TMaterialDataParam<Vector3I, true> MaterialParamVec3ICore;
+		typedef TMaterialDataParam<Vector4I, true> MaterialParamVec4ICore;
+		typedef TMaterialDataParam<Matrix3, true> MaterialParamMat3Core;
+		typedef TMaterialDataParam<Matrix4, true> MaterialParamMat4Core;
+		typedef TMaterialDataParam<Color, true> MaterialParamColorCore;
+
+		typedef TMaterialParamStruct<true> MaterialParamStructCore;
+		typedef TMaterialParamTexture<true> MaterialParamTextureCore;
+		typedef TMaterialParamLoadStoreTexture<true> MaterialParamLoadStoreTextureCore;
+		typedef TMaterialParamBuffer<true> MaterialParamBufferCore;
+		typedef TMaterialParamSampState<true> MaterialParamSampStateCore;
+	}
 
 
 	/** @} */
 	/** @} */
 }
 }

+ 32 - 32
Source/BansheeCore/Include/BsMaterialParams.h

@@ -260,7 +260,7 @@ namespace bs
 	class BS_CORE_EXPORT MaterialParamTextureDataCore
 	class BS_CORE_EXPORT MaterialParamTextureDataCore
 	{
 	{
 	public:
 	public:
-		SPtr<TextureCore> value;
+		SPtr<ct::TextureCore> value;
 		bool isLoadStore;
 		bool isLoadStore;
 		TextureSurface surface;
 		TextureSurface surface;
 	};
 	};
@@ -282,7 +282,7 @@ namespace bs
 	class BS_CORE_EXPORT MaterialParamBufferDataCore
 	class BS_CORE_EXPORT MaterialParamBufferDataCore
 	{
 	{
 	public:
 	public:
-		SPtr<GpuBufferCore> value;
+		SPtr<ct::GpuBufferCore> value;
 	};
 	};
 
 
 	/** Data for a single buffer parameter. */
 	/** Data for a single buffer parameter. */
@@ -296,7 +296,7 @@ namespace bs
 	class BS_CORE_EXPORT MaterialParamSamplerStateDataCore
 	class BS_CORE_EXPORT MaterialParamSamplerStateDataCore
 	{
 	{
 	public:
 	public:
-		SPtr<SamplerStateCore> value;
+		SPtr<ct::SamplerStateCore> value;
 	};
 	};
 
 
 	/** Data for a single sampler state parameter. */
 	/** Data for a single sampler state parameter. */
@@ -324,16 +324,16 @@ namespace bs
 
 
 	template<> struct TMaterialParamsTypes < true >
 	template<> struct TMaterialParamsTypes < true >
 	{
 	{
-		typedef GpuParamsCore GpuParamsType;
-		typedef SPtr<TextureCore> TextureType;
-		typedef SPtr<GpuBufferCore> BufferType;
-		typedef SPtr<SamplerStateCore> SamplerType;
-		typedef SPtr<GpuParamBlockBufferCore> ParamsBufferType;
+		typedef ct::GpuParamsCore GpuParamsType;
+		typedef SPtr<ct::TextureCore> TextureType;
+		typedef SPtr<ct::GpuBufferCore> BufferType;
+		typedef SPtr<ct::SamplerStateCore> SamplerType;
+		typedef SPtr<ct::GpuParamBlockBufferCore> ParamsBufferType;
 		typedef MaterialParamStructDataCore StructParamDataType;
 		typedef MaterialParamStructDataCore StructParamDataType;
 		typedef MaterialParamTextureDataCore TextureParamDataType;
 		typedef MaterialParamTextureDataCore TextureParamDataType;
 		typedef MaterialParamBufferDataCore BufferParamDataType;
 		typedef MaterialParamBufferDataCore BufferParamDataType;
 		typedef MaterialParamSamplerStateDataCore SamplerStateParamDataType;
 		typedef MaterialParamSamplerStateDataCore SamplerStateParamDataType;
-		typedef SPtr<ShaderCore> ShaderType;
+		typedef SPtr<ct::ShaderCore> ShaderType;
 	};
 	};
 
 
 	/** Common code that may be specialized for both MaterialParams and MaterialParamsCore. */
 	/** Common code that may be specialized for both MaterialParams and MaterialParamsCore. */
@@ -558,28 +558,6 @@ namespace bs
 		SamplerType* mDefaultSamplerStateParams = nullptr;
 		SamplerType* mDefaultSamplerStateParams = nullptr;
 	};
 	};
 
 
-	class MaterialParams;
-
-	/** Core thread version of MaterialParams. */
-	class BS_CORE_EXPORT MaterialParamsCore : public TMaterialParams<true>
-	{
-	public:
-		/** Initializes the core thread version of MaterialParams from its sim thread counterpart. */
-		MaterialParamsCore(const SPtr<ShaderCore>& shader, const SPtr<MaterialParams>& params);
-		
-		/** @copydoc TMaterialParams::TMaterialParams(const ShaderType&) */
-		MaterialParamsCore(const SPtr<ShaderCore>& shader);
-
-		/** 
-		 * Updates the stored parameters from the provided buffer, allowing changes to be transfered between the sim and 
-		 * core thread material param objects. Buffer must be retrieved from MaterialParams::getSyncData. 
-		 *
-		 * @param[in]		buffer		Buffer containing the dirty data.
-		 * @param[in, out]	size		Size of the provided buffer.
-		 */
-		void setSyncData(UINT8* buffer, UINT32 size);
-	};
-
 	/** 
 	/** 
 	 * Contains all parameter values set in a Material. This is similar to GpuParams which also stores parameter values,
 	 * Contains all parameter values set in a Material. This is similar to GpuParams which also stores parameter values,
 	 * however GpuParams are built for use on the GPU-side and don't store parameters that don't exist in a compiled GPU
 	 * however GpuParams are built for use on the GPU-side and don't store parameters that don't exist in a compiled GPU
@@ -613,7 +591,7 @@ namespace bs
 		void getSyncData(UINT8* buffer, UINT32& size);
 		void getSyncData(UINT8* buffer, UINT32& size);
 
 
 	private:
 	private:
-		friend class MaterialParamsCore;
+		friend class ct::MaterialParamsCore;
 
 
 		UINT64 mLastSyncVersion;
 		UINT64 mLastSyncVersion;
 
 
@@ -628,5 +606,27 @@ namespace bs
 		RTTITypeBase* getRTTI() const override;
 		RTTITypeBase* getRTTI() const override;
 	};
 	};
 
 
+	namespace ct
+	{
+	/** Core thread version of MaterialParams. */
+	class BS_CORE_EXPORT MaterialParamsCore : public TMaterialParams<true>
+	{
+	public:
+		/** Initializes the core thread version of MaterialParams from its sim thread counterpart. */
+		MaterialParamsCore(const SPtr<ShaderCore>& shader, const SPtr<MaterialParams>& params);
+		
+		/** @copydoc TMaterialParams::TMaterialParams(const ShaderType&) */
+		MaterialParamsCore(const SPtr<ShaderCore>& shader);
+
+		/** 
+		 * Updates the stored parameters from the provided buffer, allowing changes to be transfered between the sim and 
+		 * core thread material param objects. Buffer must be retrieved from MaterialParams::getSyncData. 
+		 *
+		 * @param[in]		buffer		Buffer containing the dirty data.
+		 * @param[in, out]	size		Size of the provided buffer.
+		 */
+		void setSyncData(UINT8* buffer, UINT32 size);
+	};
+	}
 	/** @} */
 	/** @} */
 }
 }

+ 5 - 2
Source/BansheeCore/Include/BsMesh.h

@@ -126,7 +126,7 @@ namespace bs
 		SPtr<MorphShapes> getMorphShapes() const { return mMorphShapes; }
 		SPtr<MorphShapes> getMorphShapes() const { return mMorphShapes; }
 
 
 		/** Retrieves a core implementation of a mesh usable only from the core thread. */
 		/** Retrieves a core implementation of a mesh usable only from the core thread. */
-		SPtr<MeshCore> getCore() const;
+		SPtr<ct::MeshCore> getCore() const;
 
 
 		/**	Returns a dummy mesh, containing just one triangle. Don't modify the returned mesh. */
 		/**	Returns a dummy mesh, containing just one triangle. Don't modify the returned mesh. */
 		static HMesh dummy();
 		static HMesh dummy();
@@ -141,7 +141,7 @@ namespace bs
 		void updateBounds(const MeshData& meshData);
 		void updateBounds(const MeshData& meshData);
 
 
 		/** @copydoc CoreObject::createCore */
 		/** @copydoc CoreObject::createCore */
-		SPtr<CoreObjectCore> createCore() const override;
+		SPtr<ct::CoreObjectCore> createCore() const override;
 
 
 		/**
 		/**
 		 * Creates buffers used for caching of CPU mesh data.
 		 * Creates buffers used for caching of CPU mesh data.
@@ -263,6 +263,8 @@ namespace bs
 
 
 	/** @} */
 	/** @} */
 
 
+	namespace ct
+	{
 	/** @addtogroup Resources-Internal
 	/** @addtogroup Resources-Internal
 	 *  @{
 	 *  @{
 	 */
 	 */
@@ -397,4 +399,5 @@ namespace bs
 	};
 	};
 
 
 	/** @} */
 	/** @} */
+	}
 }
 }

+ 62 - 59
Source/BansheeCore/Include/BsMeshBase.h

@@ -53,11 +53,11 @@ namespace bs
 
 
 	protected:
 	protected:
 		friend class MeshBase;
 		friend class MeshBase;
-		friend class MeshCoreBase;
+		friend class ct::MeshCoreBase;
 		friend class Mesh;
 		friend class Mesh;
-		friend class MeshCore;
+		friend class ct::MeshCore;
 		friend class TransientMesh;
 		friend class TransientMesh;
-		friend class TransientMeshCore;
+		friend class ct::TransientMeshCore;
 		friend class MeshBaseRTTI;
 		friend class MeshBaseRTTI;
 
 
 		Vector<SubMesh> mSubMeshes;
 		Vector<SubMesh> mSubMeshes;
@@ -72,61 +72,6 @@ namespace bs
 	 *  @{
 	 *  @{
 	 */
 	 */
 
 
-	/**
-	 * Core version of a class used as a basis for all implemenations of meshes.
-	 *
-	 * @see		MeshBase
-	 *
-	 * @note	Core thread.
-	 */
-	class BS_CORE_EXPORT MeshCoreBase : public CoreObjectCore
-	{
-	public:
-		MeshCoreBase(UINT32 numVertices, UINT32 numIndices, const Vector<SubMesh>& subMeshes);
-		virtual ~MeshCoreBase() { }
-
-		/**	Get vertex data used for rendering. */
-		virtual SPtr<VertexData> getVertexData() const = 0;
-
-		/**	Get index data used for rendering. */
-		virtual SPtr<IndexBufferCore> getIndexBuffer() const = 0;
-
-		/**
-		 * Returns an offset into the vertex buffers that is returned by getVertexData() that signifies where this meshes
-		 * vertices begin.
-		 * 			
-		 * @note	Used when multiple meshes share the same buffers.
-		 */
-		virtual UINT32 getVertexOffset() const { return 0; }
-
-		/**
-		 * Returns an offset into the index buffer that is returned by getIndexData() that signifies where this meshes
-		 * indices begin.
-		 * 			
-		 * @note	Used when multiple meshes share the same buffers.
-		 */
-		virtual UINT32 getIndexOffset() const { return 0; }
-
-		/** Returns a structure that describes how are the vertices stored in the mesh's vertex buffer. */
-		virtual SPtr<VertexDataDesc> getVertexDesc() const = 0;
-
-		/**
-		 * Called whenever this mesh starts being used on the GPU.
-		 * 			
-		 * @note	Needs to be called after all commands referencing this mesh have been sent to the GPU.
-		 */
-		virtual void _notifyUsedOnGPU() { }
-
-		/**	Returns properties that contain information about the mesh. */
-		const MeshProperties& getProperties() const { return mProperties; }
-
-	protected:
-		/** @copydoc CoreObjectCore::syncToCore */
-		void syncToCore(const CoreSyncData& data) override;
-
-		MeshProperties mProperties;
-	};
-
 	/**
 	/**
 	 * Base class all mesh implementations derive from. Meshes hold geometry information, normally in the form of one or 
 	 * Base class all mesh implementations derive from. Meshes hold geometry information, normally in the form of one or 
 	 * several index or vertex buffers. Different mesh implementations might choose to manage those buffers differently.
 	 * several index or vertex buffers. Different mesh implementations might choose to manage those buffers differently.
@@ -163,7 +108,7 @@ namespace bs
 		const MeshProperties& getProperties() const { return mProperties; }
 		const MeshProperties& getProperties() const { return mProperties; }
 
 
 		/**	Retrieves a core implementation of a mesh usable only from the core thread. */
 		/**	Retrieves a core implementation of a mesh usable only from the core thread. */
-		SPtr<MeshCoreBase> getCore() const;
+		SPtr<ct::MeshCoreBase> getCore() const;
 
 
 	protected:
 	protected:
 		/** @copydoc CoreObject::syncToCore */
 		/** @copydoc CoreObject::syncToCore */
@@ -183,5 +128,63 @@ namespace bs
 		RTTITypeBase* getRTTI() const override;
 		RTTITypeBase* getRTTI() const override;
 	};
 	};
 
 
+	namespace ct
+	{
+	/**
+	 * Core version of a class used as a basis for all implemenations of meshes.
+	 *
+	 * @see		MeshBase
+	 *
+	 * @note	Core thread.
+	 */
+	class BS_CORE_EXPORT MeshCoreBase : public CoreObjectCore
+	{
+	public:
+		MeshCoreBase(UINT32 numVertices, UINT32 numIndices, const Vector<SubMesh>& subMeshes);
+		virtual ~MeshCoreBase() { }
+
+		/**	Get vertex data used for rendering. */
+		virtual SPtr<VertexData> getVertexData() const = 0;
+
+		/**	Get index data used for rendering. */
+		virtual SPtr<IndexBufferCore> getIndexBuffer() const = 0;
+
+		/**
+		 * Returns an offset into the vertex buffers that is returned by getVertexData() that signifies where this meshes
+		 * vertices begin.
+		 * 			
+		 * @note	Used when multiple meshes share the same buffers.
+		 */
+		virtual UINT32 getVertexOffset() const { return 0; }
+
+		/**
+		 * Returns an offset into the index buffer that is returned by getIndexData() that signifies where this meshes
+		 * indices begin.
+		 * 			
+		 * @note	Used when multiple meshes share the same buffers.
+		 */
+		virtual UINT32 getIndexOffset() const { return 0; }
+
+		/** Returns a structure that describes how are the vertices stored in the mesh's vertex buffer. */
+		virtual SPtr<VertexDataDesc> getVertexDesc() const = 0;
+
+		/**
+		 * Called whenever this mesh starts being used on the GPU.
+		 * 			
+		 * @note	Needs to be called after all commands referencing this mesh have been sent to the GPU.
+		 */
+		virtual void _notifyUsedOnGPU() { }
+
+		/**	Returns properties that contain information about the mesh. */
+		const MeshProperties& getProperties() const { return mProperties; }
+
+	protected:
+		/** @copydoc CoreObjectCore::syncToCore */
+		void syncToCore(const CoreSyncData& data) override;
+
+		MeshProperties mProperties;
+	};
+	}
+
 	/** @} */
 	/** @} */
 }
 }

+ 2 - 2
Source/BansheeCore/Include/BsMeshData.h

@@ -279,9 +279,9 @@ namespace bs
 
 
 	private:
 	private:
 		friend class Mesh;
 		friend class Mesh;
-		friend class MeshCore;
+		friend class ct::MeshCore;
 		friend class MeshHeap;
 		friend class MeshHeap;
-		friend class MeshHeapCore;
+		friend class ct::MeshHeapCore;
 
 
 		UINT32 mDescBuilding;
 		UINT32 mDescBuilding;
 
 

+ 73 - 69
Source/BansheeCore/Include/BsMeshHeap.h

@@ -8,6 +8,78 @@
 
 
 namespace bs
 namespace bs
 {
 {
+	/** @addtogroup Resources
+	 *  @{
+	 */
+
+	/**
+	 * Mesh heap allows you to quickly allocate and deallocate a large amounts of temporary meshes without the large 
+	 * overhead of normal Mesh creation. Only requirement is that meshes share the same vertex description and index type.
+	 * 			
+	 * @note	
+	 * This class should be considered as a replacement for a normal Mesh if you are constantly updating the mesh (for 
+	 * example every frame) and you are not able to discard entire mesh contents on each update. Not using discard flag on
+	 * normal meshes may introduce GPU-CPU sync points which may severely limit performance. Primary purpose of this class
+	 * is to avoid those sync points by not forcing you to discard contents.
+	 * Downside is that this class may allocate 2-3x (or more) memory than it is actually needed for your data.
+	 * @note
+	 * Sim thread only
+	 */
+	class BS_CORE_EXPORT MeshHeap : public CoreObject
+	{
+	public:
+		/**
+		 * Allocates a new mesh in the heap, expanding the heap if needed. Mesh will be initialized with the provided 
+		 * @p meshData. You may use the returned transient mesh for drawing.
+		 *
+		 * @note	
+		 * Offsets provided by MeshData are ignored. MeshHeap will determine where the data will be written internally.
+		 */
+		SPtr<TransientMesh> alloc(const SPtr<MeshData>& meshData, DrawOperationType drawOp = DOT_TRIANGLE_LIST);
+
+		/**
+		 * Deallocates the provided mesh and makes that room on the heap re-usable as soon as the GPU is also done with the 
+		 * mesh.
+		 */
+		void dealloc(const SPtr<TransientMesh>& mesh);
+
+		/** Retrieves a core implementation of a mesh heap usable only from the core thread. */
+		SPtr<ct::MeshHeapCore> getCore() const;
+
+		/**
+		 * Creates a new mesh heap.
+		 *
+		 * @param[in]	numVertices	Initial number of vertices the heap may store. This will grow automatically if needed.
+		 * @param[in]	numIndices	Initial number of indices the heap may store. This will grow automatically if needed.
+		 * @param[in]	vertexDesc	Description of the stored vertices.
+		 * @param[in]	indexType	Type of the stored indices.
+		 */
+		static SPtr<MeshHeap> create(UINT32 numVertices, UINT32 numIndices, 
+			const SPtr<VertexDataDesc>& vertexDesc, IndexType indexType = IT_32BIT);
+
+	private:
+		/** @copydoc create */
+		MeshHeap(UINT32 numVertices, UINT32 numIndices, 
+			const SPtr<VertexDataDesc>& vertexDesc, IndexType indexType = IT_32BIT);
+
+		/** @copydoc CoreObject::createCore */
+		SPtr<ct::CoreObjectCore> createCore() const override;
+
+	private:
+		UINT32 mNumVertices;
+		UINT32 mNumIndices;
+
+		SPtr<VertexDataDesc> mVertexDesc;
+		IndexType mIndexType;
+
+		Map<UINT32, SPtr<TransientMesh>> mMeshes;
+		UINT32 mNextFreeId;
+	};
+
+	/** @} */
+
+	namespace ct
+	{
 	/** @addtogroup Resources-Internal
 	/** @addtogroup Resources-Internal
 	 *  @{
 	 *  @{
 	 */
 	 */
@@ -162,73 +234,5 @@ namespace bs
 	};
 	};
 
 
 	/** @} */
 	/** @} */
-	/** @addtogroup Resources
-	 *  @{
-	 */
-
-	/**
-	 * Mesh heap allows you to quickly allocate and deallocate a large amounts of temporary meshes without the large 
-	 * overhead of normal Mesh creation. Only requirement is that meshes share the same vertex description and index type.
-	 * 			
-	 * @note	
-	 * This class should be considered as a replacement for a normal Mesh if you are constantly updating the mesh (for 
-	 * example every frame) and you are not able to discard entire mesh contents on each update. Not using discard flag on
-	 * normal meshes may introduce GPU-CPU sync points which may severely limit performance. Primary purpose of this class
-	 * is to avoid those sync points by not forcing you to discard contents.
-	 * Downside is that this class may allocate 2-3x (or more) memory than it is actually needed for your data.
-	 * @note
-	 * Sim thread only
-	 */
-	class BS_CORE_EXPORT MeshHeap : public CoreObject
-	{
-	public:
-		/**
-		 * Allocates a new mesh in the heap, expanding the heap if needed. Mesh will be initialized with the provided 
-		 * @p meshData. You may use the returned transient mesh for drawing.
-		 *
-		 * @note	
-		 * Offsets provided by MeshData are ignored. MeshHeap will determine where the data will be written internally.
-		 */
-		SPtr<TransientMesh> alloc(const SPtr<MeshData>& meshData, DrawOperationType drawOp = DOT_TRIANGLE_LIST);
-
-		/**
-		 * Deallocates the provided mesh and makes that room on the heap re-usable as soon as the GPU is also done with the 
-		 * mesh.
-		 */
-		void dealloc(const SPtr<TransientMesh>& mesh);
-
-		/** Retrieves a core implementation of a mesh heap usable only from the core thread. */
-		SPtr<MeshHeapCore> getCore() const;
-
-		/**
-		 * Creates a new mesh heap.
-		 *
-		 * @param[in]	numVertices	Initial number of vertices the heap may store. This will grow automatically if needed.
-		 * @param[in]	numIndices	Initial number of indices the heap may store. This will grow automatically if needed.
-		 * @param[in]	vertexDesc	Description of the stored vertices.
-		 * @param[in]	indexType	Type of the stored indices.
-		 */
-		static SPtr<MeshHeap> create(UINT32 numVertices, UINT32 numIndices, 
-			const SPtr<VertexDataDesc>& vertexDesc, IndexType indexType = IT_32BIT);
-
-	private:
-		/** @copydoc create */
-		MeshHeap(UINT32 numVertices, UINT32 numIndices, 
-			const SPtr<VertexDataDesc>& vertexDesc, IndexType indexType = IT_32BIT);
-
-		/** @copydoc CoreObject::createCore */
-		SPtr<CoreObjectCore> createCore() const override;
-
-	private:
-		UINT32 mNumVertices;
-		UINT32 mNumIndices;
-
-		SPtr<VertexDataDesc> mVertexDesc;
-		IndexType mIndexType;
-
-		Map<UINT32, SPtr<TransientMesh>> mMeshes;
-		UINT32 mNextFreeId;
-	};
-
-	/** @} */
+	}
 }
 }

+ 2 - 2
Source/BansheeCore/Include/BsOcclusionQuery.h

@@ -4,7 +4,7 @@
 
 
 #include "BsCorePrerequisites.h"
 #include "BsCorePrerequisites.h"
 
 
-namespace bs
+namespace bs { namespace ct
 {
 {
 	/** @addtogroup RenderAPI
 	/** @addtogroup RenderAPI
 	 *  @{
 	 *  @{
@@ -74,4 +74,4 @@ namespace bs
 	};
 	};
 
 
 	/** @} */
 	/** @} */
-}
+}}

+ 2 - 2
Source/BansheeCore/Include/BsParamBlocks.h

@@ -8,7 +8,7 @@
 #include "BsRenderAPI.h"
 #include "BsRenderAPI.h"
 #include "BsGpuParamBlockBuffer.h"
 #include "BsGpuParamBlockBuffer.h"
 
 
-namespace bs
+namespace bs { namespace ct
 {
 {
 	/** @addtogroup Renderer-Internal
 	/** @addtogroup Renderer-Internal
 	 *  @{
 	 *  @{
@@ -155,4 +155,4 @@ namespace bs
 	};
 	};
 
 
 	/** @} */
 	/** @} */
-}
+}}

+ 50 - 43
Source/BansheeCore/Include/BsPass.h

@@ -31,6 +31,8 @@ namespace bs
 
 
 	/** @} */
 	/** @} */
 
 
+	namespace ct
+	{
 	/** @addtogroup Material-Internal
 	/** @addtogroup Material-Internal
 	 *  @{
 	 *  @{
 	 */
 	 */
@@ -52,6 +54,7 @@ namespace bs
 	};
 	};
 
 
 	/** @} */
 	/** @} */
+	}
 
 
 	/** @addtogroup Implementation
 	/** @addtogroup Implementation
 	 *  @{
 	 *  @{
@@ -77,13 +80,13 @@ namespace bs
 	template<>
 	template<>
 	struct TPassTypes < true >
 	struct TPassTypes < true >
 	{
 	{
-		typedef SPtr<BlendStateCore> BlendStateType;
-		typedef SPtr<RasterizerStateCore> RasterizerStateType;
-		typedef SPtr<DepthStencilStateCore> DepthStencilStateType;
-		typedef SPtr<GpuProgramCore> GpuProgramType;
-		typedef SPtr<GraphicsPipelineStateCore> GraphicsPipelineStateType;
-		typedef SPtr<ComputePipelineStateCore> ComputePipelineStateType;
-		typedef PASS_DESC_CORE PassDescType;
+		typedef SPtr<ct::BlendStateCore> BlendStateType;
+		typedef SPtr<ct::RasterizerStateCore> RasterizerStateType;
+		typedef SPtr<ct::DepthStencilStateCore> DepthStencilStateType;
+		typedef SPtr<ct::GpuProgramCore> GpuProgramType;
+		typedef SPtr<ct::GraphicsPipelineStateCore> GraphicsPipelineStateType;
+		typedef SPtr<ct::ComputePipelineStateCore> ComputePipelineStateType;
+		typedef ct::PASS_DESC_CORE PassDescType;
 	};
 	};
 
 
 	/**
 	/**
@@ -145,40 +148,6 @@ namespace bs
 
 
 	/** @} */
 	/** @} */
 
 
-	/** @addtogroup Material-Internal
-	 *  @{
-	 */
-
-	/**
-	 * @copydoc	TPass
-	 *
-	 * @note	Core thread.
-	 */
-	class BS_CORE_EXPORT PassCore : public CoreObjectCore, public TPass<true>
-    {
-    public:
-		virtual ~PassCore() { }
-
-		/**	Creates a new empty pass. */
-		static SPtr<PassCore> create(const PASS_DESC_CORE& desc);
-
-	protected:
-		friend class Pass;
-		friend class TechniqueCore;
-
-		/** @copydoc CoreObjectCore::initialize */
-		void initialize() override;
-
-		PassCore() { }
-		PassCore(const PASS_DESC_CORE& desc);
-		PassCore(const PASS_DESC_CORE& desc, const SPtr<GraphicsPipelineStateCore>& pipelineState);
-		PassCore(const PASS_DESC_CORE& desc, const SPtr<ComputePipelineStateCore>& pipelineState);
-
-		/** @copydoc CoreObjectCore::syncToCore */
-		void syncToCore(const CoreSyncData& data) override;
-    };
-
-	/** @} */
 	/** @addtogroup Material
 	/** @addtogroup Material
 	 *  @{
 	 *  @{
 	 */
 	 */
@@ -194,7 +163,7 @@ namespace bs
 		virtual ~Pass() { }
 		virtual ~Pass() { }
 
 
 		/** Retrieves an implementation of a pass usable only from the core thread. */
 		/** Retrieves an implementation of a pass usable only from the core thread. */
-		SPtr<PassCore> getCore() const;
+		SPtr<ct::PassCore> getCore() const;
 
 
 		/**	Creates a new empty pass. */
 		/**	Creates a new empty pass. */
 		static SPtr<Pass> create(const PASS_DESC& desc);
 		static SPtr<Pass> create(const PASS_DESC& desc);
@@ -212,7 +181,7 @@ namespace bs
 		CoreSyncData syncToCore(FrameAlloc* allocator) override;
 		CoreSyncData syncToCore(FrameAlloc* allocator) override;
 
 
 		/** @copydoc CoreObject::createCore */
 		/** @copydoc CoreObject::createCore */
-		SPtr<CoreObjectCore> createCore() const override;
+		SPtr<ct::CoreObjectCore> createCore() const override;
 
 
 		/** @copydoc CoreObject::syncToCore */
 		/** @copydoc CoreObject::syncToCore */
 		void getCoreDependencies(Vector<CoreObject*>& dependencies) override;
 		void getCoreDependencies(Vector<CoreObject*>& dependencies) override;
@@ -230,4 +199,42 @@ namespace bs
     };
     };
 
 
 	/** @} */
 	/** @} */
+
+	namespace ct
+	{
+	/** @addtogroup Material-Internal
+	 *  @{
+	 */
+
+	/**
+	 * @copydoc	TPass
+	 *
+	 * @note	Core thread.
+	 */
+	class BS_CORE_EXPORT PassCore : public CoreObjectCore, public TPass<true>
+    {
+    public:
+		virtual ~PassCore() { }
+
+		/**	Creates a new empty pass. */
+		static SPtr<PassCore> create(const PASS_DESC_CORE& desc);
+
+	protected:
+		friend class Pass;
+		friend class TechniqueCore;
+
+		/** @copydoc CoreObjectCore::initialize */
+		void initialize() override;
+
+		PassCore() { }
+		PassCore(const PASS_DESC_CORE& desc);
+		PassCore(const PASS_DESC_CORE& desc, const SPtr<GraphicsPipelineStateCore>& pipelineState);
+		PassCore(const PASS_DESC_CORE& desc, const SPtr<ComputePipelineStateCore>& pipelineState);
+
+		/** @copydoc CoreObjectCore::syncToCore */
+		void syncToCore(const CoreSyncData& data) override;
+    };
+
+	/** @} */
+	}
 }
 }

+ 4 - 4
Source/BansheeCore/Include/BsPlatform.h

@@ -282,7 +282,7 @@ namespace bs
 		 * All provided areas are relative to the specified window. Mostly useful for frameless windows that don't have 
 		 * All provided areas are relative to the specified window. Mostly useful for frameless windows that don't have 
 		 * typical caption bar.
 		 * typical caption bar.
 		 */
 		 */
-		static void setCaptionNonClientAreas(const RenderWindowCore& window, const Vector<Rect2I>& nonClientAreas);
+		static void setCaptionNonClientAreas(const ct::RenderWindowCore& window, const Vector<Rect2I>& nonClientAreas);
 
 
 		/**
 		/**
 		 * Sets custom non client areas for the specified window. Using custom client areas will override window resize 
 		 * Sets custom non client areas for the specified window. Using custom client areas will override window resize 
@@ -294,14 +294,14 @@ namespace bs
 		 * All provided areas are relative to the specified window. Mostly useful for frameless windows that don't have 
 		 * All provided areas are relative to the specified window. Mostly useful for frameless windows that don't have 
 		 * typical border.
 		 * typical border.
 		 */
 		 */
-		static void setResizeNonClientAreas(const RenderWindowCore& window, const Vector<NonClientResizeArea>& nonClientAreas);
+		static void setResizeNonClientAreas(const ct::RenderWindowCore& window, const Vector<NonClientResizeArea>& nonClientAreas);
 
 
 		/**
 		/**
 		 * Resets the non client areas for the specified windows and allows the platform to use the default values.
 		 * Resets the non client areas for the specified windows and allows the platform to use the default values.
 		 *
 		 *
 		 * @note	Thread safe.
 		 * @note	Thread safe.
 		 */
 		 */
-		static void resetNonClientAreas(const RenderWindowCore& window);
+		static void resetNonClientAreas(const ct::RenderWindowCore& window);
 
 
 		/** 
 		/** 
 		 * Causes the current thread to pause execution for the specified amount of time.
 		 * Causes the current thread to pause execution for the specified amount of time.
@@ -379,7 +379,7 @@ namespace bs
 		 *
 		 *
 		 * @note	Sim thread only.
 		 * @note	Sim thread only.
 		 */
 		 */
-		static Event<void(RenderWindowCore*)> onMouseLeftWindow;
+		static Event<void(ct::RenderWindowCore*)> onMouseLeftWindow;
 
 
 		/**
 		/**
 		 * Triggered whenever the pointer moves.
 		 * Triggered whenever the pointer moves.

+ 6 - 6
Source/BansheeCore/Include/BsProfilerGPU.h

@@ -60,8 +60,8 @@ namespace bs
 			ProfilerString sampleName;
 			ProfilerString sampleName;
 			RenderStatsData startStats;
 			RenderStatsData startStats;
 			RenderStatsData endStats;
 			RenderStatsData endStats;
-			SPtr<TimerQuery> activeTimeQuery;
-			SPtr<OcclusionQuery> activeOcclusionQuery;
+			SPtr<ct::TimerQuery> activeTimeQuery;
+			SPtr<ct::OcclusionQuery> activeOcclusionQuery;
 		};
 		};
 
 
 		struct ActiveFrame
 		struct ActiveFrame
@@ -145,10 +145,10 @@ namespace bs
 		void endSampleInternal(ActiveSample& sample);
 		void endSampleInternal(ActiveSample& sample);
 
 
 		/**	Creates a new timer query or returns an existing free query. */
 		/**	Creates a new timer query or returns an existing free query. */
-		SPtr<TimerQuery> getTimerQuery() const;
+		SPtr<ct::TimerQuery> getTimerQuery() const;
 
 
 		/**	Creates a new occlusion query or returns an existing free query. */
 		/**	Creates a new occlusion query or returns an existing free query. */
-		SPtr<OcclusionQuery> getOcclusionQuery() const;
+		SPtr<ct::OcclusionQuery> getOcclusionQuery() const;
 
 
 		/**
 		/**
 		 * Interprets the active frame results and generates a profiler report for the frame. Provided frame queries must 
 		 * Interprets the active frame results and generates a profiler report for the frame. Provided frame queries must 
@@ -167,8 +167,8 @@ namespace bs
 		Queue<ActiveFrame> mUnresolvedFrames;
 		Queue<ActiveFrame> mUnresolvedFrames;
 		Queue<GPUProfilerReport> mReadyReports;
 		Queue<GPUProfilerReport> mReadyReports;
 
 
-		mutable Stack<SPtr<TimerQuery>> mFreeTimerQueries;
-		mutable Stack<SPtr<OcclusionQuery>> mFreeOcclusionQueries;
+		mutable Stack<SPtr<ct::TimerQuery>> mFreeTimerQueries;
+		mutable Stack<SPtr<ct::OcclusionQuery>> mFreeOcclusionQueries;
 
 
 		Mutex mMutex;
 		Mutex mMutex;
 	};
 	};

+ 2 - 2
Source/BansheeCore/Include/BsQueryManager.h

@@ -6,7 +6,7 @@
 #include "BsEventQuery.h"
 #include "BsEventQuery.h"
 #include "BsModule.h"
 #include "BsModule.h"
 
 
-namespace bs
+namespace bs { namespace ct
 {
 {
 	/** @addtogroup RenderAPI-Internal
 	/** @addtogroup RenderAPI-Internal
 	 *  @{
 	 *  @{
@@ -89,4 +89,4 @@ namespace bs
 	};
 	};
 
 
 	/** @} */
 	/** @} */
-}
+}}

+ 6 - 3
Source/BansheeCore/Include/BsRasterizerState.h

@@ -133,7 +133,7 @@ namespace bs
 		const RasterizerProperties& getProperties() const;
 		const RasterizerProperties& getProperties() const;
 
 
 		/** Retrieves a core implementation of the rasterizer state usable only from the core thread. */
 		/** Retrieves a core implementation of the rasterizer state usable only from the core thread. */
-		SPtr<RasterizerStateCore> getCore() const;
+		SPtr<ct::RasterizerStateCore> getCore() const;
 
 
 		/** Creates a new rasterizer state using the specified rasterizer state descriptor structure. */
 		/** Creates a new rasterizer state using the specified rasterizer state descriptor structure. */
 		static SPtr<RasterizerState> create(const RASTERIZER_STATE_DESC& desc);
 		static SPtr<RasterizerState> create(const RASTERIZER_STATE_DESC& desc);
@@ -150,7 +150,7 @@ namespace bs
 		RasterizerState(const RASTERIZER_STATE_DESC& desc);
 		RasterizerState(const RASTERIZER_STATE_DESC& desc);
 		
 		
 		/** @copydoc CoreObject::createCore */
 		/** @copydoc CoreObject::createCore */
-		SPtr<CoreObjectCore> createCore() const override;
+		SPtr<ct::CoreObjectCore> createCore() const override;
 
 
 		RasterizerProperties mProperties;
 		RasterizerProperties mProperties;
 		mutable UINT32 mId;
 		mutable UINT32 mId;
@@ -162,11 +162,13 @@ namespace bs
 	public:
 	public:
 		friend class RasterizerStateRTTI;
 		friend class RasterizerStateRTTI;
 		static RTTITypeBase* getRTTIStatic();
 		static RTTITypeBase* getRTTIStatic();
-		virtual RTTITypeBase* getRTTI() const override;	
+		RTTITypeBase* getRTTI() const override;	
 	};
 	};
 
 
 	/** @} */
 	/** @} */
 
 
+	namespace ct
+	{
 	/** @addtogroup RenderAPI-Internal
 	/** @addtogroup RenderAPI-Internal
 	 *  @{
 	 *  @{
 	 */
 	 */
@@ -209,6 +211,7 @@ namespace bs
 	};
 	};
 
 
 	/** @} */
 	/** @} */
+		}
 }
 }
 
 
 /** @cond STDLIB */
 /** @cond STDLIB */

+ 4 - 0
Source/BansheeCore/Include/BsRenderAPI.h

@@ -234,6 +234,9 @@ namespace bs
 	};
 	};
 
 
 	/** @} */
 	/** @} */
+
+	namespace ct
+	{
 	/** @addtogroup RenderAPI-Internal
 	/** @addtogroup RenderAPI-Internal
 	 *  @{
 	 *  @{
 	 */
 	 */
@@ -617,4 +620,5 @@ namespace bs
 	};
 	};
 
 
 	/** @} */
 	/** @} */
+	}
 }
 }

+ 3 - 0
Source/BansheeCore/Include/BsRenderStateManager.h

@@ -93,6 +93,8 @@ namespace bs
 		mutable SPtr<DepthStencilState> mDefaultDepthStencilState;
 		mutable SPtr<DepthStencilState> mDefaultDepthStencilState;
 	};
 	};
 
 
+	namespace ct
+	{
 	/**	Handles creation of various render states. */
 	/**	Handles creation of various render states. */
 	class BS_CORE_EXPORT RenderStateCoreManager : public Module<RenderStateCoreManager>
 	class BS_CORE_EXPORT RenderStateCoreManager : public Module<RenderStateCoreManager>
 	{
 	{
@@ -299,6 +301,7 @@ namespace bs
 
 
 		mutable Mutex mMutex;
 		mutable Mutex mMutex;
 	};
 	};
+	}
 
 
 	/** @} */
 	/** @} */
 }
 }

+ 9 - 3
Source/BansheeCore/Include/BsRenderTarget.h

@@ -34,6 +34,8 @@ namespace bs
 		UINT32 mipLevel = 0; 
 		UINT32 mipLevel = 0; 
 	};
 	};
 
 
+	namespace ct
+	{
 	/**
 	/**
 	 * @see		RENDER_SURFACE_DESC
 	 * @see		RENDER_SURFACE_DESC
 	 *
 	 *
@@ -57,6 +59,7 @@ namespace bs
 		/** If the texture has multiple mips, which one to bind (only one can be bound for rendering). */
 		/** If the texture has multiple mips, which one to bind (only one can be bound for rendering). */
 		UINT32 mipLevel = 0; 
 		UINT32 mipLevel = 0; 
 	};
 	};
+	}
 
 
 	/** Contains various properties that describe a render target. */
 	/** Contains various properties that describe a render target. */
 	class BS_CORE_EXPORT RenderTargetProperties
 	class BS_CORE_EXPORT RenderTargetProperties
@@ -119,7 +122,7 @@ namespace bs
 		bool requiresTextureFlipping() const { return mRequiresTextureFlipping; }
 		bool requiresTextureFlipping() const { return mRequiresTextureFlipping; }
 
 
 	protected:
 	protected:
-		friend class RenderTargetCore;
+		friend class ct::RenderTargetCore;
 		friend class RenderTarget;
 		friend class RenderTarget;
 
 
 		UINT32 mWidth = 0;
 		UINT32 mWidth = 0;
@@ -169,7 +172,7 @@ namespace bs
 		const RenderTargetProperties& getProperties() const;
 		const RenderTargetProperties& getProperties() const;
 
 
 		/** Retrieves a core implementation of a render target usable only from the core thread. */
 		/** Retrieves a core implementation of a render target usable only from the core thread. */
-		SPtr<RenderTargetCore> getCore() const;
+		SPtr<ct::RenderTargetCore> getCore() const;
 
 
 		/**
 		/**
 		 * Event that gets triggered whenever the render target is resized.
 		 * Event that gets triggered whenever the render target is resized.
@@ -179,7 +182,7 @@ namespace bs
 		mutable Event<void()> onResized;
 		mutable Event<void()> onResized;
 
 
     protected:
     protected:
-		friend class RenderTargetCore;
+		friend class ct::RenderTargetCore;
 
 
 		/**	Returns properties that describe the render target. */
 		/**	Returns properties that describe the render target. */
 		virtual const RenderTargetProperties& getPropertiesInternal() const = 0;
 		virtual const RenderTargetProperties& getPropertiesInternal() const = 0;
@@ -187,6 +190,8 @@ namespace bs
 
 
 	/** @} */
 	/** @} */
 
 
+	namespace ct
+	{
 	/** @addtogroup RenderAPI-Internal
 	/** @addtogroup RenderAPI-Internal
 	 *  @{
 	 *  @{
 	 */
 	 */
@@ -242,4 +247,5 @@ namespace bs
 	};
 	};
 
 
 	/** @} */
 	/** @} */
+	}
 }
 }

+ 7 - 4
Source/BansheeCore/Include/BsRenderTexture.h

@@ -19,14 +19,14 @@ namespace bs
 		RENDER_SURFACE_DESC depthStencilSurface;
 		RENDER_SURFACE_DESC depthStencilSurface;
 	};
 	};
 
 
-	struct RENDER_TEXTURE_DESC_CORE;
+	namespace ct { struct RENDER_TEXTURE_DESC_CORE; }
 
 
 	/**	Contains various properties that describe a render texture. */
 	/**	Contains various properties that describe a render texture. */
 	class BS_CORE_EXPORT RenderTextureProperties : public RenderTargetProperties
 	class BS_CORE_EXPORT RenderTextureProperties : public RenderTargetProperties
 	{
 	{
 	public:
 	public:
 		RenderTextureProperties(const RENDER_TEXTURE_DESC& desc, bool requiresFlipping);
 		RenderTextureProperties(const RENDER_TEXTURE_DESC& desc, bool requiresFlipping);
-		RenderTextureProperties(const RENDER_TEXTURE_DESC_CORE& desc, bool requiresFlipping);
+		RenderTextureProperties(const ct::RENDER_TEXTURE_DESC_CORE& desc, bool requiresFlipping);
 		virtual ~RenderTextureProperties() { }
 		virtual ~RenderTextureProperties() { }
 
 
 	private:
 	private:
@@ -73,7 +73,7 @@ namespace bs
 		 *
 		 *
 		 * @note	Core thread only.
 		 * @note	Core thread only.
 		 */
 		 */
-		SPtr<RenderTextureCore> getCore() const;
+		SPtr<ct::RenderTextureCore> getCore() const;
 
 
 		/**	Returns properties that describe the render texture. */
 		/**	Returns properties that describe the render texture. */
 		const RenderTextureProperties& getProperties() const;
 		const RenderTextureProperties& getProperties() const;
@@ -84,7 +84,7 @@ namespace bs
 		RenderTexture(const RENDER_TEXTURE_DESC& desc);
 		RenderTexture(const RENDER_TEXTURE_DESC& desc);
 
 
 		/** @copydoc CoreObject::createCore */
 		/** @copydoc CoreObject::createCore */
-		SPtr<CoreObjectCore> createCore() const override;
+		SPtr<ct::CoreObjectCore> createCore() const override;
 
 
 		/** @copydoc CoreObject::syncToCore */
 		/** @copydoc CoreObject::syncToCore */
 		CoreSyncData syncToCore(FrameAlloc* allocator) override;
 		CoreSyncData syncToCore(FrameAlloc* allocator) override;
@@ -98,6 +98,8 @@ namespace bs
 
 
 	/** @} */
 	/** @} */
 
 
+	namespace ct
+	{
 	/** @addtogroup RenderAPI-Internal
 	/** @addtogroup RenderAPI-Internal
 	 *  @{
 	 *  @{
 	 */
 	 */
@@ -165,4 +167,5 @@ namespace bs
 	};
 	};
 
 
 	/** @} */
 	/** @} */
+	}
 }
 }

+ 6 - 3
Source/BansheeCore/Include/BsRenderWindow.h

@@ -74,7 +74,7 @@ namespace bs
 		bool isMaximized() const { return mIsMaximized; }
 		bool isMaximized() const { return mIsMaximized; }
 
 
 	protected:
 	protected:
-		friend class RenderWindowCore;
+		friend class ct::RenderWindowCore;
 		friend class RenderWindow;
 		friend class RenderWindow;
 
 
 		bool mIsFullScreen = false;
 		bool mIsFullScreen = false;
@@ -176,7 +176,7 @@ namespace bs
 		void setWindowed(UINT32 width, UINT32 height);
 		void setWindowed(UINT32 width, UINT32 height);
 
 
 		/**	Retrieves a core implementation of a render window usable only from the core thread. */
 		/**	Retrieves a core implementation of a render window usable only from the core thread. */
-		SPtr<RenderWindowCore> getCore() const;
+		SPtr<ct::RenderWindowCore> getCore() const;
 
 
 		/**	Returns properties that describe the render window. */
 		/**	Returns properties that describe the render window. */
 		const RenderWindowProperties& getProperties() const;
 		const RenderWindowProperties& getProperties() const;
@@ -199,7 +199,7 @@ namespace bs
 		RenderWindowProperties& getMutableProperties();
 		RenderWindowProperties& getMutableProperties();
 
 
 		/** @copydoc RenderTarget::createCore */
 		/** @copydoc RenderTarget::createCore */
-		SPtr<CoreObjectCore> createCore() const override;
+		SPtr<ct::CoreObjectCore> createCore() const override;
 
 
 		/**	Updates window properties from the synced property data. */
 		/**	Updates window properties from the synced property data. */
 		virtual void syncProperties() = 0;
 		virtual void syncProperties() = 0;
@@ -211,6 +211,8 @@ namespace bs
 
 
 	/** @} */
 	/** @} */
 
 
+	namespace ct
+	{
 	/** @addtogroup RenderAPI-Internal
 	/** @addtogroup RenderAPI-Internal
 	 *  @{
 	 *  @{
 	 */
 	 */
@@ -339,4 +341,5 @@ namespace bs
 	};
 	};
 
 
 	/** @} */
 	/** @} */
+	}
 }
 }

+ 10 - 7
Source/BansheeCore/Include/BsRenderWindowManager.h

@@ -41,16 +41,16 @@ namespace bs
 		void notifyWindowDestroyed(RenderWindow* window);
 		void notifyWindowDestroyed(RenderWindow* window);
 
 
 		/**	Called by the core thread when window receives focus. */
 		/**	Called by the core thread when window receives focus. */
-		void notifyFocusReceived(RenderWindowCore* window);
+		void notifyFocusReceived(ct::RenderWindowCore* window);
 
 
 		/**	Called by the core thread when window loses focus. */
 		/**	Called by the core thread when window loses focus. */
-		void notifyFocusLost(RenderWindowCore* window);
+		void notifyFocusLost(ct::RenderWindowCore* window);
 
 
 		/**	Called by the core thread when window is moved or resized. */
 		/**	Called by the core thread when window is moved or resized. */
-		void notifyMovedOrResized(RenderWindowCore* window);
+		void notifyMovedOrResized(ct::RenderWindowCore* window);
 
 
 		/**	Called by the sim thread when window properties change. */
 		/**	Called by the sim thread when window properties change. */
-		void notifySyncDataDirty(RenderWindowCore* coreWindow);
+		void notifySyncDataDirty(ct::RenderWindowCore* coreWindow);
 
 
 		/**	Returns a list of all open render windows. */
 		/**	Returns a list of all open render windows. */
 		Vector<RenderWindow*> getRenderWindows() const;
 		Vector<RenderWindow*> getRenderWindows() const;
@@ -67,10 +67,10 @@ namespace bs
 		friend class RenderWindow;
 		friend class RenderWindow;
 
 
 		/**	Called by the core thread when mouse leaves a window. */
 		/**	Called by the core thread when mouse leaves a window. */
-		void windowMouseLeft(RenderWindowCore* window);
+		void windowMouseLeft(ct::RenderWindowCore* window);
 
 
 		/**	Finds a sim thread equivalent of the provided core thread window implementation. */
 		/**	Finds a sim thread equivalent of the provided core thread window implementation. */
-		RenderWindow* getNonCore(const RenderWindowCore* window) const;
+		RenderWindow* getNonCore(const ct::RenderWindowCore* window) const;
 
 
 		/** @copydoc create */
 		/** @copydoc create */
 		virtual SPtr<RenderWindow> createImpl(RENDER_WINDOW_DESC& desc, UINT32 windowId, const SPtr<RenderWindow>& parentWindow) = 0;
 		virtual SPtr<RenderWindow> createImpl(RENDER_WINDOW_DESC& desc, UINT32 windowId, const SPtr<RenderWindow>& parentWindow) = 0;
@@ -86,6 +86,8 @@ namespace bs
 		UnorderedSet<RenderWindow*> mDirtyProperties;
 		UnorderedSet<RenderWindow*> mDirtyProperties;
 	};
 	};
 
 
+	namespace ct
+	{
 	/**
 	/**
 	 * Handles creation and internal updates relating to render windows.
 	 * Handles creation and internal updates relating to render windows.
 	 *
 	 *
@@ -109,7 +111,7 @@ namespace bs
 		Vector<RenderWindowCore*> getRenderWindows() const;
 		Vector<RenderWindowCore*> getRenderWindows() const;
 
 
 	protected:
 	protected:
-		friend class RenderWindowCore;
+		friend class ct::RenderWindowCore;
 		friend class RenderWindow;
 		friend class RenderWindow;
 		friend class RenderWindowManager;
 		friend class RenderWindowManager;
 
 
@@ -127,6 +129,7 @@ namespace bs
 		UnorderedSet<RenderWindowCore*> mDirtyProperties;
 		UnorderedSet<RenderWindowCore*> mDirtyProperties;
 		std::atomic_uint mNextWindowId;
 		std::atomic_uint mNextWindowId;
 	};
 	};
+	}
 
 
 	/** @} */
 	/** @} */
 }
 }

+ 2 - 2
Source/BansheeCore/Include/BsRendererExtension.h

@@ -72,14 +72,14 @@ namespace bs
 		virtual void destroy() {}
 		virtual void destroy() {}
 
 
 		/** Returns true if the render() method should be called for the provided camera. */
 		/** Returns true if the render() method should be called for the provided camera. */
-		virtual bool check(const CameraCore& camera) = 0;
+		virtual bool check(const ct::CameraCore& camera) = 0;
 
 
 		/** 
 		/** 
 		 * Called at the point at which rendering should be performed for the provided camera. Relevant render targets
 		 * Called at the point at which rendering should be performed for the provided camera. Relevant render targets
 		 * are guaranteed to be already bound to the render API, depending on the RenderLocation. Note that actual structure
 		 * are guaranteed to be already bound to the render API, depending on the RenderLocation. Note that actual structure
 		 * of the render targets depends on the active renderer.
 		 * of the render targets depends on the active renderer.
 		 */
 		 */
-		virtual void render(const CameraCore& camera) = 0;
+		virtual void render(const ct::CameraCore& camera) = 0;
 
 
 		/** 
 		/** 
 		 * Determines when will the render() method execute, compared to other plugins using the same RenderLocation. 
 		 * Determines when will the render() method execute, compared to other plugins using the same RenderLocation. 

+ 1 - 1
Source/BansheeCore/Include/BsRendererFactory.h

@@ -22,7 +22,7 @@ namespace bs
 		virtual ~RendererFactory() { }
 		virtual ~RendererFactory() { }
 
 
 		/**	Creates a new instance of the renderer. */
 		/**	Creates a new instance of the renderer. */
-		virtual SPtr<CoreRenderer> create() = 0;
+		virtual SPtr<ct::CoreRenderer> create() = 0;
 
 
 		/**	Returns the name of the renderer this factory creates. */
 		/**	Returns the name of the renderer this factory creates. */
 		virtual const String& name() const = 0;
 		virtual const String& name() const = 0;

+ 2 - 2
Source/BansheeCore/Include/BsRendererManager.h

@@ -33,7 +33,7 @@ namespace bs
 		void initialize();
 		void initialize();
 
 
 		/**	Returns the currently active renderer. Null if no renderer is active. */
 		/**	Returns the currently active renderer. Null if no renderer is active. */
-		SPtr<CoreRenderer> getActive() { return mActiveRenderer; }
+		SPtr<ct::CoreRenderer> getActive() { return mActiveRenderer; }
 
 
 		/**
 		/**
 		 * Registers a new renderer factory. Any renderer you try to make active with setActive() you will need to have 
 		 * Registers a new renderer factory. Any renderer you try to make active with setActive() you will need to have 
@@ -43,7 +43,7 @@ namespace bs
 	private:
 	private:
 		Vector<SPtr<RendererFactory>> mAvailableFactories;
 		Vector<SPtr<RendererFactory>> mAvailableFactories;
 
 
-		SPtr<CoreRenderer> mActiveRenderer;
+		SPtr<ct::CoreRenderer> mActiveRenderer;
 	};
 	};
 
 
 	/** @} */
 	/** @} */

+ 1 - 1
Source/BansheeCore/Include/BsRendererMeshData.h

@@ -219,7 +219,7 @@ namespace bs
 		static SPtr<VertexDataDesc> vertexLayoutVertexDesc(VertexLayout type);
 		static SPtr<VertexDataDesc> vertexLayoutVertexDesc(VertexLayout type);
 
 
 	private:
 	private:
-		friend class CoreRenderer;
+		friend class ct::CoreRenderer;
 
 
 		RendererMeshData(UINT32 numVertices, UINT32 numIndices, VertexLayout layout, IndexType indexType = IT_32BIT);
 		RendererMeshData(UINT32 numVertices, UINT32 numIndices, VertexLayout layout, IndexType indexType = IT_32BIT);
 		RendererMeshData(const SPtr<MeshData>& meshData);
 		RendererMeshData(const SPtr<MeshData>& meshData);

+ 7 - 4
Source/BansheeCore/Include/BsSamplerState.h

@@ -116,7 +116,7 @@ namespace bs
 
 
 	protected:
 	protected:
 		friend class SamplerState;
 		friend class SamplerState;
-		friend class SamplerStateCore;
+		friend class ct::SamplerStateCore;
 		friend class SamplerStateRTTI;
 		friend class SamplerStateRTTI;
 
 
 		SAMPLER_STATE_DESC mData;
 		SAMPLER_STATE_DESC mData;
@@ -141,7 +141,7 @@ namespace bs
 		const SamplerProperties& getProperties() const;
 		const SamplerProperties& getProperties() const;
 
 
 		/**	Retrieves a core implementation of the sampler state usable only from the core thread. */
 		/**	Retrieves a core implementation of the sampler state usable only from the core thread. */
-		SPtr<SamplerStateCore> getCore() const;
+		SPtr<ct::SamplerStateCore> getCore() const;
 
 
 		/**	Creates a new sampler state using the provided descriptor structure. */
 		/**	Creates a new sampler state using the provided descriptor structure. */
 		static SPtr<SamplerState> create(const SAMPLER_STATE_DESC& desc);
 		static SPtr<SamplerState> create(const SAMPLER_STATE_DESC& desc);
@@ -156,7 +156,7 @@ namespace bs
 		SamplerState(const SAMPLER_STATE_DESC& desc);
 		SamplerState(const SAMPLER_STATE_DESC& desc);
 
 
 		/** @copydoc CoreObject::createCore */
 		/** @copydoc CoreObject::createCore */
-		SPtr<CoreObjectCore> createCore() const override;
+		SPtr<ct::CoreObjectCore> createCore() const override;
 
 
 		SamplerProperties mProperties;
 		SamplerProperties mProperties;
 
 
@@ -174,6 +174,8 @@ namespace bs
 
 
 	/** @} */
 	/** @} */
 
 
+	namespace ct
+	{
 	/** @addtogroup RenderAPI-Internal
 	/** @addtogroup RenderAPI-Internal
 	 *  @{
 	 *  @{
 	 */
 	 */
@@ -210,8 +212,9 @@ namespace bs
 
 
 		SamplerProperties mProperties;
 		SamplerProperties mProperties;
 	};
 	};
-
+	
 	/** @} */
 	/** @} */
+	}
 }
 }
 
 
 /** @cond STDLIB */
 /** @cond STDLIB */

+ 32 - 19
Source/BansheeCore/Include/BsShader.h

@@ -61,7 +61,7 @@ namespace bs
 
 
 	template<bool Core> struct TSamplerStateType {};
 	template<bool Core> struct TSamplerStateType {};
 	template<> struct TSamplerStateType < false > { typedef SPtr<SamplerState> Type; };
 	template<> struct TSamplerStateType < false > { typedef SPtr<SamplerState> Type; };
-	template<> struct TSamplerStateType < true > { typedef SPtr<SamplerStateCore> Type; };
+	template<> struct TSamplerStateType < true > { typedef SPtr<ct::SamplerStateCore> Type; };
 
 
 	/** Structure used for initializing a shader. */
 	/** Structure used for initializing a shader. */
 	template<bool Core>
 	template<bool Core>
@@ -351,28 +351,17 @@ namespace bs
 
 
 	/** @} */
 	/** @} */
 
 
+	namespace ct
+	{
 	/** @addtogroup Material-Internal
 	/** @addtogroup Material-Internal
 	 *  @{
 	 *  @{
 	 */
 	 */
 
 
 	typedef TSHADER_DESC<true> SHADER_DESC_CORE;
 	typedef TSHADER_DESC<true> SHADER_DESC_CORE;
-	
-	/** Core thread version of Shader. */
-	class BS_CORE_EXPORT ShaderCore : public CoreObjectCore, public TShader<true>
-	{
-	public:
-		/** @copydoc Shader::create */
-		static SPtr<ShaderCore> create(const String& name, const SHADER_DESC_CORE& desc, const Vector<SPtr<TechniqueCore>>& techniques);
-
-	protected:
-		friend class Shader;
-
-		ShaderCore(const String& name, const SHADER_DESC_CORE& desc, const Vector<SPtr<TechniqueCore>>& techniques, UINT32 id);
-
-		static std::atomic<UINT32> mNextShaderId;
-	};
 
 
 	/** @} */
 	/** @} */
+	}
+
 	/** @addtogroup Material
 	/** @addtogroup Material
 	 *  @{
 	 *  @{
 	 */
 	 */
@@ -391,7 +380,7 @@ namespace bs
 	{
 	{
 	public:
 	public:
 		/** Retrieves an implementation of a shader usable only from the core thread. */
 		/** Retrieves an implementation of a shader usable only from the core thread. */
-		SPtr<ShaderCore> getCore() const;
+		SPtr<ct::ShaderCore> getCore() const;
 
 
 		/**
 		/**
 		 * Sets a list include file paths that are referenced by this shader.
 		 * Sets a list include file paths that are referenced by this shader.
@@ -448,10 +437,10 @@ namespace bs
 		void getCoreDependencies(Vector<CoreObject*>& dependencies) override;
 		void getCoreDependencies(Vector<CoreObject*>& dependencies) override;
 
 
 		/** @copydoc CoreObject::createCore */
 		/** @copydoc CoreObject::createCore */
-		SPtr<CoreObjectCore> createCore() const override;
+		SPtr<ct::CoreObjectCore> createCore() const override;
 
 
 		/** Converts a sim thread version of the shader descriptor to a core thread version. */
 		/** Converts a sim thread version of the shader descriptor to a core thread version. */
-		SHADER_DESC_CORE convertDesc(const SHADER_DESC& desc) const;
+		ct::SHADER_DESC_CORE convertDesc(const SHADER_DESC& desc) const;
 
 
 	private:
 	private:
 		/************************************************************************/
 		/************************************************************************/
@@ -486,4 +475,28 @@ namespace bs
 	};
 	};
 
 
 	/** @} */
 	/** @} */
+
+	namespace ct
+	{
+	/** @addtogroup Material-Internal
+	 *  @{
+	 */
+
+	/** Core thread version of Shader. */
+	class BS_CORE_EXPORT ShaderCore : public CoreObjectCore, public TShader<true>
+	{
+	public:
+		/** @copydoc Shader::create */
+		static SPtr<ShaderCore> create(const String& name, const SHADER_DESC_CORE& desc, const Vector<SPtr<TechniqueCore>>& techniques);
+
+	protected:
+		friend class Shader;
+
+		ShaderCore(const String& name, const SHADER_DESC_CORE& desc, const Vector<SPtr<TechniqueCore>>& techniques, UINT32 id);
+
+		static std::atomic<UINT32> mNextShaderId;
+	};
+
+	/** @} */
+	}
 }
 }

+ 29 - 25
Source/BansheeCore/Include/BsTechnique.h

@@ -36,11 +36,11 @@ namespace bs
 
 
 	template<bool Core> struct TPassType { };
 	template<bool Core> struct TPassType { };
 	template<> struct TPassType < false > { typedef Pass Type; };
 	template<> struct TPassType < false > { typedef Pass Type; };
-	template<> struct TPassType < true > { typedef PassCore Type; };
+	template<> struct TPassType < true > { typedef ct::PassCore Type; };
 
 
 	template<bool Core> struct TTechniqueType {};
 	template<bool Core> struct TTechniqueType {};
 	template<> struct TTechniqueType < false > { typedef Technique Type; };
 	template<> struct TTechniqueType < false > { typedef Technique Type; };
-	template<> struct TTechniqueType < true > { typedef TechniqueCore Type; };
+	template<> struct TTechniqueType < true > { typedef ct::TechniqueCore Type; };
 
 
 	/** Templated class that is used for implementing both sim and core versions of Technique. */
 	/** Templated class that is used for implementing both sim and core versions of Technique. */
 	template<bool Core>
 	template<bool Core>
@@ -66,27 +66,6 @@ namespace bs
 
 
 	/** @} */
 	/** @} */
 
 
-	/** @addtogroup Material-Internal
-	 *  @{
-	 */
-
-	/** Core thread version of Technique. */
-	class BS_CORE_EXPORT TechniqueCore : public CoreObjectCore, public TTechnique<true>
-	{
-	public:
-		TechniqueCore(const String& language, const StringID& renderer, const Vector<StringID>& tags,
-			const Vector<SPtr<PassCore>>& passes);
-
-		/** @copydoc Technique::create(const String&, const StringID&, const Vector<SPtr<Pass>>&) */
-		static SPtr<TechniqueCore> create(const String& language, const StringID& renderer,
-			const Vector<SPtr<PassCore>>& passes);
-
-		/** @copydoc Technique::create(const String&, const StringID&, const Vector<StringID>&, const Vector<SPtr<Pass>>&) */
-		static SPtr<TechniqueCore> create(const String& language, const StringID& renderer, const Vector<StringID>& tags,
-			const Vector<SPtr<PassCore>>& passes);
-	};
-
-	/** @} */
 	/** @addtogroup Material
 	/** @addtogroup Material
 	 *  @{
 	 *  @{
 	 */
 	 */
@@ -108,7 +87,7 @@ namespace bs
 			const Vector<SPtr<Pass>>& passes);
 			const Vector<SPtr<Pass>>& passes);
 
 
 		/** Retrieves an implementation of a technique usable only from the core thread. */
 		/** Retrieves an implementation of a technique usable only from the core thread. */
-		SPtr<TechniqueCore> getCore() const;
+		SPtr<ct::TechniqueCore> getCore() const;
 
 
 		/** 
 		/** 
 		 * Creates a new technique. 
 		 * Creates a new technique. 
@@ -139,7 +118,7 @@ namespace bs
 
 
 	protected:
 	protected:
 		/** @copydoc CoreObject::createCore */
 		/** @copydoc CoreObject::createCore */
-		SPtr<CoreObjectCore> createCore() const override;
+		SPtr<ct::CoreObjectCore> createCore() const override;
 
 
 		/** @copydoc CoreObject::getCoreDependencies */
 		/** @copydoc CoreObject::getCoreDependencies */
 		void getCoreDependencies(Vector<CoreObject*>& dependencies) override;
 		void getCoreDependencies(Vector<CoreObject*>& dependencies) override;
@@ -162,4 +141,29 @@ namespace bs
 	};
 	};
 
 
 	/** @} */
 	/** @} */
+
+	namespace ct
+	{
+	/** @addtogroup Material-Internal
+	 *  @{
+	 */
+
+	/** Core thread version of Technique. */
+	class BS_CORE_EXPORT TechniqueCore : public CoreObjectCore, public TTechnique<true>
+	{
+	public:
+		TechniqueCore(const String& language, const StringID& renderer, const Vector<StringID>& tags,
+			const Vector<SPtr<PassCore>>& passes);
+
+		/** @copydoc Technique::create(const String&, const StringID&, const Vector<SPtr<Pass>>&) */
+		static SPtr<TechniqueCore> create(const String& language, const StringID& renderer,
+			const Vector<SPtr<PassCore>>& passes);
+
+		/** @copydoc Technique::create(const String&, const StringID&, const Vector<StringID>&, const Vector<SPtr<Pass>>&) */
+		static SPtr<TechniqueCore> create(const String& language, const StringID& renderer, const Vector<StringID>& tags,
+			const Vector<SPtr<PassCore>>& passes);
+	};
+
+	/** @} */
+	}
 }
 }

+ 5 - 2
Source/BansheeCore/Include/BsTexture.h

@@ -208,7 +208,7 @@ namespace bs
 		const TextureProperties& getProperties() const { return mProperties; }
 		const TextureProperties& getProperties() const { return mProperties; }
 
 
 		/**	Retrieves a core implementation of a texture usable only from the core thread. */
 		/**	Retrieves a core implementation of a texture usable only from the core thread. */
-		SPtr<TextureCore> getCore() const;
+		SPtr<ct::TextureCore> getCore() const;
 
 
 		/************************************************************************/
 		/************************************************************************/
 		/* 								STATICS		                     		*/
 		/* 								STATICS		                     		*/
@@ -262,7 +262,7 @@ namespace bs
 		void initialize() override;
 		void initialize() override;
 
 
 		/** @copydoc CoreObject::createCore */
 		/** @copydoc CoreObject::createCore */
-		SPtr<CoreObjectCore> createCore() const override;
+		SPtr<ct::CoreObjectCore> createCore() const override;
 
 
 		/** Calculates the size of the texture, in bytes. */
 		/** Calculates the size of the texture, in bytes. */
 		UINT32 calculateSize() const;
 		UINT32 calculateSize() const;
@@ -295,6 +295,8 @@ namespace bs
 
 
 	/** @} */
 	/** @} */
 
 
+	namespace ct
+	{
 	/** @addtogroup Resources-Internal
 	/** @addtogroup Resources-Internal
 	 *  @{
 	 *  @{
 	 */
 	 */
@@ -479,4 +481,5 @@ namespace bs
 	};
 	};
 
 
 	/** @} */
 	/** @} */
+	}
 }
 }

+ 3 - 0
Source/BansheeCore/Include/BsTextureManager.h

@@ -79,6 +79,8 @@ namespace bs
 		mutable HTexture mDummyTexture;
 		mutable HTexture mDummyTexture;
     };
     };
 
 
+	namespace ct
+	{
 	/**
 	/**
      * Defines interface for creation of textures. Render systems provide their own implementations.
      * Defines interface for creation of textures. Render systems provide their own implementations.
 	 *
 	 *
@@ -124,6 +126,7 @@ namespace bs
 		virtual SPtr<RenderTextureCore> createRenderTextureInternal(const RENDER_TEXTURE_DESC_CORE& desc, 
 		virtual SPtr<RenderTextureCore> createRenderTextureInternal(const RENDER_TEXTURE_DESC_CORE& desc, 
 			UINT32 deviceIdx = 0) = 0;
 			UINT32 deviceIdx = 0) = 0;
     };
     };
+		}
 
 
 	/** @} */
 	/** @} */
 }
 }

+ 3 - 0
Source/BansheeCore/Include/BsTextureView.h

@@ -6,6 +6,8 @@
 
 
 namespace bs
 namespace bs
 {
 {
+	namespace ct
+	{
 	/** @addtogroup RenderAPI-Internal
 	/** @addtogroup RenderAPI-Internal
 	 *  @{
 	 *  @{
 	 */
 	 */
@@ -95,4 +97,5 @@ namespace bs
 	};
 	};
 
 
 	/** @} */
 	/** @} */
+	}
 }
 }

+ 2 - 2
Source/BansheeCore/Include/BsTimerQuery.h

@@ -4,7 +4,7 @@
 
 
 #include "BsCorePrerequisites.h"
 #include "BsCorePrerequisites.h"
 
 
-namespace bs
+namespace bs { namespace ct
 {
 {
 	/** @addtogroup RenderAPI-Internal
 	/** @addtogroup RenderAPI-Internal
 	 *  @{
 	 *  @{
@@ -73,4 +73,4 @@ namespace bs
 	};
 	};
 
 
 	/** @} */
 	/** @} */
-}
+}}

+ 8 - 5
Source/BansheeCore/Include/BsTransientMesh.h

@@ -25,7 +25,7 @@ namespace bs
 		virtual ~TransientMesh();
 		virtual ~TransientMesh();
 
 
 		/** Retrieves a core implementation of a mesh usable only from the core thread. */
 		/** Retrieves a core implementation of a mesh usable only from the core thread. */
-		SPtr<TransientMeshCore> getCore() const;
+		SPtr<ct::TransientMeshCore> getCore() const;
 
 
 	protected:
 	protected:
 		friend class MeshHeap;
 		friend class MeshHeap;
@@ -42,7 +42,7 @@ namespace bs
 		void markAsDestroyed() { mIsDestroyed = true; }
 		void markAsDestroyed() { mIsDestroyed = true; }
 
 
 		/** @copydoc RenderTarget::createCore */
 		/** @copydoc RenderTarget::createCore */
-		SPtr<CoreObjectCore> createCore() const override;
+		SPtr<ct::CoreObjectCore> createCore() const override;
 
 
 	protected:
 	protected:
 		bool mIsDestroyed;
 		bool mIsDestroyed;
@@ -52,6 +52,8 @@ namespace bs
 
 
 	/** @} */
 	/** @} */
 
 
+	namespace ct
+	{
 	/** @addtogroup Resources-Internal
 	/** @addtogroup Resources-Internal
 	 *  @{
 	 *  @{
 	 */
 	 */
@@ -80,13 +82,13 @@ namespace bs
 		UINT32 getMeshHeapId() const { return mId; }
 		UINT32 getMeshHeapId() const { return mId; }
 
 
 		/** @copydoc MeshCoreBase::getVertexOffset */
 		/** @copydoc MeshCoreBase::getVertexOffset */
-		virtual UINT32 getVertexOffset() const override;
+		UINT32 getVertexOffset() const override;
 
 
 		 /** @copydoc MeshCoreBase::getIndexOffset */
 		 /** @copydoc MeshCoreBase::getIndexOffset */
-		virtual UINT32 getIndexOffset() const override;
+		UINT32 getIndexOffset() const override;
 
 
 		 /** @copydoc MeshCoreBase::_notifyUsedOnGPU */
 		 /** @copydoc MeshCoreBase::_notifyUsedOnGPU */
-		virtual void _notifyUsedOnGPU() override;
+		void _notifyUsedOnGPU() override;
 
 
 	protected:
 	protected:
 		friend class TransientMesh;
 		friend class TransientMesh;
@@ -96,4 +98,5 @@ namespace bs
 	};
 	};
 
 
 	/** @} */
 	/** @} */
+	}
 }
 }

+ 6 - 3
Source/BansheeCore/Include/BsVertexBuffer.h

@@ -35,7 +35,7 @@ namespace bs
 
 
 	protected:
 	protected:
 		friend class VertexBuffer;
 		friend class VertexBuffer;
-		friend class VertexBufferCore;
+		friend class ct::VertexBufferCore;
 
 
 		UINT32 mNumVertices;
 		UINT32 mNumVertices;
 		UINT32 mVertexSize;
 		UINT32 mVertexSize;
@@ -52,7 +52,7 @@ namespace bs
 		 *
 		 *
 		 * @note	Core thread only.
 		 * @note	Core thread only.
 		 */
 		 */
-		SPtr<VertexBufferCore> getCore() const;
+		SPtr<ct::VertexBufferCore> getCore() const;
 
 
 		/** @copydoc HardwareBufferManager::createVertexBuffer */
 		/** @copydoc HardwareBufferManager::createVertexBuffer */
 		static SPtr<VertexBuffer> create(const VERTEX_BUFFER_DESC& desc);
 		static SPtr<VertexBuffer> create(const VERTEX_BUFFER_DESC& desc);
@@ -64,7 +64,7 @@ namespace bs
 		VertexBuffer(const VERTEX_BUFFER_DESC& desc);
 		VertexBuffer(const VERTEX_BUFFER_DESC& desc);
 
 
 		/** @copydoc CoreObject::createCore */
 		/** @copydoc CoreObject::createCore */
-		virtual SPtr<CoreObjectCore> createCore() const;
+		virtual SPtr<ct::CoreObjectCore> createCore() const;
 
 
 	protected:
 	protected:
 		VertexBufferProperties mProperties;
 		VertexBufferProperties mProperties;
@@ -74,6 +74,8 @@ namespace bs
 
 
 	/** @} */
 	/** @} */
 
 
+	namespace ct
+	{
 	/** @addtogroup RenderAPI-Internal
 	/** @addtogroup RenderAPI-Internal
 	 *  @{
 	 *  @{
 	 */
 	 */
@@ -96,4 +98,5 @@ namespace bs
 	};
 	};
 
 
 	/** @} */
 	/** @} */
+		}
 }
 }

+ 2 - 2
Source/BansheeCore/Include/BsVertexData.h

@@ -6,7 +6,7 @@
 #include "BsVertexDeclaration.h"
 #include "BsVertexDeclaration.h"
 #include "BsVertexBuffer.h"
 #include "BsVertexBuffer.h"
 
 
-namespace bs 
+namespace bs { namespace ct
 {
 {
 	/** @addtogroup RenderAPI
 	/** @addtogroup RenderAPI
 	 *  @{
 	 *  @{
@@ -55,4 +55,4 @@ namespace bs
 	};
 	};
 
 
 	/** @} */
 	/** @} */
-}
+}}

+ 2 - 2
Source/BansheeCore/Include/BsVertexDataDesc.h

@@ -72,9 +72,9 @@ namespace bs
 
 
 	private:
 	private:
 		friend class Mesh;
 		friend class Mesh;
-		friend class MeshCore;
+		friend class ct::MeshCore;
 		friend class MeshHeap;
 		friend class MeshHeap;
-		friend class MeshHeapCore;
+		friend class ct::MeshHeapCore;
 
 
 		/**	Returns the largest stream index of all the stored vertex elements. */
 		/**	Returns the largest stream index of all the stored vertex elements. */
 		UINT32 getMaxStreamIdx() const;
 		UINT32 getMaxStreamIdx() const;

+ 5 - 2
Source/BansheeCore/Include/BsVertexDeclaration.h

@@ -175,7 +175,7 @@ namespace bs
 		const VertexDeclarationProperties& getProperties() const { return mProperties; }
 		const VertexDeclarationProperties& getProperties() const { return mProperties; }
 
 
 		/**	Retrieves a core implementation of a vertex declaration usable only from the core thread. */
 		/**	Retrieves a core implementation of a vertex declaration usable only from the core thread. */
-		SPtr<VertexDeclarationCore> getCore() const;
+		SPtr<ct::VertexDeclarationCore> getCore() const;
 
 
 		/** @copydoc HardwareBufferManager::createVertexDeclaration */
 		/** @copydoc HardwareBufferManager::createVertexDeclaration */
 		static SPtr<VertexDeclaration> create(const SPtr<VertexDataDesc>& desc);
 		static SPtr<VertexDeclaration> create(const SPtr<VertexDataDesc>& desc);
@@ -186,7 +186,7 @@ namespace bs
 		VertexDeclaration(const List<VertexElement>& elements);
 		VertexDeclaration(const List<VertexElement>& elements);
 
 
 		/** @copydoc CoreObject::createCore */
 		/** @copydoc CoreObject::createCore */
-		SPtr<CoreObjectCore> createCore() const override;
+		SPtr<ct::CoreObjectCore> createCore() const override;
 
 
 	protected:
 	protected:
 		VertexDeclarationProperties mProperties;
 		VertexDeclarationProperties mProperties;
@@ -208,6 +208,8 @@ namespace bs
 
 
 	/** @} */
 	/** @} */
 
 
+	namespace ct
+	{
 	/** @addtogroup RenderAPI-Internal
 	/** @addtogroup RenderAPI-Internal
 	 *  @{
 	 *  @{
 	 */
 	 */
@@ -258,4 +260,5 @@ namespace bs
     };
     };
 
 
 	/** @} */
 	/** @} */
+	}
 }
 }

+ 6 - 3
Source/BansheeCore/Include/BsViewport.h

@@ -138,7 +138,7 @@ namespace bs
 		void setTarget(const SPtr<RenderTarget>& target);
 		void setTarget(const SPtr<RenderTarget>& target);
 
 
 		/**	Retrieves a core implementation of a viewport usable only from the core thread. */
 		/**	Retrieves a core implementation of a viewport usable only from the core thread. */
-		SPtr<ViewportCore> getCore() const;
+		SPtr<ct::ViewportCore> getCore() const;
 
 
 	    /**
 	    /**
          * Creates a new viewport.
          * Creates a new viewport.
@@ -167,7 +167,7 @@ namespace bs
 		void getCoreDependencies(Vector<CoreObject*>& dependencies) override;
 		void getCoreDependencies(Vector<CoreObject*>& dependencies) override;
 
 
 		/** @copydoc CoreObject::createCore */
 		/** @copydoc CoreObject::createCore */
-		SPtr<CoreObjectCore> createCore() const override;
+		SPtr<ct::CoreObjectCore> createCore() const override;
 
 
         SPtr<RenderTarget> mTarget;
         SPtr<RenderTarget> mTarget;
 
 
@@ -181,11 +181,13 @@ namespace bs
 	public:
 	public:
 		friend class ViewportRTTI;
 		friend class ViewportRTTI;
 		static RTTITypeBase* getRTTIStatic();
 		static RTTITypeBase* getRTTIStatic();
-		virtual RTTITypeBase* getRTTI() const override;
+		RTTITypeBase* getRTTI() const override;
     };
     };
 
 
 	/** @} */
 	/** @} */
 
 
+	namespace ct
+	{
 	/** @addtogroup RenderAPI-Internal
 	/** @addtogroup RenderAPI-Internal
 	 *  @{
 	 *  @{
 	 */
 	 */
@@ -222,4 +224,5 @@ namespace bs
     };
     };
 
 
 	/** @} */
 	/** @} */
+		}
 }
 }

+ 1 - 1
Source/BansheeCore/Include/Win32/BSWin32PlatformData.h

@@ -29,7 +29,7 @@ namespace bs
 		bool mIsCursorHidden = false;
 		bool mIsCursorHidden = false;
 		NativeCursorData mCursor;
 		NativeCursorData mCursor;
 		bool mUsingCustomCursor = false;
 		bool mUsingCustomCursor = false;
-		Map<const RenderWindowCore*, WindowNonClientAreaData> mNonClientAreas;
+		Map<const ct::RenderWindowCore*, WindowNonClientAreaData> mNonClientAreas;
 
 
 		bool mIsTrackingMouse = false;
 		bool mIsTrackingMouse = false;
 		NativeDropTargetData mDropTargets;
 		NativeDropTargetData mDropTargets;

+ 44 - 41
Source/BansheeCore/Source/BsBlendState.cpp

@@ -96,43 +96,6 @@ namespace bs
 		return mData.renderTargetDesc[renderTargetIdx].renderTargetWriteMask;
 		return mData.renderTargetDesc[renderTargetIdx].renderTargetWriteMask;
 	}
 	}
 
 
-	BlendStateCore::BlendStateCore(const BLEND_STATE_DESC& desc, UINT32 id)
-		:mProperties(desc), mId(id)
-	{
-
-	}
-
-	BlendStateCore::~BlendStateCore()
-	{
-
-	}
-
-	void BlendStateCore::initialize()
-	{
-		// Since we cache states it's possible this object was already initialized
-		// (i.e. multiple sim-states can share a single core-state)
-		if (isInitialized())
-			return;
-
-		createInternal();
-		CoreObjectCore::initialize();
-	}
-
-	const BlendProperties& BlendStateCore::getProperties() const
-	{
-		return mProperties;
-	}
-
-	SPtr<BlendStateCore> BlendStateCore::create(const BLEND_STATE_DESC& desc)
-	{
-		return RenderStateCoreManager::instance().createBlendState(desc);
-	}
-
-	const SPtr<BlendStateCore>& BlendStateCore::getDefault()
-	{
-		return RenderStateCoreManager::instance().getDefaultBlendState();
-	}
-
 	BlendState::BlendState(const BLEND_STATE_DESC& desc)
 	BlendState::BlendState(const BLEND_STATE_DESC& desc)
 		:mProperties(desc), mId(0)
 		:mProperties(desc), mId(0)
 	{ }
 	{ }
@@ -142,14 +105,14 @@ namespace bs
 
 
 	}
 	}
 
 
-	SPtr<BlendStateCore> BlendState::getCore() const
+	SPtr<ct::BlendStateCore> BlendState::getCore() const
 	{
 	{
-		return std::static_pointer_cast<BlendStateCore>(mCoreSpecific);
+		return std::static_pointer_cast<ct::BlendStateCore>(mCoreSpecific);
 	}
 	}
 
 
-	SPtr<CoreObjectCore> BlendState::createCore() const
+	SPtr<ct::CoreObjectCore> BlendState::createCore() const
 	{
 	{
-		SPtr<BlendStateCore> core = RenderStateCoreManager::instance()._createBlendState(mProperties.mData);
+		SPtr<ct::BlendStateCore> core = ct::RenderStateCoreManager::instance()._createBlendState(mProperties.mData);
 		mId = core->getId(); // Accessing core from sim thread is okay here since core ID is immutable
 		mId = core->getId(); // Accessing core from sim thread is okay here since core ID is immutable
 
 
 		return core;
 		return core;
@@ -204,4 +167,44 @@ namespace bs
 	{
 	{
 		return BlendState::getRTTIStatic();
 		return BlendState::getRTTIStatic();
 	}
 	}
+
+	namespace ct
+	{
+	BlendStateCore::BlendStateCore(const BLEND_STATE_DESC& desc, UINT32 id)
+		:mProperties(desc), mId(id)
+	{
+
+	}
+
+	BlendStateCore::~BlendStateCore()
+	{
+
+	}
+
+	void BlendStateCore::initialize()
+	{
+		// Since we cache states it's possible this object was already initialized
+		// (i.e. multiple sim-states can share a single core-state)
+		if (isInitialized())
+			return;
+
+		createInternal();
+		CoreObjectCore::initialize();
+	}
+
+	const BlendProperties& BlendStateCore::getProperties() const
+	{
+		return mProperties;
+	}
+
+	SPtr<BlendStateCore> BlendStateCore::create(const BLEND_STATE_DESC& desc)
+	{
+		return RenderStateCoreManager::instance().createBlendState(desc);
+	}
+
+	const SPtr<BlendStateCore>& BlendStateCore::getDefault()
+	{
+		return RenderStateCoreManager::instance().getDefaultBlendState();
+	}
+	}
 }
 }

+ 90 - 87
Source/BansheeCore/Source/BsCamera.cpp

@@ -276,7 +276,7 @@ namespace bs
 				}
 				}
 			}
 			}
 
 
-			RenderAPICore* renderAPI = bs::RenderAPICore::instancePtr();
+			ct::RenderAPICore* renderAPI = ct::RenderAPICore::instancePtr();
 			renderAPI->convertProjectionMatrix(mProjMatrix, mProjMatrixRS);
 			renderAPI->convertProjectionMatrix(mProjMatrix, mProjMatrixRS);
 			mProjMatrixInv = mProjMatrix.inverse();
 			mProjMatrixInv = mProjMatrix.inverse();
 			mProjMatrixRSInv = mProjMatrixRS.inverse();
 			mProjMatrixRSInv = mProjMatrixRS.inverse();
@@ -721,84 +721,6 @@ namespace bs
 		return Vector3(0.0f, 0.0f, 0.0f);
 		return Vector3(0.0f, 0.0f, 0.0f);
 	}
 	}
 
 
-	CameraCore::~CameraCore()
-	{
-		RendererManager::instance().getActive()->notifyCameraRemoved(this);
-	}
-
-	CameraCore::CameraCore(SPtr<RenderTargetCore> target, float left, float top, float width, float height)
-	{
-		mViewport = ViewportCore::create(target, left, top, width, height);
-	}
-
-	CameraCore::CameraCore(const SPtr<ViewportCore>& viewport)
-	{
-		mViewport = viewport;
-	}
-
-	void CameraCore::initialize()
-	{
-		RendererManager::instance().getActive()->notifyCameraAdded(this);
-
-		CoreObjectCore::initialize();
-	}
-
-	Rect2I CameraCore::getViewportRect() const
-	{
-		return mViewport->getArea();
-	}
-
-	void CameraCore::syncToCore(const CoreSyncData& data)
-	{
-		char* dataPtr = (char*)data.getBuffer();
-
-		CameraDirtyFlag dirtyFlag;
-		dataPtr = rttiReadElem(dirtyFlag, dataPtr);
-		dataPtr = rttiReadElem(mPosition, dataPtr);
-		dataPtr = rttiReadElem(mRotation, dataPtr);
-
-		mRecalcFrustum = true;
-		mRecalcFrustumPlanes = true;
-		mRecalcView = true;
-
-		if (dirtyFlag != CameraDirtyFlag::Transform)
-		{
-			dataPtr = rttiReadElem(mLayers, dataPtr);
-			dataPtr = rttiReadElem(mProjType, dataPtr);
-			dataPtr = rttiReadElem(mHorzFOV, dataPtr);
-			dataPtr = rttiReadElem(mFarDist, dataPtr);
-			dataPtr = rttiReadElem(mNearDist, dataPtr);
-			dataPtr = rttiReadElem(mAspect, dataPtr);
-			dataPtr = rttiReadElem(mOrthoHeight, dataPtr);
-			dataPtr = rttiReadElem(mPriority, dataPtr);
-			dataPtr = rttiReadElem(mCustomViewMatrix, dataPtr);
-			dataPtr = rttiReadElem(mCustomProjMatrix, dataPtr);
-			dataPtr = rttiReadElem(mFrustumExtentsManuallySet, dataPtr);
-			dataPtr = rttiReadElem(mCameraFlags, dataPtr);
-			dataPtr = rttiReadElem(mIsActive, dataPtr);
-			dataPtr = rttiReadElem(mMSAA, dataPtr);
-
-			SPtr<TextureCore>* skyTexture = (SPtr<TextureCore>*)dataPtr;
-			mSkyTexture = *skyTexture;
-			skyTexture->~SPtr<TextureCore>();
-			dataPtr += sizeof(SPtr<TextureCore>);
-
-			UINT32 ppSize = 0;
-			dataPtr = rttiReadElem(ppSize, dataPtr);
-
-			if(ppSize > 0)
-			{
-				if (mPPSettings == nullptr)
-					mPPSettings = RendererManager::instance().getActive()->createPostProcessSettings();
-
-				mPPSettings->_setSyncData((UINT8*)dataPtr, ppSize);
-				dataPtr += ppSize;
-			}
-		}
-
-		RendererManager::instance().getActive()->notifyCameraUpdated(this, (UINT32)dirtyFlag);
-	}
-
 	Camera::Camera(SPtr<RenderTarget> target, float left, float top, float width, float height)
 	Camera::Camera(SPtr<RenderTarget> target, float left, float top, float width, float height)
 		:mMain(false), mLastUpdateHash(0)
 		:mMain(false), mLastUpdateHash(0)
 	{
 	{
@@ -808,9 +730,9 @@ namespace bs
 		mViewport = Viewport::create(target, left, top, width, height);
 		mViewport = Viewport::create(target, left, top, width, height);
 	}
 	}
 
 
-	SPtr<CameraCore> Camera::getCore() const
+	SPtr<ct::CameraCore> Camera::getCore() const
 	{
 	{
-		return std::static_pointer_cast<CameraCore>(mCoreSpecific);
+		return std::static_pointer_cast<ct::CameraCore>(mCoreSpecific);
 	}
 	}
 
 
 	SPtr<Camera> Camera::create(SPtr<RenderTarget> target, float left, float top, float width, float height)
 	SPtr<Camera> Camera::create(SPtr<RenderTarget> target, float left, float top, float width, float height)
@@ -832,10 +754,10 @@ namespace bs
 		return handlerPtr;
 		return handlerPtr;
 	}
 	}
 
 
-	SPtr<CoreObjectCore> Camera::createCore() const
+	SPtr<ct::CoreObjectCore> Camera::createCore() const
 	{
 	{
-		CameraCore* handler = new (bs_alloc<CameraCore>()) CameraCore(mViewport->getCore());
-		SPtr<CameraCore> handlerPtr = bs_shared_ptr<CameraCore>(handler);
+		ct::CameraCore* handler = new (bs_alloc<ct::CameraCore>()) ct::CameraCore(mViewport->getCore());
+		SPtr<ct::CameraCore> handlerPtr = bs_shared_ptr<ct::CameraCore>(handler);
 		handlerPtr->_setThisPtr(handlerPtr);
 		handlerPtr->_setThisPtr(handlerPtr);
 
 
 		return handlerPtr;
 		return handlerPtr;
@@ -850,7 +772,7 @@ namespace bs
 	{
 	{
 		UINT32 dirtyFlag = getCoreDirtyFlags();
 		UINT32 dirtyFlag = getCoreDirtyFlags();
 
 
-		SPtr<TextureCore> skyTexture;
+		SPtr<ct::TextureCore> skyTexture;
 		if (mSkyTexture.isLoaded())
 		if (mSkyTexture.isLoaded())
 			skyTexture = mSkyTexture->getCore();
 			skyTexture = mSkyTexture->getCore();
 
 
@@ -876,7 +798,7 @@ namespace bs
 			size += rttiGetElemSize(mCameraFlags);
 			size += rttiGetElemSize(mCameraFlags);
 			size += rttiGetElemSize(mIsActive);
 			size += rttiGetElemSize(mIsActive);
 			size += rttiGetElemSize(mMSAA);
 			size += rttiGetElemSize(mMSAA);
-			size += sizeof(SPtr<TextureCore>);
+			size += sizeof(SPtr<ct::TextureCore>);
 			size += sizeof(UINT32);
 			size += sizeof(UINT32);
 
 
 			if(mPPSettings != nullptr)
 			if(mPPSettings != nullptr)
@@ -910,7 +832,7 @@ namespace bs
 			dataPtr = rttiWriteElem(mIsActive, dataPtr);
 			dataPtr = rttiWriteElem(mIsActive, dataPtr);
 			dataPtr = rttiWriteElem(mMSAA, dataPtr);
 			dataPtr = rttiWriteElem(mMSAA, dataPtr);
 
 
-			SPtr<TextureCore>* skyTexDest = new (dataPtr) SPtr<TextureCore>();
+			SPtr<ct::TextureCore>* skyTexDest = new (dataPtr) SPtr<ct::TextureCore>();
 			*skyTexDest = skyTexture;
 			*skyTexDest = skyTexture;
 			dataPtr += sizeof(skyTexture);
 			dataPtr += sizeof(skyTexture);
 
 
@@ -944,4 +866,85 @@ namespace bs
 	{
 	{
 		return Camera::getRTTIStatic();
 		return Camera::getRTTIStatic();
 	}
 	}
+
+	namespace ct
+	{
+	CameraCore::~CameraCore()
+	{
+		RendererManager::instance().getActive()->notifyCameraRemoved(this);
+	}
+
+	CameraCore::CameraCore(SPtr<RenderTargetCore> target, float left, float top, float width, float height)
+	{
+		mViewport = ViewportCore::create(target, left, top, width, height);
+	}
+
+	CameraCore::CameraCore(const SPtr<ViewportCore>& viewport)
+	{
+		mViewport = viewport;
+	}
+
+	void CameraCore::initialize()
+	{
+		RendererManager::instance().getActive()->notifyCameraAdded(this);
+
+		CoreObjectCore::initialize();
+	}
+
+	Rect2I CameraCore::getViewportRect() const
+	{
+		return mViewport->getArea();
+	}
+
+	void CameraCore::syncToCore(const CoreSyncData& data)
+	{
+		char* dataPtr = (char*)data.getBuffer();
+
+		CameraDirtyFlag dirtyFlag;
+		dataPtr = rttiReadElem(dirtyFlag, dataPtr);
+		dataPtr = rttiReadElem(mPosition, dataPtr);
+		dataPtr = rttiReadElem(mRotation, dataPtr);
+
+		mRecalcFrustum = true;
+		mRecalcFrustumPlanes = true;
+		mRecalcView = true;
+
+		if (dirtyFlag != CameraDirtyFlag::Transform)
+		{
+			dataPtr = rttiReadElem(mLayers, dataPtr);
+			dataPtr = rttiReadElem(mProjType, dataPtr);
+			dataPtr = rttiReadElem(mHorzFOV, dataPtr);
+			dataPtr = rttiReadElem(mFarDist, dataPtr);
+			dataPtr = rttiReadElem(mNearDist, dataPtr);
+			dataPtr = rttiReadElem(mAspect, dataPtr);
+			dataPtr = rttiReadElem(mOrthoHeight, dataPtr);
+			dataPtr = rttiReadElem(mPriority, dataPtr);
+			dataPtr = rttiReadElem(mCustomViewMatrix, dataPtr);
+			dataPtr = rttiReadElem(mCustomProjMatrix, dataPtr);
+			dataPtr = rttiReadElem(mFrustumExtentsManuallySet, dataPtr);
+			dataPtr = rttiReadElem(mCameraFlags, dataPtr);
+			dataPtr = rttiReadElem(mIsActive, dataPtr);
+			dataPtr = rttiReadElem(mMSAA, dataPtr);
+
+			SPtr<TextureCore>* skyTexture = (SPtr<TextureCore>*)dataPtr;
+			mSkyTexture = *skyTexture;
+			skyTexture->~SPtr<TextureCore>();
+			dataPtr += sizeof(SPtr<TextureCore>);
+
+			UINT32 ppSize = 0;
+			dataPtr = rttiReadElem(ppSize, dataPtr);
+
+			if(ppSize > 0)
+			{
+				if (mPPSettings == nullptr)
+					mPPSettings = RendererManager::instance().getActive()->createPostProcessSettings();
+
+				mPPSettings->_setSyncData((UINT8*)dataPtr, ppSize);
+				dataPtr += ppSize;
+			}
+		}
+
+		RendererManager::instance().getActive()->notifyCameraUpdated(this, (UINT32)dirtyFlag);
+	}
+	}
 }
 }

+ 2 - 2
Source/BansheeCore/Source/BsCommandBuffer.cpp

@@ -3,7 +3,7 @@
 #include "BsCommandBuffer.h"
 #include "BsCommandBuffer.h"
 #include "BsCommandBufferManager.h"
 #include "BsCommandBufferManager.h"
 
 
-namespace bs
+namespace bs { namespace ct
 {
 {
 	void CommandSyncMask::addDependency(const SPtr<CommandBuffer>& buffer)
 	void CommandSyncMask::addDependency(const SPtr<CommandBuffer>& buffer)
 	{
 	{
@@ -75,4 +75,4 @@ namespace bs
 	{
 	{
 		return CommandBufferManager::instance().create(type, deviceIdx, queueIdx, secondary);
 		return CommandBufferManager::instance().create(type, deviceIdx, queueIdx, secondary);
 	}
 	}
-}
+}}

+ 2 - 2
Source/BansheeCore/Source/BsCommandBufferManager.cpp

@@ -2,7 +2,7 @@
 //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
 //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
 #include "BsCommandBufferManager.h"
 #include "BsCommandBufferManager.h"
 
 
-namespace bs
+namespace bs { namespace ct
 {
 {
 	SPtr<CommandBuffer> CommandBufferManager::create(GpuQueueType type, UINT32 deviceIdx, UINT32 queueIdx,
 	SPtr<CommandBuffer> CommandBufferManager::create(GpuQueueType type, UINT32 deviceIdx, UINT32 queueIdx,
 		bool secondary)
 		bool secondary)
@@ -11,4 +11,4 @@ namespace bs
 
 
 		return createInternal(type, deviceIdx, queueIdx, secondary);
 		return createInternal(type, deviceIdx, queueIdx, secondary);
 	}
 	}
-}
+}}

+ 6 - 6
Source/BansheeCore/Source/BsCoreApplication.cpp

@@ -72,7 +72,7 @@ namespace bs
 		
 		
 		Input::shutDown();
 		Input::shutDown();
 
 
-		ParamBlockManager::shutDown();
+		ct::ParamBlockManager::shutDown();
 		StringTableManager::shutDown();
 		StringTableManager::shutDown();
 		Resources::shutDown();
 		Resources::shutDown();
 		ResourceListenerManager::shutDown();
 		ResourceListenerManager::shutDown();
@@ -96,7 +96,7 @@ namespace bs
 		unloadPlugin(mRendererPlugin);
 		unloadPlugin(mRendererPlugin);
 
 
 		RenderAPIManager::shutDown();
 		RenderAPIManager::shutDown();
-		GpuProgramCoreManager::shutDown();
+		ct::GpuProgramCoreManager::shutDown();
 		GpuProgramManager::shutDown();
 		GpuProgramManager::shutDown();
 
 
 		CoreObjectManager::shutDown(); // Must shut down before DynLibManager to ensure all objects are destroyed before unloading their libraries
 		CoreObjectManager::shutDown(); // Must shut down before DynLibManager to ensure all objects are destroyed before unloading their libraries
@@ -143,12 +143,12 @@ namespace bs
 		ResourceListenerManager::startUp();
 		ResourceListenerManager::startUp();
 		GpuProgramManager::startUp();
 		GpuProgramManager::startUp();
 		RenderStateManager::startUp();
 		RenderStateManager::startUp();
-		GpuProgramCoreManager::startUp();
+		ct::GpuProgramCoreManager::startUp();
 		RenderAPIManager::startUp();
 		RenderAPIManager::startUp();
 
 
 		mPrimaryWindow = RenderAPIManager::instance().initialize(mStartUpDesc.renderAPI, mStartUpDesc.primaryWindowDesc);
 		mPrimaryWindow = RenderAPIManager::instance().initialize(mStartUpDesc.renderAPI, mStartUpDesc.primaryWindowDesc);
 
 
-		ParamBlockManager::startUp();
+		ct::ParamBlockManager::startUp();
 		Input::startUp();
 		Input::startUp();
 		RendererManager::startUp();
 		RendererManager::startUp();
 
 
@@ -269,8 +269,8 @@ namespace bs
 
 
 			gCoreThread().queueCommand(std::bind(&CoreApplication::frameRenderingFinishedCallback, this), CTQF_InternalQueue);
 			gCoreThread().queueCommand(std::bind(&CoreApplication::frameRenderingFinishedCallback, this), CTQF_InternalQueue);
 
 
-			gCoreThread().queueCommand(std::bind(&RenderWindowCoreManager::_update, RenderWindowCoreManager::instancePtr()), CTQF_InternalQueue);
-			gCoreThread().queueCommand(std::bind(&QueryManager::_update, QueryManager::instancePtr()), CTQF_InternalQueue);
+			gCoreThread().queueCommand(std::bind(&ct::RenderWindowCoreManager::_update, ct::RenderWindowCoreManager::instancePtr()), CTQF_InternalQueue);
+			gCoreThread().queueCommand(std::bind(&ct::QueryManager::_update, ct::QueryManager::instancePtr()), CTQF_InternalQueue);
 			gCoreThread().queueCommand(std::bind(&CoreApplication::endCoreProfiling, this), CTQF_InternalQueue);
 			gCoreThread().queueCommand(std::bind(&CoreApplication::endCoreProfiling, this), CTQF_InternalQueue);
 
 
 			gProfilerCPU().endThread();
 			gProfilerCPU().endThread();

+ 10 - 9
Source/BansheeCore/Source/BsCoreObject.cpp

@@ -110,7 +110,7 @@ namespace bs
 		mThis = ptrThis;
 		mThis = ptrThis;
 	}
 	}
 
 
-	void CoreObject::queueGpuCommand(const SPtr<CoreObjectCore>& obj, std::function<void()> func)
+	void CoreObject::queueGpuCommand(const SPtr<ct::CoreObjectCore>& obj, std::function<void()> func)
 	{
 	{
 		// We call another internal method and go through an additional layer of abstraction in order to keep an active
 		// We call another internal method and go through an additional layer of abstraction in order to keep an active
 		// reference to the obj (saved in the bound function).
 		// reference to the obj (saved in the bound function).
@@ -119,36 +119,37 @@ namespace bs
 		gCoreThread().queueCommand(std::bind(&CoreObject::executeGpuCommand, obj, func));
 		gCoreThread().queueCommand(std::bind(&CoreObject::executeGpuCommand, obj, func));
 	}
 	}
 
 
-	AsyncOp CoreObject::queueReturnGpuCommand(const SPtr<CoreObjectCore>& obj, std::function<void(AsyncOp&)> func)
+	AsyncOp CoreObject::queueReturnGpuCommand(const SPtr<ct::CoreObjectCore>& obj, std::function<void(AsyncOp&)> func)
 	{
 	{
 		// See queueGpuCommand
 		// See queueGpuCommand
 		return gCoreThread().queueReturnCommand(std::bind(&CoreObject::executeReturnGpuCommand, obj, func, _1));
 		return gCoreThread().queueReturnCommand(std::bind(&CoreObject::executeReturnGpuCommand, obj, func, _1));
 	}
 	}
 
 
-	void CoreObject::queueInitializeGpuCommand(const SPtr<CoreObjectCore>& obj)
+	void CoreObject::queueInitializeGpuCommand(const SPtr<ct::CoreObjectCore>& obj)
 	{
 	{
-		std::function<void()> func = std::bind(&CoreObjectCore::initialize, obj.get());
+		std::function<void()> func = std::bind(&ct::CoreObjectCore::initialize, obj.get());
 
 
 		CoreThread::instance().queueCommand(std::bind(&CoreObject::executeGpuCommand, obj, func), CTQF_InternalQueue);
 		CoreThread::instance().queueCommand(std::bind(&CoreObject::executeGpuCommand, obj, func), CTQF_InternalQueue);
 	}
 	}
 
 
-	void CoreObject::queueDestroyGpuCommand(const SPtr<CoreObjectCore>& obj)
+	void CoreObject::queueDestroyGpuCommand(const SPtr<ct::CoreObjectCore>& obj)
 	{
 	{
 		std::function<void()> func = [&](){}; // Do nothing function. We just need the shared pointer to stay alive until it reaches the core thread
 		std::function<void()> func = [&](){}; // Do nothing function. We just need the shared pointer to stay alive until it reaches the core thread
 
 
 		gCoreThread().queueCommand(std::bind(&CoreObject::executeGpuCommand, obj, func));
 		gCoreThread().queueCommand(std::bind(&CoreObject::executeGpuCommand, obj, func));
 	}
 	}
 
 
-	void CoreObject::executeGpuCommand(const SPtr<CoreObjectCore>& obj, std::function<void()> func)
+	void CoreObject::executeGpuCommand(const SPtr<ct::CoreObjectCore>& obj, std::function<void()> func)
 	{
 	{
-		volatile SPtr<CoreObjectCore> objParam = obj; // Makes sure obj isn't optimized out?
+		volatile SPtr<ct::CoreObjectCore> objParam = obj; // Makes sure obj isn't optimized out?
 
 
 		func();
 		func();
 	}
 	}
 
 
-	void CoreObject::executeReturnGpuCommand(const SPtr<CoreObjectCore>& obj, std::function<void(AsyncOp&)> func, AsyncOp& op)
+	void CoreObject::executeReturnGpuCommand(const SPtr<ct::CoreObjectCore>& obj, std::function<void(AsyncOp&)> func, 
+		AsyncOp& op)
 	{
 	{
-		volatile SPtr<CoreObjectCore> objParam = obj; // Makes sure obj isn't optimized out?
+		volatile SPtr<ct::CoreObjectCore> objParam = obj; // Makes sure obj isn't optimized out?
 
 
 		func(op);
 		func(op);
 	}
 	}

+ 3 - 0
Source/BansheeCore/Source/BsCoreObjectCore.cpp

@@ -5,6 +5,8 @@
 
 
 namespace bs
 namespace bs
 {
 {
+	namespace ct 
+	{
 	Signal CoreObjectCore::mCoreGpuObjectLoadedCondition;
 	Signal CoreObjectCore::mCoreGpuObjectLoadedCondition;
 	Mutex CoreObjectCore::mCoreGpuObjectLoadedMutex;
 	Mutex CoreObjectCore::mCoreGpuObjectLoadedMutex;
 
 
@@ -53,4 +55,5 @@ namespace bs
 	{
 	{
 		mThis = ptrThis;
 		mThis = ptrThis;
 	}
 	}
+	}
 }
 }

+ 5 - 5
Source/BansheeCore/Source/BsCoreObjectManager.cpp

@@ -58,7 +58,7 @@ namespace bs
 
 
 			if (isDirty)
 			if (isDirty)
 			{
 			{
-				SPtr<CoreObjectCore> coreObject = object->getCore();
+				SPtr<ct::CoreObjectCore> coreObject = object->getCore();
 				if (coreObject != nullptr)
 				if (coreObject != nullptr)
 				{
 				{
 					CoreSyncData objSyncData = object->syncToCore(gCoreThread().getFrameAlloc());
 					CoreSyncData objSyncData = object->syncToCore(gCoreThread().getFrameAlloc());
@@ -215,7 +215,7 @@ namespace bs
 	{
 	{
 		struct IndividualCoreSyncData
 		struct IndividualCoreSyncData
 		{
 		{
-			SPtr<CoreObjectCore> destination;
+			SPtr<ct::CoreObjectCore> destination;
 			CoreSyncData syncData;
 			CoreSyncData syncData;
 			FrameAlloc* allocator;
 			FrameAlloc* allocator;
 		};
 		};
@@ -244,7 +244,7 @@ namespace bs
 					syncObject(dependency);
 					syncObject(dependency);
 			}
 			}
 
 
-			SPtr<CoreObjectCore> objectCore = curObj->getCore();
+			SPtr<ct::CoreObjectCore> objectCore = curObj->getCore();
 			if (objectCore == nullptr)
 			if (objectCore == nullptr)
 			{
 			{
 				curObj->markCoreClean();
 				curObj->markCoreClean();
@@ -347,7 +347,7 @@ namespace bs
 						syncObject(dependency);
 						syncObject(dependency);
 				}
 				}
 
 
-				SPtr<CoreObjectCore> objectCore = curObj->getCore();
+				SPtr<ct::CoreObjectCore> objectCore = curObj->getCore();
 				if (objectCore == nullptr)
 				if (objectCore == nullptr)
 				{
 				{
 					curObj->markCoreClean();
 					curObj->markCoreClean();
@@ -387,7 +387,7 @@ namespace bs
 
 
 		for (auto& objSyncData : syncData.entries)
 		for (auto& objSyncData : syncData.entries)
 		{
 		{
-			SPtr<CoreObjectCore> destinationObj = objSyncData.destinationObj;
+			SPtr<ct::CoreObjectCore> destinationObj = objSyncData.destinationObj;
 			if (destinationObj != nullptr)
 			if (destinationObj != nullptr)
 				destinationObj->syncToCore(objSyncData.syncData);
 				destinationObj->syncToCore(objSyncData.syncData);
 
 

+ 3 - 3
Source/BansheeCore/Source/BsCoreRenderer.cpp

@@ -7,7 +7,7 @@
 #include "BsMaterial.h"
 #include "BsMaterial.h"
 #include "BsRendererExtension.h"
 #include "BsRendererExtension.h"
 
 
-namespace bs
+namespace bs { namespace ct
 {
 {
 	CoreRenderer::CoreRenderer()
 	CoreRenderer::CoreRenderer()
 		:mCallbacks(&compareCallback)
 		:mCallbacks(&compareCallback)
@@ -37,5 +37,5 @@ namespace bs
 		}
 		}
 		else
 		else
 			return (UINT32)a->getLocation() < (UINT32)b->getLocation();
 			return (UINT32)a->getLocation() < (UINT32)b->getLocation();
-	};
-}
+	}
+}}

+ 44 - 41
Source/BansheeCore/Source/BsDepthStencilState.cpp

@@ -33,43 +33,6 @@ namespace bs
 
 
 	}
 	}
 
 
-	DepthStencilStateCore::DepthStencilStateCore(const DEPTH_STENCIL_STATE_DESC& desc, UINT32 id)
-		: mProperties(desc), mId(id)
-	{
-
-	}
-
-	DepthStencilStateCore::~DepthStencilStateCore()
-	{
-
-	}
-
-	void DepthStencilStateCore::initialize()
-	{
-		// Since we cache states it's possible this object was already initialized
-		// (i.e. multiple sim-states can share a single core-state)
-		if (isInitialized())
-			return;
-
-		createInternal();
-		CoreObjectCore::initialize();
-	}
-
-	const DepthStencilProperties& DepthStencilStateCore::getProperties() const
-	{
-		return mProperties;
-	}
-
-	SPtr<DepthStencilStateCore> DepthStencilStateCore::create(const DEPTH_STENCIL_STATE_DESC& desc)
-	{
-		return RenderStateCoreManager::instance().createDepthStencilState(desc);
-	}
-
-	const SPtr<DepthStencilStateCore>& DepthStencilStateCore::getDefault()
-	{
-		return RenderStateCoreManager::instance().getDefaultDepthStencilState();
-	}
-
 	DepthStencilState::DepthStencilState(const DEPTH_STENCIL_STATE_DESC& desc)
 	DepthStencilState::DepthStencilState(const DEPTH_STENCIL_STATE_DESC& desc)
 		:mProperties(desc), mId(0)
 		:mProperties(desc), mId(0)
 	{
 	{
@@ -81,14 +44,14 @@ namespace bs
 
 
 	}
 	}
 
 
-	SPtr<DepthStencilStateCore> DepthStencilState::getCore() const
+	SPtr<ct::DepthStencilStateCore> DepthStencilState::getCore() const
 	{
 	{
-		return std::static_pointer_cast<DepthStencilStateCore>(mCoreSpecific);
+		return std::static_pointer_cast<ct::DepthStencilStateCore>(mCoreSpecific);
 	}
 	}
 
 
-	SPtr<CoreObjectCore> DepthStencilState::createCore() const
+	SPtr<ct::CoreObjectCore> DepthStencilState::createCore() const
 	{
 	{
-		SPtr<DepthStencilStateCore> core = RenderStateCoreManager::instance()._createDepthStencilState(mProperties.mData);
+		SPtr<ct::DepthStencilStateCore> core = ct::RenderStateCoreManager::instance()._createDepthStencilState(mProperties.mData);
 		mId = core->getId(); // Accessing core from sim thread is okay here since core ID is immutable
 		mId = core->getId(); // Accessing core from sim thread is okay here since core ID is immutable
 
 
 		return core;
 		return core;
@@ -143,4 +106,44 @@ namespace bs
 	{
 	{
 		return DepthStencilState::getRTTIStatic();
 		return DepthStencilState::getRTTIStatic();
 	}
 	}
+
+	namespace ct
+	{
+	DepthStencilStateCore::DepthStencilStateCore(const DEPTH_STENCIL_STATE_DESC& desc, UINT32 id)
+		: mProperties(desc), mId(id)
+	{
+
+	}
+
+	DepthStencilStateCore::~DepthStencilStateCore()
+	{
+
+	}
+
+	void DepthStencilStateCore::initialize()
+	{
+		// Since we cache states it's possible this object was already initialized
+		// (i.e. multiple sim-states can share a single core-state)
+		if (isInitialized())
+			return;
+
+		createInternal();
+		CoreObjectCore::initialize();
+	}
+
+	const DepthStencilProperties& DepthStencilStateCore::getProperties() const
+	{
+		return mProperties;
+	}
+
+	SPtr<DepthStencilStateCore> DepthStencilStateCore::create(const DEPTH_STENCIL_STATE_DESC& desc)
+	{
+		return RenderStateCoreManager::instance().createDepthStencilState(desc);
+	}
+
+	const SPtr<DepthStencilStateCore>& DepthStencilStateCore::getDefault()
+	{
+		return RenderStateCoreManager::instance().getDefaultDepthStencilState();
+	}
+	}
 }
 }

+ 2 - 2
Source/BansheeCore/Source/BsEventQuery.cpp

@@ -3,10 +3,10 @@
 #include "BsEventQuery.h"
 #include "BsEventQuery.h"
 #include "BsQueryManager.h"
 #include "BsQueryManager.h"
 
 
-namespace bs
+namespace bs { namespace ct
 {
 {
 	SPtr<EventQuery> EventQuery::create(UINT32 deviceIdx)
 	SPtr<EventQuery> EventQuery::create(UINT32 deviceIdx)
 	{
 	{
 		return QueryManager::instance().createEventQuery(deviceIdx);
 		return QueryManager::instance().createEventQuery(deviceIdx);
 	}
 	}
-}
+}}

+ 23 - 20
Source/BansheeCore/Source/BsGpuBuffer.cpp

@@ -26,35 +26,19 @@ namespace bs
 			mDesc.elementSize = GpuBuffer::getFormatSize(mDesc.format);
 			mDesc.elementSize = GpuBuffer::getFormatSize(mDesc.format);
 	}
 	}
 
 
-	GpuBufferCore::GpuBufferCore(const GPU_BUFFER_DESC& desc, UINT32 deviceMask)
-		:HardwareBuffer(getBufferSize(desc)), mProperties(desc)
-	{
-	}
-
-	GpuBufferCore::~GpuBufferCore()
-	{
-		// Make sure that derived classes call clearBufferViews
-		// I can't call it here since it needs a virtual method call
-	}
-
-	SPtr<GpuBufferCore> GpuBufferCore::create(const GPU_BUFFER_DESC& desc, GpuDeviceFlags deviceMask)
-	{
-		return HardwareBufferCoreManager::instance().createGpuBuffer(desc, deviceMask);
-	}
-
 	GpuBuffer::GpuBuffer(const GPU_BUFFER_DESC& desc)
 	GpuBuffer::GpuBuffer(const GPU_BUFFER_DESC& desc)
 		:mProperties(desc)
 		:mProperties(desc)
 	{  
 	{  
 	}
 	}
 
 
-	SPtr<GpuBufferCore> GpuBuffer::getCore() const
+	SPtr<ct::GpuBufferCore> GpuBuffer::getCore() const
 	{
 	{
-		return std::static_pointer_cast<GpuBufferCore>(mCoreSpecific);
+		return std::static_pointer_cast<ct::GpuBufferCore>(mCoreSpecific);
 	}
 	}
 
 
-	SPtr<CoreObjectCore> GpuBuffer::createCore() const
+	SPtr<ct::CoreObjectCore> GpuBuffer::createCore() const
 	{
 	{
-		return HardwareBufferCoreManager::instance().createGpuBufferInternal(mProperties.mDesc);
+		return ct::HardwareBufferCoreManager::instance().createGpuBufferInternal(mProperties.mDesc);
 	}
 	}
 
 
 	UINT32 GpuBuffer::getFormatSize(GpuBufferFormat format)
 	UINT32 GpuBuffer::getFormatSize(GpuBufferFormat format)
@@ -111,4 +95,23 @@ namespace bs
 	{
 	{
 		return HardwareBufferManager::instance().createGpuBuffer(desc);
 		return HardwareBufferManager::instance().createGpuBuffer(desc);
 	}
 	}
+
+	namespace ct
+	{
+	GpuBufferCore::GpuBufferCore(const GPU_BUFFER_DESC& desc, UINT32 deviceMask)
+		:HardwareBuffer(getBufferSize(desc)), mProperties(desc)
+	{
+	}
+
+	GpuBufferCore::~GpuBufferCore()
+	{
+		// Make sure that derived classes call clearBufferViews
+		// I can't call it here since it needs a virtual method call
+	}
+
+	SPtr<GpuBufferCore> GpuBufferCore::create(const GPU_BUFFER_DESC& desc, GpuDeviceFlags deviceMask)
+	{
+		return HardwareBufferCoreManager::instance().createGpuBuffer(desc, deviceMask);
+	}
+	}
 }
 }

+ 2 - 2
Source/BansheeCore/Source/BsGpuParam.cpp

@@ -43,7 +43,7 @@ namespace bs
 		UINT32 elementSizeBytes = mParamDesc->elementSize * sizeof(UINT32);
 		UINT32 elementSizeBytes = mParamDesc->elementSize * sizeof(UINT32);
 		UINT32 sizeBytes = std::min(elementSizeBytes, (UINT32)sizeof(T)); // Truncate if it doesn't fit within parameter size
 		UINT32 sizeBytes = std::min(elementSizeBytes, (UINT32)sizeof(T)); // Truncate if it doesn't fit within parameter size
 
 
-		bool transposeMatrices = RenderAPICore::instance().getAPIInfo().getGpuProgramHasColumnMajorMatrices();
+		bool transposeMatrices = ct::RenderAPICore::instance().getAPIInfo().getGpuProgramHasColumnMajorMatrices();
 		if (TransposePolicy<T>::transposeEnabled(transposeMatrices))
 		if (TransposePolicy<T>::transposeEnabled(transposeMatrices))
 		{
 		{
 			T transposed = TransposePolicy<T>::transpose(value);
 			T transposed = TransposePolicy<T>::transpose(value);
@@ -86,7 +86,7 @@ namespace bs
 		T value;
 		T value;
 		paramBlock->read((mParamDesc->cpuMemOffset + arrayIdx * mParamDesc->arrayElementStride) * sizeof(UINT32), &value, sizeBytes);
 		paramBlock->read((mParamDesc->cpuMemOffset + arrayIdx * mParamDesc->arrayElementStride) * sizeof(UINT32), &value, sizeBytes);
 
 
-		bool transposeMatrices = RenderAPICore::instance().getAPIInfo().getGpuProgramHasColumnMajorMatrices();
+		bool transposeMatrices = ct::RenderAPICore::instance().getAPIInfo().getGpuProgramHasColumnMajorMatrices();
 		if (TransposePolicy<T>::transposeEnabled(transposeMatrices))
 		if (TransposePolicy<T>::transposeEnabled(transposeMatrices))
 			return TransposePolicy<T>::transpose(value);
 			return TransposePolicy<T>::transpose(value);
 		else
 		else

+ 44 - 41
Source/BansheeCore/Source/BsGpuParamBlockBuffer.cpp

@@ -6,8 +6,8 @@
 
 
 namespace bs
 namespace bs
 {
 {
-	GpuParamBlockBufferCore::GpuParamBlockBufferCore(UINT32 size, GpuParamBlockUsage usage, GpuDeviceFlags deviceMask)
-		:mUsage(usage), mSize(size), mCachedData(nullptr), mGPUBufferDirty(false)
+	GpuParamBlockBuffer::GpuParamBlockBuffer(UINT32 size, GpuParamBlockUsage usage)
+		:mUsage(usage), mSize(size), mCachedData(nullptr)
 	{
 	{
 		if (mSize > 0)
 		if (mSize > 0)
 			mCachedData = (UINT8*)bs_alloc(mSize);
 			mCachedData = (UINT8*)bs_alloc(mSize);
@@ -15,13 +15,13 @@ namespace bs
 		memset(mCachedData, 0, mSize);
 		memset(mCachedData, 0, mSize);
 	}
 	}
 
 
-	GpuParamBlockBufferCore::~GpuParamBlockBufferCore()
+	GpuParamBlockBuffer::~GpuParamBlockBuffer()
 	{
 	{
 		if (mCachedData != nullptr)
 		if (mCachedData != nullptr)
 			bs_free(mCachedData);
 			bs_free(mCachedData);
 	}
 	}
 
 
-	void GpuParamBlockBufferCore::write(UINT32 offset, const void* data, UINT32 size)
+	void GpuParamBlockBuffer::write(UINT32 offset, const void* data, UINT32 size)
 	{
 	{
 #if BS_DEBUG_MODE
 #if BS_DEBUG_MODE
 		if ((offset + size) > mSize)
 		if ((offset + size) > mSize)
@@ -33,10 +33,10 @@ namespace bs
 #endif
 #endif
 
 
 		memcpy(mCachedData + offset, data, size);
 		memcpy(mCachedData + offset, data, size);
-		mGPUBufferDirty = true;
+		markCoreDirty();
 	}
 	}
 
 
-	void GpuParamBlockBufferCore::read(UINT32 offset, void* data, UINT32 size)
+	void GpuParamBlockBuffer::read(UINT32 offset, void* data, UINT32 size)
 	{
 	{
 #if BS_DEBUG_MODE
 #if BS_DEBUG_MODE
 		if ((offset + size) > mSize)
 		if ((offset + size) > mSize)
@@ -50,7 +50,7 @@ namespace bs
 		memcpy(data, mCachedData + offset, size);
 		memcpy(data, mCachedData + offset, size);
 	}
 	}
 
 
-	void GpuParamBlockBufferCore::zeroOut(UINT32 offset, UINT32 size)
+	void GpuParamBlockBuffer::zeroOut(UINT32 offset, UINT32 size)
 	{
 	{
 #if BS_DEBUG_MODE
 #if BS_DEBUG_MODE
 		if ((offset + size) > mSize)
 		if ((offset + size) > mSize)
@@ -62,33 +62,36 @@ namespace bs
 #endif
 #endif
 
 
 		memset(mCachedData + offset, 0, size);
 		memset(mCachedData + offset, 0, size);
-		mGPUBufferDirty = true;
+		markCoreDirty();
 	}
 	}
 
 
-	void GpuParamBlockBufferCore::flushToGPU(UINT32 queueIdx)
+	SPtr<ct::GpuParamBlockBufferCore> GpuParamBlockBuffer::getCore() const
 	{
 	{
-		if (mGPUBufferDirty)
-		{
-			writeToGPU(mCachedData, queueIdx);
-			mGPUBufferDirty = false;
-		}
+		return std::static_pointer_cast<ct::GpuParamBlockBufferCore>(mCoreSpecific);
 	}
 	}
 
 
-	void GpuParamBlockBufferCore::syncToCore(const CoreSyncData& data)
+	SPtr<ct::CoreObjectCore> GpuParamBlockBuffer::createCore() const
 	{
 	{
-		assert(mSize == data.getBufferSize());
+		return ct::HardwareBufferCoreManager::instance().createGpuParamBlockBufferInternal(mSize, mUsage);
+	}
 
 
-		write(0, data.getBuffer(), data.getBufferSize());
+	CoreSyncData GpuParamBlockBuffer::syncToCore(FrameAlloc* allocator)
+	{
+		UINT8* buffer = allocator->alloc(mSize);
+		read(0, buffer, mSize);
+
+		return CoreSyncData(buffer, mSize);
 	}
 	}
 
 
-	SPtr<GpuParamBlockBufferCore> GpuParamBlockBufferCore::create(UINT32 size, GpuParamBlockUsage usage, 
-		GpuDeviceFlags deviceMask)
+	SPtr<GpuParamBlockBuffer> GpuParamBlockBuffer::create(UINT32 size, GpuParamBlockUsage usage)
 	{
 	{
-		return HardwareBufferCoreManager::instance().createGpuParamBlockBuffer(size, usage, deviceMask);
+		return HardwareBufferManager::instance().createGpuParamBlockBuffer(size, usage);
 	}
 	}
 
 
-	GpuParamBlockBuffer::GpuParamBlockBuffer(UINT32 size, GpuParamBlockUsage usage)
-		:mUsage(usage), mSize(size), mCachedData(nullptr)
+	namespace ct
+	{
+	GpuParamBlockBufferCore::GpuParamBlockBufferCore(UINT32 size, GpuParamBlockUsage usage, GpuDeviceFlags deviceMask)
+		:mUsage(usage), mSize(size), mCachedData(nullptr), mGPUBufferDirty(false)
 	{
 	{
 		if (mSize > 0)
 		if (mSize > 0)
 			mCachedData = (UINT8*)bs_alloc(mSize);
 			mCachedData = (UINT8*)bs_alloc(mSize);
@@ -96,13 +99,13 @@ namespace bs
 		memset(mCachedData, 0, mSize);
 		memset(mCachedData, 0, mSize);
 	}
 	}
 
 
-	GpuParamBlockBuffer::~GpuParamBlockBuffer()
+	GpuParamBlockBufferCore::~GpuParamBlockBufferCore()
 	{
 	{
 		if (mCachedData != nullptr)
 		if (mCachedData != nullptr)
 			bs_free(mCachedData);
 			bs_free(mCachedData);
 	}
 	}
 
 
-	void GpuParamBlockBuffer::write(UINT32 offset, const void* data, UINT32 size)
+	void GpuParamBlockBufferCore::write(UINT32 offset, const void* data, UINT32 size)
 	{
 	{
 #if BS_DEBUG_MODE
 #if BS_DEBUG_MODE
 		if ((offset + size) > mSize)
 		if ((offset + size) > mSize)
@@ -114,10 +117,10 @@ namespace bs
 #endif
 #endif
 
 
 		memcpy(mCachedData + offset, data, size);
 		memcpy(mCachedData + offset, data, size);
-		markCoreDirty();
+		mGPUBufferDirty = true;
 	}
 	}
 
 
-	void GpuParamBlockBuffer::read(UINT32 offset, void* data, UINT32 size)
+	void GpuParamBlockBufferCore::read(UINT32 offset, void* data, UINT32 size)
 	{
 	{
 #if BS_DEBUG_MODE
 #if BS_DEBUG_MODE
 		if ((offset + size) > mSize)
 		if ((offset + size) > mSize)
@@ -131,7 +134,7 @@ namespace bs
 		memcpy(data, mCachedData + offset, size);
 		memcpy(data, mCachedData + offset, size);
 	}
 	}
 
 
-	void GpuParamBlockBuffer::zeroOut(UINT32 offset, UINT32 size)
+	void GpuParamBlockBufferCore::zeroOut(UINT32 offset, UINT32 size)
 	{
 	{
 #if BS_DEBUG_MODE
 #if BS_DEBUG_MODE
 		if ((offset + size) > mSize)
 		if ((offset + size) > mSize)
@@ -143,29 +146,29 @@ namespace bs
 #endif
 #endif
 
 
 		memset(mCachedData + offset, 0, size);
 		memset(mCachedData + offset, 0, size);
-		markCoreDirty();
-	}
-
-	SPtr<GpuParamBlockBufferCore> GpuParamBlockBuffer::getCore() const
-	{
-		return std::static_pointer_cast<GpuParamBlockBufferCore>(mCoreSpecific);
+		mGPUBufferDirty = true;
 	}
 	}
 
 
-	SPtr<CoreObjectCore> GpuParamBlockBuffer::createCore() const
+	void GpuParamBlockBufferCore::flushToGPU(UINT32 queueIdx)
 	{
 	{
-		return HardwareBufferCoreManager::instance().createGpuParamBlockBufferInternal(mSize, mUsage);
+		if (mGPUBufferDirty)
+		{
+			writeToGPU(mCachedData, queueIdx);
+			mGPUBufferDirty = false;
+		}
 	}
 	}
 
 
-	CoreSyncData GpuParamBlockBuffer::syncToCore(FrameAlloc* allocator)
+	void GpuParamBlockBufferCore::syncToCore(const CoreSyncData& data)
 	{
 	{
-		UINT8* buffer = allocator->alloc(mSize);
-		read(0, buffer, mSize);
+		assert(mSize == data.getBufferSize());
 
 
-		return CoreSyncData(buffer, mSize);
+		write(0, data.getBuffer(), data.getBufferSize());
 	}
 	}
 
 
-	SPtr<GpuParamBlockBuffer> GpuParamBlockBuffer::create(UINT32 size, GpuParamBlockUsage usage)
+	SPtr<GpuParamBlockBufferCore> GpuParamBlockBufferCore::create(UINT32 size, GpuParamBlockUsage usage, 
+		GpuDeviceFlags deviceMask)
 	{
 	{
-		return HardwareBufferManager::instance().createGpuParamBlockBuffer(size, usage);
+		return HardwareBufferCoreManager::instance().createGpuParamBlockBuffer(size, usage, deviceMask);
+	}
 	}
 	}
 }
 }

+ 119 - 116
Source/BansheeCore/Source/BsGpuParams.cpp

@@ -544,103 +544,6 @@ namespace bs
 	template BS_CORE_EXPORT void TGpuParams<true>::getParam<Matrix4x2>(GpuProgramType type, const String&, TGpuDataParam<Matrix4x2, true>&) const;
 	template BS_CORE_EXPORT void TGpuParams<true>::getParam<Matrix4x2>(GpuProgramType type, const String&, TGpuDataParam<Matrix4x2, true>&) const;
 	template BS_CORE_EXPORT void TGpuParams<true>::getParam<Matrix4x3>(GpuProgramType type, const String&, TGpuDataParam<Matrix4x3, true>&) const;
 	template BS_CORE_EXPORT void TGpuParams<true>::getParam<Matrix4x3>(GpuProgramType type, const String&, TGpuDataParam<Matrix4x3, true>&) const;
 
 
-	GpuParamsCore::GpuParamsCore(const SPtr<GpuPipelineParamInfoCore>& paramInfo, GpuDeviceFlags deviceMask)
-		: TGpuParams(paramInfo)
-	{
-
-	}
-
-	SPtr<GpuParamsCore> GpuParamsCore::_getThisPtr() const
-	{
-		return std::static_pointer_cast<GpuParamsCore>(getThisPtr());
-	}
-
-	void GpuParamsCore::syncToCore(const CoreSyncData& data)
-	{
-		UINT32 numParamBlocks = mParamInfo->getNumElements(GpuPipelineParamInfo::ParamType::ParamBlock);
-		UINT32 numTextures = mParamInfo->getNumElements(GpuPipelineParamInfo::ParamType::Texture);
-		UINT32 numStorageTextures = mParamInfo->getNumElements(GpuPipelineParamInfo::ParamType::LoadStoreTexture);
-		UINT32 numBuffers = mParamInfo->getNumElements(GpuPipelineParamInfo::ParamType::Buffer);
-		UINT32 numSamplers = mParamInfo->getNumElements(GpuPipelineParamInfo::ParamType::SamplerState);
-
-		UINT32 loadStoreSurfacesSize = numStorageTextures * sizeof(TextureSurface);
-		UINT32 paramBufferSize = numParamBlocks * sizeof(SPtr<GpuParamBlockBufferCore>);
-		UINT32 textureArraySize = numTextures * sizeof(SPtr<TextureCore>);
-		UINT32 loadStoreTextureArraySize = numStorageTextures * sizeof(SPtr<TextureCore>);
-		UINT32 bufferArraySize = numBuffers * sizeof(SPtr<GpuBufferCore>);
-		UINT32 samplerArraySize = numSamplers * sizeof(SPtr<SamplerStateCore>);
-
-		UINT32 totalSize = loadStoreSurfacesSize + paramBufferSize + textureArraySize + loadStoreTextureArraySize
-			+ bufferArraySize + samplerArraySize;
-
-		UINT32 textureInfoOffset = 0;
-		UINT32 paramBufferOffset = textureInfoOffset + loadStoreSurfacesSize;
-		UINT32 textureArrayOffset = paramBufferOffset + paramBufferSize;
-		UINT32 loadStoreTextureArrayOffset = textureArrayOffset + textureArraySize;
-		UINT32 bufferArrayOffset = loadStoreTextureArrayOffset + loadStoreTextureArraySize;
-		UINT32 samplerArrayOffset = bufferArrayOffset + bufferArraySize;
-
-		assert(data.getBufferSize() == totalSize);
-
-		UINT8* dataPtr = data.getBuffer();
-
-		TextureSurface* loadStoreSurfaces = (TextureSurface*)(dataPtr + textureInfoOffset);
-		SPtr<GpuParamBlockBufferCore>* paramBuffers = (SPtr<GpuParamBlockBufferCore>*)(dataPtr + paramBufferOffset);
-		SPtr<TextureCore>* textures = (SPtr<TextureCore>*)(dataPtr + textureArrayOffset);
-		SPtr<TextureCore>* loadStoreTextures = (SPtr<TextureCore>*)(dataPtr + loadStoreTextureArrayOffset);
-		SPtr<GpuBufferCore>* buffers = (SPtr<GpuBufferCore>*)(dataPtr + bufferArrayOffset);
-		SPtr<SamplerStateCore>* samplers = (SPtr<SamplerStateCore>*)(dataPtr + samplerArrayOffset);
-
-		// Copy & destruct
-		for (UINT32 i = 0; i < numParamBlocks; i++)
-		{
-			mParamBlockBuffers[i] = paramBuffers[i];
-			paramBuffers[i].~SPtr<GpuParamBlockBufferCore>();
-		}
-
-		for (UINT32 i = 0; i < numTextures; i++)
-		{
-			mTextures[i] = textures[i];
-			textures[i].~SPtr<TextureCore>();
-		}
-
-		for (UINT32 i = 0; i < numStorageTextures; i++)
-		{
-			mLoadStoreSurfaces[i] = loadStoreSurfaces[i];
-			loadStoreSurfaces[i].~TextureSurface();
-
-			mLoadStoreTextures[i] = loadStoreTextures[i];
-			loadStoreTextures[i].~SPtr<TextureCore>();
-		}
-
-		for (UINT32 i = 0; i < numBuffers; i++)
-		{
-			mBuffers[i] = buffers[i];
-			buffers[i].~SPtr<GpuBufferCore>();
-		}
-
-		for (UINT32 i = 0; i < numSamplers; i++)
-		{
-			mSamplerStates[i] = samplers[i];
-			samplers[i].~SPtr<SamplerStateCore>();
-		}
-	}
-
-	SPtr<GpuParamsCore> GpuParamsCore::create(const SPtr<GraphicsPipelineStateCore>& pipelineState, GpuDeviceFlags deviceMask)
-	{
-		return HardwareBufferCoreManager::instance().createGpuParams(pipelineState->getParamInfo(), deviceMask);
-	}
-
-	SPtr<GpuParamsCore> GpuParamsCore::create(const SPtr<ComputePipelineStateCore>& pipelineState, GpuDeviceFlags deviceMask)
-	{
-		return HardwareBufferCoreManager::instance().createGpuParams(pipelineState->getParamInfo(), deviceMask);
-	}
-
-	SPtr<GpuParamsCore> GpuParamsCore::create(const SPtr<GpuPipelineParamInfoCore>& paramInfo, GpuDeviceFlags deviceMask)
-	{
-		return HardwareBufferCoreManager::instance().createGpuParams(paramInfo, deviceMask);
-	}
-
 	const GpuDataParamInfos GpuParams::PARAM_SIZES;
 	const GpuDataParamInfos GpuParams::PARAM_SIZES;
 
 
 	GpuParams::GpuParams(const SPtr<GpuPipelineParamInfo>& paramInfo)
 	GpuParams::GpuParams(const SPtr<GpuPipelineParamInfo>& paramInfo)
@@ -654,16 +557,16 @@ namespace bs
 		return std::static_pointer_cast<GpuParams>(getThisPtr());
 		return std::static_pointer_cast<GpuParams>(getThisPtr());
 	}
 	}
 
 
-	SPtr<GpuParamsCore> GpuParams::getCore() const
+	SPtr<ct::GpuParamsCore> GpuParams::getCore() const
 	{
 	{
-		return std::static_pointer_cast<GpuParamsCore>(mCoreSpecific);
+		return std::static_pointer_cast<ct::GpuParamsCore>(mCoreSpecific);
 	}
 	}
 
 
-	SPtr<CoreObjectCore> GpuParams::createCore() const
+	SPtr<ct::CoreObjectCore> GpuParams::createCore() const
 	{
 	{
 		SPtr<GpuPipelineParamInfo> paramInfo = std::static_pointer_cast<GpuPipelineParamInfo>(mParamInfo);
 		SPtr<GpuPipelineParamInfo> paramInfo = std::static_pointer_cast<GpuPipelineParamInfo>(mParamInfo);
 
 
-		return HardwareBufferCoreManager::instance().createGpuParams(paramInfo->getCore());
+		return ct::HardwareBufferCoreManager::instance().createGpuParams(paramInfo->getCore());
 	}
 	}
 
 
 	void GpuParams::_markCoreDirty()
 	void GpuParams::_markCoreDirty()
@@ -700,11 +603,11 @@ namespace bs
 		UINT32 numSamplers = mParamInfo->getNumElements(GpuPipelineParamInfo::ParamType::SamplerState);
 		UINT32 numSamplers = mParamInfo->getNumElements(GpuPipelineParamInfo::ParamType::SamplerState);
 
 
 		UINT32 loadStoreSurfacesSize = numStorageTextures * sizeof(TextureSurface);
 		UINT32 loadStoreSurfacesSize = numStorageTextures * sizeof(TextureSurface);
-		UINT32 paramBufferSize = numParamBlocks * sizeof(SPtr<GpuParamBlockBufferCore>);
-		UINT32 textureArraySize = numTextures * sizeof(SPtr<TextureCore>);
-		UINT32 loadStoreTextureArraySize = numStorageTextures * sizeof(SPtr<TextureCore>);
-		UINT32 bufferArraySize = numBuffers * sizeof(SPtr<GpuBufferCore>);
-		UINT32 samplerArraySize = numSamplers * sizeof(SPtr<SamplerStateCore>);
+		UINT32 paramBufferSize = numParamBlocks * sizeof(SPtr<ct::GpuParamBlockBufferCore>);
+		UINT32 textureArraySize = numTextures * sizeof(SPtr<ct::TextureCore>);
+		UINT32 loadStoreTextureArraySize = numStorageTextures * sizeof(SPtr<ct::TextureCore>);
+		UINT32 bufferArraySize = numBuffers * sizeof(SPtr<ct::GpuBufferCore>);
+		UINT32 samplerArraySize = numSamplers * sizeof(SPtr<ct::SamplerStateCore>);
 
 
 		UINT32 totalSize = loadStoreSurfacesSize + paramBufferSize + textureArraySize + loadStoreTextureArraySize 
 		UINT32 totalSize = loadStoreSurfacesSize + paramBufferSize + textureArraySize + loadStoreTextureArraySize 
 			+ bufferArraySize + samplerArraySize;
 			+ bufferArraySize + samplerArraySize;
@@ -719,16 +622,16 @@ namespace bs
 		UINT8* data = allocator->alloc(totalSize);
 		UINT8* data = allocator->alloc(totalSize);
 
 
 		TextureSurface* loadStoreSurfaces = (TextureSurface*)(data + textureInfoOffset);
 		TextureSurface* loadStoreSurfaces = (TextureSurface*)(data + textureInfoOffset);
-		SPtr<GpuParamBlockBufferCore>* paramBuffers = (SPtr<GpuParamBlockBufferCore>*)(data + paramBufferOffset);
-		SPtr<TextureCore>* textures = (SPtr<TextureCore>*)(data + textureArrayOffset);
-		SPtr<TextureCore>* loadStoreTextures = (SPtr<TextureCore>*)(data + loadStoreTextureArrayOffset);
-		SPtr<GpuBufferCore>* buffers = (SPtr<GpuBufferCore>*)(data + bufferArrayOffset);
-		SPtr<SamplerStateCore>* samplers = (SPtr<SamplerStateCore>*)(data + samplerArrayOffset);
+		SPtr<ct::GpuParamBlockBufferCore>* paramBuffers = (SPtr<ct::GpuParamBlockBufferCore>*)(data + paramBufferOffset);
+		SPtr<ct::TextureCore>* textures = (SPtr<ct::TextureCore>*)(data + textureArrayOffset);
+		SPtr<ct::TextureCore>* loadStoreTextures = (SPtr<ct::TextureCore>*)(data + loadStoreTextureArrayOffset);
+		SPtr<ct::GpuBufferCore>* buffers = (SPtr<ct::GpuBufferCore>*)(data + bufferArrayOffset);
+		SPtr<ct::SamplerStateCore>* samplers = (SPtr<ct::SamplerStateCore>*)(data + samplerArrayOffset);
 
 
 		// Construct & copy
 		// Construct & copy
 		for (UINT32 i = 0; i < numParamBlocks; i++)
 		for (UINT32 i = 0; i < numParamBlocks; i++)
 		{
 		{
-			new (&paramBuffers[i]) SPtr<GpuParamBlockBufferCore>();
+			new (&paramBuffers[i]) SPtr<ct::GpuParamBlockBufferCore>();
 
 
 			if (mParamBlockBuffers[i] != nullptr)
 			if (mParamBlockBuffers[i] != nullptr)
 				paramBuffers[i] = mParamBlockBuffers[i]->getCore();
 				paramBuffers[i] = mParamBlockBuffers[i]->getCore();
@@ -736,7 +639,7 @@ namespace bs
 
 
 		for (UINT32 i = 0; i < numTextures; i++)
 		for (UINT32 i = 0; i < numTextures; i++)
 		{
 		{
-			new (&textures[i]) SPtr<TextureCore>();
+			new (&textures[i]) SPtr<ct::TextureCore>();
 
 
 			if (mTextures[i].isLoaded())
 			if (mTextures[i].isLoaded())
 				textures[i] = mTextures[i]->getCore();
 				textures[i] = mTextures[i]->getCore();
@@ -749,7 +652,7 @@ namespace bs
 			new (&loadStoreSurfaces[i]) TextureSurface();
 			new (&loadStoreSurfaces[i]) TextureSurface();
 			loadStoreSurfaces[i] = mLoadStoreSurfaces[i];
 			loadStoreSurfaces[i] = mLoadStoreSurfaces[i];
 
 
-			new (&loadStoreTextures[i]) SPtr<TextureCore>();
+			new (&loadStoreTextures[i]) SPtr<ct::TextureCore>();
 
 
 			if (mLoadStoreTextures[i].isLoaded())
 			if (mLoadStoreTextures[i].isLoaded())
 				loadStoreTextures[i] = mLoadStoreTextures[i]->getCore();
 				loadStoreTextures[i] = mLoadStoreTextures[i]->getCore();
@@ -759,7 +662,7 @@ namespace bs
 
 
 		for (UINT32 i = 0; i < numBuffers; i++)
 		for (UINT32 i = 0; i < numBuffers; i++)
 		{
 		{
-			new (&buffers[i]) SPtr<GpuBufferCore>();
+			new (&buffers[i]) SPtr<ct::GpuBufferCore>();
 
 
 			if (mBuffers[i] != nullptr)
 			if (mBuffers[i] != nullptr)
 				buffers[i] = mBuffers[i]->getCore();
 				buffers[i] = mBuffers[i]->getCore();
@@ -769,7 +672,7 @@ namespace bs
 
 
 		for (UINT32 i = 0; i < numSamplers; i++)
 		for (UINT32 i = 0; i < numSamplers; i++)
 		{
 		{
-			new (&samplers[i]) SPtr<SamplerStateCore>();
+			new (&samplers[i]) SPtr<ct::SamplerStateCore>();
 
 
 			if (mSamplerStates[i] != nullptr)
 			if (mSamplerStates[i] != nullptr)
 				samplers[i] = mSamplerStates[i]->getCore();
 				samplers[i] = mSamplerStates[i]->getCore();
@@ -797,4 +700,104 @@ namespace bs
 				resources.push_back(mLoadStoreTextures[i]);
 				resources.push_back(mLoadStoreTextures[i]);
 		}
 		}
 	}
 	}
+
+	namespace ct
+	{
+	GpuParamsCore::GpuParamsCore(const SPtr<GpuPipelineParamInfoCore>& paramInfo, GpuDeviceFlags deviceMask)
+		: TGpuParams(paramInfo)
+	{
+
+	}
+
+	SPtr<GpuParamsCore> GpuParamsCore::_getThisPtr() const
+	{
+		return std::static_pointer_cast<GpuParamsCore>(getThisPtr());
+	}
+
+	void GpuParamsCore::syncToCore(const CoreSyncData& data)
+	{
+		UINT32 numParamBlocks = mParamInfo->getNumElements(GpuPipelineParamInfo::ParamType::ParamBlock);
+		UINT32 numTextures = mParamInfo->getNumElements(GpuPipelineParamInfo::ParamType::Texture);
+		UINT32 numStorageTextures = mParamInfo->getNumElements(GpuPipelineParamInfo::ParamType::LoadStoreTexture);
+		UINT32 numBuffers = mParamInfo->getNumElements(GpuPipelineParamInfo::ParamType::Buffer);
+		UINT32 numSamplers = mParamInfo->getNumElements(GpuPipelineParamInfo::ParamType::SamplerState);
+
+		UINT32 loadStoreSurfacesSize = numStorageTextures * sizeof(TextureSurface);
+		UINT32 paramBufferSize = numParamBlocks * sizeof(SPtr<GpuParamBlockBufferCore>);
+		UINT32 textureArraySize = numTextures * sizeof(SPtr<TextureCore>);
+		UINT32 loadStoreTextureArraySize = numStorageTextures * sizeof(SPtr<TextureCore>);
+		UINT32 bufferArraySize = numBuffers * sizeof(SPtr<GpuBufferCore>);
+		UINT32 samplerArraySize = numSamplers * sizeof(SPtr<SamplerStateCore>);
+
+		UINT32 totalSize = loadStoreSurfacesSize + paramBufferSize + textureArraySize + loadStoreTextureArraySize
+			+ bufferArraySize + samplerArraySize;
+
+		UINT32 textureInfoOffset = 0;
+		UINT32 paramBufferOffset = textureInfoOffset + loadStoreSurfacesSize;
+		UINT32 textureArrayOffset = paramBufferOffset + paramBufferSize;
+		UINT32 loadStoreTextureArrayOffset = textureArrayOffset + textureArraySize;
+		UINT32 bufferArrayOffset = loadStoreTextureArrayOffset + loadStoreTextureArraySize;
+		UINT32 samplerArrayOffset = bufferArrayOffset + bufferArraySize;
+
+		assert(data.getBufferSize() == totalSize);
+
+		UINT8* dataPtr = data.getBuffer();
+
+		TextureSurface* loadStoreSurfaces = (TextureSurface*)(dataPtr + textureInfoOffset);
+		SPtr<GpuParamBlockBufferCore>* paramBuffers = (SPtr<GpuParamBlockBufferCore>*)(dataPtr + paramBufferOffset);
+		SPtr<TextureCore>* textures = (SPtr<TextureCore>*)(dataPtr + textureArrayOffset);
+		SPtr<TextureCore>* loadStoreTextures = (SPtr<TextureCore>*)(dataPtr + loadStoreTextureArrayOffset);
+		SPtr<GpuBufferCore>* buffers = (SPtr<GpuBufferCore>*)(dataPtr + bufferArrayOffset);
+		SPtr<SamplerStateCore>* samplers = (SPtr<SamplerStateCore>*)(dataPtr + samplerArrayOffset);
+
+		// Copy & destruct
+		for (UINT32 i = 0; i < numParamBlocks; i++)
+		{
+			mParamBlockBuffers[i] = paramBuffers[i];
+			paramBuffers[i].~SPtr<GpuParamBlockBufferCore>();
+		}
+
+		for (UINT32 i = 0; i < numTextures; i++)
+		{
+			mTextures[i] = textures[i];
+			textures[i].~SPtr<TextureCore>();
+		}
+
+		for (UINT32 i = 0; i < numStorageTextures; i++)
+		{
+			mLoadStoreSurfaces[i] = loadStoreSurfaces[i];
+			loadStoreSurfaces[i].~TextureSurface();
+
+			mLoadStoreTextures[i] = loadStoreTextures[i];
+			loadStoreTextures[i].~SPtr<TextureCore>();
+		}
+
+		for (UINT32 i = 0; i < numBuffers; i++)
+		{
+			mBuffers[i] = buffers[i];
+			buffers[i].~SPtr<GpuBufferCore>();
+		}
+
+		for (UINT32 i = 0; i < numSamplers; i++)
+		{
+			mSamplerStates[i] = samplers[i];
+			samplers[i].~SPtr<SamplerStateCore>();
+		}
+	}
+
+	SPtr<GpuParamsCore> GpuParamsCore::create(const SPtr<GraphicsPipelineStateCore>& pipelineState, GpuDeviceFlags deviceMask)
+	{
+		return HardwareBufferCoreManager::instance().createGpuParams(pipelineState->getParamInfo(), deviceMask);
+	}
+
+	SPtr<GpuParamsCore> GpuParamsCore::create(const SPtr<ComputePipelineStateCore>& pipelineState, GpuDeviceFlags deviceMask)
+	{
+		return HardwareBufferCoreManager::instance().createGpuParams(pipelineState->getParamInfo(), deviceMask);
+	}
+
+	SPtr<GpuParamsCore> GpuParamsCore::create(const SPtr<GpuPipelineParamInfoCore>& paramInfo, GpuDeviceFlags deviceMask)
+	{
+		return HardwareBufferCoreManager::instance().createGpuParams(paramInfo, deviceMask);
+	}
+	}
 }
 }

+ 9 - 9
Source/BansheeCore/Source/BsGpuParamsSet.cpp

@@ -124,36 +124,36 @@ namespace bs
 		return allParamDescs;
 		return allParamDescs;
 	}
 	}
 
 
-	Vector<SPtr<GpuParamDesc>> getAllParamDescs(const SPtr<TechniqueCore>& technique)
+	Vector<SPtr<GpuParamDesc>> getAllParamDescs(const SPtr<ct::TechniqueCore>& technique)
 	{
 	{
 		Vector<SPtr<GpuParamDesc>> allParamDescs;
 		Vector<SPtr<GpuParamDesc>> allParamDescs;
 
 
 		// Make sure all gpu programs are fully loaded
 		// Make sure all gpu programs are fully loaded
 		for (UINT32 i = 0; i < technique->getNumPasses(); i++)
 		for (UINT32 i = 0; i < technique->getNumPasses(); i++)
 		{
 		{
-			SPtr<PassCore> curPass = technique->getPass(i);
+			SPtr<ct::PassCore> curPass = technique->getPass(i);
 
 
-			SPtr<GpuProgramCore> vertProgram = curPass->getVertexProgram();
+			SPtr<ct::GpuProgramCore> vertProgram = curPass->getVertexProgram();
 			if (vertProgram)
 			if (vertProgram)
 				allParamDescs.push_back(vertProgram->getParamDesc());
 				allParamDescs.push_back(vertProgram->getParamDesc());
 
 
-			SPtr<GpuProgramCore> fragProgram = curPass->getFragmentProgram();
+			SPtr<ct::GpuProgramCore> fragProgram = curPass->getFragmentProgram();
 			if (fragProgram)
 			if (fragProgram)
 				allParamDescs.push_back(fragProgram->getParamDesc());
 				allParamDescs.push_back(fragProgram->getParamDesc());
 
 
-			SPtr<GpuProgramCore> geomProgram = curPass->getGeometryProgram();
+			SPtr<ct::GpuProgramCore> geomProgram = curPass->getGeometryProgram();
 			if (geomProgram)
 			if (geomProgram)
 				allParamDescs.push_back(geomProgram->getParamDesc());
 				allParamDescs.push_back(geomProgram->getParamDesc());
 
 
-			SPtr<GpuProgramCore> hullProgram = curPass->getHullProgram();
+			SPtr<ct::GpuProgramCore> hullProgram = curPass->getHullProgram();
 			if (hullProgram)
 			if (hullProgram)
 				allParamDescs.push_back(hullProgram->getParamDesc());
 				allParamDescs.push_back(hullProgram->getParamDesc());
 
 
-			SPtr<GpuProgramCore> domainProgram = curPass->getDomainProgram();
+			SPtr<ct::GpuProgramCore> domainProgram = curPass->getDomainProgram();
 			if (domainProgram)
 			if (domainProgram)
 				allParamDescs.push_back(domainProgram->getParamDesc());
 				allParamDescs.push_back(domainProgram->getParamDesc());
 
 
-			SPtr<GpuProgramCore> computeProgram = curPass->getComputeProgram();
+			SPtr<ct::GpuProgramCore> computeProgram = curPass->getComputeProgram();
 			if (computeProgram)
 			if (computeProgram)
 				allParamDescs.push_back(computeProgram->getParamDesc());
 				allParamDescs.push_back(computeProgram->getParamDesc());
 		}
 		}
@@ -897,7 +897,7 @@ namespace bs
 
 
 			UINT8* data = params->getData(materialParamInfo->index);
 			UINT8* data = params->getData(materialParamInfo->index);
 
 
-			bool transposeMatrices = RenderAPICore::instance().getAPIInfo().getGpuProgramHasColumnMajorMatrices();
+			bool transposeMatrices = ct::RenderAPICore::instance().getAPIInfo().getGpuProgramHasColumnMajorMatrices();
 			if (transposeMatrices)
 			if (transposeMatrices)
 			{
 			{
 				auto writeTransposed = [&](auto& temp)
 				auto writeTransposed = [&](auto& temp)

+ 17 - 14
Source/BansheeCore/Source/BsGpuPipelineParamInfo.cpp

@@ -216,16 +216,6 @@ namespace bs
 		slot = mResourceInfos[(int)type][sequentialSlot].slot;
 		slot = mResourceInfos[(int)type][sequentialSlot].slot;
 	}
 	}
 
 
-	GpuPipelineParamInfoCore::GpuPipelineParamInfoCore(const GPU_PIPELINE_PARAMS_DESC& desc, GpuDeviceFlags deviceMask)
-		:GpuPipelineParamInfoBase(desc)
-	{ }
-
-	SPtr<GpuPipelineParamInfoCore> GpuPipelineParamInfoCore::create(const GPU_PIPELINE_PARAMS_DESC& desc, 
-		GpuDeviceFlags deviceMask)
-	{
-		return RenderStateCoreManager::instance().createPipelineParamInfo(desc, deviceMask);
-	}
-
 	GpuPipelineParamInfo::GpuPipelineParamInfo(const GPU_PIPELINE_PARAMS_DESC& desc)
 	GpuPipelineParamInfo::GpuPipelineParamInfo(const GPU_PIPELINE_PARAMS_DESC& desc)
 		:GpuPipelineParamInfoBase(desc)
 		:GpuPipelineParamInfoBase(desc)
 	{ }
 	{ }
@@ -240,12 +230,12 @@ namespace bs
 		return paramInfo;
 		return paramInfo;
 	}
 	}
 
 
-	SPtr<GpuPipelineParamInfoCore> GpuPipelineParamInfo::getCore() const
+	SPtr<ct::GpuPipelineParamInfoCore> GpuPipelineParamInfo::getCore() const
 	{
 	{
-		return std::static_pointer_cast<GpuPipelineParamInfoCore>(mCoreSpecific);
+		return std::static_pointer_cast<ct::GpuPipelineParamInfoCore>(mCoreSpecific);
 	}
 	}
 
 
-	SPtr<CoreObjectCore> GpuPipelineParamInfo::createCore() const
+	SPtr<ct::CoreObjectCore> GpuPipelineParamInfo::createCore() const
 	{
 	{
 		GPU_PIPELINE_PARAMS_DESC desc;
 		GPU_PIPELINE_PARAMS_DESC desc;
 		desc.fragmentParams = mParamDescs[GPT_FRAGMENT_PROGRAM];
 		desc.fragmentParams = mParamDescs[GPT_FRAGMENT_PROGRAM];
@@ -255,6 +245,19 @@ namespace bs
 		desc.domainParams = mParamDescs[GPT_DOMAIN_PROGRAM];
 		desc.domainParams = mParamDescs[GPT_DOMAIN_PROGRAM];
 		desc.computeParams = mParamDescs[GPT_COMPUTE_PROGRAM];
 		desc.computeParams = mParamDescs[GPT_COMPUTE_PROGRAM];
 
 
-		return RenderStateCoreManager::instance()._createPipelineParamInfo(desc);
+		return ct::RenderStateCoreManager::instance()._createPipelineParamInfo(desc);
+	}
+
+	namespace ct
+	{
+	GpuPipelineParamInfoCore::GpuPipelineParamInfoCore(const GPU_PIPELINE_PARAMS_DESC& desc, GpuDeviceFlags deviceMask)
+		:GpuPipelineParamInfoBase(desc)
+	{ }
+
+	SPtr<GpuPipelineParamInfoCore> GpuPipelineParamInfoCore::create(const GPU_PIPELINE_PARAMS_DESC& desc, 
+		GpuDeviceFlags deviceMask)
+	{
+		return RenderStateCoreManager::instance().createPipelineParamInfo(desc, deviceMask);
+	}
 	}
 	}
 }
 }

+ 63 - 60
Source/BansheeCore/Source/BsGpuPipelineState.cpp

@@ -12,7 +12,7 @@
 namespace bs
 namespace bs
 {
 {
 	/** Converts a sim thread pipeline state descriptor to a core thread one. */
 	/** Converts a sim thread pipeline state descriptor to a core thread one. */
-	void convertPassDesc(const PIPELINE_STATE_DESC& input, PIPELINE_STATE_CORE_DESC& output)
+	void convertPassDesc(const PIPELINE_STATE_DESC& input, ct::PIPELINE_STATE_CORE_DESC& output)
 	{
 	{
 		output.blendState = input.blendState != nullptr ? input.blendState->getCore() : nullptr;
 		output.blendState = input.blendState != nullptr ? input.blendState->getCore() : nullptr;
 		output.rasterizerState = input.rasterizerState != nullptr ? input.rasterizerState->getCore() : nullptr;
 		output.rasterizerState = input.rasterizerState != nullptr ? input.rasterizerState->getCore() : nullptr;
@@ -36,38 +36,6 @@ namespace bs
 	template class TGraphicsPipelineState < false > ;
 	template class TGraphicsPipelineState < false > ;
 	template class TGraphicsPipelineState < true >;
 	template class TGraphicsPipelineState < true >;
 
 
-	GraphicsPipelineStateCore::GraphicsPipelineStateCore(const PIPELINE_STATE_CORE_DESC& desc, GpuDeviceFlags deviceMask)
-		:TGraphicsPipelineState(desc), mDeviceMask(deviceMask)
-	{ }
-
-	void GraphicsPipelineStateCore::initialize()
-	{
-		GPU_PIPELINE_PARAMS_DESC paramsDesc;
-		if (mData.vertexProgram != nullptr)
-			paramsDesc.vertexParams = mData.vertexProgram->getParamDesc();
-
-		if (mData.fragmentProgram != nullptr)
-			paramsDesc.fragmentParams = mData.fragmentProgram->getParamDesc();
-
-		if (mData.geometryProgram != nullptr)
-			paramsDesc.geometryParams = mData.geometryProgram->getParamDesc();
-
-		if (mData.hullProgram != nullptr)
-			paramsDesc.hullParams = mData.hullProgram->getParamDesc();
-
-		if (mData.domainProgram != nullptr)
-			paramsDesc.domainParams = mData.domainProgram->getParamDesc();
-
-		mParamInfo = GpuPipelineParamInfoCore::create(paramsDesc, mDeviceMask);
-
-		CoreObjectCore::initialize();
-	}
-
-	SPtr<GraphicsPipelineStateCore> GraphicsPipelineStateCore::create(const PIPELINE_STATE_CORE_DESC& desc, GpuDeviceFlags deviceMask)
-	{
-		return RenderStateCoreManager::instance().createGraphicsPipelineState(desc, deviceMask);
-	}
-
 	GraphicsPipelineState::GraphicsPipelineState(const PIPELINE_STATE_DESC& desc)
 	GraphicsPipelineState::GraphicsPipelineState(const PIPELINE_STATE_DESC& desc)
 		:TGraphicsPipelineState(desc)
 		:TGraphicsPipelineState(desc)
 	{
 	{
@@ -105,17 +73,17 @@ namespace bs
 		mParamInfo = GpuPipelineParamInfo::create(paramsDesc);
 		mParamInfo = GpuPipelineParamInfo::create(paramsDesc);
 	}
 	}
 
 
-	SPtr<GraphicsPipelineStateCore> GraphicsPipelineState::getCore() const
+	SPtr<ct::GraphicsPipelineStateCore> GraphicsPipelineState::getCore() const
 	{
 	{
-		return std::static_pointer_cast<GraphicsPipelineStateCore>(mCoreSpecific);
+		return std::static_pointer_cast<ct::GraphicsPipelineStateCore>(mCoreSpecific);
 	}
 	}
 
 
-	SPtr<CoreObjectCore> GraphicsPipelineState::createCore() const
+	SPtr<ct::CoreObjectCore> GraphicsPipelineState::createCore() const
 	{
 	{
-		PIPELINE_STATE_CORE_DESC desc;
+		ct::PIPELINE_STATE_CORE_DESC desc;
 		convertPassDesc(mData, desc);
 		convertPassDesc(mData, desc);
 
 
-		return RenderStateCoreManager::instance()._createGraphicsPipelineState(desc);
+		return ct::RenderStateCoreManager::instance()._createGraphicsPipelineState(desc);
 	}
 	}
 
 
 	SPtr<GraphicsPipelineState> GraphicsPipelineState::create(const PIPELINE_STATE_DESC& desc)
 	SPtr<GraphicsPipelineState> GraphicsPipelineState::create(const PIPELINE_STATE_DESC& desc)
@@ -135,48 +103,83 @@ namespace bs
 	template class TComputePipelineState < false >;
 	template class TComputePipelineState < false >;
 	template class TComputePipelineState < true >;
 	template class TComputePipelineState < true >;
 
 
-	ComputePipelineStateCore::ComputePipelineStateCore(const SPtr<GpuProgramCore>& program, GpuDeviceFlags deviceMask)
-		:TComputePipelineState(program), mDeviceMask(deviceMask)
-	{ }
-
-	void ComputePipelineStateCore::initialize()
+	ComputePipelineState::ComputePipelineState(const SPtr<GpuProgram>& program)
+		:TComputePipelineState(program)
 	{
 	{
 		GPU_PIPELINE_PARAMS_DESC paramsDesc;
 		GPU_PIPELINE_PARAMS_DESC paramsDesc;
-		paramsDesc.computeParams = mProgram->getParamDesc();
+		program->blockUntilCoreInitialized();
+		paramsDesc.computeParams = program->getParamDesc();
 
 
-		mParamInfo = GpuPipelineParamInfoCore::create(paramsDesc, mDeviceMask);
+		mParamInfo = GpuPipelineParamInfo::create(paramsDesc);
+	}
 
 
-		CoreObjectCore::initialize();
+	SPtr<ct::ComputePipelineStateCore> ComputePipelineState::getCore() const
+	{
+		return std::static_pointer_cast<ct::ComputePipelineStateCore>(mCoreSpecific);
 	}
 	}
 
 
-	SPtr<ComputePipelineStateCore> ComputePipelineStateCore::create(const SPtr<GpuProgramCore>& program, 
-		GpuDeviceFlags deviceMask)
+	SPtr<ct::CoreObjectCore> ComputePipelineState::createCore() const
 	{
 	{
-		return RenderStateCoreManager::instance().createComputePipelineState(program, deviceMask);
+		return ct::RenderStateCoreManager::instance()._createComputePipelineState(mProgram->getCore());
 	}
 	}
 
 
-	ComputePipelineState::ComputePipelineState(const SPtr<GpuProgram>& program)
-		:TComputePipelineState(program)
+	SPtr<ComputePipelineState> ComputePipelineState::create(const SPtr<GpuProgram>& program)
+	{
+		return RenderStateManager::instance().createComputePipelineState(program);
+	}
+
+	namespace ct
+	{
+	GraphicsPipelineStateCore::GraphicsPipelineStateCore(const PIPELINE_STATE_CORE_DESC& desc, GpuDeviceFlags deviceMask)
+		:TGraphicsPipelineState(desc), mDeviceMask(deviceMask)
+	{ }
+
+	void GraphicsPipelineStateCore::initialize()
 	{
 	{
 		GPU_PIPELINE_PARAMS_DESC paramsDesc;
 		GPU_PIPELINE_PARAMS_DESC paramsDesc;
-		program->blockUntilCoreInitialized();
-		paramsDesc.computeParams = program->getParamDesc();
+		if (mData.vertexProgram != nullptr)
+			paramsDesc.vertexParams = mData.vertexProgram->getParamDesc();
 
 
-		mParamInfo = GpuPipelineParamInfo::create(paramsDesc);
+		if (mData.fragmentProgram != nullptr)
+			paramsDesc.fragmentParams = mData.fragmentProgram->getParamDesc();
+
+		if (mData.geometryProgram != nullptr)
+			paramsDesc.geometryParams = mData.geometryProgram->getParamDesc();
+
+		if (mData.hullProgram != nullptr)
+			paramsDesc.hullParams = mData.hullProgram->getParamDesc();
+
+		if (mData.domainProgram != nullptr)
+			paramsDesc.domainParams = mData.domainProgram->getParamDesc();
+
+		mParamInfo = GpuPipelineParamInfoCore::create(paramsDesc, mDeviceMask);
+
+		CoreObjectCore::initialize();
 	}
 	}
 
 
-	SPtr<ComputePipelineStateCore> ComputePipelineState::getCore() const
+	SPtr<GraphicsPipelineStateCore> GraphicsPipelineStateCore::create(const PIPELINE_STATE_CORE_DESC& desc, GpuDeviceFlags deviceMask)
 	{
 	{
-		return std::static_pointer_cast<ComputePipelineStateCore>(mCoreSpecific);
+		return RenderStateCoreManager::instance().createGraphicsPipelineState(desc, deviceMask);
 	}
 	}
 
 
-	SPtr<CoreObjectCore> ComputePipelineState::createCore() const
+	ComputePipelineStateCore::ComputePipelineStateCore(const SPtr<GpuProgramCore>& program, GpuDeviceFlags deviceMask)
+		:TComputePipelineState(program), mDeviceMask(deviceMask)
+	{ }
+
+	void ComputePipelineStateCore::initialize()
 	{
 	{
-		return RenderStateCoreManager::instance()._createComputePipelineState(mProgram->getCore());
+		GPU_PIPELINE_PARAMS_DESC paramsDesc;
+		paramsDesc.computeParams = mProgram->getParamDesc();
+
+		mParamInfo = GpuPipelineParamInfoCore::create(paramsDesc, mDeviceMask);
+
+		CoreObjectCore::initialize();
 	}
 	}
 
 
-	SPtr<ComputePipelineState> ComputePipelineState::create(const SPtr<GpuProgram>& program)
+	SPtr<ComputePipelineStateCore> ComputePipelineStateCore::create(const SPtr<GpuProgramCore>& program, 
+		GpuDeviceFlags deviceMask)
 	{
 	{
-		return RenderStateManager::instance().createComputePipelineState(program);
+		return RenderStateCoreManager::instance().createComputePipelineState(program, deviceMask);
+	}
 	}
 	}
 }
 }

+ 32 - 29
Source/BansheeCore/Source/BsGpuProgram.cpp

@@ -14,31 +14,6 @@ namespace bs
 		:mType(gptype), mEntryPoint(entryPoint), mSource(source)
 		:mType(gptype), mEntryPoint(entryPoint), mSource(source)
 	{ }
 	{ }
 		
 		
-	GpuProgramCore::GpuProgramCore(const GPU_PROGRAM_DESC& desc, GpuDeviceFlags deviceMask)
-		:mNeedsAdjacencyInfo(desc.requiresAdjacency), mIsCompiled(false), mProperties(desc.source, desc.entryPoint, 
-			desc.type)
-	{
-		mParametersDesc = bs_shared_ptr_new<GpuParamDesc>();
-	}
-
-	bool GpuProgramCore::isSupported() const
-    {
-		if (!isRequiredCapabilitiesSupported())
-			return false;
-
-		return true;
-    }
-
-	bool GpuProgramCore::isRequiredCapabilitiesSupported() const
-	{
-		return true;
-	}
-
-	SPtr<GpuProgramCore> GpuProgramCore::create(const GPU_PROGRAM_DESC& desc, GpuDeviceFlags deviceMask)
-	{
-		return GpuProgramCoreManager::instance().create(desc, deviceMask);
-	}
-
 	GpuProgram::GpuProgram(const GPU_PROGRAM_DESC& desc)
 	GpuProgram::GpuProgram(const GPU_PROGRAM_DESC& desc)
 		: mNeedsAdjacencyInfo(desc.requiresAdjacency), mLanguage(desc.language)
 		: mNeedsAdjacencyInfo(desc.requiresAdjacency), mLanguage(desc.language)
 		, mProperties(desc.source, desc.entryPoint, desc.type)
 		, mProperties(desc.source, desc.entryPoint, desc.type)
@@ -61,12 +36,12 @@ namespace bs
 		return getCore()->getParamDesc();
 		return getCore()->getParamDesc();
 	}
 	}
 
 
-	SPtr<GpuProgramCore> GpuProgram::getCore() const
+	SPtr<ct::GpuProgramCore> GpuProgram::getCore() const
 	{
 	{
-		return std::static_pointer_cast<GpuProgramCore>(mCoreSpecific);
+		return std::static_pointer_cast<ct::GpuProgramCore>(mCoreSpecific);
 	}
 	}
 
 
-	SPtr<CoreObjectCore> GpuProgram::createCore() const
+	SPtr<ct::CoreObjectCore> GpuProgram::createCore() const
 	{
 	{
 		GPU_PROGRAM_DESC desc;
 		GPU_PROGRAM_DESC desc;
 		desc.source = mProperties.getSource();
 		desc.source = mProperties.getSource();
@@ -75,7 +50,7 @@ namespace bs
 		desc.type = mProperties.getType();
 		desc.type = mProperties.getType();
 		desc.requiresAdjacency = mNeedsAdjacencyInfo;
 		desc.requiresAdjacency = mNeedsAdjacencyInfo;
 
 
-		return GpuProgramCoreManager::instance().createInternal(desc);
+		return ct::GpuProgramCoreManager::instance().createInternal(desc);
 	}
 	}
 
 
 	SPtr<GpuProgram> GpuProgram::create(const GPU_PROGRAM_DESC& desc)
 	SPtr<GpuProgram> GpuProgram::create(const GPU_PROGRAM_DESC& desc)
@@ -95,4 +70,32 @@ namespace bs
 	{
 	{
 		return GpuProgram::getRTTIStatic();
 		return GpuProgram::getRTTIStatic();
 	}
 	}
+
+	namespace ct
+	{
+	GpuProgramCore::GpuProgramCore(const GPU_PROGRAM_DESC& desc, GpuDeviceFlags deviceMask)
+		:mNeedsAdjacencyInfo(desc.requiresAdjacency), mIsCompiled(false), mProperties(desc.source, desc.entryPoint, 
+			desc.type)
+	{
+		mParametersDesc = bs_shared_ptr_new<GpuParamDesc>();
+	}
+
+	bool GpuProgramCore::isSupported() const
+    {
+		if (!isRequiredCapabilitiesSupported())
+			return false;
+
+		return true;
+    }
+
+	bool GpuProgramCore::isRequiredCapabilitiesSupported() const
+	{
+		return true;
+	}
+
+	SPtr<GpuProgramCore> GpuProgramCore::create(const GPU_PROGRAM_DESC& desc, GpuDeviceFlags deviceMask)
+	{
+		return GpuProgramCoreManager::instance().create(desc, deviceMask);
+	}
+	}
 }
 }

+ 26 - 23
Source/BansheeCore/Source/BsGpuProgramManager.cpp

@@ -5,6 +5,31 @@
 
 
 namespace bs 
 namespace bs 
 {
 {
+	SPtr<GpuProgram> GpuProgramManager::create(const GPU_PROGRAM_DESC& desc)
+	{
+		GpuProgram* program = new (bs_alloc<GpuProgram>()) GpuProgram(desc);
+		SPtr<GpuProgram> ret = bs_core_ptr<GpuProgram>(program);
+		ret->_setThisPtr(ret);
+		ret->initialize();
+
+		return ret;
+	}
+
+	SPtr<GpuProgram> GpuProgramManager::createEmpty(const String& language, GpuProgramType type)
+	{
+		GPU_PROGRAM_DESC desc;
+		desc.language = language;
+		desc.type = type;
+
+		GpuProgram* program = new (bs_alloc<GpuProgram>()) GpuProgram(desc);
+		SPtr<GpuProgram> ret = bs_core_ptr<GpuProgram>(program);
+		ret->_setThisPtr(ret);
+
+		return ret;
+	}
+
+	namespace ct
+	{
 	String sNullLang = "null";
 	String sNullLang = "null";
 
 
 	/** Null GPU program used in place of GPU programs we cannot create. Null programs don't do anything. */
 	/** Null GPU program used in place of GPU programs we cannot create. Null programs don't do anything. */
@@ -55,29 +80,6 @@ namespace bs
 		}
 		}
 	};
 	};
 
 
-	SPtr<GpuProgram> GpuProgramManager::create(const GPU_PROGRAM_DESC& desc)
-	{
-		GpuProgram* program = new (bs_alloc<GpuProgram>()) GpuProgram(desc);
-		SPtr<GpuProgram> ret = bs_core_ptr<GpuProgram>(program);
-		ret->_setThisPtr(ret);
-		ret->initialize();
-
-		return ret;
-	}
-
-	SPtr<GpuProgram> GpuProgramManager::createEmpty(const String& language, GpuProgramType type)
-	{
-		GPU_PROGRAM_DESC desc;
-		desc.language = language;
-		desc.type = type;
-
-		GpuProgram* program = new (bs_alloc<GpuProgram>()) GpuProgram(desc);
-		SPtr<GpuProgram> ret = bs_core_ptr<GpuProgram>(program);
-		ret->_setThisPtr(ret);
-
-		return ret;
-	}
-
 	GpuProgramCoreManager::GpuProgramCoreManager()
 	GpuProgramCoreManager::GpuProgramCoreManager()
 	{
 	{
 		mNullFactory = bs_new<NullProgramFactory>();
 		mNullFactory = bs_new<NullProgramFactory>();
@@ -135,4 +137,5 @@ namespace bs
 
 
 		return ret;
 		return ret;
 	}
 	}
+	}
 }
 }

+ 4 - 0
Source/BansheeCore/Source/BsHardwareBufferManager.cpp

@@ -73,6 +73,9 @@ namespace bs
 		return paramsPtr;
 		return paramsPtr;
     }
     }
 
 
+	namespace ct
+	{
+
 	HardwareBufferCoreManager::VertexDeclarationKey::VertexDeclarationKey(const List<VertexElement>& elements)
 	HardwareBufferCoreManager::VertexDeclarationKey::VertexDeclarationKey(const List<VertexElement>& elements)
 		:elements(elements)
 		:elements(elements)
 	{ }
 	{ }
@@ -196,4 +199,5 @@ namespace bs
 
 
 		return paramsPtr;
 		return paramsPtr;
     }
     }
+	}
 }
 }

+ 16 - 13
Source/BansheeCore/Source/BsIndexBuffer.cpp

@@ -22,38 +22,41 @@ namespace bs
 		:mIndexType(idxType), mNumIndices(numIndices), mIndexSize(calcIndexSize(idxType))
 		:mIndexType(idxType), mNumIndices(numIndices), mIndexSize(calcIndexSize(idxType))
 	{ }
 	{ }
 
 
-	IndexBufferCore::IndexBufferCore(const INDEX_BUFFER_DESC& desc, GpuDeviceFlags deviceMask)
-		:HardwareBuffer(calcIndexSize(desc.indexType) * desc.numIndices), mProperties(desc.indexType, desc.numIndices)
-	{ }
-
-	SPtr<IndexBufferCore> IndexBufferCore::create(const INDEX_BUFFER_DESC& desc, GpuDeviceFlags deviceMask)
-	{
-		return HardwareBufferCoreManager::instance().createIndexBuffer(desc, deviceMask);
-	}
-
     IndexBuffer::IndexBuffer(const INDEX_BUFFER_DESC& desc)
     IndexBuffer::IndexBuffer(const INDEX_BUFFER_DESC& desc)
 		:mProperties(desc.indexType, desc.numIndices), mUsage(desc.usage)
 		:mProperties(desc.indexType, desc.numIndices), mUsage(desc.usage)
     {
     {
 
 
 	}
 	}
 
 
-	SPtr<IndexBufferCore> IndexBuffer::getCore() const
+	SPtr<ct::IndexBufferCore> IndexBuffer::getCore() const
 	{
 	{
-		return std::static_pointer_cast<IndexBufferCore>(mCoreSpecific);
+		return std::static_pointer_cast<ct::IndexBufferCore>(mCoreSpecific);
 	}
 	}
 
 
-	SPtr<CoreObjectCore> IndexBuffer::createCore() const
+	SPtr<ct::CoreObjectCore> IndexBuffer::createCore() const
 	{
 	{
 		INDEX_BUFFER_DESC desc;
 		INDEX_BUFFER_DESC desc;
 		desc.indexType = mProperties.mIndexType;
 		desc.indexType = mProperties.mIndexType;
 		desc.numIndices = mProperties.mNumIndices;
 		desc.numIndices = mProperties.mNumIndices;
 		desc.usage = mUsage;
 		desc.usage = mUsage;
 
 
-		return HardwareBufferCoreManager::instance().createIndexBufferInternal(desc);
+		return ct::HardwareBufferCoreManager::instance().createIndexBufferInternal(desc);
 	}
 	}
 
 
 	SPtr<IndexBuffer> IndexBuffer::create(const INDEX_BUFFER_DESC& desc)
 	SPtr<IndexBuffer> IndexBuffer::create(const INDEX_BUFFER_DESC& desc)
 	{
 	{
 		return HardwareBufferManager::instance().createIndexBuffer(desc);
 		return HardwareBufferManager::instance().createIndexBuffer(desc);
 	}
 	}
+
+	namespace ct
+	{
+	IndexBufferCore::IndexBufferCore(const INDEX_BUFFER_DESC& desc, GpuDeviceFlags deviceMask)
+		:HardwareBuffer(calcIndexSize(desc.indexType) * desc.numIndices), mProperties(desc.indexType, desc.numIndices)
+	{ }
+
+	SPtr<IndexBufferCore> IndexBufferCore::create(const INDEX_BUFFER_DESC& desc, GpuDeviceFlags deviceMask)
+	{
+		return HardwareBufferCoreManager::instance().createIndexBuffer(desc, deviceMask);
+	}
+	}
 }
 }

+ 83 - 80
Source/BansheeCore/Source/BsMaterial.cpp

@@ -31,11 +31,11 @@ namespace bs
 	bool isShaderValid(const HShader& shader) { return shader.isLoaded(); }
 	bool isShaderValid(const HShader& shader) { return shader.isLoaded(); }
 
 
 	template<>
 	template<>
-	bool isShaderValid(const SPtr<ShaderCore>& shader) { return shader != nullptr; }
+	bool isShaderValid(const SPtr<ct::ShaderCore>& shader) { return shader != nullptr; }
 
 
 	template<bool Core> struct TMatType { };
 	template<bool Core> struct TMatType { };
 	template<> struct TMatType<false> { typedef Material Type; };
 	template<> struct TMatType<false> { typedef Material Type; };
-	template<> struct TMatType<true> { typedef MaterialCore Type; };
+	template<> struct TMatType<true> { typedef ct::MaterialCore Type; };
 
 
 	template<bool Core>
 	template<bool Core>
 	SPtr<typename TMatType<Core>::Type> getMaterialPtr(const TMaterial<Core>* material)
 	SPtr<typename TMatType<Core>::Type> getMaterialPtr(const TMaterial<Core>* material)
@@ -358,68 +358,6 @@ namespace bs
 	template BS_CORE_EXPORT void TMaterial<true>::getParam(const String&, TMaterialDataParam<Matrix4x2, true>&) const;
 	template BS_CORE_EXPORT void TMaterial<true>::getParam(const String&, TMaterialDataParam<Matrix4x2, true>&) const;
 	template BS_CORE_EXPORT void TMaterial<true>::getParam(const String&, TMaterialDataParam<Matrix4x3, true>&) const;
 	template BS_CORE_EXPORT void TMaterial<true>::getParam(const String&, TMaterialDataParam<Matrix4x3, true>&) const;
 
 
-	MaterialCore::MaterialCore(const SPtr<ShaderCore>& shader)
-	{
-		setShader(shader);
-	}
-
-	MaterialCore::MaterialCore(const SPtr<ShaderCore>& shader, const Vector<SPtr<TechniqueCore>>& techniques,
-		const SPtr<MaterialParamsCore>& materialParams)
-	{
-		mShader = shader;
-		mParams = materialParams;
-		mTechniques = techniques;
-	}
-
-	void MaterialCore::setShader(const SPtr<ShaderCore>& shader)
-	{
-		mShader = shader;
-
-		initializeTechniques();
-
-		_markCoreDirty();
-	}
-
-	void MaterialCore::syncToCore(const CoreSyncData& data)
-	{
-		char* dataPtr = (char*)data.getBuffer();
-
-		SPtr<ShaderCore>* shader = (SPtr<ShaderCore>*)dataPtr;
-
-		mShader = *shader;
-		shader->~SPtr<ShaderCore>();
-		dataPtr += sizeof(SPtr<ShaderCore>);
-
-		UINT32 numTechniques;
-		dataPtr = rttiReadElem(numTechniques, dataPtr);
-
-		mTechniques.resize(numTechniques);
-		for(UINT32 i = 0; i < numTechniques; i++)
-		{
-			SPtr<TechniqueCore>* technique = (SPtr<TechniqueCore>*)dataPtr;
-			mTechniques[i] = *technique;
-			technique->~SPtr<TechniqueCore>();
-			dataPtr += sizeof(SPtr<TechniqueCore>);
-		}
-
-		UINT32 paramsSize = 0;
-		dataPtr = rttiReadElem(paramsSize, dataPtr);
-		if (mParams != nullptr)
-			mParams->setSyncData((UINT8*)dataPtr, paramsSize);
-
-		dataPtr += paramsSize;
-	}
-
-	SPtr<MaterialCore> MaterialCore::create(const SPtr<ShaderCore>& shader)
-	{
-		MaterialCore* material = new (bs_alloc<MaterialCore>()) MaterialCore(shader);
-		SPtr<MaterialCore> materialPtr = bs_shared_ptr<MaterialCore>(material);
-		materialPtr->_setThisPtr(materialPtr);
-		materialPtr->initialize();
-
-		return materialPtr;
-	}
-
 	Material::Material()
 	Material::Material()
 		:mLoadFlags(Load_None)
 		:mLoadFlags(Load_None)
 	{ }
 	{ }
@@ -466,33 +404,33 @@ namespace bs
 		markListenerResourcesDirty();
 		markListenerResourcesDirty();
 	}
 	}
 
 
-	SPtr<MaterialCore> Material::getCore() const
+	SPtr<ct::MaterialCore> Material::getCore() const
 	{
 	{
-		return std::static_pointer_cast<MaterialCore>(mCoreSpecific);
+		return std::static_pointer_cast<ct::MaterialCore>(mCoreSpecific);
 	}
 	}
 
 
-	SPtr<CoreObjectCore> Material::createCore() const
+	SPtr<ct::CoreObjectCore> Material::createCore() const
 	{
 	{
-		MaterialCore* material = nullptr;
+		ct::MaterialCore* material = nullptr;
 
 
-		SPtr<ShaderCore> shader;
+		SPtr<ct::ShaderCore> shader;
 		if (mShader.isLoaded())
 		if (mShader.isLoaded())
 		{
 		{
 			shader = mShader->getCore();
 			shader = mShader->getCore();
 
 
-			Vector<SPtr<TechniqueCore>> techniques(mTechniques.size());
+			Vector<SPtr<ct::TechniqueCore>> techniques(mTechniques.size());
 			for (UINT32 i = 0; i < (UINT32)mTechniques.size(); i++)
 			for (UINT32 i = 0; i < (UINT32)mTechniques.size(); i++)
 				techniques[i] = mTechniques[i]->getCore();
 				techniques[i] = mTechniques[i]->getCore();
 			
 			
-			SPtr<MaterialParamsCore> materialParams = bs_shared_ptr_new<MaterialParamsCore>(shader, mParams);
+			SPtr<ct::MaterialParamsCore> materialParams = bs_shared_ptr_new<ct::MaterialParamsCore>(shader, mParams);
 
 
-			material = new (bs_alloc<MaterialCore>()) MaterialCore(shader, techniques, materialParams);
+			material = new (bs_alloc<ct::MaterialCore>()) ct::MaterialCore(shader, techniques, materialParams);
 		}
 		}
 		
 		
 		if (material == nullptr)
 		if (material == nullptr)
-			material = new (bs_alloc<MaterialCore>()) MaterialCore(shader);
+			material = new (bs_alloc<ct::MaterialCore>()) ct::MaterialCore(shader);
 
 
-		SPtr<MaterialCore> materialPtr = bs_shared_ptr<MaterialCore>(material);
+		SPtr<ct::MaterialCore> materialPtr = bs_shared_ptr<ct::MaterialCore>(material);
 		materialPtr->_setThisPtr(materialPtr);
 		materialPtr->_setThisPtr(materialPtr);
 
 
 		return materialPtr;
 		return materialPtr;
@@ -505,27 +443,27 @@ namespace bs
 			mParams->getSyncData(nullptr, paramsSize);
 			mParams->getSyncData(nullptr, paramsSize);
 
 
 		UINT32 numTechniques = (UINT32)mTechniques.size();
 		UINT32 numTechniques = (UINT32)mTechniques.size();
-		UINT32 size = sizeof(UINT32) * 2 + sizeof(SPtr<ShaderCore>) + 
-			sizeof(SPtr<TechniqueCore>) * numTechniques + paramsSize;
+		UINT32 size = sizeof(UINT32) * 2 + sizeof(SPtr<ct::ShaderCore>) + 
+			sizeof(SPtr<ct::TechniqueCore>) * numTechniques + paramsSize;
 
 
 		UINT8* buffer = allocator->alloc(size);
 		UINT8* buffer = allocator->alloc(size);
 		char* dataPtr = (char*)buffer;
 		char* dataPtr = (char*)buffer;
 		
 		
-		SPtr<ShaderCore>* shader = new (dataPtr)SPtr<ShaderCore>();
+		SPtr<ct::ShaderCore>* shader = new (dataPtr)SPtr<ct::ShaderCore>();
 		if (mShader.isLoaded(false))
 		if (mShader.isLoaded(false))
 			*shader = mShader->getCore();
 			*shader = mShader->getCore();
 		else
 		else
 			*shader = nullptr;
 			*shader = nullptr;
 
 
-		dataPtr += sizeof(SPtr<ShaderCore>);
+		dataPtr += sizeof(SPtr<ct::ShaderCore>);
 		dataPtr = rttiWriteElem(numTechniques, dataPtr);
 		dataPtr = rttiWriteElem(numTechniques, dataPtr);
 
 
 		for(UINT32 i = 0; i < numTechniques; i++)
 		for(UINT32 i = 0; i < numTechniques; i++)
 		{
 		{
-			SPtr<TechniqueCore>* technique = new (dataPtr)SPtr<TechniqueCore>();
+			SPtr<ct::TechniqueCore>* technique = new (dataPtr)SPtr<ct::TechniqueCore>();
 				*technique = mTechniques[i]->getCore();
 				*technique = mTechniques[i]->getCore();
 
 
-			dataPtr += sizeof(SPtr<TechniqueCore>);
+			dataPtr += sizeof(SPtr<ct::TechniqueCore>);
 		}
 		}
 
 
 		dataPtr = rttiWriteElem(paramsSize, dataPtr);
 		dataPtr = rttiWriteElem(paramsSize, dataPtr);
@@ -781,4 +719,69 @@ namespace bs
 	{
 	{
 		return Material::getRTTIStatic();
 		return Material::getRTTIStatic();
 	}
 	}
+
+	namespace ct
+	{
+	MaterialCore::MaterialCore(const SPtr<ShaderCore>& shader)
+	{
+		setShader(shader);
+	}
+
+	MaterialCore::MaterialCore(const SPtr<ShaderCore>& shader, const Vector<SPtr<TechniqueCore>>& techniques,
+		const SPtr<MaterialParamsCore>& materialParams)
+	{
+		mShader = shader;
+		mParams = materialParams;
+		mTechniques = techniques;
+	}
+
+	void MaterialCore::setShader(const SPtr<ShaderCore>& shader)
+	{
+		mShader = shader;
+
+		initializeTechniques();
+
+		_markCoreDirty();
+	}
+
+	void MaterialCore::syncToCore(const CoreSyncData& data)
+	{
+		char* dataPtr = (char*)data.getBuffer();
+
+		SPtr<ShaderCore>* shader = (SPtr<ShaderCore>*)dataPtr;
+
+		mShader = *shader;
+		shader->~SPtr<ShaderCore>();
+		dataPtr += sizeof(SPtr<ShaderCore>);
+
+		UINT32 numTechniques;
+		dataPtr = rttiReadElem(numTechniques, dataPtr);
+
+		mTechniques.resize(numTechniques);
+		for(UINT32 i = 0; i < numTechniques; i++)
+		{
+			SPtr<TechniqueCore>* technique = (SPtr<TechniqueCore>*)dataPtr;
+			mTechniques[i] = *technique;
+			technique->~SPtr<TechniqueCore>();
+			dataPtr += sizeof(SPtr<TechniqueCore>);
+		}
+
+		UINT32 paramsSize = 0;
+		dataPtr = rttiReadElem(paramsSize, dataPtr);
+		if (mParams != nullptr)
+			mParams->setSyncData((UINT8*)dataPtr, paramsSize);
+
+		dataPtr += paramsSize;
+	}
+
+	SPtr<MaterialCore> MaterialCore::create(const SPtr<ShaderCore>& shader)
+	{
+		MaterialCore* material = new (bs_alloc<MaterialCore>()) MaterialCore(shader);
+		SPtr<MaterialCore> materialPtr = bs_shared_ptr<MaterialCore>(material);
+		materialPtr->_setThisPtr(materialPtr);
+		materialPtr->initialize();
+
+		return materialPtr;
+	}
+	}
 }
 }

+ 131 - 128
Source/BansheeCore/Source/BsMaterialParams.cpp

@@ -547,134 +547,6 @@ namespace bs
 	template class TMaterialParams<true>;
 	template class TMaterialParams<true>;
 	template class TMaterialParams<false>;
 	template class TMaterialParams<false>;
 
 
-	MaterialParamsCore::MaterialParamsCore(const SPtr<ShaderCore>& shader)
-		:TMaterialParams(shader)
-	{ }
-
-	MaterialParamsCore::MaterialParamsCore(const SPtr<ShaderCore>& shader, const SPtr<MaterialParams>& params)
-		: TMaterialParams(shader)
-	{
-		memcpy(mDataParamsBuffer, params->mDataParamsBuffer, mDataSize);
-
-		for (auto& param : mParams)
-		{
-			switch (param.type)
-			{
-			case ParamType::Texture:
-			{
-				HTexture texture = params->mTextureParams[param.index].value;
-				SPtr<TextureCore> textureCore;
-				if (texture.isLoaded())
-					textureCore = texture->getCore();
-
-				mTextureParams[param.index].value = textureCore;
-				mTextureParams[param.index].isLoadStore = params->mTextureParams[param.index].isLoadStore;
-				mTextureParams[param.index].surface = params->mTextureParams[param.index].surface;
-			}
-				break;
-			case ParamType::Buffer:
-			{
-				SPtr<GpuBuffer> buffer = params->mBufferParams[param.index].value;
-				SPtr<GpuBufferCore> bufferCore;
-				if (buffer != nullptr)
-					bufferCore = buffer->getCore();
-
-				mBufferParams[param.index].value = bufferCore;
-			}
-				break;
-			case ParamType::Sampler:
-			{
-				SPtr<SamplerState> sampState = params->mSamplerStateParams[param.index].value;
-				SPtr<SamplerStateCore> sampStateCore;
-				if (sampState != nullptr)
-					sampStateCore = sampState->getCore();
-
-				mSamplerStateParams[param.index].value = sampStateCore;
-			}
-				break;
-			}
-		}
-	}
-
-	void MaterialParamsCore::setSyncData(UINT8* buffer, UINT32 size)
-	{
-		char* sourceData = (char*)buffer;
-
-		UINT32 numDirtyDataParams = 0;
-		UINT32 numDirtyTextureParams = 0;
-		UINT32 numDirtyBufferParams = 0;
-		UINT32 numDirtySamplerParams = 0;
-
-		sourceData = rttiReadElem(numDirtyDataParams, sourceData);
-		sourceData = rttiReadElem(numDirtyTextureParams, sourceData);
-		sourceData = rttiReadElem(numDirtyBufferParams, sourceData);
-		sourceData = rttiReadElem(numDirtySamplerParams, sourceData);
-
-		mParamVersion++;
-
-		for(UINT32 i = 0; i < numDirtyDataParams; i++)
-		{
-			UINT32 paramIdx = 0;
-			sourceData = rttiReadElem(paramIdx, sourceData);
-
-			ParamData& param = mParams[paramIdx];
-			param.version = mParamVersion;
-
-			UINT32 arraySize = param.arraySize > 1 ? param.arraySize : 1;
-			const GpuParamDataTypeInfo& typeInfo = GpuParams::PARAM_SIZES.lookup[(int)param.type];
-			UINT32 paramSize = typeInfo.numColumns * typeInfo.numRows * typeInfo.baseTypeSize;
-
-			UINT32 dataParamSize = arraySize * paramSize;
-			memcpy(&mDataParamsBuffer[param.index], sourceData, dataParamSize);
-			sourceData += dataParamSize;
-		}
-
-		for(UINT32 i = 0; i < numDirtyTextureParams; i++)
-		{
-			UINT32 paramIdx = 0;
-			sourceData = rttiReadElem(paramIdx, sourceData);
-
-			ParamData& param = mParams[paramIdx];
-			param.version = mParamVersion;
-
-			MaterialParamTextureDataCore* sourceTexData = (MaterialParamTextureDataCore*)sourceData;
-			sourceData += sizeof(MaterialParamTextureDataCore);
-
-			mTextureParams[param.index] = *sourceTexData;
-			sourceTexData->~MaterialParamTextureDataCore();
-		}
-
-		for (UINT32 i = 0; i < numDirtyBufferParams; i++)
-		{
-			UINT32 paramIdx = 0;
-			sourceData = rttiReadElem(paramIdx, sourceData);
-
-			ParamData& param = mParams[paramIdx];
-			param.version = mParamVersion;
-
-			MaterialParamBufferDataCore* sourceBufferData = (MaterialParamBufferDataCore*)sourceData;
-			sourceData += sizeof(MaterialParamBufferDataCore);
-
-			mBufferParams[param.index] = *sourceBufferData;
-			sourceBufferData->~MaterialParamBufferDataCore();
-		}
-
-		for (UINT32 i = 0; i < numDirtySamplerParams; i++)
-		{
-			UINT32 paramIdx = 0;
-			sourceData = rttiReadElem(paramIdx, sourceData);
-
-			ParamData& param = mParams[paramIdx];
-			param.version = mParamVersion;
-
-			MaterialParamSamplerStateDataCore* sourceSamplerStateData = (MaterialParamSamplerStateDataCore*)sourceData;
-			sourceData += sizeof(MaterialParamSamplerStateDataCore);
-
-			mSamplerStateParams[param.index] = *sourceSamplerStateData;
-			sourceSamplerStateData->~MaterialParamSamplerStateDataCore();
-		}
-	}
-
 	MaterialParams::MaterialParams(const HShader& shader)
 	MaterialParams::MaterialParams(const HShader& shader)
 		:TMaterialParams(shader), mLastSyncVersion(1)
 		:TMaterialParams(shader), mLastSyncVersion(1)
 	{ }
 	{ }
@@ -840,4 +712,135 @@ namespace bs
 	{
 	{
 		return MaterialParams::getRTTIStatic();
 		return MaterialParams::getRTTIStatic();
 	}
 	}
+
+	namespace ct
+	{
+	MaterialParamsCore::MaterialParamsCore(const SPtr<ShaderCore>& shader)
+		:TMaterialParams(shader)
+	{ }
+
+	MaterialParamsCore::MaterialParamsCore(const SPtr<ShaderCore>& shader, const SPtr<MaterialParams>& params)
+		: TMaterialParams(shader)
+	{
+		memcpy(mDataParamsBuffer, params->mDataParamsBuffer, mDataSize);
+
+		for (auto& param : mParams)
+		{
+			switch (param.type)
+			{
+			case ParamType::Texture:
+			{
+				HTexture texture = params->mTextureParams[param.index].value;
+				SPtr<TextureCore> textureCore;
+				if (texture.isLoaded())
+					textureCore = texture->getCore();
+
+				mTextureParams[param.index].value = textureCore;
+				mTextureParams[param.index].isLoadStore = params->mTextureParams[param.index].isLoadStore;
+				mTextureParams[param.index].surface = params->mTextureParams[param.index].surface;
+			}
+				break;
+			case ParamType::Buffer:
+			{
+				SPtr<GpuBuffer> buffer = params->mBufferParams[param.index].value;
+				SPtr<GpuBufferCore> bufferCore;
+				if (buffer != nullptr)
+					bufferCore = buffer->getCore();
+
+				mBufferParams[param.index].value = bufferCore;
+			}
+				break;
+			case ParamType::Sampler:
+			{
+				SPtr<SamplerState> sampState = params->mSamplerStateParams[param.index].value;
+				SPtr<SamplerStateCore> sampStateCore;
+				if (sampState != nullptr)
+					sampStateCore = sampState->getCore();
+
+				mSamplerStateParams[param.index].value = sampStateCore;
+			}
+				break;
+			}
+		}
+	}
+
+	void MaterialParamsCore::setSyncData(UINT8* buffer, UINT32 size)
+	{
+		char* sourceData = (char*)buffer;
+
+		UINT32 numDirtyDataParams = 0;
+		UINT32 numDirtyTextureParams = 0;
+		UINT32 numDirtyBufferParams = 0;
+		UINT32 numDirtySamplerParams = 0;
+
+		sourceData = rttiReadElem(numDirtyDataParams, sourceData);
+		sourceData = rttiReadElem(numDirtyTextureParams, sourceData);
+		sourceData = rttiReadElem(numDirtyBufferParams, sourceData);
+		sourceData = rttiReadElem(numDirtySamplerParams, sourceData);
+
+		mParamVersion++;
+
+		for(UINT32 i = 0; i < numDirtyDataParams; i++)
+		{
+			UINT32 paramIdx = 0;
+			sourceData = rttiReadElem(paramIdx, sourceData);
+
+			ParamData& param = mParams[paramIdx];
+			param.version = mParamVersion;
+
+			UINT32 arraySize = param.arraySize > 1 ? param.arraySize : 1;
+			const GpuParamDataTypeInfo& typeInfo = GpuParams::PARAM_SIZES.lookup[(int)param.type];
+			UINT32 paramSize = typeInfo.numColumns * typeInfo.numRows * typeInfo.baseTypeSize;
+
+			UINT32 dataParamSize = arraySize * paramSize;
+			memcpy(&mDataParamsBuffer[param.index], sourceData, dataParamSize);
+			sourceData += dataParamSize;
+		}
+
+		for(UINT32 i = 0; i < numDirtyTextureParams; i++)
+		{
+			UINT32 paramIdx = 0;
+			sourceData = rttiReadElem(paramIdx, sourceData);
+
+			ParamData& param = mParams[paramIdx];
+			param.version = mParamVersion;
+
+			MaterialParamTextureDataCore* sourceTexData = (MaterialParamTextureDataCore*)sourceData;
+			sourceData += sizeof(MaterialParamTextureDataCore);
+
+			mTextureParams[param.index] = *sourceTexData;
+			sourceTexData->~MaterialParamTextureDataCore();
+		}
+
+		for (UINT32 i = 0; i < numDirtyBufferParams; i++)
+		{
+			UINT32 paramIdx = 0;
+			sourceData = rttiReadElem(paramIdx, sourceData);
+
+			ParamData& param = mParams[paramIdx];
+			param.version = mParamVersion;
+
+			MaterialParamBufferDataCore* sourceBufferData = (MaterialParamBufferDataCore*)sourceData;
+			sourceData += sizeof(MaterialParamBufferDataCore);
+
+			mBufferParams[param.index] = *sourceBufferData;
+			sourceBufferData->~MaterialParamBufferDataCore();
+		}
+
+		for (UINT32 i = 0; i < numDirtySamplerParams; i++)
+		{
+			UINT32 paramIdx = 0;
+			sourceData = rttiReadElem(paramIdx, sourceData);
+
+			ParamData& param = mParams[paramIdx];
+			param.version = mParamVersion;
+
+			MaterialParamSamplerStateDataCore* sourceSamplerStateData = (MaterialParamSamplerStateDataCore*)sourceData;
+			sourceData += sizeof(MaterialParamSamplerStateDataCore);
+
+			mSamplerStateParams[param.index] = *sourceSamplerStateData;
+			sourceSamplerStateData->~MaterialParamSamplerStateDataCore();
+		}
+	}
+	}
 }
 }

+ 392 - 389
Source/BansheeCore/Source/BsMesh.cpp

@@ -16,6 +16,283 @@ namespace bs
 {
 {
 	MESH_DESC MESH_DESC::DEFAULT = MESH_DESC();
 	MESH_DESC MESH_DESC::DEFAULT = MESH_DESC();
 
 
+	Mesh::Mesh(const MESH_DESC& desc)
+		:MeshBase(desc.numVertices, desc.numIndices, desc.subMeshes), mVertexDesc(desc.vertexDesc), mUsage(desc.usage),
+		mIndexType(desc.indexType), mSkeleton(desc.skeleton), mMorphShapes(desc.morphShapes)
+	{
+
+	}
+
+	Mesh::Mesh(const SPtr<MeshData>& initialMeshData, const MESH_DESC& desc)
+		:MeshBase(initialMeshData->getNumVertices(), initialMeshData->getNumIndices(), desc.subMeshes),
+		mCPUData(initialMeshData), mVertexDesc(initialMeshData->getVertexDesc()),
+		mUsage(desc.usage), mIndexType(initialMeshData->getIndexType()), mSkeleton(desc.skeleton), 
+		mMorphShapes(desc.morphShapes)
+	{
+
+	}
+
+	Mesh::Mesh()
+		:MeshBase(0, 0, DOT_TRIANGLE_LIST), mUsage(MU_STATIC), mIndexType(IT_32BIT)
+	{
+
+	}
+
+	Mesh::~Mesh()
+	{
+		
+	}
+
+	AsyncOp Mesh::writeData(const SPtr<MeshData>& data, bool discardEntireBuffer)
+	{
+		updateBounds(*data);
+		updateCPUBuffer(0, *data);
+
+		data->_lock();
+
+		std::function<void(const SPtr<ct::MeshCore>&, const SPtr<MeshData>&, bool, AsyncOp&)> func =
+			[&](const SPtr<ct::MeshCore>& mesh, const SPtr<MeshData>& _meshData, bool _discardEntireBuffer, AsyncOp& asyncOp)
+		{
+			mesh->writeData(*_meshData, _discardEntireBuffer, false);
+			_meshData->_unlock();
+			asyncOp._completeOperation();
+
+		};
+
+		return gCoreThread().queueReturnCommand(std::bind(func, getCore(),
+			 data, discardEntireBuffer, std::placeholders::_1));
+	}
+
+	AsyncOp Mesh::readData(const SPtr<MeshData>& data)
+	{
+		data->_lock();
+
+		std::function<void(const SPtr<ct::MeshCore>&, const SPtr<MeshData>&, AsyncOp&)> func =
+			[&](const SPtr<ct::MeshCore>& mesh, const SPtr<MeshData>& _meshData, AsyncOp& asyncOp)
+		{
+			// Make sure any queued command start executing before reading
+			ct::RenderAPICore::instance().submitCommandBuffer(nullptr);
+
+			mesh->readData(*_meshData);
+			_meshData->_unlock();
+			asyncOp._completeOperation();
+
+		};
+
+		return gCoreThread().queueReturnCommand(std::bind(func, getCore(),
+			data, std::placeholders::_1));
+	}
+
+	SPtr<MeshData> Mesh::allocBuffer() const
+	{
+		SPtr<MeshData> meshData = bs_shared_ptr_new<MeshData>(mProperties.mNumVertices, mProperties.mNumIndices, 
+			mVertexDesc, mIndexType);
+
+		return meshData;
+	}
+
+	void Mesh::initialize()
+	{
+		if (mCPUData != nullptr)
+			updateBounds(*mCPUData);
+
+		MeshBase::initialize();
+
+		if ((mUsage & MU_CPUCACHED) != 0 && mCPUData == nullptr)
+			createCPUBuffer();
+	}
+
+	void Mesh::updateBounds(const MeshData& meshData)
+	{
+		mProperties.mBounds = meshData.calculateBounds();
+		markCoreDirty();
+	}
+
+	SPtr<ct::MeshCore> Mesh::getCore() const
+	{
+		return std::static_pointer_cast<ct::MeshCore>(mCoreSpecific);
+	}
+
+	SPtr<ct::CoreObjectCore> Mesh::createCore() const
+	{
+		MESH_DESC desc;
+		desc.numVertices = mProperties.mNumVertices;
+		desc.numIndices = mProperties.mNumIndices;
+		desc.vertexDesc = mVertexDesc;
+		desc.subMeshes = mProperties.mSubMeshes;
+		desc.usage = mUsage;
+		desc.indexType = mIndexType;
+		desc.skeleton = mSkeleton;
+		desc.morphShapes = mMorphShapes;
+
+		ct::MeshCore* obj = new (bs_alloc<ct::MeshCore>()) ct::MeshCore(mCPUData, desc, GDF_DEFAULT);
+
+		SPtr<ct::CoreObjectCore> meshCore = bs_shared_ptr<ct::MeshCore>(obj);
+		meshCore->_setThisPtr(meshCore);
+
+		if ((mUsage & MU_CPUCACHED) == 0)
+			mCPUData = nullptr;
+
+		return meshCore;
+	}
+
+	void Mesh::updateCPUBuffer(UINT32 subresourceIdx, const MeshData& pixelData)
+	{
+		if ((mUsage & MU_CPUCACHED) == 0)
+			return;
+
+		if (subresourceIdx > 0)
+		{
+			LOGERR("Invalid subresource index: " + toString(subresourceIdx) + ". Supported range: 0 .. 1.");
+			return;
+		}
+
+		if (pixelData.getNumIndices() != mProperties.getNumIndices() ||
+			pixelData.getNumVertices() != mProperties.getNumVertices() ||
+			pixelData.getIndexType() != mIndexType ||
+			pixelData.getVertexDesc()->getVertexStride() != mVertexDesc->getVertexStride())
+		{
+			LOGERR("Provided buffer is not of valid dimensions or format in order to update this mesh.");
+			return;
+		}
+
+		if (mCPUData->getSize() != pixelData.getSize())
+			BS_EXCEPT(InternalErrorException, "Buffer sizes don't match.");
+
+		UINT8* dest = mCPUData->getData();
+		UINT8* src = pixelData.getData();
+
+		memcpy(dest, src, pixelData.getSize());
+	}
+
+	void Mesh::readCachedData(MeshData& dest)
+	{
+		if ((mUsage & MU_CPUCACHED) == 0)
+		{
+			LOGERR("Attempting to read CPU data from a mesh that is created without CPU caching.");
+			return;
+		}
+
+		if (dest.getNumIndices() != mProperties.getNumIndices() ||
+			dest.getNumVertices() != mProperties.getNumVertices() ||
+			dest.getIndexType() != mIndexType ||
+			dest.getVertexDesc()->getVertexStride() != mVertexDesc->getVertexStride())
+		{
+			LOGERR("Provided buffer is not of valid dimensions or format in order to read from this mesh.");
+			return;
+		}
+		
+		if (mCPUData->getSize() != dest.getSize())
+			BS_EXCEPT(InternalErrorException, "Buffer sizes don't match.");
+
+		UINT8* srcPtr = mCPUData->getData();
+		UINT8* destPtr = dest.getData();
+
+		memcpy(destPtr, srcPtr, dest.getSize());
+	}
+
+	void Mesh::createCPUBuffer()
+	{
+		mCPUData = allocBuffer();
+	}
+
+	HMesh Mesh::dummy()
+	{
+		return MeshManager::instance().getDummyMesh();
+	}
+
+	/************************************************************************/
+	/* 								SERIALIZATION                      		*/
+	/************************************************************************/
+
+	RTTITypeBase* Mesh::getRTTIStatic()
+	{
+		return MeshRTTI::instance();
+	}
+
+	RTTITypeBase* Mesh::getRTTI() const
+	{
+		return Mesh::getRTTIStatic();
+	}
+
+	/************************************************************************/
+	/* 								STATICS		                     		*/
+	/************************************************************************/
+
+	HMesh Mesh::create(UINT32 numVertices, UINT32 numIndices, const SPtr<VertexDataDesc>& vertexDesc, 
+		int usage, DrawOperationType drawOp, IndexType indexType)
+	{
+		MESH_DESC desc;
+		desc.numVertices = numVertices;
+		desc.numIndices = numIndices;
+		desc.vertexDesc = vertexDesc;
+		desc.usage = usage;
+		desc.subMeshes.push_back(SubMesh(0, numIndices, drawOp));
+		desc.indexType = indexType;
+
+		SPtr<Mesh> meshPtr = _createPtr(desc);
+		return static_resource_cast<Mesh>(gResources()._createResourceHandle(meshPtr));
+	}
+
+	HMesh Mesh::create(const MESH_DESC& desc)
+	{
+		SPtr<Mesh> meshPtr = _createPtr(desc);
+		return static_resource_cast<Mesh>(gResources()._createResourceHandle(meshPtr));
+	}
+
+	HMesh Mesh::create(const SPtr<MeshData>& initialMeshData, const MESH_DESC& desc)
+	{
+		SPtr<Mesh> meshPtr = _createPtr(initialMeshData, desc);
+		return static_resource_cast<Mesh>(gResources()._createResourceHandle(meshPtr));
+	}
+
+	HMesh Mesh::create(const SPtr<MeshData>& initialMeshData, int usage, DrawOperationType drawOp)
+	{
+		SPtr<Mesh> meshPtr = _createPtr(initialMeshData, usage, drawOp);
+		return static_resource_cast<Mesh>(gResources()._createResourceHandle(meshPtr));
+	}
+
+	SPtr<Mesh> Mesh::_createPtr(const MESH_DESC& desc)
+	{
+		SPtr<Mesh> mesh = bs_core_ptr<Mesh>(new (bs_alloc<Mesh>()) Mesh(desc));
+		mesh->_setThisPtr(mesh);
+		mesh->initialize();
+
+		return mesh;
+	}
+
+	SPtr<Mesh> Mesh::_createPtr(const SPtr<MeshData>& initialMeshData, const MESH_DESC& desc)
+	{
+		SPtr<Mesh> mesh = bs_core_ptr<Mesh>(new (bs_alloc<Mesh>()) Mesh(initialMeshData, desc));
+		mesh->_setThisPtr(mesh);
+		mesh->initialize();
+
+		return mesh;
+	}
+
+	SPtr<Mesh> Mesh::_createPtr(const SPtr<MeshData>& initialMeshData, int usage, DrawOperationType drawOp)
+	{
+		MESH_DESC desc;
+		desc.usage = usage;
+		desc.subMeshes.push_back(SubMesh(0, initialMeshData->getNumIndices(), drawOp));
+
+		SPtr<Mesh> mesh = bs_core_ptr<Mesh>(new (bs_alloc<Mesh>()) Mesh(initialMeshData, desc));
+		mesh->_setThisPtr(mesh);
+		mesh->initialize();
+
+		return mesh;
+	}
+
+	SPtr<Mesh> Mesh::createEmpty()
+	{
+		SPtr<Mesh> mesh = bs_core_ptr<Mesh>(new (bs_alloc<Mesh>()) Mesh());
+		mesh->_setThisPtr(mesh);
+
+		return mesh;
+	}
+
+	namespace ct
+	{
 	MeshCore::MeshCore(const SPtr<MeshData>& initialMeshData, const MESH_DESC& desc, GpuDeviceFlags deviceMask)
 	MeshCore::MeshCore(const SPtr<MeshData>& initialMeshData, const MESH_DESC& desc, GpuDeviceFlags deviceMask)
 		: MeshCoreBase(desc.numVertices, desc.numIndices, desc.subMeshes), mVertexData(nullptr), mIndexBuffer(nullptr)
 		: MeshCoreBase(desc.numVertices, desc.numIndices, desc.subMeshes), mVertexData(nullptr), mIndexBuffer(nullptr)
 		, mVertexDesc(desc.vertexDesc), mUsage(desc.usage), mIndexType(desc.indexType), mDeviceMask(deviceMask)
 		, mVertexDesc(desc.vertexDesc), mUsage(desc.usage), mIndexType(desc.indexType), mDeviceMask(deviceMask)
@@ -183,464 +460,190 @@ namespace bs
 					if (!meshData.getVertexDesc()->hasElement(VES_COLOR, semanticIdx, i))
 					if (!meshData.getVertexDesc()->hasElement(VES_COLOR, semanticIdx, i))
 						continue;
 						continue;
 
 
-					UINT8* colorData = bufferCopy + mVertexDesc->getElementOffsetFromStream(VES_COLOR, semanticIdx, i);
-					for (UINT32 j = 0; j < mVertexData->vertexCount; j++)
-					{
-						UINT32* curColor = (UINT32*)colorData;
-
-						(*curColor) = ((*curColor) & 0xFF00FF00) | ((*curColor >> 16) & 0x000000FF) | ((*curColor << 16) & 0x00FF0000);
-
-						colorData += vertexStride;
-					}
-				}
-
-				vertexBuffer->writeData(0, bufferSize, bufferCopy, discardEntireBuffer ? BWT_DISCARD : BWT_NORMAL, queueIdx);
-
-				bs_free(bufferCopy);
-			}
-			else
-			{
-				vertexBuffer->writeData(0, bufferSize, srcVertBufferData, discardEntireBuffer ? BWT_DISCARD : BWT_NORMAL, 
-					queueIdx);
-			}
-		}
-
-		if (performUpdateBounds)
-			updateBounds(meshData);
-	}
-
-	void MeshCore::readData(MeshData& meshData, UINT32 deviceIdx, UINT32 queueIdx)
-	{
-		THROW_IF_NOT_CORE_THREAD;
-
-		IndexType indexType = IT_32BIT;
-		if (mIndexBuffer)
-			indexType = mIndexBuffer->getProperties().getType();
-
-		if (mIndexBuffer)
-		{
-			const IndexBufferProperties& ibProps = mIndexBuffer->getProperties();
-
-			if (meshData.getIndexElementSize() != ibProps.getIndexSize())
-			{
-				LOGERR("Provided index size doesn't match meshes index size. Needed: " +
-					toString(ibProps.getIndexSize()) + ". Got: " + toString(meshData.getIndexElementSize()));
-				return;
-			}
-
-			UINT8* idxData = static_cast<UINT8*>(mIndexBuffer->lock(GBL_READ_ONLY, deviceIdx, queueIdx));
-			UINT32 idxElemSize = ibProps.getIndexSize();
-
-			UINT8* indices = nullptr;
-
-			if (indexType == IT_16BIT)
-				indices = (UINT8*)meshData.getIndices16();
-			else
-				indices = (UINT8*)meshData.getIndices32();
-
-			UINT32 numIndicesToCopy = std::min(mProperties.mNumIndices, meshData.getNumIndices());
-
-			UINT32 indicesSize = numIndicesToCopy * idxElemSize;
-			if (indicesSize > meshData.getIndexBufferSize())
-			{
-				LOGERR("Provided buffer doesn't have enough space to store mesh indices.");
-				return;
-			}
-
-			memcpy(indices, idxData, numIndicesToCopy * idxElemSize);
-
-			mIndexBuffer->unlock();
-		}
-
-		if (mVertexData)
-		{
-			auto vertexBuffers = mVertexData->getBuffers();
-
-			UINT32 streamIdx = 0;
-			for (auto iter = vertexBuffers.begin(); iter != vertexBuffers.end(); ++iter)
-			{
-				if (!meshData.getVertexDesc()->hasStream(streamIdx))
-					continue;
-
-				SPtr<VertexBufferCore> vertexBuffer = iter->second;
-				const VertexBufferProperties& vbProps = vertexBuffer->getProperties();
-
-				// Ensure both have the same sized vertices
-				UINT32 myVertSize = mVertexDesc->getVertexStride(streamIdx);
-				UINT32 otherVertSize = meshData.getVertexDesc()->getVertexStride(streamIdx);
-				if (myVertSize != otherVertSize)
-				{
-					LOGERR("Provided vertex size for stream " + toString(streamIdx) + " doesn't match meshes vertex size. Needed: " +
-						toString(myVertSize) + ". Got: " + toString(otherVertSize));
-
-					continue;
-				}
-
-				UINT32 numVerticesToCopy = meshData.getNumVertices();
-				UINT32 bufferSize = vbProps.getVertexSize() * numVerticesToCopy;
-
-				if (bufferSize > vertexBuffer->getSize())
-				{
-					LOGERR("Vertex buffer values for stream \"" + toString(streamIdx) + "\" are being read out of valid range.");
-					continue;
-				}
-
-				UINT8* vertDataPtr = static_cast<UINT8*>(vertexBuffer->lock(GBL_READ_ONLY, deviceIdx, queueIdx));
-
-				UINT8* dest = meshData.getStreamData(streamIdx);
-				memcpy(dest, vertDataPtr, bufferSize);
-
-				vertexBuffer->unlock();
-
-				streamIdx++;
-			}
-		}
-	}
-
-	void MeshCore::updateBounds(const MeshData& meshData)
-	{
-		mProperties.mBounds = meshData.calculateBounds();
-		
-		// TODO - Sync this to sim-thread possibly?
-	}
-
-	SPtr<MeshCore> MeshCore::create(UINT32 numVertices, UINT32 numIndices, const SPtr<VertexDataDesc>& vertexDesc,
-		int usage, DrawOperationType drawOp, IndexType indexType, GpuDeviceFlags deviceMask)
-	{
-		MESH_DESC desc;
-		desc.numVertices = numVertices;
-		desc.numIndices = numIndices;
-		desc.vertexDesc = vertexDesc;
-		desc.subMeshes.push_back(SubMesh(0, numIndices, drawOp));
-		desc.usage = usage;
-		desc.indexType = indexType;
-
-		SPtr<MeshCore> mesh = bs_shared_ptr<MeshCore>(new (bs_alloc<MeshCore>()) MeshCore(nullptr, desc, deviceMask));
-		mesh->_setThisPtr(mesh);
-		mesh->initialize();
-
-		return mesh;
-	}
-
-	SPtr<MeshCore> MeshCore::create(const MESH_DESC& desc, GpuDeviceFlags deviceMask)
-	{
-		SPtr<MeshCore> mesh = bs_shared_ptr<MeshCore>(new (bs_alloc<MeshCore>()) MeshCore(nullptr, desc, deviceMask));
-
-		mesh->_setThisPtr(mesh);
-		mesh->initialize();
-
-		return mesh;
-	}
-
-	SPtr<MeshCore> MeshCore::create(const SPtr<MeshData>& initialMeshData, const MESH_DESC& desc, GpuDeviceFlags deviceMask)
-	{
-		MESH_DESC descCopy = desc;
-		descCopy.numVertices = initialMeshData->getNumVertices();
-		descCopy.numIndices = initialMeshData->getNumIndices();
-		descCopy.vertexDesc = initialMeshData->getVertexDesc();
-		descCopy.indexType = initialMeshData->getIndexType();
-
-		SPtr<MeshCore> mesh = 
-			bs_shared_ptr<MeshCore>(new (bs_alloc<MeshCore>()) MeshCore(initialMeshData, descCopy, deviceMask));
-
-		mesh->_setThisPtr(mesh);
-		mesh->initialize();
-
-		return mesh;
-	}
-
-	SPtr<MeshCore> MeshCore::create(const SPtr<MeshData>& initialMeshData, int usage, DrawOperationType drawOp, 
-		GpuDeviceFlags deviceMask)
-	{
-		MESH_DESC desc;
-		desc.numVertices = initialMeshData->getNumVertices();
-		desc.numIndices = initialMeshData->getNumIndices();
-		desc.vertexDesc = initialMeshData->getVertexDesc();
-		desc.indexType = initialMeshData->getIndexType();
-		desc.subMeshes.push_back(SubMesh(0, initialMeshData->getNumIndices(), drawOp));
-		desc.usage = usage;
-
-		SPtr<MeshCore> mesh = 
-			bs_shared_ptr<MeshCore>(new (bs_alloc<MeshCore>()) MeshCore(initialMeshData, desc, deviceMask));
-
-		mesh->_setThisPtr(mesh);
-		mesh->initialize();
-
-		return mesh;
-	}
-
-	Mesh::Mesh(const MESH_DESC& desc)
-		:MeshBase(desc.numVertices, desc.numIndices, desc.subMeshes), mVertexDesc(desc.vertexDesc), mUsage(desc.usage),
-		mIndexType(desc.indexType), mSkeleton(desc.skeleton), mMorphShapes(desc.morphShapes)
-	{
-
-	}
-
-	Mesh::Mesh(const SPtr<MeshData>& initialMeshData, const MESH_DESC& desc)
-		:MeshBase(initialMeshData->getNumVertices(), initialMeshData->getNumIndices(), desc.subMeshes),
-		mCPUData(initialMeshData), mVertexDesc(initialMeshData->getVertexDesc()),
-		mUsage(desc.usage), mIndexType(initialMeshData->getIndexType()), mSkeleton(desc.skeleton), 
-		mMorphShapes(desc.morphShapes)
-	{
-
-	}
-
-	Mesh::Mesh()
-		:MeshBase(0, 0, DOT_TRIANGLE_LIST), mUsage(MU_STATIC), mIndexType(IT_32BIT)
-	{
-
-	}
-
-	Mesh::~Mesh()
-	{
-		
-	}
-
-	AsyncOp Mesh::writeData(const SPtr<MeshData>& data, bool discardEntireBuffer)
-	{
-		updateBounds(*data);
-		updateCPUBuffer(0, *data);
-
-		data->_lock();
-
-		std::function<void(const SPtr<MeshCore>&, const SPtr<MeshData>&, bool, AsyncOp&)> func =
-			[&](const SPtr<MeshCore>& mesh, const SPtr<MeshData>& _meshData, bool _discardEntireBuffer, AsyncOp& asyncOp)
-		{
-			mesh->writeData(*_meshData, _discardEntireBuffer, false);
-			_meshData->_unlock();
-			asyncOp._completeOperation();
-
-		};
-
-		return gCoreThread().queueReturnCommand(std::bind(func, getCore(),
-			 data, discardEntireBuffer, std::placeholders::_1));
-	}
-
-	AsyncOp Mesh::readData(const SPtr<MeshData>& data)
-	{
-		data->_lock();
-
-		std::function<void(const SPtr<MeshCore>&, const SPtr<MeshData>&, AsyncOp&)> func =
-			[&](const SPtr<MeshCore>& mesh, const SPtr<MeshData>& _meshData, AsyncOp& asyncOp)
-		{
-			// Make sure any queued command start executing before reading
-			RenderAPICore::instance().submitCommandBuffer(nullptr);
-
-			mesh->readData(*_meshData);
-			_meshData->_unlock();
-			asyncOp._completeOperation();
+					UINT8* colorData = bufferCopy + mVertexDesc->getElementOffsetFromStream(VES_COLOR, semanticIdx, i);
+					for (UINT32 j = 0; j < mVertexData->vertexCount; j++)
+					{
+						UINT32* curColor = (UINT32*)colorData;
 
 
-		};
+						(*curColor) = ((*curColor) & 0xFF00FF00) | ((*curColor >> 16) & 0x000000FF) | ((*curColor << 16) & 0x00FF0000);
 
 
-		return gCoreThread().queueReturnCommand(std::bind(func, getCore(),
-			data, std::placeholders::_1));
-	}
+						colorData += vertexStride;
+					}
+				}
 
 
-	SPtr<MeshData> Mesh::allocBuffer() const
-	{
-		SPtr<MeshData> meshData = bs_shared_ptr_new<MeshData>(mProperties.mNumVertices, mProperties.mNumIndices, 
-			mVertexDesc, mIndexType);
+				vertexBuffer->writeData(0, bufferSize, bufferCopy, discardEntireBuffer ? BWT_DISCARD : BWT_NORMAL, queueIdx);
 
 
-		return meshData;
+				bs_free(bufferCopy);
+			}
+			else
+			{
+				vertexBuffer->writeData(0, bufferSize, srcVertBufferData, discardEntireBuffer ? BWT_DISCARD : BWT_NORMAL, 
+					queueIdx);
+			}
+		}
+
+		if (performUpdateBounds)
+			updateBounds(meshData);
 	}
 	}
 
 
-	void Mesh::initialize()
+	void MeshCore::readData(MeshData& meshData, UINT32 deviceIdx, UINT32 queueIdx)
 	{
 	{
-		if (mCPUData != nullptr)
-			updateBounds(*mCPUData);
-
-		MeshBase::initialize();
+		THROW_IF_NOT_CORE_THREAD;
 
 
-		if ((mUsage & MU_CPUCACHED) != 0 && mCPUData == nullptr)
-			createCPUBuffer();
-	}
+		IndexType indexType = IT_32BIT;
+		if (mIndexBuffer)
+			indexType = mIndexBuffer->getProperties().getType();
 
 
-	void Mesh::updateBounds(const MeshData& meshData)
-	{
-		mProperties.mBounds = meshData.calculateBounds();
-		markCoreDirty();
-	}
+		if (mIndexBuffer)
+		{
+			const IndexBufferProperties& ibProps = mIndexBuffer->getProperties();
 
 
-	SPtr<MeshCore> Mesh::getCore() const
-	{
-		return std::static_pointer_cast<MeshCore>(mCoreSpecific);
-	}
+			if (meshData.getIndexElementSize() != ibProps.getIndexSize())
+			{
+				LOGERR("Provided index size doesn't match meshes index size. Needed: " +
+					toString(ibProps.getIndexSize()) + ". Got: " + toString(meshData.getIndexElementSize()));
+				return;
+			}
 
 
-	SPtr<CoreObjectCore> Mesh::createCore() const
-	{
-		MESH_DESC desc;
-		desc.numVertices = mProperties.mNumVertices;
-		desc.numIndices = mProperties.mNumIndices;
-		desc.vertexDesc = mVertexDesc;
-		desc.subMeshes = mProperties.mSubMeshes;
-		desc.usage = mUsage;
-		desc.indexType = mIndexType;
-		desc.skeleton = mSkeleton;
-		desc.morphShapes = mMorphShapes;
+			UINT8* idxData = static_cast<UINT8*>(mIndexBuffer->lock(GBL_READ_ONLY, deviceIdx, queueIdx));
+			UINT32 idxElemSize = ibProps.getIndexSize();
 
 
-		MeshCore* obj = new (bs_alloc<MeshCore>()) MeshCore(mCPUData, desc, GDF_DEFAULT);
+			UINT8* indices = nullptr;
 
 
-		SPtr<CoreObjectCore> meshCore = bs_shared_ptr<MeshCore>(obj);
-		meshCore->_setThisPtr(meshCore);
+			if (indexType == IT_16BIT)
+				indices = (UINT8*)meshData.getIndices16();
+			else
+				indices = (UINT8*)meshData.getIndices32();
 
 
-		if ((mUsage & MU_CPUCACHED) == 0)
-			mCPUData = nullptr;
+			UINT32 numIndicesToCopy = std::min(mProperties.mNumIndices, meshData.getNumIndices());
 
 
-		return meshCore;
-	}
+			UINT32 indicesSize = numIndicesToCopy * idxElemSize;
+			if (indicesSize > meshData.getIndexBufferSize())
+			{
+				LOGERR("Provided buffer doesn't have enough space to store mesh indices.");
+				return;
+			}
 
 
-	void Mesh::updateCPUBuffer(UINT32 subresourceIdx, const MeshData& pixelData)
-	{
-		if ((mUsage & MU_CPUCACHED) == 0)
-			return;
+			memcpy(indices, idxData, numIndicesToCopy * idxElemSize);
 
 
-		if (subresourceIdx > 0)
-		{
-			LOGERR("Invalid subresource index: " + toString(subresourceIdx) + ". Supported range: 0 .. 1.");
-			return;
+			mIndexBuffer->unlock();
 		}
 		}
 
 
-		if (pixelData.getNumIndices() != mProperties.getNumIndices() ||
-			pixelData.getNumVertices() != mProperties.getNumVertices() ||
-			pixelData.getIndexType() != mIndexType ||
-			pixelData.getVertexDesc()->getVertexStride() != mVertexDesc->getVertexStride())
+		if (mVertexData)
 		{
 		{
-			LOGERR("Provided buffer is not of valid dimensions or format in order to update this mesh.");
-			return;
-		}
-
-		if (mCPUData->getSize() != pixelData.getSize())
-			BS_EXCEPT(InternalErrorException, "Buffer sizes don't match.");
+			auto vertexBuffers = mVertexData->getBuffers();
 
 
-		UINT8* dest = mCPUData->getData();
-		UINT8* src = pixelData.getData();
+			UINT32 streamIdx = 0;
+			for (auto iter = vertexBuffers.begin(); iter != vertexBuffers.end(); ++iter)
+			{
+				if (!meshData.getVertexDesc()->hasStream(streamIdx))
+					continue;
 
 
-		memcpy(dest, src, pixelData.getSize());
-	}
+				SPtr<VertexBufferCore> vertexBuffer = iter->second;
+				const VertexBufferProperties& vbProps = vertexBuffer->getProperties();
 
 
-	void Mesh::readCachedData(MeshData& dest)
-	{
-		if ((mUsage & MU_CPUCACHED) == 0)
-		{
-			LOGERR("Attempting to read CPU data from a mesh that is created without CPU caching.");
-			return;
-		}
+				// Ensure both have the same sized vertices
+				UINT32 myVertSize = mVertexDesc->getVertexStride(streamIdx);
+				UINT32 otherVertSize = meshData.getVertexDesc()->getVertexStride(streamIdx);
+				if (myVertSize != otherVertSize)
+				{
+					LOGERR("Provided vertex size for stream " + toString(streamIdx) + " doesn't match meshes vertex size. Needed: " +
+						toString(myVertSize) + ". Got: " + toString(otherVertSize));
 
 
-		if (dest.getNumIndices() != mProperties.getNumIndices() ||
-			dest.getNumVertices() != mProperties.getNumVertices() ||
-			dest.getIndexType() != mIndexType ||
-			dest.getVertexDesc()->getVertexStride() != mVertexDesc->getVertexStride())
-		{
-			LOGERR("Provided buffer is not of valid dimensions or format in order to read from this mesh.");
-			return;
-		}
-		
-		if (mCPUData->getSize() != dest.getSize())
-			BS_EXCEPT(InternalErrorException, "Buffer sizes don't match.");
+					continue;
+				}
 
 
-		UINT8* srcPtr = mCPUData->getData();
-		UINT8* destPtr = dest.getData();
+				UINT32 numVerticesToCopy = meshData.getNumVertices();
+				UINT32 bufferSize = vbProps.getVertexSize() * numVerticesToCopy;
 
 
-		memcpy(destPtr, srcPtr, dest.getSize());
-	}
+				if (bufferSize > vertexBuffer->getSize())
+				{
+					LOGERR("Vertex buffer values for stream \"" + toString(streamIdx) + "\" are being read out of valid range.");
+					continue;
+				}
 
 
-	void Mesh::createCPUBuffer()
-	{
-		mCPUData = allocBuffer();
-	}
+				UINT8* vertDataPtr = static_cast<UINT8*>(vertexBuffer->lock(GBL_READ_ONLY, deviceIdx, queueIdx));
 
 
-	HMesh Mesh::dummy()
-	{
-		return MeshManager::instance().getDummyMesh();
-	}
+				UINT8* dest = meshData.getStreamData(streamIdx);
+				memcpy(dest, vertDataPtr, bufferSize);
 
 
-	/************************************************************************/
-	/* 								SERIALIZATION                      		*/
-	/************************************************************************/
+				vertexBuffer->unlock();
 
 
-	RTTITypeBase* Mesh::getRTTIStatic()
-	{
-		return MeshRTTI::instance();
+				streamIdx++;
+			}
+		}
 	}
 	}
 
 
-	RTTITypeBase* Mesh::getRTTI() const
+	void MeshCore::updateBounds(const MeshData& meshData)
 	{
 	{
-		return Mesh::getRTTIStatic();
+		mProperties.mBounds = meshData.calculateBounds();
+		
+		// TODO - Sync this to sim-thread possibly?
 	}
 	}
 
 
-	/************************************************************************/
-	/* 								STATICS		                     		*/
-	/************************************************************************/
-
-	HMesh Mesh::create(UINT32 numVertices, UINT32 numIndices, const SPtr<VertexDataDesc>& vertexDesc, 
-		int usage, DrawOperationType drawOp, IndexType indexType)
+	SPtr<MeshCore> MeshCore::create(UINT32 numVertices, UINT32 numIndices, const SPtr<VertexDataDesc>& vertexDesc,
+		int usage, DrawOperationType drawOp, IndexType indexType, GpuDeviceFlags deviceMask)
 	{
 	{
 		MESH_DESC desc;
 		MESH_DESC desc;
 		desc.numVertices = numVertices;
 		desc.numVertices = numVertices;
 		desc.numIndices = numIndices;
 		desc.numIndices = numIndices;
 		desc.vertexDesc = vertexDesc;
 		desc.vertexDesc = vertexDesc;
-		desc.usage = usage;
 		desc.subMeshes.push_back(SubMesh(0, numIndices, drawOp));
 		desc.subMeshes.push_back(SubMesh(0, numIndices, drawOp));
+		desc.usage = usage;
 		desc.indexType = indexType;
 		desc.indexType = indexType;
 
 
-		SPtr<Mesh> meshPtr = _createPtr(desc);
-		return static_resource_cast<Mesh>(gResources()._createResourceHandle(meshPtr));
-	}
-
-	HMesh Mesh::create(const MESH_DESC& desc)
-	{
-		SPtr<Mesh> meshPtr = _createPtr(desc);
-		return static_resource_cast<Mesh>(gResources()._createResourceHandle(meshPtr));
-	}
+		SPtr<MeshCore> mesh = bs_shared_ptr<MeshCore>(new (bs_alloc<MeshCore>()) MeshCore(nullptr, desc, deviceMask));
+		mesh->_setThisPtr(mesh);
+		mesh->initialize();
 
 
-	HMesh Mesh::create(const SPtr<MeshData>& initialMeshData, const MESH_DESC& desc)
-	{
-		SPtr<Mesh> meshPtr = _createPtr(initialMeshData, desc);
-		return static_resource_cast<Mesh>(gResources()._createResourceHandle(meshPtr));
+		return mesh;
 	}
 	}
 
 
-	HMesh Mesh::create(const SPtr<MeshData>& initialMeshData, int usage, DrawOperationType drawOp)
+	SPtr<MeshCore> MeshCore::create(const MESH_DESC& desc, GpuDeviceFlags deviceMask)
 	{
 	{
-		SPtr<Mesh> meshPtr = _createPtr(initialMeshData, usage, drawOp);
-		return static_resource_cast<Mesh>(gResources()._createResourceHandle(meshPtr));
-	}
+		SPtr<MeshCore> mesh = bs_shared_ptr<MeshCore>(new (bs_alloc<MeshCore>()) MeshCore(nullptr, desc, deviceMask));
 
 
-	SPtr<Mesh> Mesh::_createPtr(const MESH_DESC& desc)
-	{
-		SPtr<Mesh> mesh = bs_core_ptr<Mesh>(new (bs_alloc<Mesh>()) Mesh(desc));
 		mesh->_setThisPtr(mesh);
 		mesh->_setThisPtr(mesh);
 		mesh->initialize();
 		mesh->initialize();
 
 
 		return mesh;
 		return mesh;
 	}
 	}
 
 
-	SPtr<Mesh> Mesh::_createPtr(const SPtr<MeshData>& initialMeshData, const MESH_DESC& desc)
+	SPtr<MeshCore> MeshCore::create(const SPtr<MeshData>& initialMeshData, const MESH_DESC& desc, GpuDeviceFlags deviceMask)
 	{
 	{
-		SPtr<Mesh> mesh = bs_core_ptr<Mesh>(new (bs_alloc<Mesh>()) Mesh(initialMeshData, desc));
+		MESH_DESC descCopy = desc;
+		descCopy.numVertices = initialMeshData->getNumVertices();
+		descCopy.numIndices = initialMeshData->getNumIndices();
+		descCopy.vertexDesc = initialMeshData->getVertexDesc();
+		descCopy.indexType = initialMeshData->getIndexType();
+
+		SPtr<MeshCore> mesh = 
+			bs_shared_ptr<MeshCore>(new (bs_alloc<MeshCore>()) MeshCore(initialMeshData, descCopy, deviceMask));
+
 		mesh->_setThisPtr(mesh);
 		mesh->_setThisPtr(mesh);
 		mesh->initialize();
 		mesh->initialize();
 
 
 		return mesh;
 		return mesh;
 	}
 	}
 
 
-	SPtr<Mesh> Mesh::_createPtr(const SPtr<MeshData>& initialMeshData, int usage, DrawOperationType drawOp)
+	SPtr<MeshCore> MeshCore::create(const SPtr<MeshData>& initialMeshData, int usage, DrawOperationType drawOp, 
+		GpuDeviceFlags deviceMask)
 	{
 	{
 		MESH_DESC desc;
 		MESH_DESC desc;
-		desc.usage = usage;
+		desc.numVertices = initialMeshData->getNumVertices();
+		desc.numIndices = initialMeshData->getNumIndices();
+		desc.vertexDesc = initialMeshData->getVertexDesc();
+		desc.indexType = initialMeshData->getIndexType();
 		desc.subMeshes.push_back(SubMesh(0, initialMeshData->getNumIndices(), drawOp));
 		desc.subMeshes.push_back(SubMesh(0, initialMeshData->getNumIndices(), drawOp));
+		desc.usage = usage;
+
+		SPtr<MeshCore> mesh = 
+			bs_shared_ptr<MeshCore>(new (bs_alloc<MeshCore>()) MeshCore(initialMeshData, desc, deviceMask));
 
 
-		SPtr<Mesh> mesh = bs_core_ptr<Mesh>(new (bs_alloc<Mesh>()) Mesh(initialMeshData, desc));
 		mesh->_setThisPtr(mesh);
 		mesh->_setThisPtr(mesh);
 		mesh->initialize();
 		mesh->initialize();
 
 
 		return mesh;
 		return mesh;
 	}
 	}
-
-	SPtr<Mesh> Mesh::createEmpty()
-	{
-		SPtr<Mesh> mesh = bs_core_ptr<Mesh>(new (bs_alloc<Mesh>()) Mesh());
-		mesh->_setThisPtr(mesh);
-
-		return mesh;
 	}
 	}
 }
 }

+ 14 - 12
Source/BansheeCore/Source/BsMeshBase.cpp

@@ -4,7 +4,6 @@
 #include "BsMeshBaseRTTI.h"
 #include "BsMeshBaseRTTI.h"
 #include "BsCoreThread.h"
 #include "BsCoreThread.h"
 #include "BsFrameAlloc.h"
 #include "BsFrameAlloc.h"
-#include "BsDebug.h"
 
 
 namespace bs
 namespace bs
 {
 {
@@ -42,15 +41,6 @@ namespace bs
 		return (UINT32)mSubMeshes.size();
 		return (UINT32)mSubMeshes.size();
 	}
 	}
 
 
-	MeshCoreBase::MeshCoreBase(UINT32 numVertices, UINT32 numIndices, const Vector<SubMesh>& subMeshes)
-		:mProperties(numVertices, numIndices, subMeshes)
-	{ }
-
-	void MeshCoreBase::syncToCore(const CoreSyncData& data)
-	{
-		mProperties.mBounds = data.getData<Bounds>();
-	}
-
 	MeshBase::MeshBase(UINT32 numVertices, UINT32 numIndices, DrawOperationType drawOp)
 	MeshBase::MeshBase(UINT32 numVertices, UINT32 numIndices, DrawOperationType drawOp)
 		:mProperties(numVertices, numIndices, drawOp)
 		:mProperties(numVertices, numIndices, drawOp)
 	{ }
 	{ }
@@ -71,9 +61,9 @@ namespace bs
 		return CoreSyncData(buffer, size);
 		return CoreSyncData(buffer, size);
 	}
 	}
 
 
-	SPtr<MeshCoreBase> MeshBase::getCore() const
+	SPtr<ct::MeshCoreBase> MeshBase::getCore() const
 	{
 	{
-		return std::static_pointer_cast<MeshCoreBase>(mCoreSpecific);
+		return std::static_pointer_cast<ct::MeshCoreBase>(mCoreSpecific);
 	}
 	}
 
 
 	/************************************************************************/
 	/************************************************************************/
@@ -89,4 +79,16 @@ namespace bs
 	{
 	{
 		return MeshBase::getRTTIStatic();
 		return MeshBase::getRTTIStatic();
 	}
 	}
+
+	namespace ct
+	{
+	MeshCoreBase::MeshCoreBase(UINT32 numVertices, UINT32 numIndices, const Vector<SubMesh>& subMeshes)
+		:mProperties(numVertices, numIndices, subMeshes)
+	{ }
+
+	void MeshCoreBase::syncToCore(const CoreSyncData& data)
+	{
+		mProperties.mBounds = data.getData<Bounds>();
+	}
+	}
 }
 }

+ 67 - 64
Source/BansheeCore/Source/BsMeshHeap.cpp

@@ -13,6 +13,73 @@
 
 
 namespace bs
 namespace bs
 {
 {
+	MeshHeap::MeshHeap(UINT32 numVertices, UINT32 numIndices, 
+		const SPtr<VertexDataDesc>& vertexDesc, IndexType indexType)
+		:mNumVertices(numVertices), mNumIndices(numIndices), mVertexDesc(vertexDesc), mIndexType(indexType), mNextFreeId(0)
+	{
+	}
+
+	SPtr<MeshHeap> MeshHeap::create(UINT32 numVertices, UINT32 numIndices, const SPtr<VertexDataDesc>& vertexDesc, 
+		IndexType indexType)
+	{
+		MeshHeap* meshHeap = new (bs_alloc<MeshHeap>()) MeshHeap(numVertices, numIndices, vertexDesc, indexType); 
+		SPtr<MeshHeap> meshHeapPtr = bs_core_ptr<MeshHeap>(meshHeap);
+
+		meshHeapPtr->_setThisPtr(meshHeapPtr);
+		meshHeapPtr->initialize();
+
+		return meshHeapPtr;
+	}
+
+	SPtr<TransientMesh> MeshHeap::alloc(const SPtr<MeshData>& meshData, DrawOperationType drawOp)
+	{
+		UINT32 meshIdx = mNextFreeId++;
+
+		SPtr<MeshHeap> thisPtr = std::static_pointer_cast<MeshHeap>(getThisPtr());
+		TransientMesh* transientMesh = new (bs_alloc<TransientMesh>()) TransientMesh(thisPtr, meshIdx, 
+			meshData->getNumVertices(), meshData->getNumIndices(), drawOp); 
+		SPtr<TransientMesh> transientMeshPtr = bs_core_ptr<TransientMesh>(transientMesh);
+
+		transientMeshPtr->_setThisPtr(transientMeshPtr);
+		transientMeshPtr->initialize();
+
+		mMeshes[meshIdx] = transientMeshPtr;
+
+		queueGpuCommand(getCore(), std::bind(&ct::MeshHeapCore::alloc, getCore().get(), transientMeshPtr->getCore(), meshData));
+
+		return transientMeshPtr;
+	}
+
+	void MeshHeap::dealloc(const SPtr<TransientMesh>& mesh)
+	{
+		auto iterFind = mMeshes.find(mesh->mId);
+		if(iterFind == mMeshes.end())
+			return;
+
+		mesh->markAsDestroyed();
+		mMeshes.erase(iterFind);
+
+		queueGpuCommand(getCore(), std::bind(&ct::MeshHeapCore::dealloc, getCore().get(), mesh->getCore()));
+	}
+
+	SPtr<ct::MeshHeapCore> MeshHeap::getCore() const
+	{
+		return std::static_pointer_cast<ct::MeshHeapCore>(mCoreSpecific);
+	}
+
+	SPtr<ct::CoreObjectCore> MeshHeap::createCore() const
+	{
+		ct::MeshHeapCore* obj = new (bs_alloc<ct::MeshHeapCore>()) ct::MeshHeapCore(mNumVertices, mNumIndices,
+			mVertexDesc, mIndexType, GDF_DEFAULT);
+
+		SPtr<ct::MeshHeapCore> corePtr = bs_shared_ptr<ct::MeshHeapCore>(obj);
+		obj->_setThisPtr(corePtr);
+
+		return corePtr;
+	}
+
+	namespace ct
+	{
 	const float MeshHeapCore::GrowPercent = 1.5f;
 	const float MeshHeapCore::GrowPercent = 1.5f;
 
 
 	MeshHeapCore::MeshHeapCore(UINT32 numVertices, UINT32 numIndices,
 	MeshHeapCore::MeshHeapCore(UINT32 numVertices, UINT32 numIndices,
@@ -642,69 +709,5 @@ namespace bs
 			}
 			}
 		}
 		}
 	}
 	}
-
-	MeshHeap::MeshHeap(UINT32 numVertices, UINT32 numIndices, 
-		const SPtr<VertexDataDesc>& vertexDesc, IndexType indexType)
-		:mNumVertices(numVertices), mNumIndices(numIndices), mVertexDesc(vertexDesc), mIndexType(indexType), mNextFreeId(0)
-	{
-	}
-
-	SPtr<MeshHeap> MeshHeap::create(UINT32 numVertices, UINT32 numIndices, const SPtr<VertexDataDesc>& vertexDesc, 
-		IndexType indexType)
-	{
-		MeshHeap* meshHeap = new (bs_alloc<MeshHeap>()) MeshHeap(numVertices, numIndices, vertexDesc, indexType); 
-		SPtr<MeshHeap> meshHeapPtr = bs_core_ptr<MeshHeap>(meshHeap);
-
-		meshHeapPtr->_setThisPtr(meshHeapPtr);
-		meshHeapPtr->initialize();
-
-		return meshHeapPtr;
-	}
-
-	SPtr<TransientMesh> MeshHeap::alloc(const SPtr<MeshData>& meshData, DrawOperationType drawOp)
-	{
-		UINT32 meshIdx = mNextFreeId++;
-
-		SPtr<MeshHeap> thisPtr = std::static_pointer_cast<MeshHeap>(getThisPtr());
-		TransientMesh* transientMesh = new (bs_alloc<TransientMesh>()) TransientMesh(thisPtr, meshIdx, 
-			meshData->getNumVertices(), meshData->getNumIndices(), drawOp); 
-		SPtr<TransientMesh> transientMeshPtr = bs_core_ptr<TransientMesh>(transientMesh);
-
-		transientMeshPtr->_setThisPtr(transientMeshPtr);
-		transientMeshPtr->initialize();
-
-		mMeshes[meshIdx] = transientMeshPtr;
-
-		queueGpuCommand(getCore(), std::bind(&MeshHeapCore::alloc, getCore().get(), transientMeshPtr->getCore(), meshData));
-
-		return transientMeshPtr;
-	}
-
-	void MeshHeap::dealloc(const SPtr<TransientMesh>& mesh)
-	{
-		auto iterFind = mMeshes.find(mesh->mId);
-		if(iterFind == mMeshes.end())
-			return;
-
-		mesh->markAsDestroyed();
-		mMeshes.erase(iterFind);
-
-		queueGpuCommand(getCore(), std::bind(&MeshHeapCore::dealloc, getCore().get(), mesh->getCore()));
-	}
-
-	SPtr<MeshHeapCore> MeshHeap::getCore() const
-	{
-		return std::static_pointer_cast<MeshHeapCore>(mCoreSpecific);
-	}
-
-	SPtr<CoreObjectCore> MeshHeap::createCore() const
-	{
-		MeshHeapCore* obj = new (bs_alloc<MeshHeapCore>()) MeshHeapCore(mNumVertices, mNumIndices,
-			mVertexDesc, mIndexType, GDF_DEFAULT);
-
-		SPtr<MeshHeapCore> corePtr = bs_shared_ptr<MeshHeapCore>(obj);
-		obj->_setThisPtr(corePtr);
-
-		return corePtr;
 	}
 	}
 }
 }

+ 2 - 2
Source/BansheeCore/Source/BsOcclusionQuery.cpp

@@ -3,7 +3,7 @@
 #include "BsOcclusionQuery.h"
 #include "BsOcclusionQuery.h"
 #include "BsQueryManager.h"
 #include "BsQueryManager.h"
 
 
-namespace bs
+namespace bs { namespace ct
 {
 {
 	OcclusionQuery::OcclusionQuery(bool binary)
 	OcclusionQuery::OcclusionQuery(bool binary)
 		:mActive(false), mBinary(binary)
 		:mActive(false), mBinary(binary)
@@ -13,4 +13,4 @@ namespace bs
 	{
 	{
 		return QueryManager::instance().createOcclusionQuery(binary, deviceIdx);
 		return QueryManager::instance().createOcclusionQuery(binary, deviceIdx);
 	}
 	}
-}
+}}

+ 2 - 2
Source/BansheeCore/Source/BsParamBlocks.cpp

@@ -3,7 +3,7 @@
 #include "BsParamBlocks.h"
 #include "BsParamBlocks.h"
 #include "BsGpuParam.h"
 #include "BsGpuParam.h"
 
 
-namespace bs
+namespace bs { namespace ct
 {
 {
 	template<class T>
 	template<class T>
 	ParamBlockParam<T>::ParamBlockParam(const GpuParamDataDesc& paramDesc)
 	ParamBlockParam<T>::ParamBlockParam(const GpuParamDataDesc& paramDesc)
@@ -118,4 +118,4 @@ namespace bs
 		if (iterFind != sToInitialize.end())
 		if (iterFind != sToInitialize.end())
 			sToInitialize.erase(iterFind);
 			sToInitialize.erase(iterFind);
 	}
 	}
-}
+}}

+ 74 - 71
Source/BansheeCore/Source/BsPass.cpp

@@ -14,7 +14,7 @@
 namespace bs
 namespace bs
 {
 {
 	/** Converts a sim thread pass descriptor to a core thread one. */
 	/** Converts a sim thread pass descriptor to a core thread one. */
-	void convertPassDesc(const PASS_DESC& input, PASS_DESC_CORE& output)
+	void convertPassDesc(const PASS_DESC& input, ct::PASS_DESC_CORE& output)
 	{
 	{
 		output.blendState = input.blendState != nullptr ? input.blendState->getCore() : nullptr;
 		output.blendState = input.blendState != nullptr ? input.blendState->getCore() : nullptr;
 		output.rasterizerState = input.rasterizerState != nullptr ? input.rasterizerState->getCore() : nullptr;
 		output.rasterizerState = input.rasterizerState != nullptr ? input.rasterizerState->getCore() : nullptr;
@@ -42,7 +42,7 @@ namespace bs
 	}
 	}
 
 
 	/** Converts a sim thread pass descriptor to a core thread pipeline state descriptor. */
 	/** Converts a sim thread pass descriptor to a core thread pipeline state descriptor. */
-	void convertPassDesc(const PASS_DESC_CORE& input, PIPELINE_STATE_CORE_DESC& output)
+	void convertPassDesc(const ct::PASS_DESC_CORE& input, ct::PIPELINE_STATE_CORE_DESC& output)
 	{
 	{
 		output.blendState = input.blendState;
 		output.blendState = input.blendState;
 		output.rasterizerState = input.rasterizerState;
 		output.rasterizerState = input.rasterizerState;
@@ -95,93 +95,36 @@ namespace bs
 	template class TPass < false > ;
 	template class TPass < false > ;
 	template class TPass < true >;
 	template class TPass < true >;
 
 
-	PassCore::PassCore(const PASS_DESC_CORE& desc)
-		:TPass(desc)
-	{ }
-
-	PassCore::PassCore(const PASS_DESC_CORE& desc, const SPtr<GraphicsPipelineStateCore>& pipelineState)
-		:TPass(desc)
-	{
-		mGraphicsPipelineState = pipelineState;
-	}
-
-
-	PassCore::PassCore(const PASS_DESC_CORE& desc, const SPtr<ComputePipelineStateCore>& pipelineState)
-		:TPass(desc)
-	{
-		mComputePipelineState = pipelineState;
-	}
-
-	void PassCore::initialize()
-	{
-		if(hasComputeProgram())
-		{
-			if(mComputePipelineState == nullptr)
-				mComputePipelineState = ComputePipelineStateCore::create(getComputeProgram());
-		}
-		else
-		{
-			if (mGraphicsPipelineState == nullptr)
-			{
-				PIPELINE_STATE_CORE_DESC desc;
-				convertPassDesc(mData, desc);
-
-				mGraphicsPipelineState = GraphicsPipelineStateCore::create(desc);
-			}
-		}
-
-		CoreObjectCore::initialize();
-	}
-
-	void PassCore::syncToCore(const CoreSyncData& data)
-	{
-		UINT8* dataPtr = data.getBuffer();
-		PASS_DESC_CORE* desc = (PASS_DESC_CORE*)dataPtr;
-
-		mData = *desc;
-		desc->~PASS_DESC_CORE();
-	}
-
-	SPtr<PassCore> PassCore::create(const PASS_DESC_CORE& desc)
-	{
-		PassCore* newPass = new (bs_alloc<PassCore>()) PassCore(desc);
-		SPtr<PassCore> newPassPtr = bs_shared_ptr<PassCore>(newPass);
-		newPassPtr->_setThisPtr(newPassPtr);
-		newPassPtr->initialize();
-
-		return newPassPtr;
-	}
-
 	Pass::Pass(const PASS_DESC& desc)
 	Pass::Pass(const PASS_DESC& desc)
 		:TPass(desc)
 		:TPass(desc)
 	{ }
 	{ }
 
 
-	SPtr<PassCore> Pass::getCore() const
+	SPtr<ct::PassCore> Pass::getCore() const
 	{
 	{
-		return std::static_pointer_cast<PassCore>(mCoreSpecific);
+		return std::static_pointer_cast<ct::PassCore>(mCoreSpecific);
 	}
 	}
 
 
-	SPtr<CoreObjectCore> Pass::createCore() const
+	SPtr<ct::CoreObjectCore> Pass::createCore() const
 	{
 	{
-		PASS_DESC_CORE desc;
+		ct::PASS_DESC_CORE desc;
 		convertPassDesc(mData, desc);
 		convertPassDesc(mData, desc);
 
 
-		PassCore* pass;
+		ct::PassCore* pass;
 		if(mComputePipelineState != nullptr)
 		if(mComputePipelineState != nullptr)
 		{
 		{
-			SPtr<ComputePipelineStateCore> corePipeline = mComputePipelineState->getCore();
-			pass = new (bs_alloc<PassCore>()) PassCore(desc, corePipeline);
+			SPtr<ct::ComputePipelineStateCore> corePipeline = mComputePipelineState->getCore();
+			pass = new (bs_alloc<ct::PassCore>()) ct::PassCore(desc, corePipeline);
 		}
 		}
 		else
 		else
 		{
 		{
-			SPtr<GraphicsPipelineStateCore> corePipeline;
+			SPtr<ct::GraphicsPipelineStateCore> corePipeline;
 			if (mGraphicsPipelineState != nullptr)
 			if (mGraphicsPipelineState != nullptr)
 				corePipeline = mGraphicsPipelineState->getCore();
 				corePipeline = mGraphicsPipelineState->getCore();
 
 
-			pass = new (bs_alloc<PassCore>()) PassCore(desc, corePipeline);
+			pass = new (bs_alloc<ct::PassCore>()) ct::PassCore(desc, corePipeline);
 		}
 		}
 
 
-		SPtr<PassCore> passPtr = bs_shared_ptr<PassCore>(pass);
+		SPtr<ct::PassCore> passPtr = bs_shared_ptr<ct::PassCore>(pass);
 		passPtr->_setThisPtr(passPtr);
 		passPtr->_setThisPtr(passPtr);
 
 
 		return passPtr;
 		return passPtr;
@@ -207,10 +150,10 @@ namespace bs
 
 
 	CoreSyncData Pass::syncToCore(FrameAlloc* allocator)
 	CoreSyncData Pass::syncToCore(FrameAlloc* allocator)
 	{
 	{
-		UINT32 size = sizeof(PASS_DESC_CORE);
+		UINT32 size = sizeof(ct::PASS_DESC_CORE);
 
 
 		UINT8* data = allocator->alloc(size);
 		UINT8* data = allocator->alloc(size);
-		PASS_DESC_CORE* passDesc = new (data) PASS_DESC_CORE();
+		ct::PASS_DESC_CORE* passDesc = new (data) ct::PASS_DESC_CORE();
 		convertPassDesc(mData, *passDesc);
 		convertPassDesc(mData, *passDesc);
 
 
 		return CoreSyncData(data, size);
 		return CoreSyncData(data, size);
@@ -274,4 +217,64 @@ namespace bs
 	{
 	{
 		return Pass::getRTTIStatic();
 		return Pass::getRTTIStatic();
 	}
 	}
+
+	namespace ct
+	{
+	PassCore::PassCore(const PASS_DESC_CORE& desc)
+		:TPass(desc)
+	{ }
+
+	PassCore::PassCore(const PASS_DESC_CORE& desc, const SPtr<GraphicsPipelineStateCore>& pipelineState)
+		:TPass(desc)
+	{
+		mGraphicsPipelineState = pipelineState;
+	}
+
+
+	PassCore::PassCore(const PASS_DESC_CORE& desc, const SPtr<ComputePipelineStateCore>& pipelineState)
+		:TPass(desc)
+	{
+		mComputePipelineState = pipelineState;
+	}
+
+	void PassCore::initialize()
+	{
+		if(hasComputeProgram())
+		{
+			if(mComputePipelineState == nullptr)
+				mComputePipelineState = ComputePipelineStateCore::create(getComputeProgram());
+		}
+		else
+		{
+			if (mGraphicsPipelineState == nullptr)
+			{
+				PIPELINE_STATE_CORE_DESC desc;
+				convertPassDesc(mData, desc);
+
+				mGraphicsPipelineState = GraphicsPipelineStateCore::create(desc);
+			}
+		}
+
+		CoreObjectCore::initialize();
+	}
+
+	void PassCore::syncToCore(const CoreSyncData& data)
+	{
+		UINT8* dataPtr = data.getBuffer();
+		PASS_DESC_CORE* desc = (PASS_DESC_CORE*)dataPtr;
+
+		mData = *desc;
+		desc->~PASS_DESC_CORE();
+	}
+
+	SPtr<PassCore> PassCore::create(const PASS_DESC_CORE& desc)
+	{
+		PassCore* newPass = new (bs_alloc<PassCore>()) PassCore(desc);
+		SPtr<PassCore> newPassPtr = bs_shared_ptr<PassCore>(newPass);
+		newPassPtr->_setThisPtr(newPassPtr);
+		newPassPtr->initialize();
+
+		return newPassPtr;
+	}
+	}
 }
 }

+ 6 - 6
Source/BansheeCore/Source/BsProfilerGPU.cpp

@@ -179,30 +179,30 @@ namespace bs
 		sample.activeTimeQuery->end();
 		sample.activeTimeQuery->end();
 	}
 	}
 
 
-	SPtr<TimerQuery> ProfilerGPU::getTimerQuery() const
+	SPtr<ct::TimerQuery> ProfilerGPU::getTimerQuery() const
 	{
 	{
 		if (!mFreeTimerQueries.empty())
 		if (!mFreeTimerQueries.empty())
 		{
 		{
-			SPtr<TimerQuery> timerQuery = mFreeTimerQueries.top();
+			SPtr<ct::TimerQuery> timerQuery = mFreeTimerQueries.top();
 			mFreeTimerQueries.pop();
 			mFreeTimerQueries.pop();
 
 
 			return timerQuery;
 			return timerQuery;
 		}
 		}
 
 
-		return TimerQuery::create();
+		return ct::TimerQuery::create();
 	}
 	}
 
 
-	SPtr<OcclusionQuery> ProfilerGPU::getOcclusionQuery() const
+	SPtr<ct::OcclusionQuery> ProfilerGPU::getOcclusionQuery() const
 	{
 	{
 		if (!mFreeOcclusionQueries.empty())
 		if (!mFreeOcclusionQueries.empty())
 		{
 		{
-			SPtr<OcclusionQuery> occlusionQuery = mFreeOcclusionQueries.top();
+			SPtr<ct::OcclusionQuery> occlusionQuery = mFreeOcclusionQueries.top();
 			mFreeOcclusionQueries.pop();
 			mFreeOcclusionQueries.pop();
 
 
 			return occlusionQuery;
 			return occlusionQuery;
 		}
 		}
 
 
-		return OcclusionQuery::create(false);
+		return ct::OcclusionQuery::create(false);
 	}
 	}
 
 
 	ProfilerGPU& gProfilerGPU()
 	ProfilerGPU& gProfilerGPU()

+ 2 - 2
Source/BansheeCore/Source/BsQueryManager.cpp

@@ -6,7 +6,7 @@
 #include "BsOcclusionQuery.h"
 #include "BsOcclusionQuery.h"
 #include "BsProfilerCPU.h"
 #include "BsProfilerCPU.h"
 
 
-namespace bs
+namespace bs { namespace ct
 {
 {
 	QueryManager::QueryManager()
 	QueryManager::QueryManager()
 	{
 	{
@@ -123,4 +123,4 @@ namespace bs
 
 
 		mDeletedOcclusionQueries.clear();
 		mDeletedOcclusionQueries.clear();
 	}
 	}
-}
+}}

+ 44 - 41
Source/BansheeCore/Source/BsRasterizerState.cpp

@@ -25,43 +25,6 @@ namespace bs
 		:mData(desc), mHash(RasterizerState::generateHash(desc))
 		:mData(desc), mHash(RasterizerState::generateHash(desc))
 	{ }
 	{ }
 
 
-	RasterizerStateCore::RasterizerStateCore(const RASTERIZER_STATE_DESC& desc, UINT32 id)
-		: mProperties(desc), mId(id)
-	{
-
-	}
-
-	RasterizerStateCore::~RasterizerStateCore()
-	{
-
-	}
-
-	void RasterizerStateCore::initialize()
-	{
-		// Since we cache states it's possible this object was already initialized
-		// (i.e. multiple sim-states can share a single core-state)
-		if (isInitialized())
-			return;
-
-		createInternal();
-		CoreObjectCore::initialize();
-	}
-
-	const RasterizerProperties& RasterizerStateCore::getProperties() const
-	{
-		return mProperties;
-	}
-
-	SPtr<RasterizerStateCore> RasterizerStateCore::create(const RASTERIZER_STATE_DESC& desc)
-	{
-		return RenderStateCoreManager::instance().createRasterizerState(desc);
-	}
-
-	const SPtr<RasterizerStateCore>& RasterizerStateCore::getDefault()
-	{
-		return RenderStateCoreManager::instance().getDefaultRasterizerState();
-	}
-
 	RasterizerState::RasterizerState(const RASTERIZER_STATE_DESC& desc)
 	RasterizerState::RasterizerState(const RASTERIZER_STATE_DESC& desc)
 		: mProperties(desc), mId(0)
 		: mProperties(desc), mId(0)
 	{
 	{
@@ -73,14 +36,14 @@ namespace bs
 
 
 	}
 	}
 
 
-	SPtr<RasterizerStateCore> RasterizerState::getCore() const
+	SPtr<ct::RasterizerStateCore> RasterizerState::getCore() const
 	{
 	{
-		return std::static_pointer_cast<RasterizerStateCore>(mCoreSpecific);
+		return std::static_pointer_cast<ct::RasterizerStateCore>(mCoreSpecific);
 	}
 	}
 
 
-	SPtr<CoreObjectCore> RasterizerState::createCore() const
+	SPtr<ct::CoreObjectCore> RasterizerState::createCore() const
 	{
 	{
-		SPtr<RasterizerStateCore> core = RenderStateCoreManager::instance()._createRasterizerState(mProperties.mData);
+		SPtr<ct::RasterizerStateCore> core = ct::RenderStateCoreManager::instance()._createRasterizerState(mProperties.mData);
 		mId = core->getId(); // Accessing core from sim thread is okay here since core ID is immutable
 		mId = core->getId(); // Accessing core from sim thread is okay here since core ID is immutable
 
 
 		return core;
 		return core;
@@ -130,4 +93,44 @@ namespace bs
 	{
 	{
 		return RasterizerState::getRTTIStatic();
 		return RasterizerState::getRTTIStatic();
 	}
 	}
+
+	namespace ct
+	{
+	RasterizerStateCore::RasterizerStateCore(const RASTERIZER_STATE_DESC& desc, UINT32 id)
+		: mProperties(desc), mId(id)
+	{
+
+	}
+
+	RasterizerStateCore::~RasterizerStateCore()
+	{
+
+	}
+
+	void RasterizerStateCore::initialize()
+	{
+		// Since we cache states it's possible this object was already initialized
+		// (i.e. multiple sim-states can share a single core-state)
+		if (isInitialized())
+			return;
+
+		createInternal();
+		CoreObjectCore::initialize();
+	}
+
+	const RasterizerProperties& RasterizerStateCore::getProperties() const
+	{
+		return mProperties;
+	}
+
+	SPtr<RasterizerStateCore> RasterizerStateCore::create(const RASTERIZER_STATE_DESC& desc)
+	{
+		return RenderStateCoreManager::instance().createRasterizerState(desc);
+	}
+
+	const SPtr<RasterizerStateCore>& RasterizerStateCore::getDefault()
+	{
+		return RenderStateCoreManager::instance().getDefaultRasterizerState();
+	}
+	}
 }
 }

+ 28 - 25
Source/BansheeCore/Source/BsRenderAPI.cpp

@@ -19,131 +19,133 @@ namespace bs
 {
 {
 	void RenderAPI::setGpuParams(const SPtr<GpuParams>& gpuParams)
 	void RenderAPI::setGpuParams(const SPtr<GpuParams>& gpuParams)
 	{
 	{
-		gCoreThread().queueCommand(std::bind(&RenderAPICore::setGpuParams, RenderAPICore::instancePtr(), gpuParams->getCore(), 
+		gCoreThread().queueCommand(std::bind(&ct::RenderAPICore::setGpuParams, ct::RenderAPICore::instancePtr(), gpuParams->getCore(),
 			nullptr));
 			nullptr));
 	}
 	}
 
 
 	void RenderAPI::setGraphicsPipeline(const SPtr<GraphicsPipelineState>& pipelineState)
 	void RenderAPI::setGraphicsPipeline(const SPtr<GraphicsPipelineState>& pipelineState)
 	{
 	{
-		gCoreThread().queueCommand(std::bind(&RenderAPICore::setGraphicsPipeline, RenderAPICore::instancePtr(),
+		gCoreThread().queueCommand(std::bind(&ct::RenderAPICore::setGraphicsPipeline, ct::RenderAPICore::instancePtr(),
 			pipelineState->getCore(), nullptr));
 			pipelineState->getCore(), nullptr));
 	}
 	}
 
 
 	void RenderAPI::setComputePipeline(const SPtr<ComputePipelineState>& pipelineState)
 	void RenderAPI::setComputePipeline(const SPtr<ComputePipelineState>& pipelineState)
 	{
 	{
-		gCoreThread().queueCommand(std::bind(&RenderAPICore::setComputePipeline, RenderAPICore::instancePtr(),
+		gCoreThread().queueCommand(std::bind(&ct::RenderAPICore::setComputePipeline, ct::RenderAPICore::instancePtr(),
 							  pipelineState->getCore(), nullptr));
 							  pipelineState->getCore(), nullptr));
 	}
 	}
 
 
 	void RenderAPI::setVertexBuffers(UINT32 index, const Vector<SPtr<VertexBuffer>>& buffers)
 	void RenderAPI::setVertexBuffers(UINT32 index, const Vector<SPtr<VertexBuffer>>& buffers)
 	{
 	{
-		Vector<SPtr<VertexBufferCore>> coreBuffers(buffers.size());
+		Vector<SPtr<ct::VertexBufferCore>> coreBuffers(buffers.size());
 		for (UINT32 i = 0; i < (UINT32)buffers.size(); i++)
 		for (UINT32 i = 0; i < (UINT32)buffers.size(); i++)
 			coreBuffers[i] = buffers[i] != nullptr ? buffers[i]->getCore() : nullptr;
 			coreBuffers[i] = buffers[i] != nullptr ? buffers[i]->getCore() : nullptr;
 
 
-		std::function<void(RenderAPICore*, UINT32, const Vector<SPtr<VertexBufferCore>>&)> resizeFunc =
-			[](RenderAPICore* rs, UINT32 idx, const Vector<SPtr<VertexBufferCore>>& _buffers)
+		std::function<void(ct::RenderAPICore*, UINT32, const Vector<SPtr<ct::VertexBufferCore>>&)> resizeFunc =
+			[](ct::RenderAPICore* rs, UINT32 idx, const Vector<SPtr<ct::VertexBufferCore>>& _buffers)
 		{
 		{
-			rs->setVertexBuffers(idx, (SPtr<VertexBufferCore>*)_buffers.data(), (UINT32)_buffers.size());
+			rs->setVertexBuffers(idx, (SPtr<ct::VertexBufferCore>*)_buffers.data(), (UINT32)_buffers.size());
 		};
 		};
 
 
-		gCoreThread().queueCommand(std::bind(resizeFunc, RenderAPICore::instancePtr(), index, coreBuffers));
+		gCoreThread().queueCommand(std::bind(resizeFunc, ct::RenderAPICore::instancePtr(), index, coreBuffers));
 	}
 	}
 
 
 	void RenderAPI::setIndexBuffer(const SPtr<IndexBuffer>& buffer)
 	void RenderAPI::setIndexBuffer(const SPtr<IndexBuffer>& buffer)
 	{
 	{
-		gCoreThread().queueCommand(std::bind(&RenderAPICore::setIndexBuffer, RenderAPICore::instancePtr(), buffer->getCore(), 
+		gCoreThread().queueCommand(std::bind(&ct::RenderAPICore::setIndexBuffer, ct::RenderAPICore::instancePtr(), buffer->getCore(),
 			nullptr));
 			nullptr));
 	}
 	}
 
 
 	void RenderAPI::setVertexDeclaration(const SPtr<VertexDeclaration>& vertexDeclaration)
 	void RenderAPI::setVertexDeclaration(const SPtr<VertexDeclaration>& vertexDeclaration)
 	{
 	{
-		gCoreThread().queueCommand(std::bind(&RenderAPICore::setVertexDeclaration, RenderAPICore::instancePtr(), 
+		gCoreThread().queueCommand(std::bind(&ct::RenderAPICore::setVertexDeclaration, ct::RenderAPICore::instancePtr(),
 			vertexDeclaration->getCore(), nullptr));
 			vertexDeclaration->getCore(), nullptr));
 	}
 	}
 
 
 	void RenderAPI::setViewport(const Rect2& vp)
 	void RenderAPI::setViewport(const Rect2& vp)
 	{
 	{
-		gCoreThread().queueCommand(std::bind(&RenderAPICore::setViewport, RenderAPICore::instancePtr(), vp, nullptr));
+		gCoreThread().queueCommand(std::bind(&ct::RenderAPICore::setViewport, ct::RenderAPICore::instancePtr(), vp, nullptr));
 	}
 	}
 
 
 	void RenderAPI::setStencilRef(UINT32 value)
 	void RenderAPI::setStencilRef(UINT32 value)
 	{
 	{
-		gCoreThread().queueCommand(std::bind(&RenderAPICore::setStencilRef, RenderAPICore::instancePtr(), value, nullptr));
+		gCoreThread().queueCommand(std::bind(&ct::RenderAPICore::setStencilRef, ct::RenderAPICore::instancePtr(), value, nullptr));
 	}
 	}
 
 
 	void RenderAPI::setDrawOperation(DrawOperationType op)
 	void RenderAPI::setDrawOperation(DrawOperationType op)
 	{
 	{
-		gCoreThread().queueCommand(std::bind(&RenderAPICore::setDrawOperation, RenderAPICore::instancePtr(), op, 
+		gCoreThread().queueCommand(std::bind(&ct::RenderAPICore::setDrawOperation, ct::RenderAPICore::instancePtr(), op,
 			nullptr));
 			nullptr));
 	}
 	}
 
 
 	void RenderAPI::setScissorRect(UINT32 left, UINT32 top, UINT32 right, UINT32 bottom)
 	void RenderAPI::setScissorRect(UINT32 left, UINT32 top, UINT32 right, UINT32 bottom)
 	{
 	{
-		gCoreThread().queueCommand(std::bind(&RenderAPICore::setScissorRect, RenderAPICore::instancePtr(), left, top, right, bottom, 
+		gCoreThread().queueCommand(std::bind(&ct::RenderAPICore::setScissorRect, ct::RenderAPICore::instancePtr(), left, top, right, bottom,
 			nullptr));
 			nullptr));
 	}
 	}
 
 
 	void RenderAPI::setRenderTarget(const SPtr<RenderTarget>& target, bool readOnlyDepthStencil,
 	void RenderAPI::setRenderTarget(const SPtr<RenderTarget>& target, bool readOnlyDepthStencil,
 									RenderSurfaceMask loadMask)
 									RenderSurfaceMask loadMask)
 	{
 	{
-		gCoreThread().queueCommand(std::bind(&RenderAPICore::setRenderTarget, 
-			RenderAPICore::instancePtr(), target->getCore(), readOnlyDepthStencil, loadMask, nullptr));
+		gCoreThread().queueCommand(std::bind(&ct::RenderAPICore::setRenderTarget,
+											 ct::RenderAPICore::instancePtr(), target->getCore(), readOnlyDepthStencil, loadMask, nullptr));
 	}
 	}
 
 
 	void RenderAPI::clearRenderTarget(UINT32 buffers, const Color& color, float depth, 
 	void RenderAPI::clearRenderTarget(UINT32 buffers, const Color& color, float depth, 
 		UINT16 stencil, UINT8 targetMask)
 		UINT16 stencil, UINT8 targetMask)
 	{
 	{
-		gCoreThread().queueCommand(std::bind(&RenderAPICore::clearRenderTarget, RenderAPICore::instancePtr(), buffers, color,
+		gCoreThread().queueCommand(std::bind(&ct::RenderAPICore::clearRenderTarget, ct::RenderAPICore::instancePtr(), buffers, color,
 			depth, stencil, targetMask, nullptr));
 			depth, stencil, targetMask, nullptr));
 	}
 	}
 
 
 	void RenderAPI::clearViewport(UINT32 buffers, const Color& color, float depth, UINT16 stencil, 
 	void RenderAPI::clearViewport(UINT32 buffers, const Color& color, float depth, UINT16 stencil, 
 		UINT8 targetMask)
 		UINT8 targetMask)
 	{
 	{
-		gCoreThread().queueCommand(std::bind(&RenderAPICore::clearViewport, RenderAPICore::instancePtr(), buffers, color, depth,
+		gCoreThread().queueCommand(std::bind(&ct::RenderAPICore::clearViewport, ct::RenderAPICore::instancePtr(), buffers, color, depth,
 			stencil, targetMask, nullptr));
 			stencil, targetMask, nullptr));
 	}
 	}
 
 
 	void RenderAPI::swapBuffers(const SPtr<RenderTarget>& target)
 	void RenderAPI::swapBuffers(const SPtr<RenderTarget>& target)
 	{
 	{
-		gCoreThread().queueCommand(std::bind(&RenderAPICore::swapBuffers, RenderAPICore::instancePtr(), target->getCore(), 1));
+		gCoreThread().queueCommand(std::bind(&ct::RenderAPICore::swapBuffers, ct::RenderAPICore::instancePtr(), target->getCore(), 1));
 	}
 	}
 
 
 	void RenderAPI::draw(UINT32 vertexOffset, UINT32 vertexCount, UINT32 instanceCount)
 	void RenderAPI::draw(UINT32 vertexOffset, UINT32 vertexCount, UINT32 instanceCount)
 	{
 	{
-		gCoreThread().queueCommand(std::bind(&RenderAPICore::draw, RenderAPICore::instancePtr(), vertexOffset, 
+		gCoreThread().queueCommand(std::bind(&ct::RenderAPICore::draw, ct::RenderAPICore::instancePtr(), vertexOffset,
 			vertexCount, instanceCount, nullptr));
 			vertexCount, instanceCount, nullptr));
 	}
 	}
 
 
 	void RenderAPI::drawIndexed(UINT32 startIndex, UINT32 indexCount, UINT32 vertexOffset, 
 	void RenderAPI::drawIndexed(UINT32 startIndex, UINT32 indexCount, UINT32 vertexOffset, 
 		UINT32 vertexCount, UINT32 instanceCount)
 		UINT32 vertexCount, UINT32 instanceCount)
 	{
 	{
-		gCoreThread().queueCommand(std::bind(&RenderAPICore::drawIndexed, RenderAPICore::instancePtr(), startIndex, indexCount, 
+		gCoreThread().queueCommand(std::bind(&ct::RenderAPICore::drawIndexed, ct::RenderAPICore::instancePtr(), startIndex, indexCount,
 			vertexOffset, vertexCount, instanceCount, nullptr));
 			vertexOffset, vertexCount, instanceCount, nullptr));
 	}
 	}
 
 
 	void RenderAPI::dispatchCompute(UINT32 numGroupsX, UINT32 numGroupsY, UINT32 numGroupsZ)
 	void RenderAPI::dispatchCompute(UINT32 numGroupsX, UINT32 numGroupsY, UINT32 numGroupsZ)
 	{
 	{
-		gCoreThread().queueCommand(std::bind(&RenderAPICore::dispatchCompute, RenderAPICore::instancePtr(), numGroupsX, 
+		gCoreThread().queueCommand(std::bind(&ct::RenderAPICore::dispatchCompute, ct::RenderAPICore::instancePtr(), numGroupsX,
 			numGroupsY, numGroupsZ, nullptr));
 			numGroupsY, numGroupsZ, nullptr));
 	}
 	}
 
 
 	const VideoModeInfo& RenderAPI::getVideoModeInfo()
 	const VideoModeInfo& RenderAPI::getVideoModeInfo()
 	{
 	{
-		return RenderAPICore::instance().getVideoModeInfo();
+		return ct::RenderAPICore::instance().getVideoModeInfo();
 	}
 	}
 
 
 	void RenderAPI::convertProjectionMatrix(const Matrix4& matrix, Matrix4& dest)
 	void RenderAPI::convertProjectionMatrix(const Matrix4& matrix, Matrix4& dest)
 	{
 	{
-		RenderAPICore::instance().convertProjectionMatrix(matrix, dest);
+		ct::RenderAPICore::instance().convertProjectionMatrix(matrix, dest);
 	}
 	}
 
 
 	const RenderAPIInfo& RenderAPI::getAPIInfo()
 	const RenderAPIInfo& RenderAPI::getAPIInfo()
 	{
 	{
-		return RenderAPICore::instance().getAPIInfo();
+		return ct::RenderAPICore::instance().getAPIInfo();
 	}
 	}
 
 
+	namespace ct
+	{
     RenderAPICore::RenderAPICore()
     RenderAPICore::RenderAPICore()
         : mCurrentCapabilities(nullptr), mNumDevices(0)
         : mCurrentCapabilities(nullptr), mNumDevices(0)
     {
     {
@@ -235,4 +237,5 @@ namespace bs
 
 
 		return primCount;
 		return primCount;
 	}
 	}
+	}
 }
 }

+ 3 - 3
Source/BansheeCore/Source/BsRenderAPIManager.cpp

@@ -16,8 +16,8 @@ namespace bs
 	{
 	{
 		if(mRenderAPIInitialized)
 		if(mRenderAPIInitialized)
 		{
 		{
-			RenderAPICore::instance().destroy();
-			RenderAPICore::shutDown();
+			ct::RenderAPICore::instance().destroy();
+			ct::RenderAPICore::shutDown();
 		}
 		}
 	}
 	}
 
 
@@ -43,7 +43,7 @@ namespace bs
 			{
 			{
 				(*iter)->create();		
 				(*iter)->create();		
 				mRenderAPIInitialized = true;
 				mRenderAPIInitialized = true;
-				return RenderAPICore::instance().initialize(primaryWindowDesc);
+				return ct::RenderAPICore::instance().initialize(primaryWindowDesc);
 			}
 			}
 		}
 		}
 
 

+ 3 - 0
Source/BansheeCore/Source/BsRenderStateManager.cpp

@@ -138,6 +138,8 @@ namespace bs
 		return mDefaultDepthStencilState; 
 		return mDefaultDepthStencilState; 
 	}
 	}
 
 
+	namespace ct
+	{
 	RenderStateCoreManager::RenderStateCoreManager()
 	RenderStateCoreManager::RenderStateCoreManager()
 		:mNextBlendStateId(0), mNextRasterizerStateId(0), mNextDepthStencilStateId(0)
 		:mNextBlendStateId(0), mNextRasterizerStateId(0), mNextDepthStencilStateId(0)
 	{
 	{
@@ -522,4 +524,5 @@ namespace bs
 
 
 		return state;
 		return state;
 	}
 	}
+	}
 }
 }

+ 28 - 26
Source/BansheeCore/Source/BsRenderTarget.cpp

@@ -9,28 +9,6 @@
 
 
 namespace bs
 namespace bs
 {
 {
-	RenderTargetCore::RenderTargetCore()
-	{
-
-	}
-
-	void RenderTargetCore::setPriority(INT32 priority) 
-	{ 
-		RenderTargetProperties& props = const_cast<RenderTargetProperties&>(getProperties());
-
-		props.mPriority = priority;
-	}
-
-	const RenderTargetProperties& RenderTargetCore::getProperties() const
-	{ 
-		return getPropertiesInternal(); 
-	}
-
-	void RenderTargetCore::getCustomAttribute(const String& name, void* pData) const
-	{
-		BS_EXCEPT(InvalidParametersException, "Attribute not found.");
-	}
-
 	RenderTarget::RenderTarget()
 	RenderTarget::RenderTarget()
 	{
 	{
 		// We never sync from sim to core, so mark it clean to avoid overwriting core thread changes
 		// We never sync from sim to core, so mark it clean to avoid overwriting core thread changes
@@ -39,8 +17,8 @@ namespace bs
 
 
 	void RenderTarget::setPriority(INT32 priority)
 	void RenderTarget::setPriority(INT32 priority)
 	{
 	{
-		std::function<void(SPtr<RenderTargetCore>, INT32)> windowedFunc =
-			[](SPtr<RenderTargetCore> renderTarget, INT32 priority)
+		std::function<void(SPtr<ct::RenderTargetCore>, INT32)> windowedFunc =
+			[](SPtr<ct::RenderTargetCore> renderTarget, INT32 priority)
 		{
 		{
 			renderTarget->setPriority(priority);
 			renderTarget->setPriority(priority);
 		};
 		};
@@ -48,9 +26,9 @@ namespace bs
 		gCoreThread().queueCommand(std::bind(windowedFunc, getCore(), priority));
 		gCoreThread().queueCommand(std::bind(windowedFunc, getCore(), priority));
 	}
 	}
 
 
-	SPtr<RenderTargetCore> RenderTarget::getCore() const
+	SPtr<ct::RenderTargetCore> RenderTarget::getCore() const
 	{
 	{
-		return std::static_pointer_cast<RenderTargetCore>(mCoreSpecific);
+		return std::static_pointer_cast<ct::RenderTargetCore>(mCoreSpecific);
 	}
 	}
 
 
 	const RenderTargetProperties& RenderTarget::getProperties() const
 	const RenderTargetProperties& RenderTarget::getProperties() const
@@ -65,4 +43,28 @@ namespace bs
 		BS_EXCEPT(InvalidParametersException, "Attribute not found.");
 		BS_EXCEPT(InvalidParametersException, "Attribute not found.");
 	}
 	}
 
 
+	namespace ct
+	{
+		RenderTargetCore::RenderTargetCore()
+		{
+
+		}
+
+		void RenderTargetCore::setPriority(INT32 priority)
+		{
+			RenderTargetProperties& props = const_cast<RenderTargetProperties&>(getProperties());
+
+			props.mPriority = priority;
+		}
+
+		const RenderTargetProperties& RenderTargetCore::getProperties() const
+		{
+			return getPropertiesInternal();
+		}
+
+		void RenderTargetCore::getCustomAttribute(const String& name, void* pData) const
+		{
+			BS_EXCEPT(InvalidParametersException, "Attribute not found.");
+		}
+	}
 }        
 }        

+ 76 - 73
Source/BansheeCore/Source/BsRenderTexture.cpp

@@ -26,11 +26,11 @@ namespace bs
 		}
 		}
 	}
 	}
 
 
-	RenderTextureProperties::RenderTextureProperties(const RENDER_TEXTURE_DESC_CORE& desc, bool requiresFlipping)
+	RenderTextureProperties::RenderTextureProperties(const ct::RENDER_TEXTURE_DESC_CORE& desc, bool requiresFlipping)
 	{
 	{
 		for (UINT32 i = 0; i < BS_MAX_MULTIPLE_RENDER_TARGETS; i++)
 		for (UINT32 i = 0; i < BS_MAX_MULTIPLE_RENDER_TARGETS; i++)
 		{
 		{
-			SPtr<TextureCore> texture = desc.colorSurfaces[i].texture;
+			SPtr<ct::TextureCore> texture = desc.colorSurfaces[i].texture;
 
 
 			if (texture != nullptr)
 			if (texture != nullptr)
 			{
 			{
@@ -59,6 +59,80 @@ namespace bs
 		mRequiresTextureFlipping = requiresFlipping;
 		mRequiresTextureFlipping = requiresFlipping;
 	}
 	}
 
 
+	SPtr<RenderTexture> RenderTexture::create(const TEXTURE_DESC& desc, 
+		bool createDepth, PixelFormat depthStencilFormat)
+	{
+		return TextureManager::instance().createRenderTexture(desc, createDepth, depthStencilFormat);
+	}
+
+	SPtr<RenderTexture> RenderTexture::create(const RENDER_TEXTURE_DESC& desc)
+	{
+		return TextureManager::instance().createRenderTexture(desc);
+	}
+
+	SPtr<ct::RenderTextureCore> RenderTexture::getCore() const
+	{ 
+		return std::static_pointer_cast<ct::RenderTextureCore>(mCoreSpecific);
+	}
+
+	RenderTexture::RenderTexture(const RENDER_TEXTURE_DESC& desc)
+		:mDesc(desc)
+	{
+		for (UINT32 i = 0; i < BS_MAX_MULTIPLE_RENDER_TARGETS; i++)
+		{
+			if (desc.colorSurfaces[i].texture != nullptr)
+				mBindableColorTex[i] = desc.colorSurfaces[i].texture;
+		}
+
+		if (desc.depthStencilSurface.texture != nullptr)
+			mBindableDepthStencilTex = desc.depthStencilSurface.texture;
+	}
+
+	SPtr<ct::CoreObjectCore> RenderTexture::createCore() const
+	{
+		ct::RENDER_TEXTURE_DESC_CORE coreDesc;
+
+		for (UINT32 i = 0; i < BS_MAX_MULTIPLE_RENDER_TARGETS; i++)
+		{
+			ct::RENDER_SURFACE_DESC_CORE surfaceDesc;
+			if (mDesc.colorSurfaces[i].texture.isLoaded())
+				surfaceDesc.texture = mDesc.colorSurfaces[i].texture->getCore();
+
+			surfaceDesc.face = mDesc.colorSurfaces[i].face;
+			surfaceDesc.numFaces = mDesc.colorSurfaces[i].numFaces;
+			surfaceDesc.mipLevel = mDesc.colorSurfaces[i].mipLevel;
+
+			coreDesc.colorSurfaces[i] = surfaceDesc;
+		}
+
+		if (mDesc.depthStencilSurface.texture.isLoaded())
+			coreDesc.depthStencilSurface.texture = mDesc.depthStencilSurface.texture->getCore();
+
+		coreDesc.depthStencilSurface.face = mDesc.depthStencilSurface.face;
+		coreDesc.depthStencilSurface.numFaces = mDesc.depthStencilSurface.numFaces;
+		coreDesc.depthStencilSurface.mipLevel = mDesc.depthStencilSurface.mipLevel;
+
+		return ct::TextureCoreManager::instance().createRenderTextureInternal(coreDesc);
+	}
+
+	CoreSyncData RenderTexture::syncToCore(FrameAlloc* allocator)
+	{
+		UINT32 size = sizeof(RenderTextureProperties);
+		UINT8* buffer = allocator->alloc(size);
+
+		RenderTextureProperties& props = const_cast<RenderTextureProperties&>(getProperties());
+
+		memcpy(buffer, (void*)&props, size);
+		return CoreSyncData(buffer, size);
+	}
+
+	const RenderTextureProperties& RenderTexture::getProperties() const
+	{
+		return static_cast<const RenderTextureProperties&>(getPropertiesInternal());
+	}
+
+	namespace ct
+	{
 	RenderTextureCore::RenderTextureCore(const RENDER_TEXTURE_DESC_CORE& desc, UINT32 deviceIdx)
 	RenderTextureCore::RenderTextureCore(const RENDER_TEXTURE_DESC_CORE& desc, UINT32 deviceIdx)
 		:mDesc(desc)
 		:mDesc(desc)
 	{ }
 	{ }
@@ -215,76 +289,5 @@ namespace bs
 			}
 			}
 		}
 		}
 	}
 	}
-
-	SPtr<RenderTexture> RenderTexture::create(const TEXTURE_DESC& desc, 
-		bool createDepth, PixelFormat depthStencilFormat)
-	{
-		return TextureManager::instance().createRenderTexture(desc, createDepth, depthStencilFormat);
-	}
-
-	SPtr<RenderTexture> RenderTexture::create(const RENDER_TEXTURE_DESC& desc)
-	{
-		return TextureManager::instance().createRenderTexture(desc);
-	}
-
-	SPtr<RenderTextureCore> RenderTexture::getCore() const 
-	{ 
-		return std::static_pointer_cast<RenderTextureCore>(mCoreSpecific); 
-	}
-
-	RenderTexture::RenderTexture(const RENDER_TEXTURE_DESC& desc)
-		:mDesc(desc)
-	{
-		for (UINT32 i = 0; i < BS_MAX_MULTIPLE_RENDER_TARGETS; i++)
-		{
-			if (desc.colorSurfaces[i].texture != nullptr)
-				mBindableColorTex[i] = desc.colorSurfaces[i].texture;
-		}
-
-		if (desc.depthStencilSurface.texture != nullptr)
-			mBindableDepthStencilTex = desc.depthStencilSurface.texture;
-	}
-
-	SPtr<CoreObjectCore> RenderTexture::createCore() const
-	{
-		RENDER_TEXTURE_DESC_CORE coreDesc;
-
-		for (UINT32 i = 0; i < BS_MAX_MULTIPLE_RENDER_TARGETS; i++)
-		{
-			RENDER_SURFACE_DESC_CORE surfaceDesc;
-			if (mDesc.colorSurfaces[i].texture.isLoaded())
-				surfaceDesc.texture = mDesc.colorSurfaces[i].texture->getCore();
-
-			surfaceDesc.face = mDesc.colorSurfaces[i].face;
-			surfaceDesc.numFaces = mDesc.colorSurfaces[i].numFaces;
-			surfaceDesc.mipLevel = mDesc.colorSurfaces[i].mipLevel;
-
-			coreDesc.colorSurfaces[i] = surfaceDesc;
-		}
-
-		if (mDesc.depthStencilSurface.texture.isLoaded())
-			coreDesc.depthStencilSurface.texture = mDesc.depthStencilSurface.texture->getCore();
-
-		coreDesc.depthStencilSurface.face = mDesc.depthStencilSurface.face;
-		coreDesc.depthStencilSurface.numFaces = mDesc.depthStencilSurface.numFaces;
-		coreDesc.depthStencilSurface.mipLevel = mDesc.depthStencilSurface.mipLevel;
-
-		return TextureCoreManager::instance().createRenderTextureInternal(coreDesc);
-	}
-
-	CoreSyncData RenderTexture::syncToCore(FrameAlloc* allocator)
-	{
-		UINT32 size = sizeof(RenderTextureProperties);
-		UINT8* buffer = allocator->alloc(size);
-
-		RenderTextureProperties& props = const_cast<RenderTextureProperties&>(getProperties());
-
-		memcpy(buffer, (void*)&props, size);
-		return CoreSyncData(buffer, size);
-	}
-
-	const RenderTextureProperties& RenderTexture::getProperties() const
-	{
-		return static_cast<const RenderTextureProperties&>(getPropertiesInternal());
 	}
 	}
 }
 }

+ 174 - 171
Source/BansheeCore/Source/BsRenderWindow.cpp

@@ -26,146 +26,6 @@ namespace bs
 		mRequiresTextureFlipping = false;
 		mRequiresTextureFlipping = false;
 	}
 	}
 
 
-	RenderWindowCore::RenderWindowCore(const RENDER_WINDOW_DESC& desc, UINT32 windowId)
-		:mDesc(desc), mWindowId(windowId)
-	{
-
-	}
-
-	RenderWindowCore::~RenderWindowCore()
-	{
-		Platform::resetNonClientAreas(*this);
-
-		RenderWindowCoreManager::instance().windowDestroyed(this);
-	}
-
-	void RenderWindowCore::setHidden(bool hidden)
-	{
-		THROW_IF_NOT_CORE_THREAD;
-
-		RenderWindowProperties& props = const_cast<RenderWindowProperties&>(getProperties());
-
-		props.mHidden = hidden;
-		{
-			ScopedSpinLock lock(mLock);
-			getSyncedProperties().mHidden = hidden;
-		}
-
-		RenderWindowManager::instance().notifySyncDataDirty(this);
-	}
-
-	void RenderWindowCore::setActive(bool state)
-	{
-		THROW_IF_NOT_CORE_THREAD;
-
-		RenderWindowProperties& props = const_cast<RenderWindowProperties&>(getProperties());
-
-		props.mActive = state;
-		{
-			ScopedSpinLock lock(mLock);
-			getSyncedProperties().mActive = state;
-		}
-
-		RenderWindowManager::instance().notifySyncDataDirty(this);
-	}
-
-	void RenderWindowCore::_windowMovedOrResized()
-	{
-		THROW_IF_NOT_CORE_THREAD;
-
-		RenderWindowProperties& props = const_cast<RenderWindowProperties&>(getProperties());
-		{
-			ScopedSpinLock lock(mLock);
-			getSyncedProperties().mTop = props.mTop;
-			getSyncedProperties().mLeft = props.mLeft;
-			getSyncedProperties().mWidth = props.mWidth;
-			getSyncedProperties().mHeight = props.mHeight;
-		}
-
-		RenderWindowManager::instance().notifySyncDataDirty(this);
-		RenderWindowManager::instance().notifyMovedOrResized(this);
-	}
-
-	void RenderWindowCore::_windowFocusReceived()
-	{
-		THROW_IF_NOT_CORE_THREAD;
-
-		RenderWindowProperties& properties = const_cast<RenderWindowProperties&>(getProperties());
-		properties.mHasFocus = true;
-		{
-			ScopedSpinLock lock(mLock);
-			getSyncedProperties().mHasFocus = true;
-		}
-
-		RenderWindowManager::instance().notifySyncDataDirty(this);
-		RenderWindowManager::instance().notifyFocusReceived(this);
-	}
-
-	void RenderWindowCore::_windowFocusLost()
-	{
-		THROW_IF_NOT_CORE_THREAD;
-
-		RenderWindowProperties& properties = const_cast<RenderWindowProperties&>(getProperties());
-		properties.mHasFocus = false;
-		{
-			ScopedSpinLock lock(mLock);
-			getSyncedProperties().mHasFocus = false;
-		}
-
-		RenderWindowManager::instance().notifySyncDataDirty(this);
-		RenderWindowManager::instance().notifyFocusLost(this);
-	}
-
-	void RenderWindowCore::_notifyMaximized()
-	{
-		THROW_IF_NOT_CORE_THREAD;
-
-		RenderWindowProperties& props = const_cast<RenderWindowProperties&>(getProperties());
-
-		props.mIsMaximized = true;
-		{
-			ScopedSpinLock lock(mLock);
-			getSyncedProperties().mIsMaximized = true;
-		}
-
-		RenderWindowManager::instance().notifySyncDataDirty(this);
-	}
-
-	void RenderWindowCore::_notifyMinimized()
-	{
-		THROW_IF_NOT_CORE_THREAD;
-
-		RenderWindowProperties& props = const_cast<RenderWindowProperties&>(getProperties());
-
-		props.mIsMaximized = false;
-		{
-			ScopedSpinLock lock(mLock);
-			getSyncedProperties().mIsMaximized = false;
-		}
-
-		RenderWindowManager::instance().notifySyncDataDirty(this);
-	}
-
-	void RenderWindowCore::_notifyRestored()
-	{
-		THROW_IF_NOT_CORE_THREAD;
-
-		RenderWindowProperties& props = const_cast<RenderWindowProperties&>(getProperties());
-
-		props.mIsMaximized = false;
-		{
-			ScopedSpinLock lock(mLock);
-			getSyncedProperties().mIsMaximized = false;
-		}
-
-		RenderWindowManager::instance().notifySyncDataDirty(this);
-	}
-
-	const RenderWindowProperties& RenderWindowCore::getProperties() const
-	{
-		return static_cast<const RenderWindowProperties&>(getPropertiesInternal());
-	}
-
 	void RenderWindow::destroy()
 	void RenderWindow::destroy()
 	{
 	{
 		RenderWindowManager::instance().notifyWindowDestroyed(this);
 		RenderWindowManager::instance().notifyWindowDestroyed(this);
@@ -181,8 +41,8 @@ namespace bs
 
 
 	void RenderWindow::resize(UINT32 width, UINT32 height)
 	void RenderWindow::resize(UINT32 width, UINT32 height)
 	{
 	{
-		std::function<void(SPtr<RenderWindowCore>, UINT32, UINT32)> resizeFunc =
-			[](SPtr<RenderWindowCore> renderWindow, UINT32 width, UINT32 height)
+		std::function<void(SPtr<ct::RenderWindowCore>, UINT32, UINT32)> resizeFunc =
+			[](SPtr<ct::RenderWindowCore> renderWindow, UINT32 width, UINT32 height)
 		{
 		{
 			renderWindow->resize(width, height);
 			renderWindow->resize(width, height);
 		};
 		};
@@ -196,7 +56,7 @@ namespace bs
 			getCore()->getSyncedProperties().mHeight = height;
 			getCore()->getSyncedProperties().mHeight = height;
 		}
 		}
 
 
-		RenderWindowCoreManager::instance().notifySyncDataDirty(getCore().get());
+		ct::RenderWindowCoreManager::instance().notifySyncDataDirty(getCore().get());
 		onResized();
 		onResized();
 
 
 		gCoreThread().queueCommand(std::bind(resizeFunc, getCore(), width, height));
 		gCoreThread().queueCommand(std::bind(resizeFunc, getCore(), width, height));
@@ -204,8 +64,8 @@ namespace bs
 
 
 	void RenderWindow::move(INT32 left, INT32 top)
 	void RenderWindow::move(INT32 left, INT32 top)
 	{
 	{
-		std::function<void(SPtr<RenderWindowCore>, INT32, INT32)> moveFunc =
-			[](SPtr<RenderWindowCore> renderWindow, INT32 left, INT32 top)
+		std::function<void(SPtr<ct::RenderWindowCore>, INT32, INT32)> moveFunc =
+			[](SPtr<ct::RenderWindowCore> renderWindow, INT32 left, INT32 top)
 		{
 		{
 			renderWindow->move(left, top);
 			renderWindow->move(left, top);
 		};
 		};
@@ -219,14 +79,14 @@ namespace bs
 			getCore()->getSyncedProperties().mTop = top;
 			getCore()->getSyncedProperties().mTop = top;
 		}
 		}
 
 
-		RenderWindowCoreManager::instance().notifySyncDataDirty(getCore().get());
+		ct::RenderWindowCoreManager::instance().notifySyncDataDirty(getCore().get());
 		gCoreThread().queueCommand(std::bind(moveFunc, getCore(), left, top));
 		gCoreThread().queueCommand(std::bind(moveFunc, getCore(), left, top));
 	}
 	}
 
 
 	void RenderWindow::hide()
 	void RenderWindow::hide()
 	{
 	{
-		std::function<void(SPtr<RenderWindowCore>)> hideFunc =
-			[](SPtr<RenderWindowCore> renderWindow)
+		std::function<void(SPtr<ct::RenderWindowCore>)> hideFunc =
+			[](SPtr<ct::RenderWindowCore> renderWindow)
 		{
 		{
 			renderWindow->setHidden(true);
 			renderWindow->setHidden(true);
 		};
 		};
@@ -237,14 +97,14 @@ namespace bs
 			getCore()->getSyncedProperties().mHidden = true;
 			getCore()->getSyncedProperties().mHidden = true;
 		}
 		}
 
 
-		RenderWindowCoreManager::instance().notifySyncDataDirty(getCore().get());
+		ct::RenderWindowCoreManager::instance().notifySyncDataDirty(getCore().get());
 		gCoreThread().queueCommand(std::bind(hideFunc, getCore()));
 		gCoreThread().queueCommand(std::bind(hideFunc, getCore()));
 	}
 	}
 
 
 	void RenderWindow::show()
 	void RenderWindow::show()
 	{
 	{
-		std::function<void(SPtr<RenderWindowCore>)> showFunc =
-			[](SPtr<RenderWindowCore> renderWindow)
+		std::function<void(SPtr<ct::RenderWindowCore>)> showFunc =
+			[](SPtr<ct::RenderWindowCore> renderWindow)
 		{
 		{
 			renderWindow->setHidden(false);
 			renderWindow->setHidden(false);
 		};
 		};
@@ -255,14 +115,14 @@ namespace bs
 			getCore()->getSyncedProperties().mHidden = false;
 			getCore()->getSyncedProperties().mHidden = false;
 		}
 		}
 
 
-		RenderWindowCoreManager::instance().notifySyncDataDirty(getCore().get());
+		ct::RenderWindowCoreManager::instance().notifySyncDataDirty(getCore().get());
 		gCoreThread().queueCommand(std::bind(showFunc, getCore()));
 		gCoreThread().queueCommand(std::bind(showFunc, getCore()));
 	}
 	}
 
 
 	void RenderWindow::minimize()
 	void RenderWindow::minimize()
 	{
 	{
-		std::function<void(SPtr<RenderWindowCore>)> minimizeFunc =
-			[](SPtr<RenderWindowCore> renderWindow)
+		std::function<void(SPtr<ct::RenderWindowCore>)> minimizeFunc =
+			[](SPtr<ct::RenderWindowCore> renderWindow)
 		{
 		{
 			renderWindow->minimize();
 			renderWindow->minimize();
 		};
 		};
@@ -273,14 +133,14 @@ namespace bs
 			getCore()->getSyncedProperties().mIsMaximized = false;
 			getCore()->getSyncedProperties().mIsMaximized = false;
 		}
 		}
 
 
-		RenderWindowCoreManager::instance().notifySyncDataDirty(getCore().get());
+		ct::RenderWindowCoreManager::instance().notifySyncDataDirty(getCore().get());
 		gCoreThread().queueCommand(std::bind(minimizeFunc, getCore()));
 		gCoreThread().queueCommand(std::bind(minimizeFunc, getCore()));
 	}
 	}
 
 
 	void RenderWindow::maximize()
 	void RenderWindow::maximize()
 	{
 	{
-		std::function<void(SPtr<RenderWindowCore>)> maximizeFunc =
-			[](SPtr<RenderWindowCore> renderWindow)
+		std::function<void(SPtr<ct::RenderWindowCore>)> maximizeFunc =
+			[](SPtr<ct::RenderWindowCore> renderWindow)
 		{
 		{
 			renderWindow->maximize();
 			renderWindow->maximize();
 		};
 		};
@@ -291,14 +151,14 @@ namespace bs
 			getCore()->getSyncedProperties().mIsMaximized = true;
 			getCore()->getSyncedProperties().mIsMaximized = true;
 		}
 		}
 
 
-		RenderWindowCoreManager::instance().notifySyncDataDirty(getCore().get());
+		ct::RenderWindowCoreManager::instance().notifySyncDataDirty(getCore().get());
 		gCoreThread().queueCommand(std::bind(maximizeFunc, getCore()));
 		gCoreThread().queueCommand(std::bind(maximizeFunc, getCore()));
 	}
 	}
 
 
 	void RenderWindow::restore()
 	void RenderWindow::restore()
 	{
 	{
-		std::function<void(SPtr<RenderWindowCore>)> restoreFunc =
-			[](SPtr<RenderWindowCore> renderWindow)
+		std::function<void(SPtr<ct::RenderWindowCore>)> restoreFunc =
+			[](SPtr<ct::RenderWindowCore> renderWindow)
 		{
 		{
 			renderWindow->restore();
 			renderWindow->restore();
 		};
 		};
@@ -309,14 +169,14 @@ namespace bs
 			getCore()->getSyncedProperties().mIsMaximized = false;
 			getCore()->getSyncedProperties().mIsMaximized = false;
 		}
 		}
 
 
-		RenderWindowCoreManager::instance().notifySyncDataDirty(getCore().get());
+		ct::RenderWindowCoreManager::instance().notifySyncDataDirty(getCore().get());
 		gCoreThread().queueCommand(std::bind(restoreFunc, getCore()));
 		gCoreThread().queueCommand(std::bind(restoreFunc, getCore()));
 	}
 	}
 
 
 	void RenderWindow::setFullscreen(UINT32 width, UINT32 height, float refreshRate, UINT32 monitorIdx)
 	void RenderWindow::setFullscreen(UINT32 width, UINT32 height, float refreshRate, UINT32 monitorIdx)
 	{
 	{
-		std::function<void(SPtr<RenderWindowCore>, UINT32, UINT32, float, UINT32)> fullscreenFunc =
-			[](SPtr<RenderWindowCore> renderWindow, UINT32 width, UINT32 height, float refreshRate, UINT32 monitorIdx)
+		std::function<void(SPtr<ct::RenderWindowCore>, UINT32, UINT32, float, UINT32)> fullscreenFunc =
+			[](SPtr<ct::RenderWindowCore> renderWindow, UINT32 width, UINT32 height, float refreshRate, UINT32 monitorIdx)
 		{
 		{
 			renderWindow->setFullscreen(width, height, refreshRate, monitorIdx);
 			renderWindow->setFullscreen(width, height, refreshRate, monitorIdx);
 		};
 		};
@@ -326,8 +186,8 @@ namespace bs
 
 
 	void RenderWindow::setFullscreen(const VideoMode& mode)
 	void RenderWindow::setFullscreen(const VideoMode& mode)
 	{
 	{
-		std::function<void(SPtr<RenderWindowCore>, const VideoMode&)> fullscreenFunc =
-			[](SPtr<RenderWindowCore> renderWindow, const VideoMode& mode)
+		std::function<void(SPtr<ct::RenderWindowCore>, const VideoMode&)> fullscreenFunc =
+			[](SPtr<ct::RenderWindowCore> renderWindow, const VideoMode& mode)
 		{
 		{
 			renderWindow->setFullscreen(mode);
 			renderWindow->setFullscreen(mode);
 		};
 		};
@@ -337,8 +197,8 @@ namespace bs
 
 
 	void RenderWindow::setWindowed(UINT32 width, UINT32 height)
 	void RenderWindow::setWindowed(UINT32 width, UINT32 height)
 	{
 	{
-		std::function<void(SPtr<RenderWindowCore>, UINT32, UINT32)> windowedFunc =
-			[](SPtr<RenderWindowCore> renderWindow, UINT32 width, UINT32 height)
+		std::function<void(SPtr<ct::RenderWindowCore>, UINT32, UINT32)> windowedFunc =
+			[](SPtr<ct::RenderWindowCore> renderWindow, UINT32 width, UINT32 height)
 		{
 		{
 			renderWindow->setWindowed(width, height);
 			renderWindow->setWindowed(width, height);
 		};
 		};
@@ -346,15 +206,15 @@ namespace bs
 		gCoreThread().queueCommand(std::bind(windowedFunc, getCore(), width, height));
 		gCoreThread().queueCommand(std::bind(windowedFunc, getCore(), width, height));
 	}
 	}
 
 
-	SPtr<RenderWindowCore> RenderWindow::getCore() const
+	SPtr<ct::RenderWindowCore> RenderWindow::getCore() const
 	{
 	{
-		return std::static_pointer_cast<RenderWindowCore>(mCoreSpecific);
+		return std::static_pointer_cast<ct::RenderWindowCore>(mCoreSpecific);
 	}
 	}
 
 
-	SPtr<CoreObjectCore> RenderWindow::createCore() const
+	SPtr<ct::CoreObjectCore> RenderWindow::createCore() const
 	{
 	{
 		RENDER_WINDOW_DESC desc = mDesc;
 		RENDER_WINDOW_DESC desc = mDesc;
-		return RenderWindowCoreManager::instance().createInternal(desc, mWindowId);
+		return ct::RenderWindowCoreManager::instance().createInternal(desc, mWindowId);
 	}
 	}
 
 
 	SPtr<RenderWindow> RenderWindow::create(RENDER_WINDOW_DESC& desc, SPtr<RenderWindow> parentWindow)
 	SPtr<RenderWindow> RenderWindow::create(RENDER_WINDOW_DESC& desc, SPtr<RenderWindow> parentWindow)
@@ -371,4 +231,147 @@ namespace bs
 	{
 	{
 		return static_cast<const RenderWindowProperties&>(getPropertiesInternal());
 		return static_cast<const RenderWindowProperties&>(getPropertiesInternal());
 	}
 	}
+
+	namespace ct
+	{
+	RenderWindowCore::RenderWindowCore(const RENDER_WINDOW_DESC& desc, UINT32 windowId)
+		:mDesc(desc), mWindowId(windowId)
+	{
+
+	}
+
+	RenderWindowCore::~RenderWindowCore()
+	{
+		Platform::resetNonClientAreas(*this);
+
+		RenderWindowCoreManager::instance().windowDestroyed(this);
+	}
+
+	void RenderWindowCore::setHidden(bool hidden)
+	{
+		THROW_IF_NOT_CORE_THREAD;
+
+		RenderWindowProperties& props = const_cast<RenderWindowProperties&>(getProperties());
+
+		props.mHidden = hidden;
+		{
+			ScopedSpinLock lock(mLock);
+			getSyncedProperties().mHidden = hidden;
+		}
+
+		RenderWindowManager::instance().notifySyncDataDirty(this);
+	}
+
+	void RenderWindowCore::setActive(bool state)
+	{
+		THROW_IF_NOT_CORE_THREAD;
+
+		RenderWindowProperties& props = const_cast<RenderWindowProperties&>(getProperties());
+
+		props.mActive = state;
+		{
+			ScopedSpinLock lock(mLock);
+			getSyncedProperties().mActive = state;
+		}
+
+		RenderWindowManager::instance().notifySyncDataDirty(this);
+	}
+
+	void RenderWindowCore::_windowMovedOrResized()
+	{
+		THROW_IF_NOT_CORE_THREAD;
+
+		RenderWindowProperties& props = const_cast<RenderWindowProperties&>(getProperties());
+		{
+			ScopedSpinLock lock(mLock);
+			getSyncedProperties().mTop = props.mTop;
+			getSyncedProperties().mLeft = props.mLeft;
+			getSyncedProperties().mWidth = props.mWidth;
+			getSyncedProperties().mHeight = props.mHeight;
+		}
+
+		RenderWindowManager::instance().notifySyncDataDirty(this);
+		RenderWindowManager::instance().notifyMovedOrResized(this);
+	}
+
+	void RenderWindowCore::_windowFocusReceived()
+	{
+		THROW_IF_NOT_CORE_THREAD;
+
+		RenderWindowProperties& properties = const_cast<RenderWindowProperties&>(getProperties());
+		properties.mHasFocus = true;
+		{
+			ScopedSpinLock lock(mLock);
+			getSyncedProperties().mHasFocus = true;
+		}
+
+		RenderWindowManager::instance().notifySyncDataDirty(this);
+		RenderWindowManager::instance().notifyFocusReceived(this);
+	}
+
+	void RenderWindowCore::_windowFocusLost()
+	{
+		THROW_IF_NOT_CORE_THREAD;
+
+		RenderWindowProperties& properties = const_cast<RenderWindowProperties&>(getProperties());
+		properties.mHasFocus = false;
+		{
+			ScopedSpinLock lock(mLock);
+			getSyncedProperties().mHasFocus = false;
+		}
+
+		RenderWindowManager::instance().notifySyncDataDirty(this);
+		RenderWindowManager::instance().notifyFocusLost(this);
+	}
+
+	void RenderWindowCore::_notifyMaximized()
+	{
+		THROW_IF_NOT_CORE_THREAD;
+
+		RenderWindowProperties& props = const_cast<RenderWindowProperties&>(getProperties());
+
+		props.mIsMaximized = true;
+		{
+			ScopedSpinLock lock(mLock);
+			getSyncedProperties().mIsMaximized = true;
+		}
+
+		RenderWindowManager::instance().notifySyncDataDirty(this);
+	}
+
+	void RenderWindowCore::_notifyMinimized()
+	{
+		THROW_IF_NOT_CORE_THREAD;
+
+		RenderWindowProperties& props = const_cast<RenderWindowProperties&>(getProperties());
+
+		props.mIsMaximized = false;
+		{
+			ScopedSpinLock lock(mLock);
+			getSyncedProperties().mIsMaximized = false;
+		}
+
+		RenderWindowManager::instance().notifySyncDataDirty(this);
+	}
+
+	void RenderWindowCore::_notifyRestored()
+	{
+		THROW_IF_NOT_CORE_THREAD;
+
+		RenderWindowProperties& props = const_cast<RenderWindowProperties&>(getProperties());
+
+		props.mIsMaximized = false;
+		{
+			ScopedSpinLock lock(mLock);
+			getSyncedProperties().mIsMaximized = false;
+		}
+
+		RenderWindowManager::instance().notifySyncDataDirty(this);
+	}
+
+	const RenderWindowProperties& RenderWindowCore::getProperties() const
+	{
+		return static_cast<const RenderWindowProperties&>(getPropertiesInternal());
+	}
+	}
 }
 }

Einige Dateien werden nicht angezeigt, da zu viele Dateien in diesem Diff geändert wurden.