Sfoglia il codice sorgente

More work on improving documentation for doxygen generation

BearishSun 9 anni fa
parent
commit
74bb75edef
86 ha cambiato i file con 7620 aggiunte e 7612 eliminazioni
  1. 2 1
      Doxyfile
  2. 254 253
      Source/BansheeCore/Include/BsBlendState.h
  3. 379 381
      Source/BansheeCore/Include/BsCommandQueue.h
  4. 142 144
      Source/BansheeCore/Include/BsCoreObjectManager.h
  5. 80 16
      Source/BansheeCore/Include/BsCorePrerequisites.h
  6. 139 141
      Source/BansheeCore/Include/BsCoreRenderer.h
  7. 1 3
      Source/BansheeCore/Include/BsCoreSceneManager.h
  8. 223 220
      Source/BansheeCore/Include/BsCoreThread.h
  9. 40 42
      Source/BansheeCore/Include/BsDeferredCallManager.h
  10. 245 243
      Source/BansheeCore/Include/BsDepthStencilState.h
  11. 58 60
      Source/BansheeCore/Include/BsEventQuery.h
  12. 1 3
      Source/BansheeCore/Include/BsFCollider.h
  13. 4 2
      Source/BansheeCore/Include/BsFJoint.h
  14. 29 31
      Source/BansheeCore/Include/BsFontManager.h
  15. 5 4
      Source/BansheeCore/Include/BsGameObject.h
  16. 0 7
      Source/BansheeCore/Include/BsGameObjectHandle.h
  17. 153 155
      Source/BansheeCore/Include/BsGameObjectManager.h
  18. 219 217
      Source/BansheeCore/Include/BsGpuBuffer.h
  19. 86 88
      Source/BansheeCore/Include/BsGpuBufferView.h
  20. 5 4
      Source/BansheeCore/Include/BsGpuParamBlockBuffer.h
  21. 11 23
      Source/BansheeCore/Include/BsGpuParams.h
  22. 72 70
      Source/BansheeCore/Include/BsGpuProgram.h
  23. 1 3
      Source/BansheeCore/Include/BsGpuProgramManager.h
  24. 1 3
      Source/BansheeCore/Include/BsHardwareBuffer.h
  25. 133 135
      Source/BansheeCore/Include/BsHardwareBufferManager.h
  26. 38 40
      Source/BansheeCore/Include/BsIconUtility.h
  27. 97 93
      Source/BansheeCore/Include/BsIndexBuffer.h
  28. 803 801
      Source/BansheeCore/Include/BsMaterial.h
  29. 36 38
      Source/BansheeCore/Include/BsMaterialManager.h
  30. 1 3
      Source/BansheeCore/Include/BsMaterialParams.h
  31. 362 360
      Source/BansheeCore/Include/BsMesh.h
  32. 186 189
      Source/BansheeCore/Include/BsMeshBase.h
  33. 5 3
      Source/BansheeCore/Include/BsMeshHeap.h
  34. 58 60
      Source/BansheeCore/Include/BsMeshManager.h
  35. 144 142
      Source/BansheeCore/Include/BsMultiRenderTexture.h
  36. 160 162
      Source/BansheeCore/Include/BsOSInputHandler.h
  37. 1 3
      Source/BansheeCore/Include/BsParamBlocks.h
  38. 11 5
      Source/BansheeCore/Include/BsPass.h
  39. 46 48
      Source/BansheeCore/Include/BsPhysicsManager.h
  40. 4 3
      Source/BansheeCore/Include/BsPhysicsMesh.h
  41. 90 92
      Source/BansheeCore/Include/BsPixelBuffer.h
  42. 1 3
      Source/BansheeCore/Include/BsPlatform.h
  43. 155 157
      Source/BansheeCore/Include/BsPrefabDiff.h
  44. 75 77
      Source/BansheeCore/Include/BsProfilingManager.h
  45. 84 86
      Source/BansheeCore/Include/BsQueryManager.h
  46. 40 38
      Source/BansheeCore/Include/BsRasterizerState.h
  47. 84 86
      Source/BansheeCore/Include/BsRawInputHandler.h
  48. 4 2
      Source/BansheeCore/Include/BsRenderAPI.h
  49. 534 536
      Source/BansheeCore/Include/BsRenderAPICapabilities.h
  50. 1 3
      Source/BansheeCore/Include/BsRenderAPIFactory.h
  51. 41 43
      Source/BansheeCore/Include/BsRenderAPIManager.h
  52. 258 260
      Source/BansheeCore/Include/BsRenderStateManager.h
  53. 192 194
      Source/BansheeCore/Include/BsRenderStats.h
  54. 47 45
      Source/BansheeCore/Include/BsRenderTarget.h
  55. 178 176
      Source/BansheeCore/Include/BsRenderTexture.h
  56. 85 83
      Source/BansheeCore/Include/BsRenderWindow.h
  57. 131 133
      Source/BansheeCore/Include/BsRenderWindowManager.h
  58. 31 33
      Source/BansheeCore/Include/BsRendererFactory.h
  59. 51 53
      Source/BansheeCore/Include/BsRendererManager.h
  60. 0 4
      Source/BansheeCore/Include/BsResourceHandle.h
  61. 1 3
      Source/BansheeCore/Include/BsResourceListenerManager.h
  62. 97 99
      Source/BansheeCore/Include/BsResourceManifest.h
  63. 204 202
      Source/BansheeCore/Include/BsSamplerState.h
  64. 44 46
      Source/BansheeCore/Include/BsSavedResourceData.h
  65. 9 6
      Source/BansheeCore/Include/BsShader.h
  66. 1 3
      Source/BansheeCore/Include/BsShaderDefines.h
  67. 60 62
      Source/BansheeCore/Include/BsShaderManager.h
  68. 1 3
      Source/BansheeCore/Include/BsSpecificImporter.h
  69. 7 2
      Source/BansheeCore/Include/BsStringTable.h
  70. 5 4
      Source/BansheeCore/Include/BsTechnique.h
  71. 0 2
      Source/BansheeCore/Include/BsTextData.h
  72. 168 166
      Source/BansheeCore/Include/BsTexture.h
  73. 146 148
      Source/BansheeCore/Include/BsTextureManager.h
  74. 1 3
      Source/BansheeCore/Include/BsTextureView.h
  75. 63 65
      Source/BansheeCore/Include/BsTimerQuery.h
  76. 98 96
      Source/BansheeCore/Include/BsTransientMesh.h
  77. 56 58
      Source/BansheeCore/Include/BsUtility.h
  78. 86 84
      Source/BansheeCore/Include/BsVertexBuffer.h
  79. 48 46
      Source/BansheeCore/Include/BsVertexDeclaration.h
  80. 42 41
      Source/BansheeCore/Include/BsViewport.h
  81. 43 45
      Source/BansheeCore/Include/Win32/BSWin32PlatformData.h
  82. 1 3
      Source/BansheeCore/Include/Win32/BsWin32DropTarget.h
  83. 85 87
      Source/BansheeCore/Include/Win32/BsWin32FolderMonitor.h
  84. 28 30
      Source/BansheeCore/Include/Win32/BsWin32Platform.h
  85. 6 0
      Source/BansheeUtility/Include/BsIReflectable.h
  86. 3 5
      Source/BansheeUtility/Include/BsPrerequisitesUtil.h

+ 2 - 1
Doxyfile

@@ -775,7 +775,8 @@ WARN_LOGFILE           =
 # spaces. See also FILE_PATTERNS and EXTENSION_MAPPING
 # Note: If this tag is empty the current directory is searched.
 
-INPUT                  = Source/BansheeUtility/Include
+INPUT                  = Source/BansheeUtility/Include \
+                         Source/BansheeCore/Include
 
 # This tag can be used to specify the character encoding of the source files
 # that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses

+ 254 - 253
Source/BansheeCore/Include/BsBlendState.h

@@ -1,253 +1,254 @@
-//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
-//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
-#pragma once
-
-#include "BsCorePrerequisites.h"
-#include "BsResource.h"
-
-namespace BansheeEngine
-{
-	/** @addtogroup RenderAPI
-	 *  @{
-	 */
-
-	/**
-	 * Structure that describes blend states for a single render target. Used internally by BLEND_STATE_DESC for 
-	 * initializing a BlendState.
-	 * 			
-	 * @see		BLEND_STATE_DESC
-	 * @see		BlendState
-	 */
-	struct BS_CORE_EXPORT RENDER_TARGET_BLEND_STATE_DESC
-	{
-		RENDER_TARGET_BLEND_STATE_DESC()
-			: blendEnable(false)
-			, srcBlend(BF_ONE)
-			, dstBlend(BF_ZERO)
-			, blendOp(BO_ADD)
-			, srcBlendAlpha(BF_ONE)
-			, dstBlendAlpha(BF_ZERO)
-			, blendOpAlpha(BO_ADD)
-			, renderTargetWriteMask(0xFF)
-		{ }
-
-		bool operator==(const RENDER_TARGET_BLEND_STATE_DESC& rhs) const;
-
-		bool blendEnable;
-		BlendFactor srcBlend;
-		BlendFactor dstBlend;
-		BlendOperation blendOp;
-		BlendFactor srcBlendAlpha;
-		BlendFactor dstBlendAlpha;
-		BlendOperation blendOpAlpha;
-		// Enable write to RGBA channels separately by setting first four bits (0 - R, 1 - G, 2 - B, 3 - A)
-		UINT8 renderTargetWriteMask;
-	};
-
-	/** Structure that describes render pipeline blend states. Used for initializing BlendState. */
-	struct BS_CORE_EXPORT BLEND_STATE_DESC
-	{
-		BLEND_STATE_DESC()
-			: alphaToCoverageEnable(false)
-			, independantBlendEnable(false)
-		{ }
-
-		bool operator==(const BLEND_STATE_DESC& rhs) const;
-
-		bool alphaToCoverageEnable;
-		bool independantBlendEnable;
-		RENDER_TARGET_BLEND_STATE_DESC renderTargetDesc[BS_MAX_MULTIPLE_RENDER_TARGETS];
-	};
-
-	/** Properties of a BlendState. Shared between sim and core thread versions of BlendState. */
-	class BS_CORE_EXPORT BlendProperties
-	{
-	public:
-		BlendProperties(const BLEND_STATE_DESC& desc);
-
-		/**
-		 * Alpha to coverage allows you to perform blending without needing to worry about order of rendering like regular 
-		 * blending does. It requires multi-sampling to be active in order to work, and you need to supply an alpha texture
-		 * that determines object transparency.
-		 *
-		 * Blending is then performed by only using sub-samples covered by the alpha texture for the current pixel and 
-		 * combining them with sub-samples previously stored. 
-		 *			
-		 * Be aware this is a limited technique only useful for certain situations. Unless you are having performance 
-		 * problems use regular blending.
-		 */
-		bool getAlphaToCoverageEnabled() const { return mData.alphaToCoverageEnable; }
-
-		/**
-		 * When not set, only the first render target blend descriptor will be used for all render targets. If set each 
-		 * render target will use its own blend descriptor.
-		 */
-		bool getIndependantBlendEnable() const { return mData.independantBlendEnable; }
-
-		/**
-		 * Queries is blending enabled for the specified render target. Blending allows you to combine the color from 
-		 * current and previous pixel based on some value.
-		 */
-		bool getBlendEnabled(UINT32 renderTargetIdx) const;
-
-		/**
-		 * Determines what should the source blend factor be. This value determines what will the color being generated 
-		 * currently be multiplied by.
-		 */
-		BlendFactor getSrcBlend(UINT32 renderTargetIdx) const;
-
-		/**
-		 * Determines what should the destination blend factor be. This value determines what will the color already in 
-		 * render target be multiplied by.
-		 */
-		BlendFactor getDstBlend(UINT32 renderTargetIdx) const;
-
-		/**
-		 * Determines how are source and destination colors combined (after they are multiplied by their respective blend 
-		 * factors).
-		 */
-		BlendOperation getBlendOperation(UINT32 renderTargetIdx) const;
-
-		/**
-		 * Determines what should the alpha source blend factor be. This value determines what will the alpha value being 
-		 * generated currently be multiplied by.
-		 */
-		BlendFactor getAlphaSrcBlend(UINT32 renderTargetIdx) const;
-
-		/**
-		 * Determines what should the alpha destination blend factor be. This value determines what will the alpha value 
-		 * already in render target be multiplied by.
-		 */
-		BlendFactor getAlphaDstBlend(UINT32 renderTargetIdx) const;
-
-		/**
-		 * Determines how are source and destination alpha values combined (after they are multiplied by their respective
-		 * blend factors).
-		 */
-		BlendOperation getAlphaBlendOperation(UINT32 renderTargetIdx) const;
-
-		/**
-		 * Render target write mask allows to choose which pixel components should the pixel shader output.
-		 * 			
-		 * Only the first four bits are used. First bit representing red, second green, third blue and fourth alpha value. 
-		 * Set bits means pixel shader will output those channels.
-		 */
-		UINT8 getRenderTargetWriteMask(UINT32 renderTargetIdx) const;
-
-		/** Returns the hash value generated from the blend state properties. */
-		UINT64 getHash() const { return mHash; }
-
-	protected:
-		friend class BlendState;
-		friend class BlendStateCore;
-		friend class BlendStateRTTI;
-
-		BLEND_STATE_DESC mData;
-		UINT64 mHash;
-	};
-
-	/** @cond INTERNAL */
-
-	/**
-	 * Core thread version of BlendState.
-	 *
-	 * @note	Core thread.
-	 */
-	class BS_CORE_EXPORT BlendStateCore : public CoreObjectCore
-	{
-	public:
-		virtual ~BlendStateCore();
-
-		/** Returns information about the blend state. */
-		const BlendProperties& getProperties() const;
-
-		/** Returns a unique state ID. Only the lowest 10 bits are used. */
-		UINT32 getId() const { return mId; }
-
-		/**	Returns the default blend state that you may use when no other is available. */
-		static const SPtr<BlendStateCore>& getDefault();
-
-	protected:
-		friend class RenderStateCoreManager;
-
-		BlendStateCore(const BLEND_STATE_DESC& desc, UINT32 id);
-
-		/** @copydoc CoreObjectCore::initialize */
-		void initialize() override;
-
-		/**	Creates any API-specific state objects. */
-		virtual void createInternal() { }
-
-		BlendProperties mProperties;
-		UINT32 mId;
-	};
-
-	/** @endcond */
-
-	/**
-	 * Render system pipeline state that allows you to modify how an object is rendered. More exactly this state allows to 
-	 * you to control how is a rendered object blended with any previously renderer objects.
-	 * 			
-	 * @note	Blend states are immutable. Sim thread only.
-	 */
-	class BS_CORE_EXPORT BlendState : public IReflectable, public CoreObject
-	{
-	public:
-		virtual ~BlendState();
-
-		/**	Returns information about a blend state. */
-		const BlendProperties& getProperties() const;
-
-		/** Retrieves a core implementation of the sampler state usable only from the core thread. */
-		SPtr<BlendStateCore> getCore() const;
-
-		/**	Creates a new blend state using the specified blend state description structure. */
-		static BlendStatePtr create(const BLEND_STATE_DESC& desc);
-
-		/**	Returns the default blend state that you may use when no other is available. */
-		static const BlendStatePtr& getDefault();
-
-		/**	Generates a hash value from a blend state descriptor. */
-		static UINT64 generateHash(const BLEND_STATE_DESC& desc);
-
-	protected:
-		friend class RenderStateManager;
-
-		BlendState(const BLEND_STATE_DESC& desc);
-
-		/** @copydoc CoreObjectCore::createCore */
-		SPtr<CoreObjectCore> createCore() const override;
-
-		BlendProperties mProperties;
-		mutable UINT32 mId;
-
-		/************************************************************************/
-		/* 								RTTI		                     		*/
-		/************************************************************************/
-
-	public:
-		friend class BlendStateRTTI;
-		static RTTITypeBase* getRTTIStatic();
-		virtual RTTITypeBase* getRTTI() const override;	
-	};
-
-	/** @} */
-}
-
-/** @cond STDLIB */
-/** @addtogroup RenderAPI
- *  @{
- */
-
-/**	Hash value generator for BLEND_STATE_DESC. */
-template<>
-struct std::hash<BansheeEngine::BLEND_STATE_DESC>
-{
-	size_t operator()(const BansheeEngine::BLEND_STATE_DESC& value) const
-	{
-		return (size_t)BansheeEngine::BlendState::generateHash(value);
-	}
-};
-
-/** @} */
-/** @endcond */
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+#pragma once
+
+#include "BsCorePrerequisites.h"
+#include "BsResource.h"
+
+namespace BansheeEngine
+{
+	/** @addtogroup RenderAPI
+	 *  @{
+	 */
+
+	/**
+	 * Structure that describes blend states for a single render target. Used internally by BLEND_STATE_DESC for 
+	 * initializing a BlendState.
+	 * 			
+	 * @see		BLEND_STATE_DESC
+	 * @see		BlendState
+	 */
+	struct BS_CORE_EXPORT RENDER_TARGET_BLEND_STATE_DESC
+	{
+		RENDER_TARGET_BLEND_STATE_DESC()
+			: blendEnable(false)
+			, srcBlend(BF_ONE)
+			, dstBlend(BF_ZERO)
+			, blendOp(BO_ADD)
+			, srcBlendAlpha(BF_ONE)
+			, dstBlendAlpha(BF_ZERO)
+			, blendOpAlpha(BO_ADD)
+			, renderTargetWriteMask(0xFF)
+		{ }
+
+		bool operator==(const RENDER_TARGET_BLEND_STATE_DESC& rhs) const;
+
+		bool blendEnable;
+		BlendFactor srcBlend;
+		BlendFactor dstBlend;
+		BlendOperation blendOp;
+		BlendFactor srcBlendAlpha;
+		BlendFactor dstBlendAlpha;
+		BlendOperation blendOpAlpha;
+		// Enable write to RGBA channels separately by setting first four bits (0 - R, 1 - G, 2 - B, 3 - A)
+		UINT8 renderTargetWriteMask;
+	};
+
+	/** Structure that describes render pipeline blend states. Used for initializing BlendState. */
+	struct BS_CORE_EXPORT BLEND_STATE_DESC
+	{
+		BLEND_STATE_DESC()
+			: alphaToCoverageEnable(false)
+			, independantBlendEnable(false)
+		{ }
+
+		bool operator==(const BLEND_STATE_DESC& rhs) const;
+
+		bool alphaToCoverageEnable;
+		bool independantBlendEnable;
+		RENDER_TARGET_BLEND_STATE_DESC renderTargetDesc[BS_MAX_MULTIPLE_RENDER_TARGETS];
+	};
+
+	/** Properties of a BlendState. Shared between sim and core thread versions of BlendState. */
+	class BS_CORE_EXPORT BlendProperties
+	{
+	public:
+		BlendProperties(const BLEND_STATE_DESC& desc);
+
+		/**
+		 * Alpha to coverage allows you to perform blending without needing to worry about order of rendering like regular 
+		 * blending does. It requires multi-sampling to be active in order to work, and you need to supply an alpha texture
+		 * that determines object transparency.
+		 *
+		 * Blending is then performed by only using sub-samples covered by the alpha texture for the current pixel and 
+		 * combining them with sub-samples previously stored. 
+		 *			
+		 * Be aware this is a limited technique only useful for certain situations. Unless you are having performance 
+		 * problems use regular blending.
+		 */
+		bool getAlphaToCoverageEnabled() const { return mData.alphaToCoverageEnable; }
+
+		/**
+		 * When not set, only the first render target blend descriptor will be used for all render targets. If set each 
+		 * render target will use its own blend descriptor.
+		 */
+		bool getIndependantBlendEnable() const { return mData.independantBlendEnable; }
+
+		/**
+		 * Queries is blending enabled for the specified render target. Blending allows you to combine the color from 
+		 * current and previous pixel based on some value.
+		 */
+		bool getBlendEnabled(UINT32 renderTargetIdx) const;
+
+		/**
+		 * Determines what should the source blend factor be. This value determines what will the color being generated 
+		 * currently be multiplied by.
+		 */
+		BlendFactor getSrcBlend(UINT32 renderTargetIdx) const;
+
+		/**
+		 * Determines what should the destination blend factor be. This value determines what will the color already in 
+		 * render target be multiplied by.
+		 */
+		BlendFactor getDstBlend(UINT32 renderTargetIdx) const;
+
+		/**
+		 * Determines how are source and destination colors combined (after they are multiplied by their respective blend 
+		 * factors).
+		 */
+		BlendOperation getBlendOperation(UINT32 renderTargetIdx) const;
+
+		/**
+		 * Determines what should the alpha source blend factor be. This value determines what will the alpha value being 
+		 * generated currently be multiplied by.
+		 */
+		BlendFactor getAlphaSrcBlend(UINT32 renderTargetIdx) const;
+
+		/**
+		 * Determines what should the alpha destination blend factor be. This value determines what will the alpha value 
+		 * already in render target be multiplied by.
+		 */
+		BlendFactor getAlphaDstBlend(UINT32 renderTargetIdx) const;
+
+		/**
+		 * Determines how are source and destination alpha values combined (after they are multiplied by their respective
+		 * blend factors).
+		 */
+		BlendOperation getAlphaBlendOperation(UINT32 renderTargetIdx) const;
+
+		/**
+		 * Render target write mask allows to choose which pixel components should the pixel shader output.
+		 * 			
+		 * Only the first four bits are used. First bit representing red, second green, third blue and fourth alpha value. 
+		 * Set bits means pixel shader will output those channels.
+		 */
+		UINT8 getRenderTargetWriteMask(UINT32 renderTargetIdx) const;
+
+		/** Returns the hash value generated from the blend state properties. */
+		UINT64 getHash() const { return mHash; }
+
+	protected:
+		friend class BlendState;
+		friend class BlendStateCore;
+		friend class BlendStateRTTI;
+
+		BLEND_STATE_DESC mData;
+		UINT64 mHash;
+	};
+
+	/**
+	 * Render system pipeline state that allows you to modify how an object is rendered. More exactly this state allows to 
+	 * you to control how is a rendered object blended with any previously renderer objects.
+	 * 			
+	 * @note	Blend states are immutable. Sim thread only.
+	 */
+	class BS_CORE_EXPORT BlendState : public IReflectable, public CoreObject
+	{
+	public:
+		virtual ~BlendState();
+
+		/**	Returns information about a blend state. */
+		const BlendProperties& getProperties() const;
+
+		/** Retrieves a core implementation of the sampler state usable only from the core thread. */
+		SPtr<BlendStateCore> getCore() const;
+
+		/**	Creates a new blend state using the specified blend state description structure. */
+		static BlendStatePtr create(const BLEND_STATE_DESC& desc);
+
+		/**	Returns the default blend state that you may use when no other is available. */
+		static const BlendStatePtr& getDefault();
+
+		/**	Generates a hash value from a blend state descriptor. */
+		static UINT64 generateHash(const BLEND_STATE_DESC& desc);
+
+	protected:
+		friend class RenderStateManager;
+
+		BlendState(const BLEND_STATE_DESC& desc);
+
+		/** @copydoc CoreObjectCore::createCore */
+		SPtr<CoreObjectCore> createCore() const override;
+
+		BlendProperties mProperties;
+		mutable UINT32 mId;
+
+		/************************************************************************/
+		/* 								RTTI		                     		*/
+		/************************************************************************/
+
+	public:
+		friend class BlendStateRTTI;
+		static RTTITypeBase* getRTTIStatic();
+		virtual RTTITypeBase* getRTTI() const override;	
+	};
+
+	/** @} */
+	/** @addtogroup RenderAPI-Internal
+	 *  @{
+	 */
+
+	/**
+	 * Core thread version of BlendState.
+	 *
+	 * @note	Core thread.
+	 */
+	class BS_CORE_EXPORT BlendStateCore : public CoreObjectCore
+	{
+	public:
+		virtual ~BlendStateCore();
+
+		/** Returns information about the blend state. */
+		const BlendProperties& getProperties() const;
+
+		/** Returns a unique state ID. Only the lowest 10 bits are used. */
+		UINT32 getId() const { return mId; }
+
+		/**	Returns the default blend state that you may use when no other is available. */
+		static const SPtr<BlendStateCore>& getDefault();
+
+	protected:
+		friend class RenderStateCoreManager;
+
+		BlendStateCore(const BLEND_STATE_DESC& desc, UINT32 id);
+
+		/** @copydoc CoreObjectCore::initialize */
+		void initialize() override;
+
+		/**	Creates any API-specific state objects. */
+		virtual void createInternal() { }
+
+		BlendProperties mProperties;
+		UINT32 mId;
+	};
+
+	/** @} */
+}
+
+/** @cond STDLIB */
+/** @addtogroup RenderAPI
+ *  @{
+ */
+
+/**	Hash value generator for BLEND_STATE_DESC. */
+template<>
+struct std::hash<BansheeEngine::BLEND_STATE_DESC>
+{
+	size_t operator()(const BansheeEngine::BLEND_STATE_DESC& value) const
+	{
+		return (size_t)BansheeEngine::BlendState::generateHash(value);
+	}
+};
+
+/** @} */
+/** @endcond */

+ 379 - 381
Source/BansheeCore/Include/BsCommandQueue.h

@@ -1,382 +1,380 @@
-//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
-//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
-#pragma once
-
-#include "BsCorePrerequisites.h"
-#include "BsAsyncOp.h"
-#include <functional>
-
-namespace BansheeEngine
-{
-	/** @cond INTERNAL */
-	/** @addtogroup CoreThread
-	 *  @{
-	 */
-
-	/**
-	 * Command queue policy that provides no synchonization. Should be used with command queues that are used on a single 
-	 * thread only.
-	 */
-	class CommandQueueNoSync
-	{
-	public:
-		CommandQueueNoSync() {}
-		virtual ~CommandQueueNoSync() {}
-
-		bool isValidThread(BS_THREAD_ID_TYPE ownerThread) const
-		{
-			return BS_THREAD_CURRENT_ID == ownerThread;
-		}
-
-		void lock() { };
-		void unlock() { }
-	};
-
-	/**
-	 * Command queue policy that provides synchonization. Should be used with command queues that are used on multiple 
-	 * threads.
-	 */
-	class CommandQueueSync
-	{
-	public:
-		CommandQueueSync()
-			:mLock(mCommandQueueMutex, BS_DEFER_LOCK)
-		{ }
-		virtual ~CommandQueueSync() {}
-
-		bool isValidThread(BS_THREAD_ID_TYPE ownerThread) const
-		{
-			return true;
-		}
-
-		void lock() 
-		{
-			mLock.lock();
-		};
-
-		void unlock()
-		{
-			mLock.unlock();
-		}
-
-	private:
-		BS_MUTEX(mCommandQueueMutex);
-		BS_LOCK_TYPE mLock;
-	};
-
-	/**
-	 * Represents a single queued command in the command list. Contains all the data for executing the command and checking 
-	 * up on the command status.
-	 */
-	struct QueuedCommand
-	{
-#if BS_DEBUG_MODE
-		QueuedCommand(std::function<void(AsyncOp&)> _callback, UINT32 _debugId, const AsyncOpSyncDataPtr& asyncOpSyncData,
-			bool _notifyWhenComplete = false, UINT32 _callbackId = 0)
-			:callbackWithReturnValue(_callback), debugId(_debugId), returnsValue(true), 
-			notifyWhenComplete(_notifyWhenComplete), callbackId(_callbackId), asyncOp(asyncOpSyncData)
-		{ }
-
-		QueuedCommand(std::function<void()> _callback, UINT32 _debugId, bool _notifyWhenComplete = false, UINT32 _callbackId = 0)
-			:callback(_callback), debugId(_debugId), returnsValue(false), notifyWhenComplete(_notifyWhenComplete), callbackId(_callbackId), asyncOp(AsyncOpEmpty())
-		{ }
-
-		UINT32 debugId;
-#else
-		QueuedCommand(std::function<void(AsyncOp&)> _callback, const AsyncOpSyncDataPtr& asyncOpSyncData, 
-			bool _notifyWhenComplete = false, UINT32 _callbackId = 0)
-			:callbackWithReturnValue(_callback), returnsValue(true), notifyWhenComplete(_notifyWhenComplete), 
-			callbackId(_callbackId), asyncOp(asyncOpSyncData)
-		{ }
-
-		QueuedCommand(std::function<void()> _callback, bool _notifyWhenComplete = false, UINT32 _callbackId = 0)
-			:callback(_callback), returnsValue(false), notifyWhenComplete(_notifyWhenComplete), callbackId(_callbackId), asyncOp(AsyncOpEmpty())
-		{ }
-#endif
-
-		~QueuedCommand()
-		{ }
-
-		QueuedCommand(const QueuedCommand& source)
-		{
-			callback = source.callback;
-			callbackWithReturnValue = source.callbackWithReturnValue;
-			asyncOp = source.asyncOp;
-			returnsValue = source.returnsValue;
-			callbackId = source.callbackId;
-			notifyWhenComplete = source.notifyWhenComplete;
-
-#if BS_DEBUG_MODE
-			debugId = source.debugId;
-#endif
-		}
-
-		QueuedCommand& operator=(const QueuedCommand& rhs)
-		{
-			callback = rhs.callback;
-			callbackWithReturnValue = rhs.callbackWithReturnValue;
-			asyncOp = rhs.asyncOp;
-			returnsValue = rhs.returnsValue;
-			callbackId = rhs.callbackId;
-			notifyWhenComplete = rhs.notifyWhenComplete;
-			
-#if BS_DEBUG_MODE
-			debugId = rhs.debugId;
-#endif
-
-			return *this;
-		}
-
-		std::function<void()> callback;
-		std::function<void(AsyncOp&)> callbackWithReturnValue;
-		AsyncOp asyncOp;
-		bool returnsValue;
-		UINT32 callbackId;
-		bool notifyWhenComplete;
-	};
-
-	/** Manages a list of commands that can be queued for later execution on the core thread. */
-	class BS_CORE_EXPORT CommandQueueBase
-	{
-	public:
-		/**
-		 * Constructor.
-		 *
-		 * @param[in]	threadId	   	Identifier for the thread the command queue will be getting commands from.					
-		 */
-		CommandQueueBase(BS_THREAD_ID_TYPE threadId);
-		virtual ~CommandQueueBase();
-
-		/**
-		 * Gets the thread identifier the command queue is used on.
-		 * 			
-		 * @note	If the command queue is using a synchonized access policy generally this is not relevant as it may be 
-		 *			used on multiple threads.
-		 */
-		BS_THREAD_ID_TYPE getThreadId() const { return mMyThreadId; }
-
-		/**
-		 * Executes all provided commands one by one in order. To get the commands you should call flush().
-		 *
-		 * @param[in]	notifyCallback  	Callback that will be called if a command that has @p notifyOnComplete flag set.
-		 * 									The callback will receive @p callbackId of the command.
-		 */
-		void playbackWithNotify(Queue<QueuedCommand>* commands, std::function<void(UINT32)> notifyCallback);
-
-		/** Executes all provided commands one by one in order. To get the commands you should call flush(). */
-		void playback(Queue<QueuedCommand>* commands);
-
-		/**
-		 * Allows you to set a breakpoint that will trigger when the specified command is executed.		
-		 *
-		 * @param[in]	queueIdx  	Zero-based index of the queue the command was queued on.
-		 * @param[in]	commandIdx	Zero-based index of the command.
-		 *
-		 * @note	
-		 * This is helpful when you receive an error on the executing thread and you cannot tell from where was the command 
-		 * that caused the error queued from. However you can make a note of the queue and command index and set a 
-		 * breakpoint so that it gets triggered next time you run the program. At that point you can know exactly which part
-		 * of code queued the command by examining the stack trace.
-		 */
-		static void addBreakpoint(UINT32 queueIdx, UINT32 commandIdx);
-
-		/**
-		 * Queue up a new command to execute. Make sure the provided function has all of its parameters properly bound. 
-		 * Last parameter must be unbound and of AsyncOp& type. This is used to signal that the command is completed, and 
-		 * also for storing the return value.		
-		 *
-		 * @param[in]	_notifyWhenComplete	(optional) Call the notify method (provided in the call to playback())
-		 * 									when the command is complete.
-		 * @param[in]	_callbackId			(optional) Identifier for the callback so you can then later find it
-		 * 									if needed.
-		 *
-		 * @return							Async operation object that you can continuously check until the command 
-		 *									completes. After it completes AsyncOp::isResolved() will return true and return 
-		 *									data will be valid (if the callback provided any).
-		 *
-		 * @note	
-		 * Callback method also needs to call AsyncOp::markAsResolved once it is done processing. (If it doesn't it will 
-		 * still be called automatically, but the return value will default to nullptr)
-		 */
-		AsyncOp queueReturn(std::function<void(AsyncOp&)> commandCallback, bool _notifyWhenComplete = false, UINT32 _callbackId = 0);
-
-		/**
-		 * Queue up a new command to execute. Make sure the provided function has all of its parameters properly bound. 
-		 * Provided command is not expected to return a value. If you wish to return a value from the callback use the 
-		 * queueReturn() which accepts an AsyncOp parameter.
-		 *
-		 * @param[in]	_notifyWhenComplete	(optional) Call the notify method (provided in the call to playback())
-		 * 									when the command is complete.
-		 * @param[in]	_callbackId		   	(optional) Identifier for the callback so you can then later find
-		 * 									it if needed.
-		 */
-		void queue(std::function<void()> commandCallback, bool _notifyWhenComplete = false, UINT32 _callbackId = 0);
-
-		/**
-		 * Returns a copy of all queued commands and makes room for new ones. Must be called from the thread that created 
-		 * the command queue. Returned commands must be passed to playback() method.
-		 */
-		Queue<QueuedCommand>* flush();
-
-		/** Cancels all currently queued commands. */
-		void cancelAll();
-
-		/**	Returns true if no commands are queued. */
-		bool isEmpty();
-
-	protected:
-		/**
-		 * Helper method that throws an "Invalid thread" exception. Used primarily so we can avoid including Exception 
-		 * include in this header.
-		 */
-		void throwInvalidThreadException(const String& message) const;
-
-	private:
-		Queue<QueuedCommand>* mCommands;
-		Stack<Queue<QueuedCommand>*> mEmptyCommandQueues; /**< List of empty queues for reuse. */
-
-		AsyncOpSyncDataPtr mAsyncOpSyncData;
-		BS_THREAD_ID_TYPE mMyThreadId;
-
-		// Various variables that allow for easier debugging by allowing us to trigger breakpoints
-		// when a certain command was queued.
-#if BS_DEBUG_MODE
-		struct QueueBreakpoint
-		{
-			class HashFunction
-			{
-			public:
-				size_t operator()(const QueueBreakpoint &key) const;
-			};
-
-			class EqualFunction
-			{
-			public:
-				bool operator()(const QueueBreakpoint &a, const QueueBreakpoint &b) const;
-			};
-
-			QueueBreakpoint(UINT32 _queueIdx, UINT32 _commandIdx)
-				:queueIdx(_queueIdx), commandIdx(_commandIdx)
-			{ }
-
-			UINT32 queueIdx;
-			UINT32 commandIdx;
-
-			inline size_t operator()(const QueueBreakpoint& v) const;
-		};
-
-		UINT32 mMaxDebugIdx;
-		UINT32 mCommandQueueIdx;
-		
-		static UINT32 MaxCommandQueueIdx;
-		static UnorderedSet<QueueBreakpoint, QueueBreakpoint::HashFunction, QueueBreakpoint::EqualFunction> SetBreakpoints;
-		BS_STATIC_MUTEX(CommandQueueBreakpointMutex);
-
-		/** Checks if the specified command has a breakpoint and throw an assert if it does. */
-		static void breakIfNeeded(UINT32 queueIdx, UINT32 commandIdx);
-#endif
-	};
-
-	/**
-	 * @copydoc CommandQueueBase
-	 * 			
-	 * Use SyncPolicy to choose whether you want command queue be synchonized or not. Synchonized command queues may be 
-	 * used across multiple threads and non-synchonized only on one.
-	 */
-	template<class SyncPolicy = CommandQueueNoSync>
-	class CommandQueue : public CommandQueueBase, public SyncPolicy
-	{
-	public:
-		/** @copydoc CommandQueueBase::CommandQueueBase */
-		CommandQueue(BS_THREAD_ID_TYPE threadId)
-			:CommandQueueBase(threadId)
-		{ }
-
-		~CommandQueue() 
-		{ }
-
-		/** @copydoc CommandQueueBase::queueReturn */
-		AsyncOp queueReturn(std::function<void(AsyncOp&)> commandCallback, bool _notifyWhenComplete = false, UINT32 _callbackId = 0)
-		{
-#if BS_DEBUG_MODE
-#if BS_THREAD_SUPPORT != 0
-			if(!isValidThread(getThreadId()))
-				throwInvalidThreadException("Command queue accessed outside of its creation thread.");
-#endif
-#endif
-
-			lock();
-			AsyncOp asyncOp = CommandQueueBase::queueReturn(commandCallback, _notifyWhenComplete, _callbackId);
-			unlock();
-
-			return asyncOp;
-		}
-
-		/** @copydoc CommandQueueBase::queue */
-		void queue(std::function<void()> commandCallback, bool _notifyWhenComplete = false, UINT32 _callbackId = 0)
-		{
-#if BS_DEBUG_MODE
-#if BS_THREAD_SUPPORT != 0
-			if(!isValidThread(getThreadId()))
-				throwInvalidThreadException("Command queue accessed outside of its creation thread.");
-#endif
-#endif
-
-			lock();
-			CommandQueueBase::queue(commandCallback, _notifyWhenComplete, _callbackId);
-			unlock();
-		}
-
-		/** @copydoc CommandQueueBase::flush */
-		BansheeEngine::Queue<QueuedCommand>* flush()
-		{
-#if BS_DEBUG_MODE
-#if BS_THREAD_SUPPORT != 0
-			if(!isValidThread(getThreadId()))
-				throwInvalidThreadException("Command queue accessed outside of its creation thread.");
-#endif
-#endif
-
-			lock();
-			BansheeEngine::Queue<QueuedCommand>* commands = CommandQueueBase::flush();
-			unlock();
-
-			return commands;
-		}
-
-		/** @copydoc CommandQueueBase::cancelAll */
-		void cancelAll()
-		{
-#if BS_DEBUG_MODE
-#if BS_THREAD_SUPPORT != 0
-			if(!isValidThread(getThreadId()))
-				throwInvalidThreadException("Command queue accessed outside of its creation thread.");
-#endif
-#endif
-
-			lock();
-			CommandQueueBase::cancelAll();
-			unlock();
-		}
-
-		/** @copydoc CommandQueueBase::isEmpty */
-		bool isEmpty()
-		{
-#if BS_DEBUG_MODE
-#if BS_THREAD_SUPPORT != 0
-			if(!isValidThread(getThreadId()))
-				throwInvalidThreadException("Command queue accessed outside of its creation thread.");
-#endif
-#endif
-
-			lock();
-			bool empty = CommandQueueBase::isEmpty();
-			unlock();
-
-			return empty;
-		}
-	};
-
-	/** @} */
-	/** @endcond */
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+#pragma once
+
+#include "BsCorePrerequisites.h"
+#include "BsAsyncOp.h"
+#include <functional>
+
+namespace BansheeEngine
+{
+	/** @addtogroup CoreThread-Internal
+	 *  @{
+	 */
+
+	/**
+	 * Command queue policy that provides no synchonization. Should be used with command queues that are used on a single 
+	 * thread only.
+	 */
+	class CommandQueueNoSync
+	{
+	public:
+		CommandQueueNoSync() {}
+		virtual ~CommandQueueNoSync() {}
+
+		bool isValidThread(BS_THREAD_ID_TYPE ownerThread) const
+		{
+			return BS_THREAD_CURRENT_ID == ownerThread;
+		}
+
+		void lock() { };
+		void unlock() { }
+	};
+
+	/**
+	 * Command queue policy that provides synchonization. Should be used with command queues that are used on multiple 
+	 * threads.
+	 */
+	class CommandQueueSync
+	{
+	public:
+		CommandQueueSync()
+			:mLock(mCommandQueueMutex, BS_DEFER_LOCK)
+		{ }
+		virtual ~CommandQueueSync() {}
+
+		bool isValidThread(BS_THREAD_ID_TYPE ownerThread) const
+		{
+			return true;
+		}
+
+		void lock() 
+		{
+			mLock.lock();
+		};
+
+		void unlock()
+		{
+			mLock.unlock();
+		}
+
+	private:
+		BS_MUTEX(mCommandQueueMutex);
+		BS_LOCK_TYPE mLock;
+	};
+
+	/**
+	 * Represents a single queued command in the command list. Contains all the data for executing the command and checking 
+	 * up on the command status.
+	 */
+	struct QueuedCommand
+	{
+#if BS_DEBUG_MODE
+		QueuedCommand(std::function<void(AsyncOp&)> _callback, UINT32 _debugId, const AsyncOpSyncDataPtr& asyncOpSyncData,
+			bool _notifyWhenComplete = false, UINT32 _callbackId = 0)
+			:callbackWithReturnValue(_callback), debugId(_debugId), returnsValue(true), 
+			notifyWhenComplete(_notifyWhenComplete), callbackId(_callbackId), asyncOp(asyncOpSyncData)
+		{ }
+
+		QueuedCommand(std::function<void()> _callback, UINT32 _debugId, bool _notifyWhenComplete = false, UINT32 _callbackId = 0)
+			:callback(_callback), debugId(_debugId), returnsValue(false), notifyWhenComplete(_notifyWhenComplete), callbackId(_callbackId), asyncOp(AsyncOpEmpty())
+		{ }
+
+		UINT32 debugId;
+#else
+		QueuedCommand(std::function<void(AsyncOp&)> _callback, const AsyncOpSyncDataPtr& asyncOpSyncData, 
+			bool _notifyWhenComplete = false, UINT32 _callbackId = 0)
+			:callbackWithReturnValue(_callback), returnsValue(true), notifyWhenComplete(_notifyWhenComplete), 
+			callbackId(_callbackId), asyncOp(asyncOpSyncData)
+		{ }
+
+		QueuedCommand(std::function<void()> _callback, bool _notifyWhenComplete = false, UINT32 _callbackId = 0)
+			:callback(_callback), returnsValue(false), notifyWhenComplete(_notifyWhenComplete), callbackId(_callbackId), asyncOp(AsyncOpEmpty())
+		{ }
+#endif
+
+		~QueuedCommand()
+		{ }
+
+		QueuedCommand(const QueuedCommand& source)
+		{
+			callback = source.callback;
+			callbackWithReturnValue = source.callbackWithReturnValue;
+			asyncOp = source.asyncOp;
+			returnsValue = source.returnsValue;
+			callbackId = source.callbackId;
+			notifyWhenComplete = source.notifyWhenComplete;
+
+#if BS_DEBUG_MODE
+			debugId = source.debugId;
+#endif
+		}
+
+		QueuedCommand& operator=(const QueuedCommand& rhs)
+		{
+			callback = rhs.callback;
+			callbackWithReturnValue = rhs.callbackWithReturnValue;
+			asyncOp = rhs.asyncOp;
+			returnsValue = rhs.returnsValue;
+			callbackId = rhs.callbackId;
+			notifyWhenComplete = rhs.notifyWhenComplete;
+			
+#if BS_DEBUG_MODE
+			debugId = rhs.debugId;
+#endif
+
+			return *this;
+		}
+
+		std::function<void()> callback;
+		std::function<void(AsyncOp&)> callbackWithReturnValue;
+		AsyncOp asyncOp;
+		bool returnsValue;
+		UINT32 callbackId;
+		bool notifyWhenComplete;
+	};
+
+	/** Manages a list of commands that can be queued for later execution on the core thread. */
+	class BS_CORE_EXPORT CommandQueueBase
+	{
+	public:
+		/**
+		 * Constructor.
+		 *
+		 * @param[in]	threadId	   	Identifier for the thread the command queue will be getting commands from.					
+		 */
+		CommandQueueBase(BS_THREAD_ID_TYPE threadId);
+		virtual ~CommandQueueBase();
+
+		/**
+		 * Gets the thread identifier the command queue is used on.
+		 * 			
+		 * @note	If the command queue is using a synchonized access policy generally this is not relevant as it may be 
+		 *			used on multiple threads.
+		 */
+		BS_THREAD_ID_TYPE getThreadId() const { return mMyThreadId; }
+
+		/**
+		 * Executes all provided commands one by one in order. To get the commands you should call flush().
+		 *
+		 * @param[in]	notifyCallback  	Callback that will be called if a command that has @p notifyOnComplete flag set.
+		 * 									The callback will receive @p callbackId of the command.
+		 */
+		void playbackWithNotify(Queue<QueuedCommand>* commands, std::function<void(UINT32)> notifyCallback);
+
+		/** Executes all provided commands one by one in order. To get the commands you should call flush(). */
+		void playback(Queue<QueuedCommand>* commands);
+
+		/**
+		 * Allows you to set a breakpoint that will trigger when the specified command is executed.		
+		 *
+		 * @param[in]	queueIdx  	Zero-based index of the queue the command was queued on.
+		 * @param[in]	commandIdx	Zero-based index of the command.
+		 *
+		 * @note	
+		 * This is helpful when you receive an error on the executing thread and you cannot tell from where was the command 
+		 * that caused the error queued from. However you can make a note of the queue and command index and set a 
+		 * breakpoint so that it gets triggered next time you run the program. At that point you can know exactly which part
+		 * of code queued the command by examining the stack trace.
+		 */
+		static void addBreakpoint(UINT32 queueIdx, UINT32 commandIdx);
+
+		/**
+		 * Queue up a new command to execute. Make sure the provided function has all of its parameters properly bound. 
+		 * Last parameter must be unbound and of AsyncOp& type. This is used to signal that the command is completed, and 
+		 * also for storing the return value.		
+		 *
+		 * @param[in]	_notifyWhenComplete	(optional) Call the notify method (provided in the call to playback())
+		 * 									when the command is complete.
+		 * @param[in]	_callbackId			(optional) Identifier for the callback so you can then later find it
+		 * 									if needed.
+		 *
+		 * @return							Async operation object that you can continuously check until the command 
+		 *									completes. After it completes AsyncOp::isResolved() will return true and return 
+		 *									data will be valid (if the callback provided any).
+		 *
+		 * @note	
+		 * Callback method also needs to call AsyncOp::markAsResolved once it is done processing. (If it doesn't it will 
+		 * still be called automatically, but the return value will default to nullptr)
+		 */
+		AsyncOp queueReturn(std::function<void(AsyncOp&)> commandCallback, bool _notifyWhenComplete = false, UINT32 _callbackId = 0);
+
+		/**
+		 * Queue up a new command to execute. Make sure the provided function has all of its parameters properly bound. 
+		 * Provided command is not expected to return a value. If you wish to return a value from the callback use the 
+		 * queueReturn() which accepts an AsyncOp parameter.
+		 *
+		 * @param[in]	_notifyWhenComplete	(optional) Call the notify method (provided in the call to playback())
+		 * 									when the command is complete.
+		 * @param[in]	_callbackId		   	(optional) Identifier for the callback so you can then later find
+		 * 									it if needed.
+		 */
+		void queue(std::function<void()> commandCallback, bool _notifyWhenComplete = false, UINT32 _callbackId = 0);
+
+		/**
+		 * Returns a copy of all queued commands and makes room for new ones. Must be called from the thread that created 
+		 * the command queue. Returned commands must be passed to playback() method.
+		 */
+		Queue<QueuedCommand>* flush();
+
+		/** Cancels all currently queued commands. */
+		void cancelAll();
+
+		/**	Returns true if no commands are queued. */
+		bool isEmpty();
+
+	protected:
+		/**
+		 * Helper method that throws an "Invalid thread" exception. Used primarily so we can avoid including Exception 
+		 * include in this header.
+		 */
+		void throwInvalidThreadException(const String& message) const;
+
+	private:
+		Queue<QueuedCommand>* mCommands;
+		Stack<Queue<QueuedCommand>*> mEmptyCommandQueues; /**< List of empty queues for reuse. */
+
+		AsyncOpSyncDataPtr mAsyncOpSyncData;
+		BS_THREAD_ID_TYPE mMyThreadId;
+
+		// Various variables that allow for easier debugging by allowing us to trigger breakpoints
+		// when a certain command was queued.
+#if BS_DEBUG_MODE
+		struct QueueBreakpoint
+		{
+			class HashFunction
+			{
+			public:
+				size_t operator()(const QueueBreakpoint &key) const;
+			};
+
+			class EqualFunction
+			{
+			public:
+				bool operator()(const QueueBreakpoint &a, const QueueBreakpoint &b) const;
+			};
+
+			QueueBreakpoint(UINT32 _queueIdx, UINT32 _commandIdx)
+				:queueIdx(_queueIdx), commandIdx(_commandIdx)
+			{ }
+
+			UINT32 queueIdx;
+			UINT32 commandIdx;
+
+			inline size_t operator()(const QueueBreakpoint& v) const;
+		};
+
+		UINT32 mMaxDebugIdx;
+		UINT32 mCommandQueueIdx;
+		
+		static UINT32 MaxCommandQueueIdx;
+		static UnorderedSet<QueueBreakpoint, QueueBreakpoint::HashFunction, QueueBreakpoint::EqualFunction> SetBreakpoints;
+		BS_STATIC_MUTEX(CommandQueueBreakpointMutex);
+
+		/** Checks if the specified command has a breakpoint and throw an assert if it does. */
+		static void breakIfNeeded(UINT32 queueIdx, UINT32 commandIdx);
+#endif
+	};
+
+	/**
+	 * @copydoc CommandQueueBase
+	 * 			
+	 * Use SyncPolicy to choose whether you want command queue be synchonized or not. Synchonized command queues may be 
+	 * used across multiple threads and non-synchonized only on one.
+	 */
+	template<class SyncPolicy = CommandQueueNoSync>
+	class CommandQueue : public CommandQueueBase, public SyncPolicy
+	{
+	public:
+		/** @copydoc CommandQueueBase::CommandQueueBase */
+		CommandQueue(BS_THREAD_ID_TYPE threadId)
+			:CommandQueueBase(threadId)
+		{ }
+
+		~CommandQueue() 
+		{ }
+
+		/** @copydoc CommandQueueBase::queueReturn */
+		AsyncOp queueReturn(std::function<void(AsyncOp&)> commandCallback, bool _notifyWhenComplete = false, UINT32 _callbackId = 0)
+		{
+#if BS_DEBUG_MODE
+#if BS_THREAD_SUPPORT != 0
+			if(!isValidThread(getThreadId()))
+				throwInvalidThreadException("Command queue accessed outside of its creation thread.");
+#endif
+#endif
+
+			lock();
+			AsyncOp asyncOp = CommandQueueBase::queueReturn(commandCallback, _notifyWhenComplete, _callbackId);
+			unlock();
+
+			return asyncOp;
+		}
+
+		/** @copydoc CommandQueueBase::queue */
+		void queue(std::function<void()> commandCallback, bool _notifyWhenComplete = false, UINT32 _callbackId = 0)
+		{
+#if BS_DEBUG_MODE
+#if BS_THREAD_SUPPORT != 0
+			if(!isValidThread(getThreadId()))
+				throwInvalidThreadException("Command queue accessed outside of its creation thread.");
+#endif
+#endif
+
+			lock();
+			CommandQueueBase::queue(commandCallback, _notifyWhenComplete, _callbackId);
+			unlock();
+		}
+
+		/** @copydoc CommandQueueBase::flush */
+		BansheeEngine::Queue<QueuedCommand>* flush()
+		{
+#if BS_DEBUG_MODE
+#if BS_THREAD_SUPPORT != 0
+			if(!isValidThread(getThreadId()))
+				throwInvalidThreadException("Command queue accessed outside of its creation thread.");
+#endif
+#endif
+
+			lock();
+			BansheeEngine::Queue<QueuedCommand>* commands = CommandQueueBase::flush();
+			unlock();
+
+			return commands;
+		}
+
+		/** @copydoc CommandQueueBase::cancelAll */
+		void cancelAll()
+		{
+#if BS_DEBUG_MODE
+#if BS_THREAD_SUPPORT != 0
+			if(!isValidThread(getThreadId()))
+				throwInvalidThreadException("Command queue accessed outside of its creation thread.");
+#endif
+#endif
+
+			lock();
+			CommandQueueBase::cancelAll();
+			unlock();
+		}
+
+		/** @copydoc CommandQueueBase::isEmpty */
+		bool isEmpty()
+		{
+#if BS_DEBUG_MODE
+#if BS_THREAD_SUPPORT != 0
+			if(!isValidThread(getThreadId()))
+				throwInvalidThreadException("Command queue accessed outside of its creation thread.");
+#endif
+#endif
+
+			lock();
+			bool empty = CommandQueueBase::isEmpty();
+			unlock();
+
+			return empty;
+		}
+	};
+
+	/** @} */
 }

+ 142 - 144
Source/BansheeCore/Include/BsCoreObjectManager.h

@@ -1,144 +1,142 @@
-//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
-//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
-#pragma once
-
-#include "BsCorePrerequisites.h"
-#include "BsCoreObjectCore.h"
-#include "BsModule.h"
-
-namespace BansheeEngine
-{
-	/** @cond INTERNAL */
-	/** @addtogroup CoreThread
-	 *  @{
-	 */
-
-	// TODO Low priority - Add debug option that would remember a call stack for each resource initialization,
-	// so when we fail to release one we know which one it is.
-	
-	/**
-	 * Manager that keeps track of all active CoreObject%s.
-	 * 			
-	 * @note	Internal class. 
-	 * @note	Thread safe unless specified otherwise.
-	 */
-	class BS_CORE_EXPORT CoreObjectManager : public Module<CoreObjectManager>
-	{
-		/**
-		 * Stores dirty data that is to be transferred from sim  thread to core thread part of a CoreObject, for a single 
-		 * object.
-		 */
-		struct CoreStoredSyncObjData
-		{
-			CoreStoredSyncObjData()
-				:internalId(0)
-			{ }
-
-			CoreStoredSyncObjData(const SPtr<CoreObjectCore> destObj, UINT64 internalId, const CoreSyncData& syncData)
-				:destinationObj(destObj), syncData(syncData), internalId(internalId)
-			{ }
-
-			std::weak_ptr<CoreObjectCore> destinationObj;
-			CoreSyncData syncData;
-			UINT64 internalId;
-		};
-
-		/**
-		 * Stores dirty data that is to be transferred from sim thread to core thread part of a CoreObject, for all dirty
-		 * objects in one frame.
-		 */
-		struct CoreStoredSyncData
-		{
-			FrameAlloc* alloc = nullptr;
-			Vector<CoreStoredSyncObjData> entries;
-		};
-
-		/** Contains information about a dirty CoreObject that requires syncing to the core thread. */	
-		struct DirtyObjectData
-		{
-			CoreObject* object;
-			INT32 syncDataId;
-		};
-
-	public:
-		CoreObjectManager();
-		~CoreObjectManager();
-
-		/** Registers a new CoreObject notifying the manager the object	is created. */
-		UINT64 registerObject(CoreObject* object);
-
-		/** Unregisters a CoreObject notifying the manager the object is destroyed. */
-		void unregisterObject(CoreObject* object);
-
-		/**	Notifies the system that a CoreObject is dirty and needs to be synced with the core thread. */
-		void notifyCoreDirty(CoreObject* object);
-
-		/**	Notifies the system that CoreObject dependencies are dirty and should be updated. */
-		void notifyDependenciesDirty(CoreObject* object);
-
-		/**
-		 * Synchronizes all dirty CoreObjects with the core thread. Their dirty data will be allocated using the global 
-		 * frame allocator and then queued for update using the provided core thread accessor.
-		 *
-		 * @note	Sim thread only.
-		 */
-		void syncToCore(CoreAccessor& accessor);
-
-		/**
-		 * Synchronizes an individual dirty CoreObject with the core thread. Its dirty data will be allocated using the 
-		 * global frame allocator and then queued for update using the provided core thread accessor.
-		 *
-		 * @note	Sim thread only.
-		 */
-		void syncToCore(CoreObject* object, CoreAccessor& accessor);
-
-		/**
-		 * Clears any objects that are dirty and queued for sync on the core thread. Normally you only want to call this 
-		 * during shutdown when you no longer care about any of that data.
-		 */
-		void clearDirty();
-
-	private:
-		/**
-		 * Stores all syncable data from dirty core objects into memory allocated by the provided allocator. Additional 
-		 * meta-data is stored internally to be used by call to syncUpload().
-		 *
-		 * @param[in]	allocator Allocator to use for allocating memory for stored data.
-		 *
-		 * @note	Sim thread only.
-		 * @note	Must be followed by a call to syncUpload() with the same type.
-		 */
-		void syncDownload(FrameAlloc* allocator);
-
-		/**
-		 * Copies all the data stored by previous call to syncDownload() into core thread versions of CoreObjects.
-		 *
-		 * @note	Core thread only.
-		 * @note	Must be preceded by a call to syncDownload().
-		 */
-		void syncUpload();
-
-		/**
-		 * Updates the cached list of dependencies and dependants for the specified object.
-		 * 			
-		 * @param[in]	object			Update to update dependencies for.
-		 * @param[in]	dependencies	New set of dependencies, or null to clear all dependencies.
-		 */
-		void updateDependencies(CoreObject* object, Vector<CoreObject*>* dependencies);
-
-		UINT64 mNextAvailableID;
-		Map<UINT64, CoreObject*> mObjects;
-		Map<UINT64, DirtyObjectData> mDirtyObjects;
-		Map<UINT64, Vector<CoreObject*>> mDependencies;
-		Map<UINT64, Vector<CoreObject*>> mDependants;
-
-		Vector<CoreStoredSyncObjData> mDestroyedSyncData;
-		List<CoreStoredSyncData> mCoreSyncData;
-
-		BS_MUTEX(mObjectsMutex);
-	};
-
-	/** @} */
-	/** @endcond */
-}
-
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+#pragma once
+
+#include "BsCorePrerequisites.h"
+#include "BsCoreObjectCore.h"
+#include "BsModule.h"
+
+namespace BansheeEngine
+{
+	/** @addtogroup CoreThread-Internal
+	 *  @{
+	 */
+
+	// TODO Low priority - Add debug option that would remember a call stack for each resource initialization,
+	// so when we fail to release one we know which one it is.
+	
+	/**
+	 * Manager that keeps track of all active CoreObject%s.
+	 * 			
+	 * @note	Internal class. 
+	 * @note	Thread safe unless specified otherwise.
+	 */
+	class BS_CORE_EXPORT CoreObjectManager : public Module<CoreObjectManager>
+	{
+		/**
+		 * Stores dirty data that is to be transferred from sim  thread to core thread part of a CoreObject, for a single 
+		 * object.
+		 */
+		struct CoreStoredSyncObjData
+		{
+			CoreStoredSyncObjData()
+				:internalId(0)
+			{ }
+
+			CoreStoredSyncObjData(const SPtr<CoreObjectCore> destObj, UINT64 internalId, const CoreSyncData& syncData)
+				:destinationObj(destObj), syncData(syncData), internalId(internalId)
+			{ }
+
+			std::weak_ptr<CoreObjectCore> destinationObj;
+			CoreSyncData syncData;
+			UINT64 internalId;
+		};
+
+		/**
+		 * Stores dirty data that is to be transferred from sim thread to core thread part of a CoreObject, for all dirty
+		 * objects in one frame.
+		 */
+		struct CoreStoredSyncData
+		{
+			FrameAlloc* alloc = nullptr;
+			Vector<CoreStoredSyncObjData> entries;
+		};
+
+		/** Contains information about a dirty CoreObject that requires syncing to the core thread. */	
+		struct DirtyObjectData
+		{
+			CoreObject* object;
+			INT32 syncDataId;
+		};
+
+	public:
+		CoreObjectManager();
+		~CoreObjectManager();
+
+		/** Registers a new CoreObject notifying the manager the object	is created. */
+		UINT64 registerObject(CoreObject* object);
+
+		/** Unregisters a CoreObject notifying the manager the object is destroyed. */
+		void unregisterObject(CoreObject* object);
+
+		/**	Notifies the system that a CoreObject is dirty and needs to be synced with the core thread. */
+		void notifyCoreDirty(CoreObject* object);
+
+		/**	Notifies the system that CoreObject dependencies are dirty and should be updated. */
+		void notifyDependenciesDirty(CoreObject* object);
+
+		/**
+		 * Synchronizes all dirty CoreObjects with the core thread. Their dirty data will be allocated using the global 
+		 * frame allocator and then queued for update using the provided core thread accessor.
+		 *
+		 * @note	Sim thread only.
+		 */
+		void syncToCore(CoreAccessor& accessor);
+
+		/**
+		 * Synchronizes an individual dirty CoreObject with the core thread. Its dirty data will be allocated using the 
+		 * global frame allocator and then queued for update using the provided core thread accessor.
+		 *
+		 * @note	Sim thread only.
+		 */
+		void syncToCore(CoreObject* object, CoreAccessor& accessor);
+
+		/**
+		 * Clears any objects that are dirty and queued for sync on the core thread. Normally you only want to call this 
+		 * during shutdown when you no longer care about any of that data.
+		 */
+		void clearDirty();
+
+	private:
+		/**
+		 * Stores all syncable data from dirty core objects into memory allocated by the provided allocator. Additional 
+		 * meta-data is stored internally to be used by call to syncUpload().
+		 *
+		 * @param[in]	allocator Allocator to use for allocating memory for stored data.
+		 *
+		 * @note	Sim thread only.
+		 * @note	Must be followed by a call to syncUpload() with the same type.
+		 */
+		void syncDownload(FrameAlloc* allocator);
+
+		/**
+		 * Copies all the data stored by previous call to syncDownload() into core thread versions of CoreObjects.
+		 *
+		 * @note	Core thread only.
+		 * @note	Must be preceded by a call to syncDownload().
+		 */
+		void syncUpload();
+
+		/**
+		 * Updates the cached list of dependencies and dependants for the specified object.
+		 * 			
+		 * @param[in]	object			Update to update dependencies for.
+		 * @param[in]	dependencies	New set of dependencies, or null to clear all dependencies.
+		 */
+		void updateDependencies(CoreObject* object, Vector<CoreObject*>* dependencies);
+
+		UINT64 mNextAvailableID;
+		Map<UINT64, CoreObject*> mObjects;
+		Map<UINT64, DirtyObjectData> mDirtyObjects;
+		Map<UINT64, Vector<CoreObject*>> mDependencies;
+		Map<UINT64, Vector<CoreObject*>> mDependants;
+
+		Vector<CoreStoredSyncObjData> mDestroyedSyncData;
+		List<CoreStoredSyncData> mCoreSyncData;
+
+		BS_MUTEX(mObjectsMutex);
+	};
+
+	/** @} */
+}
+

+ 80 - 16
Source/BansheeCore/Include/BsCorePrerequisites.h

@@ -9,41 +9,40 @@
  */
 
 /** @defgroup Core Core
- *	Second lowest layer that provides some very game-specific modules tied into a coherent whole, but it tries to be very 
- *  generic and offer something that every engine might need instead of focusing on very specialized techniques.
+ *	Second lowest layer that provides core engine functionality and abstract interfaces for various systems.
  *  @{
  */
 
 /** @defgroup CoreThread Core thread
- *	Functionality for dealing with core objects and interaction with the core thread.
+ *	Core objects and interaction with the core (rendering) thread.
  */
 
 /** @defgroup Importer Importer
- *	Functionality for dealing with import of resources into engine friendly format.
+ *	Import of resources into engine friendly format.
  */
 
 /** @defgroup Input Input
- *	Functionality for dealing with input (mouse, keyboard, gamepad, etc.).
+ *	Input (mouse, keyboard, gamepad, etc.).
  */
 
 /** @defgroup Localization Localization
- *	Functionality for dealing with GUI localization.
+ *	GUI localization.
  */
 
 /** @defgroup Material Material
- *	Functionality for dealing with materials, shaders, and in general how objects are rendered.
+ *	Materials, shaders and related functionality.
  */
 
 /** @defgroup Platform Platform
- *	Functionality specific for some platform (for example Windows, Mac).
+ *	Interface for interacting with the platform (OS).
  */
 
  /** @defgroup Profiling Profiling
-  *	Functionality for measuring CPU and GPU execution times and memory usage.
+  *	Measuring CPU and GPU execution times and memory usage.
   */
 
 /** @defgroup RenderAPI RenderAPI
-  *	Functionality for interacting with underlying render API (for example DirectX, OpenGL).
+  *	Interface for interacting with the render API (DirectX, OpenGL, etc.).
   */
 
 /** @defgroup Renderer Renderer
@@ -51,19 +50,21 @@
   */
 
 /** @defgroup Resources Resources
-  *	Contains core resource types and resource management functionality (loading, saving, etc.).
+  *	Core resource types and resource management functionality (loading, saving, etc.).
   */
 
+/** @cond RTTI */
 /** @defgroup RTTI-Impl-Core RTTI types
- *  Types containing RTTI for specific classes.
+ *  RTTI implementations for classes within the core layer.
  */
+/** @endcond */
 
 /** @defgroup Scene Scene
- *  Functionality for managing scene objects and their hierarchy.
+ *  Managing scene objects and their hierarchy.
  */
 
 /** @defgroup Text Text
- *  Functionality for rendering text.
+ *  Generating text geometry.
  */
 
 /** @defgroup Utility-Core Utility
@@ -71,7 +72,7 @@
  */
 
 /** @defgroup Application-Core Application
- *  Entry point into the application and other general application functionality.
+ *  Entry point into the application and other general functionality.
  */
 
 /** @defgroup Components-Core Components
@@ -79,9 +80,72 @@
   */
 
 /** @defgroup Physics Physics
- *	Functionality for dealing with physics: colliders, triggers, rigidbodies, joints, scene queries, etc.
+ *	Physics system: colliders, triggers, rigidbodies, joints, scene queries, etc.
  */
 
+/** @defgroup Internal-Core [INTERNAL]
+ *	Low-level classes and methods not meant for normal use, useful for those that are modifying the engine.
+ *  @{
+ */
+
+/** @defgroup CoreThread-Internal Core thread
+ *	Core objects and interaction with the core (rendering) thread.
+ */
+
+/** @defgroup Importer-Internal Importer
+ *	Import of resources into engine friendly format.
+ */
+
+/** @defgroup Input-Internal Input
+ *	Input (mouse, keyboard, gamepad, etc.).
+ */
+
+/** @defgroup Localization-Internal Localization
+ *	GUI localization.
+ */
+
+/** @defgroup Material-Internal Material
+ *	Materials, shaders and related functionality.
+ */
+
+/** @defgroup Platform-Internal Platform
+ *	Interface for interacting with the platform (OS).
+ */
+
+ /** @defgroup Profiling-Internal Profiling
+  *	Measuring CPU and GPU execution times and memory usage.
+  */
+
+/** @defgroup RenderAPI-Internal RenderAPI
+  *	Interface for interacting with the render API (DirectX, OpenGL, etc.).
+  */
+
+/** @defgroup Renderer-Internal Renderer
+  *	Abstract interface and helper functionality for rendering scene objects.
+  */
+
+/** @defgroup Resources-Internal Resources
+  *	Core resource types and resource management functionality (loading, saving, etc.).
+  */
+
+/** @defgroup Scene-Internal Scene
+ *  Managing scene objects and their hierarchy.
+ */
+
+/** @defgroup Text-Internal Text
+ *  Generating text geometry.
+ */
+
+/** @defgroup Utility-Core-Internal Utility
+ *  Various utility methods and types used by the core layer.
+ */
+
+/** @defgroup Physics-Internal Physics
+ *	Physics system: colliders, triggers, rigidbodies, joints, scene queries, etc.
+ */
+
+/** @} */
+
 /** @} */
 /** @} */
 

+ 139 - 141
Source/BansheeCore/Include/BsCoreRenderer.h

@@ -1,142 +1,140 @@
-//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
-//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
-#pragma once
-
-#include "BsCorePrerequisites.h"
-#include "BsStringID.h"
-#include "BsRendererMeshData.h"
-
-namespace BansheeEngine
-{
-	/** @cond INTERNAL */
-	/** @addtogroup Renderer
-	 *  @{
-	 */
-
-	/**
-	 * Available parameter block semantics that allow the renderer to identify the use of a GPU program parameter block 
-	 * specified in a shader.
-	 */
-	static StringID RBS_Static = "Static";
-	static StringID RBS_PerCamera = "PerCamera";
-	static StringID RBS_PerFrame = "PerFrame";
-	static StringID RBS_PerObject = "PerObject";
-
-	/**
-	 * Available parameter semantics that allow the renderer to identify the use of a GPU parameter specified in a shader.
-	 */
-	static StringID RPS_WorldViewProjTfrm = "WVP";
-	static StringID RPS_ViewProjTfrm = "VP";
-	static StringID RPS_ProjTfrm = "P";
-	static StringID RPS_ViewTfrm = "V";
-	static StringID RPS_WorldTfrm = "W";
-	static StringID RPS_InvWorldTfrm = "IW";
-	static StringID RPS_WorldNoScaleTfrm = "WNoScale";
-	static StringID RPS_InvWorldNoScaleTfrm = "IWNoScale";
-	static StringID RPS_WorldDeterminantSign = "WorldDeterminantSign";
-	static StringID RPS_Diffuse = "Diffuse";
-	static StringID RPS_ViewDir = "ViewDir";
-
-	/**	Set of options that can be used for controlling the renderer. */	
-	struct BS_CORE_EXPORT CoreRendererOptions
-	{
-		virtual ~CoreRendererOptions() { }
-	};
-
-	/**
-	 * Primarily rendering class that allows you to specify how to render objects that exist in the scene graph. You need
-	 * to provide your own implementation of your class.
-	 *
-	 * @note	
-	 * Normally you would iterate over all cameras, find visible objects for each camera and render those objects in some way.
-	 */
-	class BS_CORE_EXPORT CoreRenderer
-	{
-	public:
-		CoreRenderer();
-		virtual ~CoreRenderer() { }
-
-		/** Initializes the renderer. Must be called before using the renderer. */
-		virtual void initialize() { }
-
-		/**	Cleans up the renderer. Must be called before the renderer is deleted. */
-		virtual void destroy() { }
-
-		/** Name of the renderer. Used by materials to find an appropriate technique for this renderer. */
-		virtual const StringID& getName() const = 0;
-
-		/** Called in order to render all currently active cameras. */
-		virtual void renderAll() = 0;
-
-		/**
-		 * Called whenever a new camera is created.
-		 *
-		 * @note	Core thread.
-		 */
-		virtual void _notifyCameraAdded(const CameraCore* camera) { }
-
-		/**
-		 * Called whenever a camera is destroyed.
-		 *
-		 * @note	Core thread.
-		 */
-		virtual void _notifyCameraRemoved(const CameraCore* camera) { }
-
-		/**
-		 * Creates a new empty renderer mesh data.
-		 *
-		 * @note	Sim thread.
-		 *			
-		 * @see		RendererMeshData
-		 */
-		virtual RendererMeshDataPtr _createMeshData(UINT32 numVertices, UINT32 numIndices, VertexLayout layout, IndexType indexType = IT_32BIT);
-
-		/**
-		 * Creates a new renderer mesh data using an existing generic mesh data buffer.
-		 *
-		 * @note	Sim thread.
-		 *			
-		 * @see		RendererMeshData
-		 */
-		virtual RendererMeshDataPtr _createMeshData(const MeshDataPtr& meshData);
-
-		/**
-		 * Registers a new callback that will be executed when the the specify camera is being rendered.
-		 *
-		 * @param[in]	camera		Camera for which to trigger the callback.
-		 * @param[in]	index		Index that determines the order of rendering when there are multiple registered 
-		 *							callbacks. This must be unique. Lower indices get rendered sooner. Indices below 0 get 
-		 *							rendered before the main viewport elements, while indices equal or greater to zero after. 
-		 * @param[in]	callback	Callback to trigger when the specified camera is being rendered.
-		 * @param[in]	isOverlay	If true the render callback guarantees that it will only render overlay data. Overlay 
-		 *							data doesn't require a depth buffer, a multisampled render target and is usually cheaper
-		 *							to render (although this depends on the exact renderer). 
-		 *							Overlay callbacks are always rendered after all other callbacks, even if their index is negative.
-		 *
-		 * @note	Core thread.
-		 */
-		void _registerRenderCallback(const CameraCore* camera, INT32 index, const std::function<void()>& callback, bool isOverlay = false);
-
-		/** Removes a previously registered callback registered with _registerRenderCallback(). */
-		void _unregisterRenderCallback(const CameraCore* camera, INT32 index);
-
-		/**	Sets options used for controlling the rendering. */
-		virtual void setOptions(const SPtr<CoreRendererOptions>& options) { }
-
-		/**	Returns current set of options used for controlling the rendering. */
-		virtual SPtr<CoreRendererOptions> getOptions() const { return SPtr<CoreRendererOptions>(); }
-
-	protected:
-		/**	Contains information about a render callback. */
-		struct RenderCallbackData
-		{
-			bool overlay;
-			std::function<void()> callback;
-		};
-
-		UnorderedMap<const CameraCore*, Map<INT32, RenderCallbackData>> mRenderCallbacks;
-	};
-
-	/** @} */
-	/** @endcond */
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+#pragma once
+
+#include "BsCorePrerequisites.h"
+#include "BsStringID.h"
+#include "BsRendererMeshData.h"
+
+namespace BansheeEngine
+{
+	/** @addtogroup Renderer-Internal
+	 *  @{
+	 */
+
+	/**
+	 * Available parameter block semantics that allow the renderer to identify the use of a GPU program parameter block 
+	 * specified in a shader.
+	 */
+	static StringID RBS_Static = "Static";
+	static StringID RBS_PerCamera = "PerCamera";
+	static StringID RBS_PerFrame = "PerFrame";
+	static StringID RBS_PerObject = "PerObject";
+
+	/**
+	 * Available parameter semantics that allow the renderer to identify the use of a GPU parameter specified in a shader.
+	 */
+	static StringID RPS_WorldViewProjTfrm = "WVP";
+	static StringID RPS_ViewProjTfrm = "VP";
+	static StringID RPS_ProjTfrm = "P";
+	static StringID RPS_ViewTfrm = "V";
+	static StringID RPS_WorldTfrm = "W";
+	static StringID RPS_InvWorldTfrm = "IW";
+	static StringID RPS_WorldNoScaleTfrm = "WNoScale";
+	static StringID RPS_InvWorldNoScaleTfrm = "IWNoScale";
+	static StringID RPS_WorldDeterminantSign = "WorldDeterminantSign";
+	static StringID RPS_Diffuse = "Diffuse";
+	static StringID RPS_ViewDir = "ViewDir";
+
+	/**	Set of options that can be used for controlling the renderer. */	
+	struct BS_CORE_EXPORT CoreRendererOptions
+	{
+		virtual ~CoreRendererOptions() { }
+	};
+
+	/**
+	 * Primarily rendering class that allows you to specify how to render objects that exist in the scene graph. You need
+	 * to provide your own implementation of your class.
+	 *
+	 * @note	
+	 * Normally you would iterate over all cameras, find visible objects for each camera and render those objects in some way.
+	 */
+	class BS_CORE_EXPORT CoreRenderer
+	{
+	public:
+		CoreRenderer();
+		virtual ~CoreRenderer() { }
+
+		/** Initializes the renderer. Must be called before using the renderer. */
+		virtual void initialize() { }
+
+		/**	Cleans up the renderer. Must be called before the renderer is deleted. */
+		virtual void destroy() { }
+
+		/** Name of the renderer. Used by materials to find an appropriate technique for this renderer. */
+		virtual const StringID& getName() const = 0;
+
+		/** Called in order to render all currently active cameras. */
+		virtual void renderAll() = 0;
+
+		/**
+		 * Called whenever a new camera is created.
+		 *
+		 * @note	Core thread.
+		 */
+		virtual void _notifyCameraAdded(const CameraCore* camera) { }
+
+		/**
+		 * Called whenever a camera is destroyed.
+		 *
+		 * @note	Core thread.
+		 */
+		virtual void _notifyCameraRemoved(const CameraCore* camera) { }
+
+		/**
+		 * Creates a new empty renderer mesh data.
+		 *
+		 * @note	Sim thread.
+		 *			
+		 * @see		RendererMeshData
+		 */
+		virtual RendererMeshDataPtr _createMeshData(UINT32 numVertices, UINT32 numIndices, VertexLayout layout, IndexType indexType = IT_32BIT);
+
+		/**
+		 * Creates a new renderer mesh data using an existing generic mesh data buffer.
+		 *
+		 * @note	Sim thread.
+		 *			
+		 * @see		RendererMeshData
+		 */
+		virtual RendererMeshDataPtr _createMeshData(const MeshDataPtr& meshData);
+
+		/**
+		 * Registers a new callback that will be executed when the the specify camera is being rendered.
+		 *
+		 * @param[in]	camera		Camera for which to trigger the callback.
+		 * @param[in]	index		Index that determines the order of rendering when there are multiple registered 
+		 *							callbacks. This must be unique. Lower indices get rendered sooner. Indices below 0 get 
+		 *							rendered before the main viewport elements, while indices equal or greater to zero after. 
+		 * @param[in]	callback	Callback to trigger when the specified camera is being rendered.
+		 * @param[in]	isOverlay	If true the render callback guarantees that it will only render overlay data. Overlay 
+		 *							data doesn't require a depth buffer, a multisampled render target and is usually cheaper
+		 *							to render (although this depends on the exact renderer). 
+		 *							Overlay callbacks are always rendered after all other callbacks, even if their index is negative.
+		 *
+		 * @note	Core thread.
+		 */
+		void _registerRenderCallback(const CameraCore* camera, INT32 index, const std::function<void()>& callback, bool isOverlay = false);
+
+		/** Removes a previously registered callback registered with _registerRenderCallback(). */
+		void _unregisterRenderCallback(const CameraCore* camera, INT32 index);
+
+		/**	Sets options used for controlling the rendering. */
+		virtual void setOptions(const SPtr<CoreRendererOptions>& options) { }
+
+		/**	Returns current set of options used for controlling the rendering. */
+		virtual SPtr<CoreRendererOptions> getOptions() const { return SPtr<CoreRendererOptions>(); }
+
+	protected:
+		/**	Contains information about a render callback. */
+		struct RenderCallbackData
+		{
+			bool overlay;
+			std::function<void()> callback;
+		};
+
+		UnorderedMap<const CameraCore*, Map<INT32, RenderCallbackData>> mRenderCallbacks;
+	};
+
+	/** @} */
 }

+ 1 - 3
Source/BansheeCore/Include/BsCoreSceneManager.h

@@ -8,8 +8,7 @@
 
 namespace BansheeEngine
 {
-	/** @cond INTERNAL */
-	/** @addtogroup Scene
+	/** @addtogroup Scene-Internal
 	 *  @{
 	 */
 
@@ -90,5 +89,4 @@ namespace BansheeEngine
 	BS_CORE_EXPORT CoreSceneManager& gCoreSceneManager();
 
 	/** @} */
-	/** @endcond */
 }

+ 223 - 220
Source/BansheeCore/Include/BsCoreThread.h

@@ -1,220 +1,223 @@
-//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
-//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
-#pragma once
-
-#include "BsCorePrerequisites.h"
-#include "BsModule.h"
-#include "BsCommandQueue.h"
-#include "BsCoreThreadAccessor.h"
-#include "BsThreadPool.h"
-
-namespace BansheeEngine
-{
-	/** @addtogroup CoreThread
-	 *  @{
-	 */
-	/** @cond INTERNAL */
-
-	/**
-	 * Manager for the core thread. Takes care of starting, running, queuing commands and shutting down the core thread.
-	 * 			
-	 * @note	
-	 * How threading works:
-	 * 	- This class contains a queue which is filled by commands from other threads via queueCommand() and queueReturnCommand()  
-	 * 	- Commands are executed on the core thread as soon as they are queued (if core thread is not busy with previous commands)  
-	 * 	- Core thread accessors are helpers for queuing commands. They perform better than queuing each command directly 
-	 *    using queueCommand() or queueReturnCommand().
-	 * 	- Accessors contain a command queue of their own, and queuing commands in them will not automatically start 
-	 *    executing the commands like with queueCommand or queueReturnCommand. Instead you must manually call 
-	 *    submitAccessors() when you are ready to send their commands to the core thread. Sending commands "in bulk" like 
-	 *    this is what makes them faster than directly queuing commands.
-	 * 	- Synced accessor is a special type of accessor which may be accessed from any thread. Its commands are always 
-	 *    executed after all other non-synced accessors. It is primarily useful when multiple threads are managing the same
-	 *    resource and you must ensure proper order of operations. You should use normal accessors whenever possible as 
-	 *    synced accessors involve potentially slow synchronization operations.
-	 */
-	class BS_CORE_EXPORT CoreThread : public Module<CoreThread>
-	{
-		/** Contains data about an accessor for a specific thread. */
-		struct AccessorContainer
-		{
-			CoreAccessorPtr accessor;
-			bool isMain;
-		};
-
-		/** Wrapper for the thread-local variable because MSVC can't deal with a thread-local variable marked with dllimport or dllexport,  
-		 *  and we cannot use per-member dllimport/dllexport specifiers because Module's members will then not be exported and its static
-		 *  members will not have external linkage. */
-		struct AccessorData
-		{
-			static BS_THREADLOCAL AccessorContainer* current;
-		};
-
-public:
-	CoreThread();
-	~CoreThread();
-
-	/** Returns the id of the core thread.  */
-	BS_THREAD_ID_TYPE getCoreThreadId() { return mCoreThreadId; }
-
-	/**
-	 * Creates or retrieves an accessor that you can use for executing commands on the core thread from a non-core thread. 
-	 * The accessor will be bound to the thread you call this method on.
-	 * 			
-	 * @note		
-	 * Accessors contain their own command queue and their commands will only start to get executed once that queue is 
-	 * submitted to the core thread via submitAccessors() method.
-	 */
-	CoreAccessorPtr getAccessor();
-
-	/**
-	 * Retrieves an accessor that you can use for executing commands on the core thread from a non-core thread. There is 
-	 * only one synchronized accessor and you may access it from any thread you wish. Note however that it is much more 
-	 * efficient to retrieve a separate non-synchronized accessor for each thread you will be using it on.
-	 * 			
-	 * @note	
-	 * Accessors contain their own command queue and their commands will only start to get executed once that queue
-	 * is submitted to the core thread via submitAccessors() method.
-	 * @note			
-	 * Synced accessor commands are sent after all non-synced accessor commands are sent.
-	 */
-	SyncedCoreAccessor& getSyncedAccessor();
-
-	/** Queues all the accessor commands and starts executing them on the core thread. */
-	void submitAccessors(bool blockUntilComplete = false);
-
-	/**
-	 * Queues a new command that will be added to the global command queue. You are allowed to call this from any thread,
-	 * however be aware that it involves possibly slow synchronization primitives, so limit your usage.
-	 * 			
-	 * @param[in]	blockUntilComplete	If true the thread will be blocked until the command executes. Be aware that there 
-	 *									may be many commands queued before it and they all need to be executed in order 
-	 *									before the current command is reached, which might take a long time.
-	 * 	
-	 * @see		CommandQueue::queueReturn()
-	 */
-	AsyncOp queueReturnCommand(std::function<void(AsyncOp&)> commandCallback, bool blockUntilComplete = false);
-
-	/**
-	 * Queues a new command that will be added to the global command queue.You are allowed to call this from any thread,
-	 * however be aware that it involves possibly slow synchronization primitives, so limit your usage.
-	 * 	
-	 * @param[in]	blockUntilComplete	If true the thread will be blocked until the command executes. Be aware that there 
-	 *									may be many commands queued before it and they all need to be executed in order 
-	 *									before the current command is reached, which might take a long time.
-	 *
-	 * @see		CommandQueue::queue()
-	 */
-	void queueCommand(std::function<void()> commandCallback, bool blockUntilComplete = false);
-
-	/**
-	 * Called once every frame.
-	 * 			
-	 * @note	Must be called before sim thread schedules any core thread operations for the frame. 
-	 */
-	void update();
-
-	/**
-	 * Returns a frame allocator that should be used for allocating temporary data being passed to the core thread. As the 
-	 * name implies the data only lasts one frame, so you need to be careful not to use it for longer than that.
-	 * 			
-	 * @note	Sim thread only.
-	 */
-	FrameAlloc* getFrameAlloc() const;
-private:
-	static const int NUM_FRAME_ALLOCS = 2;
-
-	/**
-	 * Double buffered frame allocators. Means sim thread cannot be more than 1 frame ahead of core thread (If that changes
-	 * you should be able to easily add more).
-	 */
-	FrameAlloc* mFrameAllocs[NUM_FRAME_ALLOCS];
-	UINT32 mActiveFrameAlloc;
-
-	static AccessorData mAccessor;
-	Vector<AccessorContainer*> mAccessors;
-
-	volatile bool mCoreThreadShutdown;
-
-	HThread mCoreThread;
-	bool mCoreThreadStarted;
-	BS_THREAD_ID_TYPE mSimThreadId;
-	BS_THREAD_ID_TYPE mCoreThreadId;
-	BS_MUTEX(mCommandQueueMutex)
-	BS_MUTEX(mAccessorMutex)
-	BS_THREAD_SYNCHRONISER(mCommandReadyCondition)
-	BS_MUTEX(mCommandNotifyMutex)
-	BS_THREAD_SYNCHRONISER(mCommandCompleteCondition)
-	BS_MUTEX(mThreadStartedMutex)
-	BS_THREAD_SYNCHRONISER(mCoreThreadStartedCondition)
-
-	CommandQueue<CommandQueueSync>* mCommandQueue;
-
-	UINT32 mMaxCommandNotifyId; /**< ID that will be assigned to the next command with a notifier callback. */
-	Vector<UINT32> mCommandsCompleted; /**< Completed commands that have notifier callbacks set up */
-
-	SyncedCoreAccessor* mSyncedCoreAccessor;
-
-	/** Starts the core thread worker method. Should only be called once. */
-	void initCoreThread();
-
-	/**	Main worker method of the core thread. Called once thread is started. */
-	void runCoreThread();
-
-	/** Shutdowns the core thread. It will complete all ready commands before shutdown. */
-	void shutdownCoreThread();
-
-	/**
-	 * Blocks the calling thread until the command with the specified ID completes. Make sure that the specified ID 
-	 * actually exists, otherwise this will block forever.
-	 */
-	void blockUntilCommandCompleted(UINT32 commandId);
-
-	/**
-	 * Callback called by the command list when a specific command finishes executing. This is only called on commands that
-	 * have a special notify on complete flag set.
-	 *
-	 * @param[in]	commandId	Identifier for the command.
-	 */
-	void commandCompletedNotify(UINT32 commandId);
-	};
-
-	/**
-	 * Returns the core thread manager used for dealing with the core thread from external threads.
-	 * 			
-	 * @see		CoreThread
-	 */
-	BS_CORE_EXPORT CoreThread& gCoreThread();
-
-	/**	Throws an exception if current thread isn't the core thread. */
-	BS_CORE_EXPORT void throwIfNotCoreThread();
-
-	/** Throws an exception if current thread is the core thread. */
-	BS_CORE_EXPORT void throwIfCoreThread();
-
-#if BS_DEBUG_MODE
-#define THROW_IF_NOT_CORE_THREAD throwIfNotCoreThread();
-#define THROW_IF_CORE_THREAD throwIfCoreThread();
-#else
-#define THROW_IF_NOT_CORE_THREAD 
-#define THROW_IF_CORE_THREAD
-#endif
-
-	/** @endcond */
-
-	/** 
-	 * Creates or retrieves an accessor that you can use for executing commands on the core thread from a non-core thread. 
-	 * The accessor will be bound to the thread you call this method on. 
-	 */
-	BS_CORE_EXPORT CoreThreadAccessor<CommandQueueNoSync>& gCoreAccessor();
-
-	/**
-	 * Retrieves an accessor that you can use for executing commands on the core thread from a non-core thread. There is 
-	 * only one synchronized accessor and you may access it from any thread you wish. Note however that it is much more 
-	 * efficient to retrieve a separate non-synchronized accessor for each thread you will be using it on.
-	 */
-	BS_CORE_EXPORT CoreThreadAccessor<CommandQueueSync>& gSyncedCoreAccessor();
-
-	/** @} */
-}
-
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+#pragma once
+
+#include "BsCorePrerequisites.h"
+#include "BsModule.h"
+#include "BsCommandQueue.h"
+#include "BsCoreThreadAccessor.h"
+#include "BsThreadPool.h"
+
+namespace BansheeEngine
+{
+	/** @addtogroup CoreThread-Internal
+	 *  @{
+	 */
+
+	/**
+	 * Manager for the core thread. Takes care of starting, running, queuing commands and shutting down the core thread.
+	 * 			
+	 * @note	
+	 * How threading works:
+	 * 	- This class contains a queue which is filled by commands from other threads via queueCommand() and queueReturnCommand()  
+	 * 	- Commands are executed on the core thread as soon as they are queued (if core thread is not busy with previous commands)  
+	 * 	- Core thread accessors are helpers for queuing commands. They perform better than queuing each command directly 
+	 *    using queueCommand() or queueReturnCommand().
+	 * 	- Accessors contain a command queue of their own, and queuing commands in them will not automatically start 
+	 *    executing the commands like with queueCommand or queueReturnCommand. Instead you must manually call 
+	 *    submitAccessors() when you are ready to send their commands to the core thread. Sending commands "in bulk" like 
+	 *    this is what makes them faster than directly queuing commands.
+	 * 	- Synced accessor is a special type of accessor which may be accessed from any thread. Its commands are always 
+	 *    executed after all other non-synced accessors. It is primarily useful when multiple threads are managing the same
+	 *    resource and you must ensure proper order of operations. You should use normal accessors whenever possible as 
+	 *    synced accessors involve potentially slow synchronization operations.
+	 */
+	class BS_CORE_EXPORT CoreThread : public Module<CoreThread>
+	{
+		/** Contains data about an accessor for a specific thread. */
+		struct AccessorContainer
+		{
+			CoreAccessorPtr accessor;
+			bool isMain;
+		};
+
+		/** Wrapper for the thread-local variable because MSVC can't deal with a thread-local variable marked with dllimport or dllexport,  
+		 *  and we cannot use per-member dllimport/dllexport specifiers because Module's members will then not be exported and its static
+		 *  members will not have external linkage. */
+		struct AccessorData
+		{
+			static BS_THREADLOCAL AccessorContainer* current;
+		};
+
+public:
+	CoreThread();
+	~CoreThread();
+
+	/** Returns the id of the core thread.  */
+	BS_THREAD_ID_TYPE getCoreThreadId() { return mCoreThreadId; }
+
+	/**
+	 * Creates or retrieves an accessor that you can use for executing commands on the core thread from a non-core thread. 
+	 * The accessor will be bound to the thread you call this method on.
+	 * 			
+	 * @note		
+	 * Accessors contain their own command queue and their commands will only start to get executed once that queue is 
+	 * submitted to the core thread via submitAccessors() method.
+	 */
+	CoreAccessorPtr getAccessor();
+
+	/**
+	 * Retrieves an accessor that you can use for executing commands on the core thread from a non-core thread. There is 
+	 * only one synchronized accessor and you may access it from any thread you wish. Note however that it is much more 
+	 * efficient to retrieve a separate non-synchronized accessor for each thread you will be using it on.
+	 * 			
+	 * @note	
+	 * Accessors contain their own command queue and their commands will only start to get executed once that queue
+	 * is submitted to the core thread via submitAccessors() method.
+	 * @note			
+	 * Synced accessor commands are sent after all non-synced accessor commands are sent.
+	 */
+	SyncedCoreAccessor& getSyncedAccessor();
+
+	/** Queues all the accessor commands and starts executing them on the core thread. */
+	void submitAccessors(bool blockUntilComplete = false);
+
+	/**
+	 * Queues a new command that will be added to the global command queue. You are allowed to call this from any thread,
+	 * however be aware that it involves possibly slow synchronization primitives, so limit your usage.
+	 * 			
+	 * @param[in]	blockUntilComplete	If true the thread will be blocked until the command executes. Be aware that there 
+	 *									may be many commands queued before it and they all need to be executed in order 
+	 *									before the current command is reached, which might take a long time.
+	 * 	
+	 * @see		CommandQueue::queueReturn()
+	 */
+	AsyncOp queueReturnCommand(std::function<void(AsyncOp&)> commandCallback, bool blockUntilComplete = false);
+
+	/**
+	 * Queues a new command that will be added to the global command queue.You are allowed to call this from any thread,
+	 * however be aware that it involves possibly slow synchronization primitives, so limit your usage.
+	 * 	
+	 * @param[in]	blockUntilComplete	If true the thread will be blocked until the command executes. Be aware that there 
+	 *									may be many commands queued before it and they all need to be executed in order 
+	 *									before the current command is reached, which might take a long time.
+	 *
+	 * @see		CommandQueue::queue()
+	 */
+	void queueCommand(std::function<void()> commandCallback, bool blockUntilComplete = false);
+
+	/**
+	 * Called once every frame.
+	 * 			
+	 * @note	Must be called before sim thread schedules any core thread operations for the frame. 
+	 */
+	void update();
+
+	/**
+	 * Returns a frame allocator that should be used for allocating temporary data being passed to the core thread. As the 
+	 * name implies the data only lasts one frame, so you need to be careful not to use it for longer than that.
+	 * 			
+	 * @note	Sim thread only.
+	 */
+	FrameAlloc* getFrameAlloc() const;
+private:
+	static const int NUM_FRAME_ALLOCS = 2;
+
+	/**
+	 * Double buffered frame allocators. Means sim thread cannot be more than 1 frame ahead of core thread (If that changes
+	 * you should be able to easily add more).
+	 */
+	FrameAlloc* mFrameAllocs[NUM_FRAME_ALLOCS];
+	UINT32 mActiveFrameAlloc;
+
+	static AccessorData mAccessor;
+	Vector<AccessorContainer*> mAccessors;
+
+	volatile bool mCoreThreadShutdown;
+
+	HThread mCoreThread;
+	bool mCoreThreadStarted;
+	BS_THREAD_ID_TYPE mSimThreadId;
+	BS_THREAD_ID_TYPE mCoreThreadId;
+	BS_MUTEX(mCommandQueueMutex)
+	BS_MUTEX(mAccessorMutex)
+	BS_THREAD_SYNCHRONISER(mCommandReadyCondition)
+	BS_MUTEX(mCommandNotifyMutex)
+	BS_THREAD_SYNCHRONISER(mCommandCompleteCondition)
+	BS_MUTEX(mThreadStartedMutex)
+	BS_THREAD_SYNCHRONISER(mCoreThreadStartedCondition)
+
+	CommandQueue<CommandQueueSync>* mCommandQueue;
+
+	UINT32 mMaxCommandNotifyId; /**< ID that will be assigned to the next command with a notifier callback. */
+	Vector<UINT32> mCommandsCompleted; /**< Completed commands that have notifier callbacks set up */
+
+	SyncedCoreAccessor* mSyncedCoreAccessor;
+
+	/** Starts the core thread worker method. Should only be called once. */
+	void initCoreThread();
+
+	/**	Main worker method of the core thread. Called once thread is started. */
+	void runCoreThread();
+
+	/** Shutdowns the core thread. It will complete all ready commands before shutdown. */
+	void shutdownCoreThread();
+
+	/**
+	 * Blocks the calling thread until the command with the specified ID completes. Make sure that the specified ID 
+	 * actually exists, otherwise this will block forever.
+	 */
+	void blockUntilCommandCompleted(UINT32 commandId);
+
+	/**
+	 * Callback called by the command list when a specific command finishes executing. This is only called on commands that
+	 * have a special notify on complete flag set.
+	 *
+	 * @param[in]	commandId	Identifier for the command.
+	 */
+	void commandCompletedNotify(UINT32 commandId);
+	};
+
+	/**
+	 * Returns the core thread manager used for dealing with the core thread from external threads.
+	 * 			
+	 * @see		CoreThread
+	 */
+	BS_CORE_EXPORT CoreThread& gCoreThread();
+
+	/**	Throws an exception if current thread isn't the core thread. */
+	BS_CORE_EXPORT void throwIfNotCoreThread();
+
+	/** Throws an exception if current thread is the core thread. */
+	BS_CORE_EXPORT void throwIfCoreThread();
+
+#if BS_DEBUG_MODE
+#define THROW_IF_NOT_CORE_THREAD throwIfNotCoreThread();
+#define THROW_IF_CORE_THREAD throwIfCoreThread();
+#else
+#define THROW_IF_NOT_CORE_THREAD 
+#define THROW_IF_CORE_THREAD
+#endif
+
+	/** @} */
+
+	/** @addtogroup CoreThread
+	 *  @{
+	 */
+
+	/** 
+	 * Creates or retrieves an accessor that you can use for executing commands on the core thread from a non-core thread. 
+	 * The accessor will be bound to the thread you call this method on. 
+	 */
+	BS_CORE_EXPORT CoreThreadAccessor<CommandQueueNoSync>& gCoreAccessor();
+
+	/**
+	 * Retrieves an accessor that you can use for executing commands on the core thread from a non-core thread. There is 
+	 * only one synchronized accessor and you may access it from any thread you wish. Note however that it is much more 
+	 * efficient to retrieve a separate non-synchronized accessor for each thread you will be using it on.
+	 */
+	BS_CORE_EXPORT CoreThreadAccessor<CommandQueueSync>& gSyncedCoreAccessor();
+
+	/** @} */
+}
+

+ 40 - 42
Source/BansheeCore/Include/BsDeferredCallManager.h

@@ -1,43 +1,41 @@
-//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
-//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
-#pragma once
-
-#include "BsCorePrerequisites.h"
-#include "BsModule.h"
-
-namespace BansheeEngine
-{
-	/** @cond INTERNAL */
-	/** @addtogroup Utility-Core
-	 *  @{
-	 */
-
-	/**
-	 * Allows you to queue calls that can get executed later.
-	 * 			
-	 * @note	Sim thread only.
-	 */
-	class BS_CORE_EXPORT DeferredCallManager : public Module<DeferredCallManager>
-	{
-	public:
-		DeferredCallManager();
-
-		/**
-		 * Register a deferred call that will be executed once at the start of next frame.
-		 *
-		 * @param[in]	func	The function to execute.
-		 */
-		void queueDeferredCall(std::function<void()> func);
-
-		/** Executes all the scheduled calls. To be called once per frame. */
-		void _update();
-
-	private:
-		friend class DeferredCall;
-
-		Vector<std::function<void()>> mCallbacks;
-	};
-
-	/** @} */
-	/** @endcond */
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+#pragma once
+
+#include "BsCorePrerequisites.h"
+#include "BsModule.h"
+
+namespace BansheeEngine
+{
+	/** @addtogroup Utility-Core-Internal
+	 *  @{
+	 */
+
+	/**
+	 * Allows you to queue calls that can get executed later.
+	 * 			
+	 * @note	Sim thread only.
+	 */
+	class BS_CORE_EXPORT DeferredCallManager : public Module<DeferredCallManager>
+	{
+	public:
+		DeferredCallManager();
+
+		/**
+		 * Register a deferred call that will be executed once at the start of next frame.
+		 *
+		 * @param[in]	func	The function to execute.
+		 */
+		void queueDeferredCall(std::function<void()> func);
+
+		/** Executes all the scheduled calls. To be called once per frame. */
+		void _update();
+
+	private:
+		friend class DeferredCall;
+
+		Vector<std::function<void()>> mCallbacks;
+	};
+
+	/** @} */
 }

+ 245 - 243
Source/BansheeCore/Include/BsDepthStencilState.h

@@ -1,244 +1,246 @@
-//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
-//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
-#pragma once
-
-#include "BsCorePrerequisites.h"
-#include "BsIReflectable.h"
-#include "BsCoreObject.h"
-
-namespace BansheeEngine
-{
-	/** @addtogroup RenderAPI
-	 *  @{
-	 */
-
-	/**
-	 * Descriptor structured used for initializing DepthStencilState.
-	 *
-	 * @see		DepthStencilState
-	 */
-	struct BS_CORE_EXPORT DEPTH_STENCIL_STATE_DESC
-	{
-		DEPTH_STENCIL_STATE_DESC()
-			: depthReadEnable(true)
-			, depthWriteEnable(true)
-			, depthComparisonFunc(CMPF_LESS)
-			, stencilEnable(false)
-			, stencilReadMask(0xFF)
-			, stencilWriteMask(0xFF)
-			, frontStencilFailOp(SOP_KEEP)
-			, frontStencilZFailOp(SOP_KEEP)
-			, frontStencilPassOp(SOP_KEEP)
-			, frontStencilComparisonFunc(CMPF_ALWAYS_PASS)
-			, backStencilFailOp(SOP_KEEP)
-			, backStencilZFailOp(SOP_KEEP)
-			, backStencilPassOp(SOP_KEEP)
-			, backStencilComparisonFunc(CMPF_ALWAYS_PASS)
-		{ }
-
-		bool operator==(const DEPTH_STENCIL_STATE_DESC& rhs) const;
-
-		bool depthReadEnable;
-		bool depthWriteEnable;
-		CompareFunction depthComparisonFunc;
-
-		bool stencilEnable;
-		UINT8 stencilReadMask;
-		UINT8 stencilWriteMask;
-
-		StencilOperation frontStencilFailOp;
-		StencilOperation frontStencilZFailOp;
-		StencilOperation frontStencilPassOp;
-		CompareFunction frontStencilComparisonFunc;
-
-		StencilOperation backStencilFailOp;
-		StencilOperation backStencilZFailOp;
-		StencilOperation backStencilPassOp;
-		CompareFunction backStencilComparisonFunc;
-	};
-
-	/** @cond SPECIALIZATIONS */
-	BS_ALLOW_MEMCPY_SERIALIZATION(DEPTH_STENCIL_STATE_DESC);
-	/** @endcond */
-
-	/** Properties of DepthStencilState. Shared between sim and core thread versions of DepthStencilState. */
-	class BS_CORE_EXPORT DepthStencilProperties
-	{
-	public:
-		DepthStencilProperties(const DEPTH_STENCIL_STATE_DESC& desc);
-
-		/**
-		 * If enabled, any pixel about to be written will be tested against the depth value currently in the buffer. If the 
-		 * depth test passes (depending on the set valueand chosen depth comparison function), that pixel is written and 
-		 * depth is updated (if depth write is enabled).
-		 */
-		bool getDepthReadEnable() const { return mData.depthReadEnable; }
-
-		/** If enabled rendering pixels will update the depth buffer value. */
-		bool getDepthWriteEnable() const { return mData.depthWriteEnable; }
-
-		/**
-		 * Determines what operation should the renderer use when comparing previous and current depth value. If the 
-		 * operation passes, pixel with the current depth value will be considered visible.
-		 */
-		CompareFunction getDepthComparisonFunc() const { return mData.depthComparisonFunc; }
-
-		/**
-		 * If true then stencil buffer will also be updated when a pixel is written, and pixels will be tested against 
-		 * the stencil buffer before rendering.
-		 */
-		bool getStencilEnable() const { return mData.stencilEnable; }
-
-		/** Mask to apply to any value read from the stencil buffer, before applying the stencil comparison function. */
-		UINT8 getStencilReadMask() const { return mData.stencilReadMask; }
-
-		/**	Mask to apply to any value about to be written in the stencil buffer. */
-		UINT8 getStencilWriteMask() const { return mData.stencilWriteMask; }
-
-		/**	Operation that happens when stencil comparison function fails on a front facing polygon. */
-		StencilOperation getStencilFrontFailOp() const { return mData.frontStencilFailOp; }
-
-		/** Operation that happens when stencil comparison function passes but depth test fails on a front facing polygon. */
-		StencilOperation getStencilFrontZFailOp() const { return mData.frontStencilZFailOp; }
-
-		/**	Operation that happens when stencil comparison function passes on a front facing polygon. */
-		StencilOperation getStencilFrontPassOp() const { return mData.frontStencilPassOp; }
-
-		/**
-		 * Stencil comparison function used for front facing polygons. Stencil buffer will be modified according to 
-		 * previously set stencil operations depending whether this comparison passes or fails.
-		 */
-		CompareFunction getStencilFrontCompFunc() const { return mData.frontStencilComparisonFunc; }
-
-		/** Operation that happens when stencil comparison function fails on a back facing polygon. */
-		StencilOperation getStencilBackFailOp() const { return mData.backStencilFailOp; }
-
-		/** Operation that happens when stencil comparison function passes but depth test fails on a back facing polygon. */
-		StencilOperation getStencilBackZFailOp() const { return mData.backStencilZFailOp; }
-
-		/**	Operation that happens when stencil comparison function passes on a back facing polygon. */
-		StencilOperation getStencilBackPassOp() const { return mData.backStencilPassOp; }
-
-		/**
-		 * Stencil comparison function used for back facing polygons. Stencil buffer will be modified according	to 
-		 * previously set stencil operations depending whether this comparison passes or fails.
-		 */
-		CompareFunction getStencilBackCompFunc() const { return mData.backStencilComparisonFunc; }
-
-		/** Returns the hash value generated from the depth-stencil state properties. */
-		UINT64 getHash() const { return mHash; }
-
-	protected:
-		friend class DepthStencilState;
-		friend class DepthStencilStateCore;
-		friend class DepthStencilStateRTTI;
-
-		DEPTH_STENCIL_STATE_DESC mData;
-		UINT64 mHash;
-	};
-
-	/** @cond INTERNAL */
-
-	/**
-	 * Core thread version of DepthStencilState.
-	 *
-	 * @note	Core thread.
-	 */
-	class BS_CORE_EXPORT DepthStencilStateCore : public CoreObjectCore
-	{
-	public:
-		virtual ~DepthStencilStateCore();
-
-		/**	Returns information about the depth stencil state. */
-		const DepthStencilProperties& getProperties() const;
-
-		/**	Returns a unique state ID. Only the lowest 10 bits are used. */
-		UINT32 getId() const { return mId; }
-
-		/**	Returns the default depth stencil state that you may use when no other is available. */
-		static const SPtr<DepthStencilStateCore>& getDefault();
-
-	protected:
-		friend class RenderStateCoreManager;
-
-		DepthStencilStateCore(const DEPTH_STENCIL_STATE_DESC& desc, UINT32 id);
-
-		/** @copydoc CoreObjectCore::initialize */
-		void initialize() override;
-
-		/**	Creates any API-specific state objects. */
-		virtual void createInternal() { }
-
-		DepthStencilProperties mProperties;
-		UINT32 mId;
-	};
-
-	/** @endcond */
-
-	/**
-	 * Render system pipeline state that allows you to modify how an object is rendered. More exactly this state allows to 
-	 * you to control how are depth and stencil buffers modified upon rendering.
-	 *
-	 * @note	Depth stencil states are immutable. Sim thread only.
-	 */
-	class BS_CORE_EXPORT DepthStencilState : public IReflectable, public CoreObject
-	{
-	public:
-		virtual ~DepthStencilState();
-
-		/**	Returns information about the depth stencil state. */
-		const DepthStencilProperties& getProperties() const;
-
-		/**	Retrieves a core implementation of a sampler state usable only from the core thread. */
-		SPtr<DepthStencilStateCore> getCore() const;
-
-		/**	Creates a new depth stencil state using the specified depth stencil state description structure. */
-		static DepthStencilStatePtr create(const DEPTH_STENCIL_STATE_DESC& desc);
-
-		/**	Returns the default depth stencil state that you may use when no other is available. */
-		static const DepthStencilStatePtr& getDefault();
-
-		/**	Generates a hash value from a depth-stencil state descriptor. */
-		static UINT64 generateHash(const DEPTH_STENCIL_STATE_DESC& desc);
-
-	protected:
-		friend class RenderStateManager;
-
-		DepthStencilState(const DEPTH_STENCIL_STATE_DESC& desc);
-
-		/** @copydoc CoreObjectCore::createCore */
-		SPtr<CoreObjectCore> createCore() const override;
-
-		DepthStencilProperties mProperties;
-		mutable UINT32 mId;
-
-		/************************************************************************/
-		/* 								RTTI		                     		*/
-		/************************************************************************/
-
-	public:
-		friend class DepthStencilStateRTTI;
-		static RTTITypeBase* getRTTIStatic();
-		virtual RTTITypeBase* getRTTI() const override;	
-	};
-
-	/** @} */
-}
-
-/** @cond STDLIB */
-/** @addtogroup RenderAPI
- *  @{
- */
-
-/**	Hash value generator for DEPTH_STENCIL_STATE_DESC. */
-template<>
-struct std::hash<BansheeEngine::DEPTH_STENCIL_STATE_DESC>
-{
-	size_t operator()(const BansheeEngine::DEPTH_STENCIL_STATE_DESC& value) const
-	{
-		return (size_t)BansheeEngine::DepthStencilState::generateHash(value);
-	}
-};
-
-/** @} */
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+#pragma once
+
+#include "BsCorePrerequisites.h"
+#include "BsIReflectable.h"
+#include "BsCoreObject.h"
+
+namespace BansheeEngine
+{
+	/** @addtogroup RenderAPI
+	 *  @{
+	 */
+
+	/**
+	 * Descriptor structured used for initializing DepthStencilState.
+	 *
+	 * @see		DepthStencilState
+	 */
+	struct BS_CORE_EXPORT DEPTH_STENCIL_STATE_DESC
+	{
+		DEPTH_STENCIL_STATE_DESC()
+			: depthReadEnable(true)
+			, depthWriteEnable(true)
+			, depthComparisonFunc(CMPF_LESS)
+			, stencilEnable(false)
+			, stencilReadMask(0xFF)
+			, stencilWriteMask(0xFF)
+			, frontStencilFailOp(SOP_KEEP)
+			, frontStencilZFailOp(SOP_KEEP)
+			, frontStencilPassOp(SOP_KEEP)
+			, frontStencilComparisonFunc(CMPF_ALWAYS_PASS)
+			, backStencilFailOp(SOP_KEEP)
+			, backStencilZFailOp(SOP_KEEP)
+			, backStencilPassOp(SOP_KEEP)
+			, backStencilComparisonFunc(CMPF_ALWAYS_PASS)
+		{ }
+
+		bool operator==(const DEPTH_STENCIL_STATE_DESC& rhs) const;
+
+		bool depthReadEnable;
+		bool depthWriteEnable;
+		CompareFunction depthComparisonFunc;
+
+		bool stencilEnable;
+		UINT8 stencilReadMask;
+		UINT8 stencilWriteMask;
+
+		StencilOperation frontStencilFailOp;
+		StencilOperation frontStencilZFailOp;
+		StencilOperation frontStencilPassOp;
+		CompareFunction frontStencilComparisonFunc;
+
+		StencilOperation backStencilFailOp;
+		StencilOperation backStencilZFailOp;
+		StencilOperation backStencilPassOp;
+		CompareFunction backStencilComparisonFunc;
+	};
+
+	/** @cond SPECIALIZATIONS */
+	BS_ALLOW_MEMCPY_SERIALIZATION(DEPTH_STENCIL_STATE_DESC);
+	/** @endcond */
+
+	/** Properties of DepthStencilState. Shared between sim and core thread versions of DepthStencilState. */
+	class BS_CORE_EXPORT DepthStencilProperties
+	{
+	public:
+		DepthStencilProperties(const DEPTH_STENCIL_STATE_DESC& desc);
+
+		/**
+		 * If enabled, any pixel about to be written will be tested against the depth value currently in the buffer. If the 
+		 * depth test passes (depending on the set valueand chosen depth comparison function), that pixel is written and 
+		 * depth is updated (if depth write is enabled).
+		 */
+		bool getDepthReadEnable() const { return mData.depthReadEnable; }
+
+		/** If enabled rendering pixels will update the depth buffer value. */
+		bool getDepthWriteEnable() const { return mData.depthWriteEnable; }
+
+		/**
+		 * Determines what operation should the renderer use when comparing previous and current depth value. If the 
+		 * operation passes, pixel with the current depth value will be considered visible.
+		 */
+		CompareFunction getDepthComparisonFunc() const { return mData.depthComparisonFunc; }
+
+		/**
+		 * If true then stencil buffer will also be updated when a pixel is written, and pixels will be tested against 
+		 * the stencil buffer before rendering.
+		 */
+		bool getStencilEnable() const { return mData.stencilEnable; }
+
+		/** Mask to apply to any value read from the stencil buffer, before applying the stencil comparison function. */
+		UINT8 getStencilReadMask() const { return mData.stencilReadMask; }
+
+		/**	Mask to apply to any value about to be written in the stencil buffer. */
+		UINT8 getStencilWriteMask() const { return mData.stencilWriteMask; }
+
+		/**	Operation that happens when stencil comparison function fails on a front facing polygon. */
+		StencilOperation getStencilFrontFailOp() const { return mData.frontStencilFailOp; }
+
+		/** Operation that happens when stencil comparison function passes but depth test fails on a front facing polygon. */
+		StencilOperation getStencilFrontZFailOp() const { return mData.frontStencilZFailOp; }
+
+		/**	Operation that happens when stencil comparison function passes on a front facing polygon. */
+		StencilOperation getStencilFrontPassOp() const { return mData.frontStencilPassOp; }
+
+		/**
+		 * Stencil comparison function used for front facing polygons. Stencil buffer will be modified according to 
+		 * previously set stencil operations depending whether this comparison passes or fails.
+		 */
+		CompareFunction getStencilFrontCompFunc() const { return mData.frontStencilComparisonFunc; }
+
+		/** Operation that happens when stencil comparison function fails on a back facing polygon. */
+		StencilOperation getStencilBackFailOp() const { return mData.backStencilFailOp; }
+
+		/** Operation that happens when stencil comparison function passes but depth test fails on a back facing polygon. */
+		StencilOperation getStencilBackZFailOp() const { return mData.backStencilZFailOp; }
+
+		/**	Operation that happens when stencil comparison function passes on a back facing polygon. */
+		StencilOperation getStencilBackPassOp() const { return mData.backStencilPassOp; }
+
+		/**
+		 * Stencil comparison function used for back facing polygons. Stencil buffer will be modified according	to 
+		 * previously set stencil operations depending whether this comparison passes or fails.
+		 */
+		CompareFunction getStencilBackCompFunc() const { return mData.backStencilComparisonFunc; }
+
+		/** Returns the hash value generated from the depth-stencil state properties. */
+		UINT64 getHash() const { return mHash; }
+
+	protected:
+		friend class DepthStencilState;
+		friend class DepthStencilStateCore;
+		friend class DepthStencilStateRTTI;
+
+		DEPTH_STENCIL_STATE_DESC mData;
+		UINT64 mHash;
+	};
+
+	/**
+	 * Render system pipeline state that allows you to modify how an object is rendered. More exactly this state allows to 
+	 * you to control how are depth and stencil buffers modified upon rendering.
+	 *
+	 * @note	Depth stencil states are immutable. Sim thread only.
+	 */
+	class BS_CORE_EXPORT DepthStencilState : public IReflectable, public CoreObject
+	{
+	public:
+		virtual ~DepthStencilState();
+
+		/**	Returns information about the depth stencil state. */
+		const DepthStencilProperties& getProperties() const;
+
+		/**	Retrieves a core implementation of a sampler state usable only from the core thread. */
+		SPtr<DepthStencilStateCore> getCore() const;
+
+		/**	Creates a new depth stencil state using the specified depth stencil state description structure. */
+		static DepthStencilStatePtr create(const DEPTH_STENCIL_STATE_DESC& desc);
+
+		/**	Returns the default depth stencil state that you may use when no other is available. */
+		static const DepthStencilStatePtr& getDefault();
+
+		/**	Generates a hash value from a depth-stencil state descriptor. */
+		static UINT64 generateHash(const DEPTH_STENCIL_STATE_DESC& desc);
+
+	protected:
+		friend class RenderStateManager;
+
+		DepthStencilState(const DEPTH_STENCIL_STATE_DESC& desc);
+
+		/** @copydoc CoreObjectCore::createCore */
+		SPtr<CoreObjectCore> createCore() const override;
+
+		DepthStencilProperties mProperties;
+		mutable UINT32 mId;
+
+		/************************************************************************/
+		/* 								RTTI		                     		*/
+		/************************************************************************/
+
+	public:
+		friend class DepthStencilStateRTTI;
+		static RTTITypeBase* getRTTIStatic();
+		virtual RTTITypeBase* getRTTI() const override;	
+	};
+
+	/** @} */
+
+	/** @addtogroup RenderAPI-Internal
+	 *  @{
+	 */
+
+	/**
+	 * Core thread version of DepthStencilState.
+	 *
+	 * @note	Core thread.
+	 */
+	class BS_CORE_EXPORT DepthStencilStateCore : public CoreObjectCore
+	{
+	public:
+		virtual ~DepthStencilStateCore();
+
+		/**	Returns information about the depth stencil state. */
+		const DepthStencilProperties& getProperties() const;
+
+		/**	Returns a unique state ID. Only the lowest 10 bits are used. */
+		UINT32 getId() const { return mId; }
+
+		/**	Returns the default depth stencil state that you may use when no other is available. */
+		static const SPtr<DepthStencilStateCore>& getDefault();
+
+	protected:
+		friend class RenderStateCoreManager;
+
+		DepthStencilStateCore(const DEPTH_STENCIL_STATE_DESC& desc, UINT32 id);
+
+		/** @copydoc CoreObjectCore::initialize */
+		void initialize() override;
+
+		/**	Creates any API-specific state objects. */
+		virtual void createInternal() { }
+
+		DepthStencilProperties mProperties;
+		UINT32 mId;
+	};
+
+	/** @} */
+}
+
+/** @cond STDLIB */
+/** @addtogroup RenderAPI
+ *  @{
+ */
+
+/**	Hash value generator for DEPTH_STENCIL_STATE_DESC. */
+template<>
+struct std::hash<BansheeEngine::DEPTH_STENCIL_STATE_DESC>
+{
+	size_t operator()(const BansheeEngine::DEPTH_STENCIL_STATE_DESC& value) const
+	{
+		return (size_t)BansheeEngine::DepthStencilState::generateHash(value);
+	}
+};
+
+/** @} */
 /** @endcond */

+ 58 - 60
Source/BansheeCore/Include/BsEventQuery.h

@@ -1,61 +1,59 @@
-//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
-//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
-#pragma once
-
-#include "BsCorePrerequisites.h"
-
-namespace BansheeEngine
-{
-	/** @cond INTERNAL */
-	/** @addtogroup RenderAPI
-	 *  @{
-	 */
-
-	/**
-	 * Represents a GPU query that gets triggered when GPU starts processing the query.
-	 * 			
-	 * @note	
-	 * Normally GPU will have many commands in its command buffer. When begin() is called it is placed in that command 
-	 * buffer. Once the buffer empties and GPU reaches the EventQuery command, the query callback is triggered.
-	 * @note			
-	 * Core thread only.
-	 */
-	class BS_CORE_EXPORT EventQuery
-	{
-	public:
-		EventQuery()
-			:mActive(false) {}
-		virtual ~EventQuery() {}
-
-		/**
-		 * Starts the query. 
-		 * 			
-		 * @note	
-		 * Once the query is started you may poll isReady() method to check when query has finished, or you may hook up 
-		 * an ::onTriggered callback and be notified that way.
-		 */
-		virtual void begin() = 0;
-
-		/** Check if GPU has processed the query. */
-		virtual bool isReady() const = 0;
-
-		/**	Triggered when GPU starts processing the query. */
-		Event<void()> onTriggered;
-
-		/**	Creates a new query, but does not schedule it on GPU. */
-		static EventQueryPtr create();
-
-	protected:
-		friend class QueryManager;
-
-		/**	Returns true if the has still not been completed by the GPU. */
-		bool isActive() const { return mActive; }
-		void setActive(bool active) { mActive = active; }
-
-	protected:
-		bool mActive;
-	};
-
-	/** @} */
-	/** @endcond */
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+#pragma once
+
+#include "BsCorePrerequisites.h"
+
+namespace BansheeEngine
+{
+	/** @addtogroup RenderAPI-Internal
+	 *  @{
+	 */
+
+	/**
+	 * Represents a GPU query that gets triggered when GPU starts processing the query.
+	 * 			
+	 * @note	
+	 * Normally GPU will have many commands in its command buffer. When begin() is called it is placed in that command 
+	 * buffer. Once the buffer empties and GPU reaches the EventQuery command, the query callback is triggered.
+	 * @note			
+	 * Core thread only.
+	 */
+	class BS_CORE_EXPORT EventQuery
+	{
+	public:
+		EventQuery()
+			:mActive(false) {}
+		virtual ~EventQuery() {}
+
+		/**
+		 * Starts the query. 
+		 * 			
+		 * @note	
+		 * Once the query is started you may poll isReady() method to check when query has finished, or you may hook up 
+		 * an ::onTriggered callback and be notified that way.
+		 */
+		virtual void begin() = 0;
+
+		/** Check if GPU has processed the query. */
+		virtual bool isReady() const = 0;
+
+		/**	Triggered when GPU starts processing the query. */
+		Event<void()> onTriggered;
+
+		/**	Creates a new query, but does not schedule it on GPU. */
+		static EventQueryPtr create();
+
+	protected:
+		friend class QueryManager;
+
+		/**	Returns true if the has still not been completed by the GPU. */
+		bool isActive() const { return mActive; }
+		void setActive(bool active) { mActive = active; }
+
+	protected:
+		bool mActive;
+	};
+
+	/** @} */
 }

+ 1 - 3
Source/BansheeCore/Include/BsFCollider.h

@@ -9,8 +9,7 @@
 
 namespace BansheeEngine
 {
-	/** @cond INTERNAL */
-	/** @addtogroup Physics
+	/** @addtogroup Physics-Internal
 	 *  @{
 	 */
 
@@ -110,5 +109,4 @@ namespace BansheeEngine
 	};
 
 	/** @} */
-	/** @endcond */
 }

+ 4 - 2
Source/BansheeCore/Include/BsFJoint.h

@@ -18,7 +18,10 @@ namespace BansheeEngine
 		A, B
 	};
 
-	/** @cond INTERNAL */
+	/** @} */
+	/** @addtogroup Physics-Internal
+	 *  @{
+	 */
 
 	/** Provides common functionality used by all Joint types. */
 	class BS_CORE_EXPORT FJoint
@@ -72,6 +75,5 @@ namespace BansheeEngine
 		virtual void setEnableCollision(bool value) = 0;
 	};
 
-	/** @endcond */
 	/** @} */
 }

+ 29 - 31
Source/BansheeCore/Include/BsFontManager.h

@@ -1,32 +1,30 @@
-//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
-//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
-#pragma once
-
-#include "BsCorePrerequisites.h"
-#include "BsModule.h"
-
-namespace BansheeEngine
-{
-	/** @cond INTERNAL */
-	/** @addtogroup Text
-	 *  @{
-	 */
-
-	/**	Handles creation of fonts. */
-	class BS_CORE_EXPORT FontManager : public Module<FontManager>
-	{
-	public:
-		/**	Creates a new font from the provided populated font data structure. */
-		FontPtr create(const Vector<SPtr<FontBitmap>>& fontData) const;
-
-		/**
-		 * Creates an empty font.
-		 *
-		 * @note	Internal method. Used by factory methods.
-		 */
-		FontPtr _createEmpty() const;
-	};
-
-	/** @} */
-	/** @endcond */
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+#pragma once
+
+#include "BsCorePrerequisites.h"
+#include "BsModule.h"
+
+namespace BansheeEngine
+{
+	/** @addtogroup Text-Internal
+	 *  @{
+	 */
+
+	/**	Handles creation of fonts. */
+	class BS_CORE_EXPORT FontManager : public Module<FontManager>
+	{
+	public:
+		/**	Creates a new font from the provided populated font data structure. */
+		FontPtr create(const Vector<SPtr<FontBitmap>>& fontData) const;
+
+		/**
+		 * Creates an empty font.
+		 *
+		 * @note	Internal method. Used by factory methods.
+		 */
+		FontPtr _createEmpty() const;
+	};
+
+	/** @} */
 }

+ 5 - 4
Source/BansheeCore/Include/BsGameObject.h

@@ -7,12 +7,10 @@
 
 namespace BansheeEngine
 {
-	/** @addtogroup Scene
+	/** @addtogroup Scene-Internal
 	 *  @{
 	 */
 
-	/** @cond INTERNAL */
-
 	/** Flags used for notifying child scene object and components when a transform has been changed. */
 	enum TransformChangedFlags
 	{
@@ -21,7 +19,10 @@ namespace BansheeEngine
 		TCF_Parent = 0x02 /**< Component will be notified when its parent changes. */
 	};
 
-	/** @endcond */
+	/** @} */
+	/** @addtogroup Scene
+	 *  @{
+	 */
 
 	/**
 	 * Type of object that can be referenced by a GameObject handle. Each object has an unique ID and is registered with 

+ 0 - 7
Source/BansheeCore/Include/BsGameObjectHandle.h

@@ -13,8 +13,6 @@ namespace BansheeEngine
 	template <typename T>
 	class GameObjectHandle;
 
-	/** @cond INTERNAL */
-
 	/**	Contains instance data that is held by all GameObject handles. */
 	struct GameObjectInstanceData
 	{
@@ -43,8 +41,6 @@ namespace BansheeEngine
 		std::shared_ptr<GameObjectInstanceData> mPtr;
 	};
 
-	/** @endcond */
-
 	/**
 	 * A handle that can point to various types of game objects. It primarily keeps track if the object is still alive, 
 	 * so anything still referencing it doesn't accidentally use it.
@@ -284,8 +280,6 @@ namespace BansheeEngine
 		return GameObjectHandle<_Ty1>(other);
 	}
 
-	/** @cond INTERNAL */
-
 	/**	Compares if two handles point to the same GameObject. */
 	template<class _Ty1, class _Ty2>
 	bool operator==(const GameObjectHandle<_Ty1>& _Left, const GameObjectHandle<_Ty2>& _Right)
@@ -301,6 +295,5 @@ namespace BansheeEngine
 		return (!(_Left == _Right));
 	}
 
-	/** @endcond */
 	/** @} */
 }

+ 153 - 155
Source/BansheeCore/Include/BsGameObjectManager.h

@@ -1,156 +1,154 @@
-//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
-//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
-#pragma once
-
-#include "BsCorePrerequisites.h"
-#include "BsModule.h"
-#include "BsGameObject.h"
-
-namespace BansheeEngine
-{
-	/** @cond INTERNAL */
-	/** @addtogroup Scene
-	 *  @{
-	 */
-
-	/**	Possible modes to use when deserializing games objects. */
-	enum GameObjectHandleDeserializationMode
-	{
-		/** All handles will point to old ID that were restored from the deserialized file. */
-		GODM_UseOriginalIds = 0x01, 
-		/** All handles will point to new IDs that were given to the deserialized GameObjects. */
-		GODM_UseNewIds = 0x02,
-		/** Handles pointing to GameObjects outside of the currently deserialized set
-		will attempt to be restored in case those objects are still active. */
-		GODM_RestoreExternal = 0x04,
-		/** Handles pointing to GameObjects outside of the currently deserialized set
-		will be broken. */
-		GODM_BreakExternal = 0x08,
-		/** Handles pointing to GameObjects that cannot be found will not be set to null. */
-		GODM_KeepMissing = 0x10
-	};
-
-	/**
-	 * Tracks GameObject creation and destructions. Also resolves GameObject references from GameObject handles.
-	 *
-	 * @note	Sim thread only.
-	 */
-	class BS_CORE_EXPORT GameObjectManager : public Module<GameObjectManager>
-	{
-		/**	Contains data for an yet unresolved game object handle. */
-		struct UnresolvedHandle
-		{
-			UINT64 originalInstanceId;
-			GameObjectHandleBase handle;
-		};
-
-	public:
-		GameObjectManager();
-		~GameObjectManager();
-
-		/**
-		 * Registers a new GameObject and returns the handle to the object.
-		 * 			
-		 * @param[in]	object			Constructed GameObject to wrap in the handle and initialize.
-		 * @param[in]	originalId		If the object is being created due to deserialization you must provide the original
-		 *								object's ID so that deserialized handles can map to it properly.
-		 * @return						Handle to the GameObject.
-		 */
-		GameObjectHandleBase registerObject(const std::shared_ptr<GameObject>& object, UINT64 originalId = 0);
-
-		/**
-		 * Unregisters a GameObject. Handles to this object will no longer be valid after this call. This should be called
-		 * whenever a GameObject is destroyed.
-		 */
-		void unregisterObject(GameObjectHandleBase& object);
-
-		/**
-		 * Attempts to find a GameObject handle based on the GameObject instance ID. Returns empty handle if ID cannot be 
-		 * found.
-		 */
-		GameObjectHandleBase getObject(UINT64 id) const;
-
-		/**
-		 * Attempts to find a GameObject handle based on the GameObject instance ID. Returns true if object with the 
-		 * specified ID is found, false otherwise.
-		 */
-		bool tryGetObject(UINT64 id, GameObjectHandleBase& object) const;
-
-		/**	Checks if the GameObject with the specified instance ID exists. */
-		bool objectExists(UINT64 id) const;
-
-		/**
-		 * Changes the instance ID by which an object can be retrieved by. 
-		 *
-		 * @note	Caller is required to update the object itself with the new ID.
-		 */
-		void remapId(UINT64 oldId, UINT64 newId);
-
-		/**	Queues the object to be destroyed at the end of a GameObject update cycle. */
-		void queueForDestroy(const GameObjectHandleBase& object);
-
-		/**	Destroys any GameObjects that were queued for destruction. */
-		void destroyQueuedObjects();
-
-		/**	Triggered when a game object is being destroyed. */
-		Event<void(const HGameObject&)> onDestroyed;
-
-		/************************************************************************/
-		/* 							DESERIALIZATION                      		*/
-		/************************************************************************/
-		// Note: GameObjects need a bit of special handling when it comes to deserialization,
-		// which is what this part of the code is used for. It performs two main actions:
-		//  - 1. Resolves all GameObjectHandles on deserialization
-		//    - We can't just resolve them as we go because during deserialization not all objects
-		//      have necessarily been created.
-		//  - 2. Maps serialized IDs to actual in-engine IDs. 
-
-		/** Needs to be called whenever GameObject deserialization starts. Must be followed by endDeserialization() call. */
-		void startDeserialization();
-
-		/** Needs to be called whenever GameObject deserialization ends. Must be preceded by startDeserialization() call. */
-		void endDeserialization();
-
-		/**	Returns true if GameObject deserialization is currently in progress. */
-		bool isGameObjectDeserializationActive() const { return mIsDeserializationActive; }
-
-		/**	Queues the specified handle and resolves it when deserialization ends. */
-		void registerUnresolvedHandle(UINT64 originalId, GameObjectHandleBase& object);
-
-		/**	Registers a callback that will be triggered when GameObject serialization ends. */
-		void registerOnDeserializationEndCallback(std::function<void()> callback);
-
-		/**
-		 * Changes the deserialization mode for any following GameObject handle.
-		 *
-		 * @param[in]	gameObjectDeserializationMode	Mode that controls how are GameObjects handles resolved when being
-		 *												deserialized.
-		 */
-		void setDeserializationMode(UINT32 gameObjectDeserializationMode);
-
-		/**
-		 * Attempts to update the ID of the provided handle by mapping its old ID to the newly deserialized object and its
-		 * new ID. Game object deserialization must be active.
-		 */
-		void resolveDeserializedHandle(UnresolvedHandle& data, UINT32 flags);
-
-		/**	Gets the currently active flags that control how are game object handles deserialized. */
-		UINT32 getDeserializationFlags() const { return mGODeserializationMode; }
-
-	private:
-		UINT64 mNextAvailableID; // 0 is not a valid ID
-		Map<UINT64, GameObjectHandleBase> mObjects;
-		Map<UINT64, GameObjectHandleBase> mQueuedForDestroy;
-
-		GameObject* mActiveDeserializedObject;
-		bool mIsDeserializationActive;
-		Map<UINT64, UINT64> mIdMapping;
-		Map<UINT64, SPtr<GameObjectHandleData>> mUnresolvedHandleData;
-		Vector<UnresolvedHandle> mUnresolvedHandles;
-		Vector<std::function<void()>> mEndCallbacks;
-		UINT32 mGODeserializationMode;
-	};
-
-	/** @} */
-	/** @endcond */
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+#pragma once
+
+#include "BsCorePrerequisites.h"
+#include "BsModule.h"
+#include "BsGameObject.h"
+
+namespace BansheeEngine
+{
+	/** @addtogroup Scene-Internal
+	 *  @{
+	 */
+
+	/**	Possible modes to use when deserializing games objects. */
+	enum GameObjectHandleDeserializationMode
+	{
+		/** All handles will point to old ID that were restored from the deserialized file. */
+		GODM_UseOriginalIds = 0x01, 
+		/** All handles will point to new IDs that were given to the deserialized GameObjects. */
+		GODM_UseNewIds = 0x02,
+		/** Handles pointing to GameObjects outside of the currently deserialized set
+		will attempt to be restored in case those objects are still active. */
+		GODM_RestoreExternal = 0x04,
+		/** Handles pointing to GameObjects outside of the currently deserialized set
+		will be broken. */
+		GODM_BreakExternal = 0x08,
+		/** Handles pointing to GameObjects that cannot be found will not be set to null. */
+		GODM_KeepMissing = 0x10
+	};
+
+	/**
+	 * Tracks GameObject creation and destructions. Also resolves GameObject references from GameObject handles.
+	 *
+	 * @note	Sim thread only.
+	 */
+	class BS_CORE_EXPORT GameObjectManager : public Module<GameObjectManager>
+	{
+		/**	Contains data for an yet unresolved game object handle. */
+		struct UnresolvedHandle
+		{
+			UINT64 originalInstanceId;
+			GameObjectHandleBase handle;
+		};
+
+	public:
+		GameObjectManager();
+		~GameObjectManager();
+
+		/**
+		 * Registers a new GameObject and returns the handle to the object.
+		 * 			
+		 * @param[in]	object			Constructed GameObject to wrap in the handle and initialize.
+		 * @param[in]	originalId		If the object is being created due to deserialization you must provide the original
+		 *								object's ID so that deserialized handles can map to it properly.
+		 * @return						Handle to the GameObject.
+		 */
+		GameObjectHandleBase registerObject(const std::shared_ptr<GameObject>& object, UINT64 originalId = 0);
+
+		/**
+		 * Unregisters a GameObject. Handles to this object will no longer be valid after this call. This should be called
+		 * whenever a GameObject is destroyed.
+		 */
+		void unregisterObject(GameObjectHandleBase& object);
+
+		/**
+		 * Attempts to find a GameObject handle based on the GameObject instance ID. Returns empty handle if ID cannot be 
+		 * found.
+		 */
+		GameObjectHandleBase getObject(UINT64 id) const;
+
+		/**
+		 * Attempts to find a GameObject handle based on the GameObject instance ID. Returns true if object with the 
+		 * specified ID is found, false otherwise.
+		 */
+		bool tryGetObject(UINT64 id, GameObjectHandleBase& object) const;
+
+		/**	Checks if the GameObject with the specified instance ID exists. */
+		bool objectExists(UINT64 id) const;
+
+		/**
+		 * Changes the instance ID by which an object can be retrieved by. 
+		 *
+		 * @note	Caller is required to update the object itself with the new ID.
+		 */
+		void remapId(UINT64 oldId, UINT64 newId);
+
+		/**	Queues the object to be destroyed at the end of a GameObject update cycle. */
+		void queueForDestroy(const GameObjectHandleBase& object);
+
+		/**	Destroys any GameObjects that were queued for destruction. */
+		void destroyQueuedObjects();
+
+		/**	Triggered when a game object is being destroyed. */
+		Event<void(const HGameObject&)> onDestroyed;
+
+		/************************************************************************/
+		/* 							DESERIALIZATION                      		*/
+		/************************************************************************/
+		// Note: GameObjects need a bit of special handling when it comes to deserialization,
+		// which is what this part of the code is used for. It performs two main actions:
+		//  - 1. Resolves all GameObjectHandles on deserialization
+		//    - We can't just resolve them as we go because during deserialization not all objects
+		//      have necessarily been created.
+		//  - 2. Maps serialized IDs to actual in-engine IDs. 
+
+		/** Needs to be called whenever GameObject deserialization starts. Must be followed by endDeserialization() call. */
+		void startDeserialization();
+
+		/** Needs to be called whenever GameObject deserialization ends. Must be preceded by startDeserialization() call. */
+		void endDeserialization();
+
+		/**	Returns true if GameObject deserialization is currently in progress. */
+		bool isGameObjectDeserializationActive() const { return mIsDeserializationActive; }
+
+		/**	Queues the specified handle and resolves it when deserialization ends. */
+		void registerUnresolvedHandle(UINT64 originalId, GameObjectHandleBase& object);
+
+		/**	Registers a callback that will be triggered when GameObject serialization ends. */
+		void registerOnDeserializationEndCallback(std::function<void()> callback);
+
+		/**
+		 * Changes the deserialization mode for any following GameObject handle.
+		 *
+		 * @param[in]	gameObjectDeserializationMode	Mode that controls how are GameObjects handles resolved when being
+		 *												deserialized.
+		 */
+		void setDeserializationMode(UINT32 gameObjectDeserializationMode);
+
+		/**
+		 * Attempts to update the ID of the provided handle by mapping its old ID to the newly deserialized object and its
+		 * new ID. Game object deserialization must be active.
+		 */
+		void resolveDeserializedHandle(UnresolvedHandle& data, UINT32 flags);
+
+		/**	Gets the currently active flags that control how are game object handles deserialized. */
+		UINT32 getDeserializationFlags() const { return mGODeserializationMode; }
+
+	private:
+		UINT64 mNextAvailableID; // 0 is not a valid ID
+		Map<UINT64, GameObjectHandleBase> mObjects;
+		Map<UINT64, GameObjectHandleBase> mQueuedForDestroy;
+
+		GameObject* mActiveDeserializedObject;
+		bool mIsDeserializationActive;
+		Map<UINT64, UINT64> mIdMapping;
+		Map<UINT64, SPtr<GameObjectHandleData>> mUnresolvedHandleData;
+		Vector<UnresolvedHandle> mUnresolvedHandles;
+		Vector<std::function<void()>> mEndCallbacks;
+		UINT32 mGODeserializationMode;
+	};
+
+	/** @} */
 }

+ 219 - 217
Source/BansheeCore/Include/BsGpuBuffer.h

@@ -1,217 +1,219 @@
-//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
-//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
-#pragma once
-
-#include "BsCorePrerequisites.h"
-#include "BsGpuBufferView.h"
-#include "BsCoreObject.h"
-
-namespace BansheeEngine 
-{
-	/** @addtogroup RenderAPI
-	 *  @{
-	 */
-
-	/** 
-	 * Information about a GpuBuffer. Allows core and non-core versions of GpuBuffer to share the same structure for 
-	 * properties. 
-	 */
-	class BS_CORE_EXPORT GpuBufferProperties
-	{
-	public:
-		GpuBufferProperties(UINT32 elementCount, UINT32 elementSize, GpuBufferType type, 
-			GpuBufferUsage usage, bool randomGpuWrite, bool useCounter);
-
-		/**
-		 * Returns the type of the GPU buffer. Type determines which kind of views (if any) can be created for the buffer, 
-		 * and how is data read or modified in it.
-		 */
-		GpuBufferType getType() const { return mType; }
-
-		/** Returns buffer usage which determines how are planning on updating the buffer contents. */
-		GpuBufferUsage getUsage() const { return mUsage; }
-
-		/** Return whether the buffer supports random reads and writes within the GPU programs. */
-		bool getRandomGpuWrite() const { return mRandomGpuWrite; }
-
-		/**	Returns whether the buffer supports counter use within GPU programs. */
-		bool getUseCounter() const { return mUseCounter; }
-
-		/**	Returns number of elements in the buffer. */
-		UINT32 getElementCount() const { return mElementCount; }
-
-		/**	Returns size of a single element in the buffer in bytes. */
-		UINT32 getElementSize() const { return mElementSize; }
-
-	protected:
-		GpuBufferType mType;
-		GpuBufferUsage mUsage;
-		bool mRandomGpuWrite;
-		bool mUseCounter;
-		UINT32 mElementCount;
-		UINT32 mElementSize;
-	};
-
-	/** @cond INTERNAL */
-
-	/**
-	 * Core thread version of a GpuBuffer.
-	 *
-	 * @note	Core thread only.
-	 */
-	class BS_CORE_EXPORT GpuBufferCore : public CoreObjectCore
-	{
-	public:
-		virtual ~GpuBufferCore();
-
-		/**
-		 * Locks the buffer returning a pointer to the internal buffer data that you may then read or write to. 
-		 * Caller must ensure it will only perform actions promised in the provided GPU lock options parameter.
-		 *
-		 * @param[in]	offset	Number of bytes at which to lock the buffer. Returned pointer points to this location.
-		 * @param[in]	length	Number of bytes to lock.
-		 * @param[in]	options How to lock the buffer. Certain options offer better performance than others.
-		 */
-		virtual void* lock(UINT32 offset, UINT32 length, GpuLockOptions options) = 0;
-
-		/**
-		 * Unlocks a previously locked buffer. Any pointers to internal buffers returned when it was locked will become 
-		 * invalid.
-		 */
-		virtual void unlock() = 0;
-
-		/**
-		 * Reads buffer data into the previously allocated buffer.
-		 *
-		 * @param[in]	offset	Number of bytes at which to start reading the buffer.
-		 * @param[in]	length	Number of bytes to read.
-		 * @param[in]	pDest	Previously allocated buffer of @p length bytes size.
-		 */
-        virtual void readData(UINT32 offset, UINT32 length, void* pDest) = 0;
-
-		/**
-		 * Writes data into the buffer.
-		 *
-		 * @param[in]	offset		Number of bytes at which to start writing to the buffer.
-		 * @param[in]	length		Number of bytes to write.
-		 * @param[in]	pDest		Previously allocated buffer used to retrieve the data from.
-		 * @param[in]	writeFlags  Flags that may be used to improve performance for specific use cases.
-		 */
-        virtual void writeData(UINT32 offset, UINT32 length, const void* pSource, BufferWriteType writeFlags = BufferWriteType::Normal) = 0;
-
-		/**
-		 * Copies data from another buffer into this buffer.
-		 *
-		 * @param[in]	srcBuffer			Buffer to copy the data from.
-		 * @param[in]	srcOffset			Offset in bytes into the source buffer - this is where reading starts from.
-		 * @param[in]	dstOffset			Offset in bytes into the destination buffer - this is where writing starts from.
-		 * @param[in]	length				Number of bytes to copy from source to destination.
-		 * @param[in]	discardWholeBuffer	If true, the contents of the current buffer will be entirely discarded. This can
-		 *									improve performance if you know you wont be needing that data any more.
-		 */
-		virtual void copyData(GpuBufferCore& srcBuffer, UINT32 srcOffset,
-			UINT32 dstOffset, UINT32 length, bool discardWholeBuffer = false) = 0;
-
-		/** Returns properties describing the buffer. */
-		const GpuBufferProperties& getProperties() const { return mProperties; }
-
-		/**
-		 * Creates a buffer view that may be used for binding a buffer to a slot in the pipeline. Views allow you to specify
-		 * how is data in the buffer organized to make it easier for the pipeline to interpret.
-		 *
-		 * @param[in]	buffer			Buffer to create the view for.
-		 * @param[in]	firstElement	Position of the first element visible by the view.
-		 * @param[in]	elementWidth	Width of one element in bytes.
-		 * @param[in]	numElements		Number of elements in the buffer.
-		 * @param[in]	useCounter		Should the buffer allow use of a counter. This is only relevant for random read write buffers.
-		 * @param[in]	usage			Determines type of the view we are creating, and which slots in the pipeline will the view be bindable to.
-		 *
-		 * @note If a view with this exact parameters already exists, it will be returned and new one will not be created.
-		 * @note Only Default and RandomWrite views are supported for this type of buffer. 
-		 */
-		// TODO Low Priority: Perhaps reflect usage flag limitation by having an enum with only the supported two options?
-		static GpuBufferView* requestView(const SPtr<GpuBufferCore>& buffer, UINT32 firstElement, UINT32 elementWidth, 
-			UINT32 numElements, bool useCounter, GpuViewUsage usage);
-
-		/**
-		 * Releases a view created with requestView. 
-		 *
-		 * @note	View will only truly get released once all references to it are released.
-		 */
-		static void releaseView(GpuBufferView* view);
-
-	protected:
-		GpuBufferCore(UINT32 elementCount, UINT32 elementSize, GpuBufferType type, 
-			GpuBufferUsage usage, bool randomGpuWrite = false, bool useCounter = false);
-
-		/** Creates an empty view for the current buffer. */
-		virtual GpuBufferView* createView() = 0;
-
-		/**	Destroys a view previously created for this buffer. */
-		virtual void destroyView(GpuBufferView* view) = 0;
-
-		/**	Destroys all buffer views regardless if their reference count is zero or not. */
-		void clearBufferViews();
-
-		/**	Helper class to help with reference counting for GPU buffer views. */
-		struct GpuBufferReference
-		{
-			GpuBufferReference(GpuBufferView* _view)
-				:view(_view), refCount(0)
-			{ }
-
-			GpuBufferView* view;
-			UINT32 refCount;
-		};
-
-		UnorderedMap<GPU_BUFFER_DESC, GpuBufferReference*, GpuBufferView::HashFunction, GpuBufferView::EqualFunction> mBufferViews;
-		GpuBufferProperties mProperties;
-	};
-
-	/** @endcond */
-
-	/**
-	 * Handles a generic GPU buffer that you may use for storing any kind of data you wish to be accessible to the GPU.
-	 * These buffers may be bounds to GPU program binding slots and accessed from a GPU program, or may be used by fixed 
-	 * pipeline in some way.
-	 *
-	 * Buffer types:
-	 *  - Raw buffers containing a block of bytes that are up to the GPU program to interpret.
-	 *	- Structured buffer containing an array of structures compliant to a certain layout. Similar to raw buffer but 
-	 *    easier to interpret the data.
-	 *	- Random read/write buffers that allow you to write to random parts of the buffer from within the GPU program, and 
-	 *    then read it later. These can only be bound to pixel and compute stages.
-	 *	- Append/Consume buffers also allow you to write to them, but in a stack-like fashion, usually where one set of 
-	 *    programs produces data while other set consumes it from the same buffer. Append/Consume buffers are structured
-	 *	  by default.
-	 *
-	 * @note	Sim thread only.
-	 */
-	class BS_CORE_EXPORT GpuBuffer : public CoreObject
-    {
-    public:
-		virtual ~GpuBuffer() { }
-
-		/** Returns properties describing the buffer. */
-		const GpuBufferProperties& getProperties() const { return mProperties; }
-
-		/** Retrieves a core implementation of a GPU buffer usable only from the core thread. */
-		SPtr<GpuBufferCore> getCore() const;
-
-	protected:
-		friend class HardwareBufferManager;
-
-		GpuBuffer(UINT32 elementCount, UINT32 elementSize, GpuBufferType type, GpuBufferUsage usage, 
-			bool randomGpuWrite = false, bool useCounter = false);
-
-		/** @copydoc CoreObject::createCore */
-		SPtr<CoreObjectCore> createCore() const override;
-
-		/** @copydoc HardwareBufferManager::createGpuParamBlockBuffer */
-		static GpuParamBlockBufferPtr create(UINT32 size, GpuParamBlockUsage usage = GPBU_DYNAMIC);
-
-		GpuBufferProperties mProperties;
-    };
-
-	/** @} */
-}
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+#pragma once
+
+#include "BsCorePrerequisites.h"
+#include "BsGpuBufferView.h"
+#include "BsCoreObject.h"
+
+namespace BansheeEngine 
+{
+	/** @addtogroup RenderAPI
+	 *  @{
+	 */
+
+	/** 
+	 * Information about a GpuBuffer. Allows core and non-core versions of GpuBuffer to share the same structure for 
+	 * properties. 
+	 */
+	class BS_CORE_EXPORT GpuBufferProperties
+	{
+	public:
+		GpuBufferProperties(UINT32 elementCount, UINT32 elementSize, GpuBufferType type, 
+			GpuBufferUsage usage, bool randomGpuWrite, bool useCounter);
+
+		/**
+		 * Returns the type of the GPU buffer. Type determines which kind of views (if any) can be created for the buffer, 
+		 * and how is data read or modified in it.
+		 */
+		GpuBufferType getType() const { return mType; }
+
+		/** Returns buffer usage which determines how are planning on updating the buffer contents. */
+		GpuBufferUsage getUsage() const { return mUsage; }
+
+		/** Return whether the buffer supports random reads and writes within the GPU programs. */
+		bool getRandomGpuWrite() const { return mRandomGpuWrite; }
+
+		/**	Returns whether the buffer supports counter use within GPU programs. */
+		bool getUseCounter() const { return mUseCounter; }
+
+		/**	Returns number of elements in the buffer. */
+		UINT32 getElementCount() const { return mElementCount; }
+
+		/**	Returns size of a single element in the buffer in bytes. */
+		UINT32 getElementSize() const { return mElementSize; }
+
+	protected:
+		GpuBufferType mType;
+		GpuBufferUsage mUsage;
+		bool mRandomGpuWrite;
+		bool mUseCounter;
+		UINT32 mElementCount;
+		UINT32 mElementSize;
+	};
+
+	/**
+	 * Handles a generic GPU buffer that you may use for storing any kind of data you wish to be accessible to the GPU.
+	 * These buffers may be bounds to GPU program binding slots and accessed from a GPU program, or may be used by fixed 
+	 * pipeline in some way.
+	 *
+	 * Buffer types:
+	 *  - Raw buffers containing a block of bytes that are up to the GPU program to interpret.
+	 *	- Structured buffer containing an array of structures compliant to a certain layout. Similar to raw buffer but 
+	 *    easier to interpret the data.
+	 *	- Random read/write buffers that allow you to write to random parts of the buffer from within the GPU program, and 
+	 *    then read it later. These can only be bound to pixel and compute stages.
+	 *	- Append/Consume buffers also allow you to write to them, but in a stack-like fashion, usually where one set of 
+	 *    programs produces data while other set consumes it from the same buffer. Append/Consume buffers are structured
+	 *	  by default.
+	 *
+	 * @note	Sim thread only.
+	 */
+	class BS_CORE_EXPORT GpuBuffer : public CoreObject
+    {
+    public:
+		virtual ~GpuBuffer() { }
+
+		/** Returns properties describing the buffer. */
+		const GpuBufferProperties& getProperties() const { return mProperties; }
+
+		/** Retrieves a core implementation of a GPU buffer usable only from the core thread. */
+		SPtr<GpuBufferCore> getCore() const;
+
+	protected:
+		friend class HardwareBufferManager;
+
+		GpuBuffer(UINT32 elementCount, UINT32 elementSize, GpuBufferType type, GpuBufferUsage usage, 
+			bool randomGpuWrite = false, bool useCounter = false);
+
+		/** @copydoc CoreObject::createCore */
+		SPtr<CoreObjectCore> createCore() const override;
+
+		/** @copydoc HardwareBufferManager::createGpuParamBlockBuffer */
+		static GpuParamBlockBufferPtr create(UINT32 size, GpuParamBlockUsage usage = GPBU_DYNAMIC);
+
+		GpuBufferProperties mProperties;
+    };
+
+	/** @} */
+
+	/** @addtogroup RenderAPI-Internal
+	 *  @{
+	 */
+
+	/**
+	 * Core thread version of a GpuBuffer.
+	 *
+	 * @note	Core thread only.
+	 */
+	class BS_CORE_EXPORT GpuBufferCore : public CoreObjectCore
+	{
+	public:
+		virtual ~GpuBufferCore();
+
+		/**
+		 * Locks the buffer returning a pointer to the internal buffer data that you may then read or write to. 
+		 * Caller must ensure it will only perform actions promised in the provided GPU lock options parameter.
+		 *
+		 * @param[in]	offset	Number of bytes at which to lock the buffer. Returned pointer points to this location.
+		 * @param[in]	length	Number of bytes to lock.
+		 * @param[in]	options How to lock the buffer. Certain options offer better performance than others.
+		 */
+		virtual void* lock(UINT32 offset, UINT32 length, GpuLockOptions options) = 0;
+
+		/**
+		 * Unlocks a previously locked buffer. Any pointers to internal buffers returned when it was locked will become 
+		 * invalid.
+		 */
+		virtual void unlock() = 0;
+
+		/**
+		 * Reads buffer data into the previously allocated buffer.
+		 *
+		 * @param[in]	offset	Number of bytes at which to start reading the buffer.
+		 * @param[in]	length	Number of bytes to read.
+		 * @param[in]	pDest	Previously allocated buffer of @p length bytes size.
+		 */
+        virtual void readData(UINT32 offset, UINT32 length, void* pDest) = 0;
+
+		/**
+		 * Writes data into the buffer.
+		 *
+		 * @param[in]	offset		Number of bytes at which to start writing to the buffer.
+		 * @param[in]	length		Number of bytes to write.
+		 * @param[in]	pDest		Previously allocated buffer used to retrieve the data from.
+		 * @param[in]	writeFlags  Flags that may be used to improve performance for specific use cases.
+		 */
+        virtual void writeData(UINT32 offset, UINT32 length, const void* pSource, BufferWriteType writeFlags = BufferWriteType::Normal) = 0;
+
+		/**
+		 * Copies data from another buffer into this buffer.
+		 *
+		 * @param[in]	srcBuffer			Buffer to copy the data from.
+		 * @param[in]	srcOffset			Offset in bytes into the source buffer - this is where reading starts from.
+		 * @param[in]	dstOffset			Offset in bytes into the destination buffer - this is where writing starts from.
+		 * @param[in]	length				Number of bytes to copy from source to destination.
+		 * @param[in]	discardWholeBuffer	If true, the contents of the current buffer will be entirely discarded. This can
+		 *									improve performance if you know you wont be needing that data any more.
+		 */
+		virtual void copyData(GpuBufferCore& srcBuffer, UINT32 srcOffset,
+			UINT32 dstOffset, UINT32 length, bool discardWholeBuffer = false) = 0;
+
+		/** Returns properties describing the buffer. */
+		const GpuBufferProperties& getProperties() const { return mProperties; }
+
+		/**
+		 * Creates a buffer view that may be used for binding a buffer to a slot in the pipeline. Views allow you to specify
+		 * how is data in the buffer organized to make it easier for the pipeline to interpret.
+		 *
+		 * @param[in]	buffer			Buffer to create the view for.
+		 * @param[in]	firstElement	Position of the first element visible by the view.
+		 * @param[in]	elementWidth	Width of one element in bytes.
+		 * @param[in]	numElements		Number of elements in the buffer.
+		 * @param[in]	useCounter		Should the buffer allow use of a counter. This is only relevant for random read write buffers.
+		 * @param[in]	usage			Determines type of the view we are creating, and which slots in the pipeline will the view be bindable to.
+		 *
+		 * @note If a view with this exact parameters already exists, it will be returned and new one will not be created.
+		 * @note Only Default and RandomWrite views are supported for this type of buffer. 
+		 */
+		// TODO Low Priority: Perhaps reflect usage flag limitation by having an enum with only the supported two options?
+		static GpuBufferView* requestView(const SPtr<GpuBufferCore>& buffer, UINT32 firstElement, UINT32 elementWidth, 
+			UINT32 numElements, bool useCounter, GpuViewUsage usage);
+
+		/**
+		 * Releases a view created with requestView. 
+		 *
+		 * @note	View will only truly get released once all references to it are released.
+		 */
+		static void releaseView(GpuBufferView* view);
+
+	protected:
+		GpuBufferCore(UINT32 elementCount, UINT32 elementSize, GpuBufferType type, 
+			GpuBufferUsage usage, bool randomGpuWrite = false, bool useCounter = false);
+
+		/** Creates an empty view for the current buffer. */
+		virtual GpuBufferView* createView() = 0;
+
+		/**	Destroys a view previously created for this buffer. */
+		virtual void destroyView(GpuBufferView* view) = 0;
+
+		/**	Destroys all buffer views regardless if their reference count is zero or not. */
+		void clearBufferViews();
+
+		/**	Helper class to help with reference counting for GPU buffer views. */
+		struct GpuBufferReference
+		{
+			GpuBufferReference(GpuBufferView* _view)
+				:view(_view), refCount(0)
+			{ }
+
+			GpuBufferView* view;
+			UINT32 refCount;
+		};
+
+		UnorderedMap<GPU_BUFFER_DESC, GpuBufferReference*, GpuBufferView::HashFunction, GpuBufferView::EqualFunction> mBufferViews;
+		GpuBufferProperties mProperties;
+	};
+
+	/** @} */
+}

+ 86 - 88
Source/BansheeCore/Include/BsGpuBufferView.h

@@ -1,89 +1,87 @@
-//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
-//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
-#pragma once
-
-#include "BsCorePrerequisites.h"
-
-namespace BansheeEngine
-{
-	/** @cond INTERNAL */
-	/** @addtogroup RenderAPI
-	 *  @{
-	 */
-
-	/**
-	 * Descriptor structure used for initializing a GPUBufferView.
-	 *
-	 * @see		GpuBuffer
-	 */
-	struct BS_CORE_EXPORT GPU_BUFFER_DESC
-	{
-		UINT32 firstElement;
-		UINT32 elementWidth;
-		UINT32 numElements;
-		bool useCounter;
-		GpuViewUsage usage;
-	};
-
-	/**
-	 * Holds information about a GPU buffer view. Views allow you to specify how is data in a buffer organized to make it 
-	 * easier for the pipeline to interpret.
-	 *			
-	 * @note	Buffers don't get bound to the pipeline directly, views do. 
-	 * @note	Core thread only.
-	 *
-	 * @see		GpuBuffer
-	 */
-	class BS_CORE_EXPORT GpuBufferView
-	{
-	public:
-		class HashFunction
-		{
-		public:
-			size_t operator()(const GPU_BUFFER_DESC& key) const;
-		};
-
-		class EqualFunction
-		{
-		public:
-			bool operator()(const GPU_BUFFER_DESC& a, const GPU_BUFFER_DESC& b) const;
-		};
-
-		GpuBufferView();
-		virtual ~GpuBufferView();
-
-		/**
-		 * Initializes the view with the specified buffer and a set of parameters describing the view to create. Must be 
-		 * called right after construction.
-		 */
-		virtual void initialize(const SPtr<GpuBufferCore>& buffer, GPU_BUFFER_DESC& desc);
-
-		/** Returns a descriptor structure used for creating the view. */
-		const GPU_BUFFER_DESC& getDesc() const { return mDesc; }
-
-		/**	Returns the buffer this view was created for. */
-		SPtr<GpuBufferCore> getBuffer() const { return mBuffer; }
-
-		/** Returns index of first element in the buffer that this view provides access to. */
-		UINT32 getFirstElement() const { return mDesc.firstElement; }
-
-		/** Returns width of an element in the buffer, in bytes. */
-		UINT32 getElementWidth() const { return mDesc.elementWidth; }
-
-		/**	Returns the total number of elements this buffer provides access to. */
-		UINT32 getNumElements() const { return mDesc.numElements; }
-
-		/**	Returns true if this view allows a GPU program to use counters on the bound buffer. */
-		bool getUseCounter() const { return mDesc.useCounter; }
-
-		/** Returns view usage which determines where in the pipeline can the view be bound. */
-		GpuViewUsage getUsage() const { return mDesc.usage; }
-
-	protected:
-		GPU_BUFFER_DESC mDesc;
-		SPtr<GpuBufferCore> mBuffer;
-	};
-
-	/** @} */
-	/** @endcond */
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+#pragma once
+
+#include "BsCorePrerequisites.h"
+
+namespace BansheeEngine
+{
+	/** @addtogroup RenderAPI-Internal
+	 *  @{
+	 */
+
+	/**
+	 * Descriptor structure used for initializing a GPUBufferView.
+	 *
+	 * @see		GpuBuffer
+	 */
+	struct BS_CORE_EXPORT GPU_BUFFER_DESC
+	{
+		UINT32 firstElement;
+		UINT32 elementWidth;
+		UINT32 numElements;
+		bool useCounter;
+		GpuViewUsage usage;
+	};
+
+	/**
+	 * Holds information about a GPU buffer view. Views allow you to specify how is data in a buffer organized to make it 
+	 * easier for the pipeline to interpret.
+	 *			
+	 * @note	Buffers don't get bound to the pipeline directly, views do. 
+	 * @note	Core thread only.
+	 *
+	 * @see		GpuBuffer
+	 */
+	class BS_CORE_EXPORT GpuBufferView
+	{
+	public:
+		class HashFunction
+		{
+		public:
+			size_t operator()(const GPU_BUFFER_DESC& key) const;
+		};
+
+		class EqualFunction
+		{
+		public:
+			bool operator()(const GPU_BUFFER_DESC& a, const GPU_BUFFER_DESC& b) const;
+		};
+
+		GpuBufferView();
+		virtual ~GpuBufferView();
+
+		/**
+		 * Initializes the view with the specified buffer and a set of parameters describing the view to create. Must be 
+		 * called right after construction.
+		 */
+		virtual void initialize(const SPtr<GpuBufferCore>& buffer, GPU_BUFFER_DESC& desc);
+
+		/** Returns a descriptor structure used for creating the view. */
+		const GPU_BUFFER_DESC& getDesc() const { return mDesc; }
+
+		/**	Returns the buffer this view was created for. */
+		SPtr<GpuBufferCore> getBuffer() const { return mBuffer; }
+
+		/** Returns index of first element in the buffer that this view provides access to. */
+		UINT32 getFirstElement() const { return mDesc.firstElement; }
+
+		/** Returns width of an element in the buffer, in bytes. */
+		UINT32 getElementWidth() const { return mDesc.elementWidth; }
+
+		/**	Returns the total number of elements this buffer provides access to. */
+		UINT32 getNumElements() const { return mDesc.numElements; }
+
+		/**	Returns true if this view allows a GPU program to use counters on the bound buffer. */
+		bool getUseCounter() const { return mDesc.useCounter; }
+
+		/** Returns view usage which determines where in the pipeline can the view be bound. */
+		GpuViewUsage getUsage() const { return mDesc.usage; }
+
+	protected:
+		GPU_BUFFER_DESC mDesc;
+		SPtr<GpuBufferCore> mBuffer;
+	};
+
+	/** @} */
 }

+ 5 - 4
Source/BansheeCore/Include/BsGpuParamBlockBuffer.h

@@ -7,12 +7,10 @@
 
 namespace BansheeEngine
 {
-	/** @addtogroup RenderAPI
+	/** @addtogroup RenderAPI-Internal
 	 *  @{
 	 */
 
-	 /** @cond INTERNAL */
-
 	/**
 	 * Core thread version of a GpuParamBlockBuffer.
 	 *
@@ -99,7 +97,10 @@ namespace BansheeEngine
 		virtual void initialize() override;
 	};
 
-	/** @endcond */
+	/** @} */
+	/** @addtogroup RenderAPI
+	 *  @{
+	 */
 
 	/**
 	 * Represents a GPU parameter block buffer. Parameter block buffers are bound to GPU programs which then fetch 

+ 11 - 23
Source/BansheeCore/Include/BsGpuParams.h

@@ -14,7 +14,6 @@ namespace BansheeEngine
 	/** @addtogroup Implementation
 	 *  @{
 	 */
-	/** @cond INTERNAL */
 
 	/** Stores information needed for binding a texture to the pipeline. */
 	struct BoundTextureInfo
@@ -48,8 +47,6 @@ namespace BansheeEngine
 	template<> struct TGpuDataParamInfo < Matrix4x3 > { enum { TypeId = GPDT_MATRIX_4X3 }; };
 	template<> struct TGpuDataParamInfo < Color > { enum { TypeId = GPDT_COLOR }; };
 
-	/** @endcond */
-	
 	/** Contains functionality common for both sim and core thread version of GpuParams. */
 	class BS_CORE_EXPORT GpuParamsBase
 	{
@@ -110,18 +107,10 @@ namespace BansheeEngine
 		/**	Checks whether matrices should be transformed before being written to the parameter buffer. */
 		bool getTransposeMatrices() const { return mTransposeMatrices; }
 
-		/**
-		 * @copydoc	CoreObject::markCoreDirty
-		 *
-		 * @note	Internal method.
-		 */
+		/** @copydoc CoreObject::markCoreDirty */
 		virtual void _markCoreDirty() { }
 
-		/**
-		 * @copydoc	IResourceListener::markListenerResourcesDirty
-		 *
-		 * @note	Internal method.
-		 */
+		/** @copydoc IResourceListener::markListenerResourcesDirty */
 		virtual void _markResourcesDirty() { }
 
 	protected:
@@ -206,18 +195,16 @@ namespace BansheeEngine
 		 */
 		template<class T> void getParam(const String& name, TGpuDataParam<T, Core>& output) const;
 
-		/** @copydoc getParam(const String&, TGpuDataParam<T, Core>&) */
+		/** @copydoc getParam */
 		void getStructParam(const String& name, TGpuParamStruct<Core>& output) const;
 
-		/**
-		 * @copydoc	getParam(const String&, TGpuDataParam<T, Core>&)
-		 */
+		/** @copydoc getParam */
 		void getTextureParam(const String& name, TGpuParamTexture<Core>& output) const;
 
-		/** @copydoc getParam(const String&, TGpuDataParam<T, Core>&) */
+		/** @copydoc getParam */
 		void getLoadStoreTextureParam(const String& name, TGpuParamLoadStoreTexture<Core>& output) const;
 
-		/** @copydoc getParam(const String&, TGpuDataParam<T, Core>&) */
+		/** @copydoc getParam */
 		void getSamplerStateParam(const String& name, TGpuParamSampState<Core>& output) const;
 
 		/**	Gets a parameter block buffer from the specified slot. */
@@ -246,12 +233,10 @@ namespace BansheeEngine
 
 	/** @} */
 
-	/** @addtogroup RenderAPI
+	/** @addtogroup RenderAPI-Internal
 	 *  @{
 	 */
 
-	/** @cond INTERNAL */
-
 	/**
 	 * Core thread version of GpuParams.
 	 *
@@ -281,7 +266,10 @@ namespace BansheeEngine
 		void syncToCore(const CoreSyncData& data) override;
 	};
 
-	/** @endcond */
+	/** @} */
+	/** @addtogroup RenderAPI
+	 *  @{
+	 */
 
 	/**
 	 * Contains descriptions for all parameters in a GPU program and also allows you to write and read those parameters. 

+ 72 - 70
Source/BansheeCore/Include/BsGpuProgram.h

@@ -86,76 +86,6 @@ namespace BansheeEngine
 		String mSource;
 	};
 
-	/** @cond INTERNAL */
-
-	/**
-	 * Core thread version of a GpuProgram.
-	 *
-	 * @note	Core thread only.
-	 */
-	class BS_CORE_EXPORT GpuProgramCore : public CoreObjectCore
-	{
-	public:
-		virtual ~GpuProgramCore() { }
-
-		/** Returns whether this program can be supported on the current renderer and hardware. */
-        virtual bool isSupported() const;
-
-		/** Returns true if shader was successfully compiled. */
-		virtual bool isCompiled() const { return mIsCompiled; }
-
-		/**	Returns an error message returned by the compiler, if the compilation failed. */
-		virtual String getCompileErrorMessage() const { return mCompileError; }
-
-		/**
-		 * Sets whether this geometry program requires adjacency information from the input primitives.
-		 *
-		 * @note	Only relevant for geometry programs.
-		 */
-		virtual void setAdjacencyInfoRequired(bool required) { mNeedsAdjacencyInfo = required; }
-
-		/**
-		 * Returns whether this geometry program requires adjacency information from the input primitives.
-		 *
-		 * @note	Only relevant for geometry programs.
-		 */
-		virtual bool isAdjacencyInfoRequired() const { return mNeedsAdjacencyInfo; }
-
-		/** @copydoc GpuProgram::createParameters */
-		virtual SPtr<GpuParamsCore> createParameters();
-
-		/** @copydoc GpuProgram::getParamDesc */
-		GpuParamDescPtr getParamDesc() const { return mParametersDesc; }
-
-		/**	Returns GPU program input declaration. Only relevant for vertex programs. */
-		SPtr<VertexDeclarationCore> getInputDeclaration() const { return mInputDeclaration; }
-
-		/**	Returns properties that contain information about the GPU program. */
-		const GpuProgramProperties& getProperties() const { return mProperties; }
-
-		/** @copydoc GpuProgram::create */
-		static SPtr<GpuProgramCore> create(const String& source, const String& entryPoint, const String& language, GpuProgramType gptype,
-			GpuProgramProfile profile, bool requiresAdjacency = false);
-
-	protected:
-		GpuProgramCore(const String& source, const String& entryPoint,
-			GpuProgramType gptype, GpuProgramProfile profile, bool isAdjacencyInfoRequired = false);
-
-		/** Returns whether required capabilities for this program is supported. */
-		bool isRequiredCapabilitiesSupported() const;
-
-		bool mNeedsAdjacencyInfo;
-
-		bool mIsCompiled;
-		String mCompileError;
-
-		GpuParamDescPtr mParametersDesc;
-		SPtr<VertexDeclarationCore> mInputDeclaration;
-		GpuProgramProperties mProperties;
-	};
-
-	/** @endcond */
-
 	/**
 	 * Contains a GPU program such as vertex or fragment program which gets compiled from the provided source code.
 	 *
@@ -243,4 +173,76 @@ namespace BansheeEngine
 	};
 
 	/** @} */
+
+	/** @addtogroup RenderAPI-Internal
+	 *  @{
+	 */
+
+	/**
+	 * Core thread version of a GpuProgram.
+	 *
+	 * @note	Core thread only.
+	 */
+	class BS_CORE_EXPORT GpuProgramCore : public CoreObjectCore
+	{
+	public:
+		virtual ~GpuProgramCore() { }
+
+		/** Returns whether this program can be supported on the current renderer and hardware. */
+        virtual bool isSupported() const;
+
+		/** Returns true if shader was successfully compiled. */
+		virtual bool isCompiled() const { return mIsCompiled; }
+
+		/**	Returns an error message returned by the compiler, if the compilation failed. */
+		virtual String getCompileErrorMessage() const { return mCompileError; }
+
+		/**
+		 * Sets whether this geometry program requires adjacency information from the input primitives.
+		 *
+		 * @note	Only relevant for geometry programs.
+		 */
+		virtual void setAdjacencyInfoRequired(bool required) { mNeedsAdjacencyInfo = required; }
+
+		/**
+		 * Returns whether this geometry program requires adjacency information from the input primitives.
+		 *
+		 * @note	Only relevant for geometry programs.
+		 */
+		virtual bool isAdjacencyInfoRequired() const { return mNeedsAdjacencyInfo; }
+
+		/** @copydoc GpuProgram::createParameters */
+		virtual SPtr<GpuParamsCore> createParameters();
+
+		/** @copydoc GpuProgram::getParamDesc */
+		GpuParamDescPtr getParamDesc() const { return mParametersDesc; }
+
+		/**	Returns GPU program input declaration. Only relevant for vertex programs. */
+		SPtr<VertexDeclarationCore> getInputDeclaration() const { return mInputDeclaration; }
+
+		/**	Returns properties that contain information about the GPU program. */
+		const GpuProgramProperties& getProperties() const { return mProperties; }
+
+		/** @copydoc GpuProgram::create */
+		static SPtr<GpuProgramCore> create(const String& source, const String& entryPoint, const String& language, GpuProgramType gptype,
+			GpuProgramProfile profile, bool requiresAdjacency = false);
+
+	protected:
+		GpuProgramCore(const String& source, const String& entryPoint,
+			GpuProgramType gptype, GpuProgramProfile profile, bool isAdjacencyInfoRequired = false);
+
+		/** Returns whether required capabilities for this program is supported. */
+		bool isRequiredCapabilitiesSupported() const;
+
+		bool mNeedsAdjacencyInfo;
+
+		bool mIsCompiled;
+		String mCompileError;
+
+		GpuParamDescPtr mParametersDesc;
+		SPtr<VertexDeclarationCore> mInputDeclaration;
+		GpuProgramProperties mProperties;
+	};
+
+	/** @} */
 }

+ 1 - 3
Source/BansheeCore/Include/BsGpuProgramManager.h

@@ -9,8 +9,7 @@
 
 namespace BansheeEngine 
 {
-	/** @cond INTERNAL */
-	/** @addtogroup RenderAPI
+	/** @addtogroup RenderAPI-Internal
 	 *  @{
 	 */
 
@@ -140,5 +139,4 @@ namespace BansheeEngine
 	};
 
 	/** @} */
-	/** @endcond */
 }

+ 1 - 3
Source/BansheeCore/Include/BsHardwareBuffer.h

@@ -6,8 +6,7 @@
 
 namespace BansheeEngine 
 {
-	/** @cond INTERNAL */
-	/** @addtogroup RenderAPI
+	/** @addtogroup RenderAPI-Internal
 	 *  @{
 	 */
 
@@ -158,5 +157,4 @@ namespace BansheeEngine
     };
 
 	/** @} */
-	/** @endcond */
 }

+ 133 - 135
Source/BansheeCore/Include/BsHardwareBufferManager.h

@@ -1,135 +1,133 @@
-//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
-//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
-#pragma once
-
-#include "BsCorePrerequisites.h"
-#include "BsModule.h"
-#include "BsVertexBuffer.h"
-#include "BsIndexBuffer.h"
-#include "BsVertexDeclaration.h"
-
-namespace BansheeEngine 
-{
-	/** @cond INTERNAL */
-	/** @addtogroup RenderAPI
-	 *  @{
-	 */
-
-	/**
-	 * Handles creation of various hardware buffers.
-	 *
-	 * @note	Sim thread only.
-	 */
-	class BS_CORE_EXPORT HardwareBufferManager : public Module<HardwareBufferManager>
-	{
-    public:
-        HardwareBufferManager();
-        virtual ~HardwareBufferManager();
-
-		/**
-		 * Creates a new vertex buffer used for holding number of vertices and other per-vertex data. Buffer can be bound 
-		 * to the pipeline and its data can be passed to the active vertex GPU program.
-		 *
-		 * @param[in]	vertexSize	Size of a single vertex in the buffer, in bytes.
-		 * @param[in]	numVerts	Number of vertices the buffer can hold.
-		 * @param[in]	usage		Usage that tells the hardware how will be buffer be used. 
-		 * @param[in]	streamOut	If true the buffer will be usable for streaming out data from the GPU.
-		 */
-		virtual VertexBufferPtr createVertexBuffer(UINT32 vertexSize, UINT32 numVerts, GpuBufferUsage usage, bool streamOut = false);
-
-		/**
-		 * Creates a new index buffer that holds indices referencing vertices in a vertex buffer. Indices are interpreted 
-		 * by the pipeline and vertices are drawn in the order specified in the index buffer.
-		 *
-		 * @param[in]	itype		Index type, determines size of an index.
-		 * @param[in]	numIndexes	Number of indexes can buffer can hold.
-		 * @param[in]	usage		Usage that tells the hardware how will be buffer be used. 
-		 */
-		virtual IndexBufferPtr createIndexBuffer(IndexType itype, UINT32 numIndexes, GpuBufferUsage usage);
-
-		/**
-		 * Creates an GPU parameter block that you can use for setting parameters for GPU programs. Parameter blocks may be
-		 * used for sharing parameter data between multiple GPU programs, requiring you to update only one buffer for all of
-		 * them, potentially improving performance.
-		 *
-		 * @param[in]	size	Size of the parameter buffer in bytes.
-		 * @param[in]	usage	Usage that tells the hardware how will be buffer be used. 
-		 */
-		virtual GpuParamBlockBufferPtr createGpuParamBlockBuffer(UINT32 size, GpuParamBlockUsage usage = GPBU_DYNAMIC);
-
-		/**
-		 * Creates a generic buffer that can be passed as a parameter to a GPU program. This type of buffer can hold various 
-		 * type of data and can be used for various purposes. See "GpuBufferType" for explanation of different buffer types.
-		 *
-		 * @param[in]	elementCount  	Number of elements in the buffer. 
-		 * @param[in]	elementSize   	Size of each individual element in the buffer, in bytes.
-		 * @param[in]	type		  	Type of the buffer.
-		 * @param[in]	usage		  	Usage that tells the hardware how will be buffer be used. 
-		 * @param[in]	randomGpuWrite	(optional) Allows the GPU to write to the resource.
-		 * @param[in]	useCounter	  	(optional) Binds a counter that can be used from a GPU program on the buffer.
-		 *
-		 * @note	
-		 * Be aware that due to some render API restrictions some of these settings cannot be used together, and if so you 
-		 * will receive an assert in debug mode.
-		 */
-		virtual GpuBufferPtr createGpuBuffer(UINT32 elementCount, UINT32 elementSize, 
-			GpuBufferType type, GpuBufferUsage usage, bool randomGpuWrite = false, bool useCounter = false);
-
-		/** Creates a new vertex declaration from a list of vertex elements. */
-		virtual VertexDeclarationPtr createVertexDeclaration(const List<VertexElement>& elements);
-	};
-
-	/**
-	 * Handles creation of various hardware buffers.
-	 *
-	 * @note	Core thread only.
-	 */
-	class BS_CORE_EXPORT HardwareBufferCoreManager : public Module<HardwareBufferCoreManager>
-	{
-    public:
-		virtual ~HardwareBufferCoreManager() { }
-
-		/** @copydoc HardwareBufferManager::createVertexBuffer */
-		virtual SPtr<VertexBufferCore> createVertexBuffer(UINT32 vertexSize, UINT32 numVerts, GpuBufferUsage usage, bool streamOut = false);
-
-		/** @copydoc HardwareBufferManager::createIndexBuffer */
-		virtual SPtr<IndexBufferCore> createIndexBuffer(IndexType itype, UINT32 numIndexes, GpuBufferUsage usage);
-
-		/** @copydoc HardwareBufferManager::createVertexDeclaration */
-		virtual SPtr<VertexDeclarationCore> createVertexDeclaration(const List<VertexElement>& elements);
-
-		/** @copydoc HardwareBufferManager::createGpuParamBlockBuffer */
-		virtual SPtr<GpuParamBlockBufferCore> createGpuParamBlockBuffer(UINT32 size, GpuParamBlockUsage usage = GPBU_DYNAMIC);
-
-		/** @copydoc HardwareBufferManager::createGpuBuffer */
-		virtual SPtr<GpuBufferCore> createGpuBuffer(UINT32 elementCount, UINT32 elementSize, 
-			GpuBufferType type, GpuBufferUsage usage, bool randomGpuWrite = false, bool useCounter = false);
-
-	protected:
-		friend class IndexBuffer;
-		friend class VertexBuffer;
-		friend class VertexDeclaration;
-		friend class GpuParamBlockBuffer;
-		friend class GpuBuffer;
-
-		/** @copydoc createVertexBuffer */
-		virtual SPtr<VertexBufferCore> createVertexBufferInternal(UINT32 vertexSize, UINT32 numVerts, GpuBufferUsage usage, bool streamOut = false) = 0;
-
-		/** @copydoc createIndexBuffer */
-		virtual SPtr<IndexBufferCore> createIndexBufferInternal(IndexType itype, UINT32 numIndexes, GpuBufferUsage usage) = 0;
-
-		/** @copydoc createGpuParamBlockBuffer */
-		virtual SPtr<GpuParamBlockBufferCore> createGpuParamBlockBufferInternal(UINT32 size, GpuParamBlockUsage usage = GPBU_DYNAMIC) = 0;
-
-		/** @copydoc createGpuBuffer */
-		virtual SPtr<GpuBufferCore> createGpuBufferInternal(UINT32 elementCount, UINT32 elementSize,
-			GpuBufferType type, GpuBufferUsage usage, bool randomGpuWrite = false, bool useCounter = false) = 0;
-
-		/** @copydoc createVertexDeclaration */
-		virtual SPtr<VertexDeclarationCore> createVertexDeclarationInternal(const List<VertexElement>& elements);
-	};
-
-	/** @} */
-	/** @endcond */
-}
-
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+#pragma once
+
+#include "BsCorePrerequisites.h"
+#include "BsModule.h"
+#include "BsVertexBuffer.h"
+#include "BsIndexBuffer.h"
+#include "BsVertexDeclaration.h"
+
+namespace BansheeEngine 
+{
+	/** @addtogroup RenderAPI-Internal
+	 *  @{
+	 */
+
+	/**
+	 * Handles creation of various hardware buffers.
+	 *
+	 * @note	Sim thread only.
+	 */
+	class BS_CORE_EXPORT HardwareBufferManager : public Module<HardwareBufferManager>
+	{
+    public:
+        HardwareBufferManager();
+        virtual ~HardwareBufferManager();
+
+		/**
+		 * Creates a new vertex buffer used for holding number of vertices and other per-vertex data. Buffer can be bound 
+		 * to the pipeline and its data can be passed to the active vertex GPU program.
+		 *
+		 * @param[in]	vertexSize	Size of a single vertex in the buffer, in bytes.
+		 * @param[in]	numVerts	Number of vertices the buffer can hold.
+		 * @param[in]	usage		Usage that tells the hardware how will be buffer be used. 
+		 * @param[in]	streamOut	If true the buffer will be usable for streaming out data from the GPU.
+		 */
+		virtual VertexBufferPtr createVertexBuffer(UINT32 vertexSize, UINT32 numVerts, GpuBufferUsage usage, bool streamOut = false);
+
+		/**
+		 * Creates a new index buffer that holds indices referencing vertices in a vertex buffer. Indices are interpreted 
+		 * by the pipeline and vertices are drawn in the order specified in the index buffer.
+		 *
+		 * @param[in]	itype		Index type, determines size of an index.
+		 * @param[in]	numIndexes	Number of indexes can buffer can hold.
+		 * @param[in]	usage		Usage that tells the hardware how will be buffer be used. 
+		 */
+		virtual IndexBufferPtr createIndexBuffer(IndexType itype, UINT32 numIndexes, GpuBufferUsage usage);
+
+		/**
+		 * Creates an GPU parameter block that you can use for setting parameters for GPU programs. Parameter blocks may be
+		 * used for sharing parameter data between multiple GPU programs, requiring you to update only one buffer for all of
+		 * them, potentially improving performance.
+		 *
+		 * @param[in]	size	Size of the parameter buffer in bytes.
+		 * @param[in]	usage	Usage that tells the hardware how will be buffer be used. 
+		 */
+		virtual GpuParamBlockBufferPtr createGpuParamBlockBuffer(UINT32 size, GpuParamBlockUsage usage = GPBU_DYNAMIC);
+
+		/**
+		 * Creates a generic buffer that can be passed as a parameter to a GPU program. This type of buffer can hold various 
+		 * type of data and can be used for various purposes. See "GpuBufferType" for explanation of different buffer types.
+		 *
+		 * @param[in]	elementCount  	Number of elements in the buffer. 
+		 * @param[in]	elementSize   	Size of each individual element in the buffer, in bytes.
+		 * @param[in]	type		  	Type of the buffer.
+		 * @param[in]	usage		  	Usage that tells the hardware how will be buffer be used. 
+		 * @param[in]	randomGpuWrite	(optional) Allows the GPU to write to the resource.
+		 * @param[in]	useCounter	  	(optional) Binds a counter that can be used from a GPU program on the buffer.
+		 *
+		 * @note	
+		 * Be aware that due to some render API restrictions some of these settings cannot be used together, and if so you 
+		 * will receive an assert in debug mode.
+		 */
+		virtual GpuBufferPtr createGpuBuffer(UINT32 elementCount, UINT32 elementSize, 
+			GpuBufferType type, GpuBufferUsage usage, bool randomGpuWrite = false, bool useCounter = false);
+
+		/** Creates a new vertex declaration from a list of vertex elements. */
+		virtual VertexDeclarationPtr createVertexDeclaration(const List<VertexElement>& elements);
+	};
+
+	/**
+	 * Handles creation of various hardware buffers.
+	 *
+	 * @note	Core thread only.
+	 */
+	class BS_CORE_EXPORT HardwareBufferCoreManager : public Module<HardwareBufferCoreManager>
+	{
+    public:
+		virtual ~HardwareBufferCoreManager() { }
+
+		/** @copydoc HardwareBufferManager::createVertexBuffer */
+		virtual SPtr<VertexBufferCore> createVertexBuffer(UINT32 vertexSize, UINT32 numVerts, GpuBufferUsage usage, bool streamOut = false);
+
+		/** @copydoc HardwareBufferManager::createIndexBuffer */
+		virtual SPtr<IndexBufferCore> createIndexBuffer(IndexType itype, UINT32 numIndexes, GpuBufferUsage usage);
+
+		/** @copydoc HardwareBufferManager::createVertexDeclaration */
+		virtual SPtr<VertexDeclarationCore> createVertexDeclaration(const List<VertexElement>& elements);
+
+		/** @copydoc HardwareBufferManager::createGpuParamBlockBuffer */
+		virtual SPtr<GpuParamBlockBufferCore> createGpuParamBlockBuffer(UINT32 size, GpuParamBlockUsage usage = GPBU_DYNAMIC);
+
+		/** @copydoc HardwareBufferManager::createGpuBuffer */
+		virtual SPtr<GpuBufferCore> createGpuBuffer(UINT32 elementCount, UINT32 elementSize, 
+			GpuBufferType type, GpuBufferUsage usage, bool randomGpuWrite = false, bool useCounter = false);
+
+	protected:
+		friend class IndexBuffer;
+		friend class VertexBuffer;
+		friend class VertexDeclaration;
+		friend class GpuParamBlockBuffer;
+		friend class GpuBuffer;
+
+		/** @copydoc createVertexBuffer */
+		virtual SPtr<VertexBufferCore> createVertexBufferInternal(UINT32 vertexSize, UINT32 numVerts, GpuBufferUsage usage, bool streamOut = false) = 0;
+
+		/** @copydoc createIndexBuffer */
+		virtual SPtr<IndexBufferCore> createIndexBufferInternal(IndexType itype, UINT32 numIndexes, GpuBufferUsage usage) = 0;
+
+		/** @copydoc createGpuParamBlockBuffer */
+		virtual SPtr<GpuParamBlockBufferCore> createGpuParamBlockBufferInternal(UINT32 size, GpuParamBlockUsage usage = GPBU_DYNAMIC) = 0;
+
+		/** @copydoc createGpuBuffer */
+		virtual SPtr<GpuBufferCore> createGpuBufferInternal(UINT32 elementCount, UINT32 elementSize,
+			GpuBufferType type, GpuBufferUsage usage, bool randomGpuWrite = false, bool useCounter = false) = 0;
+
+		/** @copydoc createVertexDeclaration */
+		virtual SPtr<VertexDeclarationCore> createVertexDeclarationInternal(const List<VertexElement>& elements);
+	};
+
+	/** @} */
+}
+

+ 38 - 40
Source/BansheeCore/Include/BsIconUtility.h

@@ -1,41 +1,39 @@
-//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
-//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
-#pragma once
-
-#include "BsCorePrerequisites.h"
-
-namespace BansheeEngine
-{
-	/** @cond INTERNAL */
-	/** @addtogroup Utility-Core
-	 *  @{
-	 */
-
-	/**	Manipulates icons in executable files. */
-	class BS_CORE_EXPORT IconUtility
-	{
-	public:
-		/**
-		 * Updates icons in the provided executable. Only icons that already exist in the executable can be updated, no new
-		 * icons can be inserted. Icons must be square.
-		 *
-		 * @param[in]	filePath	Path to the executable.
-		 * @param[in]	icons   	Pixels of images to replace. Each entry maps an icon width (and height, since they're 
-		 *							square) to its pixels.
-		 */
-		static void updateIconExe(const Path& filePath, const Map<UINT32, PixelDataPtr>& icons);
-
-	private:
-		/**
-		 * Updates data of an existing icon with new pixels.
-		 *
-		 * @param[in] 	iconData	Existing icon bytes, in Windows ICO format.
-		 * @param[in]	icons		Pixels of images to replace. Each entry maps an icon width (and height, since they're
-		 *							square) to its pixels.
-		 */
-		static void updateIconData(UINT8* iconData, const Map<UINT32, PixelDataPtr>& icons);
-	};
-
-	/** @} */
-	/** @endcond */
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+#pragma once
+
+#include "BsCorePrerequisites.h"
+
+namespace BansheeEngine
+{
+	/** @addtogroup Utility-Core-Internal
+	 *  @{
+	 */
+
+	/**	Manipulates icons in executable files. */
+	class BS_CORE_EXPORT IconUtility
+	{
+	public:
+		/**
+		 * Updates icons in the provided executable. Only icons that already exist in the executable can be updated, no new
+		 * icons can be inserted. Icons must be square.
+		 *
+		 * @param[in]	filePath	Path to the executable.
+		 * @param[in]	icons   	Pixels of images to replace. Each entry maps an icon width (and height, since they're 
+		 *							square) to its pixels.
+		 */
+		static void updateIconExe(const Path& filePath, const Map<UINT32, PixelDataPtr>& icons);
+
+	private:
+		/**
+		 * Updates data of an existing icon with new pixels.
+		 *
+		 * @param[in] 	iconData	Existing icon bytes, in Windows ICO format.
+		 * @param[in]	icons		Pixels of images to replace. Each entry maps an icon width (and height, since they're
+		 *							square) to its pixels.
+		 */
+		static void updateIconData(UINT8* iconData, const Map<UINT32, PixelDataPtr>& icons);
+	};
+
+	/** @} */
 }

+ 97 - 93
Source/BansheeCore/Include/BsIndexBuffer.h

@@ -1,94 +1,98 @@
-//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
-//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
-#pragma once
-
-#include "BsCorePrerequisites.h"
-#include "BsHardwareBuffer.h"
-#include "BsCoreObject.h"
-
-namespace BansheeEngine 
-{
-	/** @addtogroup RenderAPI
-	 *  @{
-	 */
-
-	/**	Type of the indices used, used for determining size. */
-	enum IndexType 
-	{
-		IT_16BIT,
-		IT_32BIT
-	};
-
-	/**	Contains information about an index buffer. */
-	class BS_CORE_EXPORT IndexBufferProperties
-	{
-	public:
-		IndexBufferProperties(IndexType idxType, UINT32 numIndexes);
-
-		/**	Returns the type of indices stored. */
-		IndexType getType() const { return mIndexType; }
-
-		/**	Returns the number of indices this buffer can hold. */
-		UINT32 getNumIndices() const { return mNumIndexes; }
-
-		/**	Returns the size of a single index in bytes. */
-		UINT32 getIndexSize() const { return mIndexSize; }
-
-	protected:
-		friend class IndexBuffer;
-		friend class IndexBufferCore;
-
-		IndexType mIndexType;
-		UINT32 mNumIndexes;
-		UINT32 mIndexSize;
-	};
-
-	/** @cond INTERNAL */
-
-	/** Core thread specific implementation of an IndexBuffer. */
-	class BS_CORE_EXPORT IndexBufferCore : public CoreObjectCore, public HardwareBuffer
-	{
-	public:
-		IndexBufferCore(IndexType idxType, UINT32 numIndexes, GpuBufferUsage usage);
-		virtual ~IndexBufferCore() { }
-
-		/**	Returns information about the index buffer. */
-		const IndexBufferProperties& getProperties() const { return mProperties; }
-
-	protected:
-		IndexBufferProperties mProperties;
-	};
-
-	/** @endcond */
-
-	/** Hardware buffer that hold indices that reference vertices in a vertex buffer. */
-    class BS_CORE_EXPORT IndexBuffer : public CoreObject
-    {
-	public:
-		virtual ~IndexBuffer() { }
-
-		/** Returns information about the index buffer. */
-		const IndexBufferProperties& getProperties() const { return mProperties; }
-
-		/**
-		 * Retrieves a core implementation of an index buffer usable only from the core thread.
-		 *
-		 * @note	Core thread only.
-		 */
-		SPtr<IndexBufferCore> getCore() const;
-
-		/** @copydoc HardwareBufferManager::createIndexBuffer */
-		static IndexBufferPtr create(IndexType itype, UINT32 numIndexes, GpuBufferUsage usage);
-
-	protected:
-		friend class HardwareBufferManager;
-
-		IndexBuffer(IndexType idxType, UINT32 numIndexes, GpuBufferUsage usage);
-
-		/** @copydoc CoreObject::createCore */
-		virtual SPtr<CoreObjectCore> createCore() const;
-
-		IndexBufferProperties mProperties;
-		GpuBufferUsage mUsage;
-    };
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+#pragma once
+
+#include "BsCorePrerequisites.h"
+#include "BsHardwareBuffer.h"
+#include "BsCoreObject.h"
+
+namespace BansheeEngine 
+{
+	/** @addtogroup RenderAPI
+	 *  @{
+	 */
+
+	/**	Type of the indices used, used for determining size. */
+	enum IndexType 
+	{
+		IT_16BIT,
+		IT_32BIT
+	};
+
+	/**	Contains information about an index buffer. */
+	class BS_CORE_EXPORT IndexBufferProperties
+	{
+	public:
+		IndexBufferProperties(IndexType idxType, UINT32 numIndexes);
+
+		/**	Returns the type of indices stored. */
+		IndexType getType() const { return mIndexType; }
+
+		/**	Returns the number of indices this buffer can hold. */
+		UINT32 getNumIndices() const { return mNumIndexes; }
+
+		/**	Returns the size of a single index in bytes. */
+		UINT32 getIndexSize() const { return mIndexSize; }
+
+	protected:
+		friend class IndexBuffer;
+		friend class IndexBufferCore;
+
+		IndexType mIndexType;
+		UINT32 mNumIndexes;
+		UINT32 mIndexSize;
+	};
+
+	/** Hardware buffer that hold indices that reference vertices in a vertex buffer. */
+    class BS_CORE_EXPORT IndexBuffer : public CoreObject
+    {
+	public:
+		virtual ~IndexBuffer() { }
+
+		/** Returns information about the index buffer. */
+		const IndexBufferProperties& getProperties() const { return mProperties; }
+
+		/**
+		 * Retrieves a core implementation of an index buffer usable only from the core thread.
+		 *
+		 * @note	Core thread only.
+		 */
+		SPtr<IndexBufferCore> getCore() const;
+
+		/** @copydoc HardwareBufferManager::createIndexBuffer */
+		static IndexBufferPtr create(IndexType itype, UINT32 numIndexes, GpuBufferUsage usage);
+
+	protected:
+		friend class HardwareBufferManager;
+
+		IndexBuffer(IndexType idxType, UINT32 numIndexes, GpuBufferUsage usage);
+
+		/** @copydoc CoreObject::createCore */
+		virtual SPtr<CoreObjectCore> createCore() const;
+
+		IndexBufferProperties mProperties;
+		GpuBufferUsage mUsage;
+    };
+
+	/** @} */
+
+	/** @addtogroup RenderAPI-Internal
+	 *  @{
+	 */
+
+	/** Core thread specific implementation of an IndexBuffer. */
+	class BS_CORE_EXPORT IndexBufferCore : public CoreObjectCore, public HardwareBuffer
+	{
+	public:
+		IndexBufferCore(IndexType idxType, UINT32 numIndexes, GpuBufferUsage usage);
+		virtual ~IndexBufferCore() { }
+
+		/**	Returns information about the index buffer. */
+		const IndexBufferProperties& getProperties() const { return mProperties; }
+
+	protected:
+		IndexBufferProperties mProperties;
+	};
+
+	/** @} */
 }

+ 803 - 801
Source/BansheeCore/Include/BsMaterial.h

@@ -1,802 +1,804 @@
-//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
-//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
-#pragma once
-
-#include "BsCorePrerequisites.h"
-#include "BsResource.h"
-#include "BsIResourceListener.h"
-#include "BsMaterialParam.h"
-#include "BsVector2.h"
-#include "BsVector3.h"
-#include "BsVector4.h"
-#include "BsMatrix3.h"
-#include "BsMatrix4.h"
-
-namespace BansheeEngine
-{
-	/** @addtogroup Implementation
-	 *  @{
-	 */
-
-	class MaterialParams;
-
-	/** Helper class containing parameters for all types of GPU programs used in a pass. */
-	template<bool Core>
-	class TPassParameters
-	{
-	public:
-		typedef typename TGpuParamsPtrType<Core>::Type GpuParamsType;
-
-		/**
-		 * Returns a set of GPU parameters based on an index.
-		 *
-		 * @note	Useful when needing to iterate over all sets of GPU parameters.
-		 */
-		GpuParamsType& getParamByIdx(UINT32 idx)
-		{
-			GpuParamsType* paramArray[] = { &mVertParams, &mFragParams, &mGeomParams, &mHullParams, &mDomainParams, &mComputeParams };
-
-			return *paramArray[idx];
-		}
-
-		/**
-		 * Sets GPU parameters based on an index.
-		 *
-		 * @note	Useful when needing to iterate over all sets of GPU parameters.
-		 */
-		void setParamByIdx(UINT32 idx, const GpuParamsType& params)
-		{
-			GpuParamsType* paramArray[] = { &mVertParams, &mFragParams, &mGeomParams, &mHullParams, &mDomainParams, &mComputeParams };
-
-			(*paramArray[idx]) = params;
-		}
-
-		GpuParamsType mVertParams;
-		GpuParamsType mFragParams;
-		GpuParamsType mGeomParams;
-		GpuParamsType mHullParams;
-		GpuParamsType mDomainParams;
-		GpuParamsType mComputeParams;
-	};
-
-	template<bool Core> struct TGpuParamBlockBufferPtrType { };
-	template<> struct TGpuParamBlockBufferPtrType<false> { typedef SPtr<GpuParamBlockBuffer> Type; };
-	template<> struct TGpuParamBlockBufferPtrType<true> { typedef SPtr<GpuParamBlockBufferCore> Type; };
-
-	template<bool Core> struct TGpuProgramType { };
-	template<> struct TGpuProgramType<false> { typedef GpuProgramPtr Type; };
-	template<> struct TGpuProgramType<true> { typedef SPtr<GpuProgramCore> Type; };
-
-	/** Contains sim thread pass parameters for each shader stage. */
-	class BS_CORE_EXPORT PassParameters : public TPassParameters<false>
-	{
-	public:
-		static const UINT32 NUM_PARAMS;
-	};
-
-	/** Contains core thread pass parameters for each shader stage. */
-	class BS_CORE_EXPORT PassParametersCore : public TPassParameters<true>
-	{
-	public:
-		static const UINT32 NUM_PARAMS;
-	};
-
-	/**
-	 * Material that controls how objects are rendered. It is represented by a shader and parameters used to set up that
-	 * shader. It provides a simple interface for manipulating the parameters.
-	 */
-	class BS_CORE_EXPORT MaterialBase
-	{
-	public:
-		/** Data used to describe a structure defined within a shader. */
-		struct StructData
-		{
-			StructData()
-				:size(0), data(nullptr)
-			{ }
-
-			StructData(UINT32 _size)
-				:size(_size)
-			{
-				data = std::shared_ptr<void>(bs_alloc(_size), &bs_free);
-			}
-
-			/**
-			 * Writes the specified data to the internal buffer. Caller must ensure size of the provided buffer is correct.
-			 */
-			void write(void* _data)
-			{
-				memcpy(data.get(), _data, size);
-			}
-
-			std::shared_ptr<void> data;
-			UINT32 size;
-		};
-
-		virtual ~MaterialBase() { }
-
-	protected:
-		/** Retrieves a list of all shader GPU parameters, and the GPU program variable names they map to. */
-		const Map<String, String>& getValidParamNames() const { return mValidParams; }
-
-		/** @copydoc CoreObject::markCoreDirty */
-		virtual void _markCoreDirty() { }
-
-		/** @copydoc CoreObject::markDependenciesDirty */
-		virtual void _markDependenciesDirty() { }
-
-		/** @copydoc IResourceListener::markResourcesDirty */
-		virtual void _markResourcesDirty() { }
-
-		/** Returns all GPU parameter descriptions in the specified technique. */
-		static Vector<GpuParamDescPtr> getAllParamDescs(const SPtr<Technique>& technique);
-
-		/** Returns all GPU parameter descriptions in the specified technique. */
-		static Vector<GpuParamDescPtr> getAllParamDescs(const SPtr<TechniqueCore>& technique);
-
-		Set<String> mValidShareableParamBlocks;
-		Map<String, String> mValidParams; // Also maps Shader param name -> gpu variable name
-	};
-
-	/** @copydoc MaterialBase */
-	template<bool Core>
-	class BS_CORE_EXPORT TMaterial : public MaterialBase
-	{
-	public:
-		template<bool Core> struct TPassType {};
-		template<> struct TPassType < false > { typedef SPtr<Pass> Type; };
-		template<> struct TPassType < true > { typedef SPtr<PassCore> Type; };
-
-		template<bool Core> struct TTechniqueType {};
-		template<> struct TTechniqueType < false > { typedef SPtr<Technique> Type; };
-		template<> struct TTechniqueType < true > { typedef SPtr<TechniqueCore> Type; };
-
-		template<bool Core> struct TShaderType {};
-		template<> struct TShaderType < false > { typedef HShader Type; };
-		template<> struct TShaderType < true > { typedef SPtr<ShaderCore> Type; };
-
-		template<bool Core> struct TGpuParamBlockBufferType {};
-		template<> struct TGpuParamBlockBufferType < false > { typedef GpuParamBlockBuffer Type; };
-		template<> struct TGpuParamBlockBufferType < true > { typedef GpuParamBlockBufferCore Type; };
-
-		template<bool Core> struct TPassParamsType {};
-		template<> struct TPassParamsType < false > { typedef PassParameters Type; };
-		template<> struct TPassParamsType < true > { typedef PassParametersCore Type; };
-
-		typedef typename TGpuParamsPtrType<Core>::Type GpuParamsType;
-		typedef typename TGpuParamTextureType<Core>::Type TextureType;
-		typedef typename TGpuParamSamplerStateType<Core>::Type SamplerStateType;
-		typedef typename TGpuParamBlockBufferPtrType<Core>::Type ParamBlockPtrType;
-		typedef typename TGpuParamBlockBufferType<Core>::Type ParamBlockType;
-		typedef typename TGpuProgramType<Core>::Type GpuProgramType;
-		typedef typename TPassType<Core>::Type PassType;
-		typedef typename TTechniqueType<Core>::Type TechniqueType;
-		typedef typename TShaderType<Core>::Type ShaderType;
-		typedef typename TPassParamsType<Core>::Type PassParamsType;
-
-		virtual ~TMaterial() { }
-
-		/** Returns the currently active shader. */
-		ShaderType getShader() const { return mShader; }
-
-		/** Returns the number of passes that are used by the shader used in the material. */
-		UINT32 getNumPasses() const;
-
-		/** Retrieves a specific shader pass. */
-		PassType getPass(UINT32 passIdx) const;
-
-		/**   
-		 * Assigns a float value to the shader parameter with the specified name. 
-		 *
-		 * Optionally if the parameter is an array you may provide an array index to assign the value to.
-		 */
-		void setFloat(const String& name, float value, UINT32 arrayIdx = 0)	{ return getParamFloat(name).set(value, arrayIdx); }
-
-		/**   
-		 * Assigns a color to the shader parameter with the specified name. 
-		 *
-		 * Optionally if the parameter is an array you may provide an array index to assign the value to.
-		 */
-		void setColor(const String& name, const Color& value, UINT32 arrayIdx = 0) { return getParamColor(name).set(value, arrayIdx); }
-
-		/**   
-		 * Assigns a 2D vector to the shader parameter with the specified name. 
-		 *
-		 * Optionally if the parameter is an array you may provide an array index to assign the value to.
-		 */
-		void setVec2(const String& name, const Vector2& value, UINT32 arrayIdx = 0)	{ return getParamVec2(name).set(value, arrayIdx); }
-
-		/**   
-		 * Assigns a 3D vector to the shader parameter with the specified name. 
-		 *
-		 * Optionally if the parameter is an array you may provide an array index to assign the value to.
-		 */
-		void setVec3(const String& name, const Vector3& value, UINT32 arrayIdx = 0)	{ return getParamVec3(name).set(value, arrayIdx); }
-
-		/**   
-		 * Assigns a 4D vector to the shader parameter with the specified name. 
-		 *
-		 * Optionally if the parameter is an array you may provide an array index to assign the value to.
-		 */
-		void setVec4(const String& name, const Vector4& value, UINT32 arrayIdx = 0)	{ return getParamVec4(name).set(value, arrayIdx); }
-
-		/**   
-		 * Assigns a 3x3 matrix to the shader parameter with the specified name. 
-		 *
-		 * Optionally if the parameter is an array you may provide an array index to assign the value to.
-		 */
-		void setMat3(const String& name, const Matrix3& value, UINT32 arrayIdx = 0)	{ return getParamMat3(name).set(value, arrayIdx); }
-
-		/**   
-		 * Assigns a 4x4 matrix to the shader parameter with the specified name. 
-		 *
-		 * Optionally if the parameter is an array you may provide an array index to assign the value to.
-		 */
-		void setMat4(const String& name, const Matrix4& value, UINT32 arrayIdx = 0)	{ return getParamMat4(name).set(value, arrayIdx); }
-
-		/**   
-		 * Assigns a structure to the shader parameter with the specified name.
-		 *  		
-		 * Structure is provided as a raw buffer and caller must ensure structure in buffer matches what the shader expects.
-		 *
-		 * Optionally if the parameter is an array you may provide an array index to assign the value to.
-		 */
-		void setStructData(const String& name, void* value, UINT32 size, UINT32 arrayIdx = 0) { return getParamStruct(name).set(value, size, arrayIdx); }
-
-		/** Assigns a texture to the shader parameter with the specified name. */
-		void setTexture(const String& name, const TextureType& value) { return getParamTexture(name).set(value); }
-
-		/** Assigns a texture to be used for random load/store operations to the shader parameter with the specified name. */
-		void setLoadStoreTexture(const String& name, const TextureType& value, const TextureSurface& surface)
-		{ 
-			return getParamLoadStoreTexture(name).set(value, surface); 
-		}
-
-		/** Assigns a sampler state to the shader parameter with the specified name. */
-		void setSamplerState(const String& name, const SamplerStateType& value) { return getParamSamplerState(name).set(value); }
-
-		/**
-		 * Returns a float value assigned with the parameter with the specified name.
-		 *
-		 * Optionally if the parameter is an array you may provide an array index you which to retrieve.
-		 */
-		float getFloat(const String& name, UINT32 arrayIdx = 0) const { return getParamFloat(name).get(arrayIdx); }
-
-		/**
-		 * Returns a color assigned with the parameter with the specified name.
-		 *
-		 * Optionally if the parameter is an array you may provide an array index you which to retrieve.
-		 */
-		Color getColor(const String& name, UINT32 arrayIdx = 0) const { return getParamColor(name).get(arrayIdx); }
-
-		/**
-		 * Returns a 2D vector assigned with the parameter with the specified name.
-		 *
-		 * Optionally if the parameter is an array you may provide an array index you which to retrieve.
-		 */
-		Vector2 getVec2(const String& name, UINT32 arrayIdx = 0) const { return getParamVec2(name).get(arrayIdx); }
-
-		/**
-		 * Returns a 3D vector assigned with the parameter with the specified name.
-		 *
-		 * Optionally if the parameter is an array you may provide an array index you which to retrieve.
-		 */
-		Vector3 getVec3(const String& name, UINT32 arrayIdx = 0) const { return getParamVec3(name).get(arrayIdx); }
-
-		/**
-		 * Returns a 4D vector assigned with the parameter with the specified name.
-		 *
-		 * Optionally if the parameter is an array you may provide an array index you which to retrieve.
-		 */
-		Vector4 getVec4(const String& name, UINT32 arrayIdx = 0) const { return getParamVec4(name).get(arrayIdx); }
-
-		/**
-		 * Returns a 3x3 matrix assigned with the parameter with the specified name.
-		 *
-		 * Optionally if the parameter is an array you may provide an array index you which to retrieve.
-		 */
-		Matrix3 getMat3(const String& name, UINT32 arrayIdx = 0) const { return getParamMat3(name).get(arrayIdx); }
-
-		/**
-		 * Returns a 4x4 matrix assigned with the parameter with the specified name.
-		 *
-		 * Optionally if the parameter is an array you may provide an array index you which to retrieve.
-		 */
-		Matrix4 getMat4(const String& name, UINT32 arrayIdx = 0) const { return getParamMat4(name).get(arrayIdx); }
-
-		/** Returns a texture assigned with the parameter with the specified name. */
-		TextureType getTexture(const String& name) const { return getParamTexture(name).get(); }
-
-		/** Returns a sampler state assigned with the parameter with the specified name. */
-		SamplerStateType getSamplerState(const String& name) const	{ return getParamSamplerState(name).get(); }
-
-		/**
-		 * Returns a buffer representing a structure assigned to the parameter with the specified name.
-		 *
-		 * Optionally if the parameter is an array you may provide an array index you which to retrieve.
-		 */
-		MaterialBase::StructData getStructData(const String& name, UINT32 arrayIdx = 0) const
-		{
-			TMaterialParamStruct<Core> structParam = getParamStruct(name);
-
-			MaterialBase::StructData data(structParam.getElementSize());
-			structParam.get(data.data.get(), structParam.getElementSize(), arrayIdx);
-
-			return data;
-		}
-
-		/**
-		 * Returns a float GPU parameter. This parameter may be used for more efficiently getting/setting GPU parameter 
-		 * values than calling Material::get* / Material::set* methods. 
-		 *
-		 * @note	
-		 * Expected behavior is that you would retrieve this parameter when initially constructing the material, and then 
-		 * use it throughout material lifetime to assign and retrieve parameter values.
-		 * @note			
-		 * If material shader changes this handle will be invalidated.
-		 */
-		TMaterialDataParam<float, Core> getParamFloat(const String& name) const
-		{
-			TMaterialDataParam<float, Core> gpuParam;
-			getParam(name, gpuParam);
-
-			return gpuParam;
-		}
-
-		/**
-		 * Returns a color GPU parameter. This parameter may be used for more efficiently getting/setting GPU parameter 
-		 * values than calling Material::get* / Material::set* methods. 
-		 *
-		 * @note	
-		 * Expected behavior is that you would retrieve this parameter when initially constructing the material, 
-		 * and then use it throughout material lifetime to assign and retrieve parameter values.
-		 * @note
-		 * If material shader changes this handle will be invalidated.
-		 */
-		TMaterialDataParam<Color, Core> getParamColor(const String& name) const
-		{
-			TMaterialDataParam<Color, Core> gpuParam;
-			getParam(name, gpuParam);
-
-			return gpuParam;
-		}
-
-		/**
-		 * Returns a 2D vector GPU parameter. This parameter may be used for more efficiently getting/setting GPU parameter 
-		 * values than calling Material::get* / Material::set* methods. 
-		 *
-		 * @note	
-		 * Expected behavior is that you would retrieve this parameter when initially constructing the material, and then 
-		 * use it throughout material lifetime to assign and retrieve parameter values.
-		 * @note	
-		 * If material shader changes this handle will be invalidated.
-		 */
-		TMaterialDataParam<Vector2, Core> getParamVec2(const String& name) const
-		{
-			TMaterialDataParam<Vector2, Core> gpuParam;
-			getParam(name, gpuParam);
-
-			return gpuParam;
-		}
-
-		/**
-		 * Returns a 3D vector GPU parameter. This parameter may be used for more efficiently getting/setting GPU parameter
-		 * values than calling Material::get* / Material::set* methods. 
-		 *
-		 * @note	
-		 * Expected behavior is that you would retrieve this parameter when initially constructing the material, and then
-		 * use it throughout material lifetime to assign and retrieve parameter values.
-		 * @note			
-		 * If material shader changes this handle will be invalidated.
-		 */
-		TMaterialDataParam<Vector3, Core> getParamVec3(const String& name) const
-		{
-			TMaterialDataParam<Vector3, Core> gpuParam;
-			getParam(name, gpuParam);
-
-			return gpuParam;
-		}
-
-		/**
-		 * Returns a 4D vector GPU parameter. This parameter may be used for more efficiently getting/setting GPU parameter
-		 * values than calling Material::get* / Material::set* methods. 
-		 *
-		 * @note	
-		 * Expected behavior is that you would retrieve this parameter when initially constructing the material, and then 
-		 * use it throughout material lifetime to assign and retrieve parameter values.
-		 * @note	
-		 * If material shader changes this handle will be invalidated.
-		 */
-		TMaterialDataParam<Vector4, Core> getParamVec4(const String& name) const
-		{
-			TMaterialDataParam<Vector4, Core> gpuParam;
-			getParam(name, gpuParam);
-
-			return gpuParam;
-		}
-
-		/**
-		 * Returns a 3x3 matrix GPU parameter. This parameter may be used for more efficiently getting/setting GPU 
-		 * parameter values than calling Material::get* / Material::set* methods. 
-		 *
-		 * @note	
-		 * Expected behavior is that you would retrieve this parameter when initially constructing the material, and then 
-		 * use it throughout material lifetime to assign and retrieve parameter values.
-		 * @note	
-		 * If material shader changes this handle will be invalidated.
-		 */
-		TMaterialDataParam<Matrix3, Core> getParamMat3(const String& name) const
-		{
-			TMaterialDataParam<Matrix3, Core> gpuParam;
-			getParam(name, gpuParam);
-
-			return gpuParam;
-		}
-
-		/**
-		 * Returns a 4x4 matrix GPU parameter. This parameter may be used for more efficiently getting/setting GPU parameter
-		 * values than calling Material::get* / Material::set* methods. 
-		 *
-		 * @note	
-		 * Expected behavior is that you would retrieve this parameter when initially constructing the material, and then 
-		 * use it throughout material lifetime to assign and retrieve parameter values.
-		 * @note	
-		 * If material shader changes this handle will be invalidated.
-		 */
-		TMaterialDataParam<Matrix4, Core> getParamMat4(const String& name) const
-		{
-			TMaterialDataParam<Matrix4, Core> gpuParam;
-			getParam(name, gpuParam);
-
-			return gpuParam;
-		}
-
-		/**
-		 * Returns a structure GPU parameter. This parameter may be used for more efficiently getting/setting GPU parameter
-		 * values than calling Material::get* / Material::set* methods. 
-		 *
-		 * @note	
-		 * Expected behavior is that you would retrieve this parameter when initially constructing the material, and then 
-		 * use it throughout material lifetime to assign and retrieve parameter values.
-		 * @note			
-		 * If material shader changes this handle will be invalidated.
-		 */
-		TMaterialParamStruct<Core> getParamStruct(const String& name) const;
-
-		/**
-		 * Returns a texture GPU parameter. This parameter may be used for more efficiently getting/setting GPU parameter 
-		 * values than calling Material::get* / Material::set* methods. 
-		 *
-		 * @note	
-		 * Expected behavior is that you would retrieve this parameter when initially constructing the material, and then 
-		 * use it throughout material lifetime to assign and retrieve parameter values.
-		 * @note
-		 * If material shader changes this handle will be invalidated.
-		 */
-		TMaterialParamTexture<Core> getParamTexture(const String& name) const;
-
-		/**
-		 * Returns a GPU parameter for binding a load/store texture. This parameter may be used for more efficiently 
-		 * getting/setting GPU parameter values than calling Material::get* / Material::set* methods. 
-		 *
-		 * @note	
-		 * Expected behavior is that you would retrieve this parameter when initially constructing the material, and then 
-		 * use it throughout material lifetime to assign and retrieve parameter values.
-		 * @note			
-		 * If material shader changes this handle will be invalidated.
-		 */
-		TMaterialParamLoadStoreTexture<Core> getParamLoadStoreTexture(const String& name) const;
-
-		/**
-		 * Returns a sampler state GPU parameter. This parameter may be used for more efficiently getting/setting GPU 
-		 * parameter values than calling Material::get* / Material::set* methods. 
-		 *
-		 * @note	
-		 * Expected behavior is that you would retrieve this parameter when initially constructing the material, and then 
-		 * use it throughout material lifetime to assign and retrieve parameter values.
-		 * @note			
-		 * If material shader changes this handle will be invalidated.
-		 */
-		TMaterialParamSampState<Core> getParamSamplerState(const String& name) const;
-
-		/** Returns a set of parameters for all GPU programs in the specified shader pass. */
-		SPtr<PassParamsType> getPassParameters(UINT32 passIdx) const { return mParametersPerPass[passIdx]; }
-
-		/**
-		 * Assign a parameter block buffer with the specified name.
-		 *
-		 * @note	
-		 * Parameter block buffers can be used as quick way of setting multiple parameters on a material at once, or
-		 * potentially sharing parameters between multiple materials. This reduces driver overhead as the parameters
-		 * in the buffers need only be set once and then reused multiple times.
-		 */
-		void setParamBlockBuffer(const String& name, const ParamBlockPtrType& paramBlock);
-
-		/**
-		 * Allows you to retrieve a handle to a parameter that you can then use for quickly setting and retrieving parameter
-		 * data. This allows you to set/get parameter data without all the cost of extra lookups otherwise required.
-		 * 			
-		 * @note	
-		 * All of these handles will be invalidated if material shader ever changes. It is up to the caller to keep track 
-		 * of that.
-		 */
-		template <typename T>
-		void getParam(const String& name, TMaterialDataParam<T, Core>& output) const;
-
-	protected:
-		/** 
-		 * Creates a material param out of multiple GPU params. Caller must ensure all GPU params reference the same 
-		 * parameter. 
-		 */
-		template <typename T>
-		TMaterialDataParam<T, false> createDataParam(const String& name, 
-			const SPtr<Vector<TGpuDataParam<T, false>>>& gpuParams) const
-		{
-			return TMaterialDataParam<T, false>(name, getCachedParams(), gpuParams);
-		}
-
-		/** 
-		 * Creates a material param out of multiple GPU params. Caller must ensure all GPU params reference the same 
-		 * parameter. 
-		 */
-		template <typename T>
-		TMaterialDataParam<T, true> createDataParam(const String& name, 
-			const SPtr<Vector<TGpuDataParam<T, true>>>& gpuParams) const
-		{
-			return TMaterialDataParam<T, true>(gpuParams);
-		}
-
-		/** 
-		 * Creates a material param out of multiple GPU params. Caller must ensure all GPU params reference the same 
-		 * parameter. 
-		 */
-		TMaterialParamStruct<false> createStructParam(const String& name, 
-			const SPtr<Vector<TGpuParamStruct<false>>>& gpuParams) const
-		{
-			return TMaterialParamStruct<false>(name, getCachedParams(), gpuParams);
-		}
-
-		/** 
-		 * Creates a material param out of multiple GPU params. Caller must ensure all GPU params reference the same 
-		 * parameter. 
-		 */
-		TMaterialParamStruct<true> createStructParam(const String& name, 
-			const SPtr<Vector<TGpuParamStruct<true>>>& gpuParams) const
-		{
-			return TMaterialParamStruct<true>(gpuParams);
-		}
-
-		/** 
-		 * Creates a material param out of multiple GPU params. Caller must ensure all GPU params reference the same 
-		 * parameter. 
-		 */
-		TMaterialParamTexture<false> createTextureParam(const String& name, 
-			const SPtr<Vector<TGpuParamTexture<false>>>& gpuParams) const
-		{
-			return TMaterialParamTexture<false>(name, getCachedParams(), gpuParams);
-		}
-
-		/** 
-		 * Creates a material param out of multiple GPU params. Caller must ensure all GPU params reference the same 
-		 * parameter. 
-		 */
-		TMaterialParamTexture<true> createTextureParam(const String& name,
-			const SPtr<Vector<TGpuParamTexture<true>>>& gpuParams) const
-		{
-			return TMaterialParamTexture<true>(gpuParams);
-		}
-
-		/** 
-		 * Creates a material param out of multiple GPU params. Caller must ensure all GPU params reference the same 
-		 * parameter. 
-		 */
-		TMaterialParamLoadStoreTexture<false> createLoadStoreTextureParam(const String& name, 
-			const SPtr<Vector<TGpuParamLoadStoreTexture<false>>>& gpuParams) const
-		{
-			return TMaterialParamLoadStoreTexture<false>(name, getCachedParams(), gpuParams);
-		}
-
-		/** 
-		 * Creates a material param out of multiple GPU params. Caller must ensure all GPU params reference the same 
-		 * parameter. 
-		 */
-		TMaterialParamLoadStoreTexture<true> createLoadStoreTextureParam(const String& name,
-			const SPtr<Vector<TGpuParamLoadStoreTexture<true>>>& gpuParams) const
-		{
-			return TMaterialParamLoadStoreTexture<true>(gpuParams);
-		}
-
-		/** 
-		 * Creates a material param out of multiple GPU params. Caller must ensure all GPU params reference the same 
-		 * parameter. 
-		 */
-		TMaterialParamSampState<false> createSamplerStateParam(const String& name, 
-			const SPtr<Vector<TGpuParamSampState<false>>>& gpuParams) const
-		{
-			return TMaterialParamSampState<false>(name, getCachedParams(), gpuParams);
-		}
-
-		/** 
-		 * Creates a material param out of multiple GPU params. Caller must ensure all GPU params reference the same 
-		 * parameter. 
-		 */
-		TMaterialParamSampState<true> createSamplerStateParam(const String& name,
-			const SPtr<Vector<TGpuParamSampState<true>>>& gpuParams) const
-		{
-			return TMaterialParamSampState<true>(gpuParams);
-		}
-
-		/**
-		 * Assigns a value from a raw buffer to the parameter with the specified name. Buffer must be of sizeof(T) * 
-		 * numElements size and initialized.
-		 *
-		 * @note	Provided parameter must exist, no checking is done.
-		 */
-		template <typename T>
-		void setParamValue(const String& name, UINT8* buffer, UINT32 numElements);
-
-		/** Called during initialization, creates enough space to cache all parameters (not used on core thread). */
-		void createCachedParams(const SPtr<ShaderCore>& shader) { /* Do nothing */}
-
-		/** Called during initialization, creates enough space to cache all parameters. */
-		virtual void createCachedParams(const HShader& shader) { }
-
-		/** Returns a list of all values assigned to material parameters. */
-		virtual SPtr<MaterialParams> getCachedParams() const { return nullptr; }
-
-		/**
-		 * Initializes the material by using the best technique from the currently set shader. Shader must contain the 
-		 * technique that matches the current renderer and render system.
-		 */
-		void initBestTechnique();
-
-		/** Assigns all the default parameters specified in the shader to the material. */
-		void initDefaultParameters();
-
-		/** Throw an exception if no shader is set, or no acceptable technique was found. */
-		void throwIfNotInitialized() const;
-
-		Vector<SPtr<PassParamsType>> mParametersPerPass;
-		ShaderType mShader;
-		TechniqueType mBestTechnique;
-	};
-
-	/** @} */
-
-	/** @addtogroup Material
-	 *  @{
-	 */
-
-	/** @cond 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 SPtr<TechniqueCore>& bestTechnique, 
-			const Set<String>& validShareableParamBlocks, const Map<String, String>& validParams, 
-			const Vector<SPtr<PassParametersCore>>& passParams);
-
-		/** @copydoc CoreObjectCore::syncToCore */
-		void syncToCore(const CoreSyncData& data) override;
-	};
-
-	/** @endcond */
-
-	/** @copydoc MaterialBase */
-	class BS_CORE_EXPORT Material : public Resource, public TMaterial<false>, public IResourceListener
-	{
-	public:
-		~Material() { }
-
-		/**
-		 * Sets a shader that will be used by the material. Best technique within the provided shader will be used for the 
-		 * material.
-		 *
-		 * @note	
-		 * Shader must be set before doing any other operations with the material.
-		 * @note			
-		 * After setting the shader if you change the implementation of systems that a shader technique is dependent upon 
-		 * (render system, renderer, etc), you will need to call this method again on all your Materials to make sure
-		 * technique used is updated.
-		 */
-		void setShader(const HShader& shader);
-
-		/** Retrieves an implementation of a material usable only from the core thread. */
-		SPtr<MaterialCore> getCore() const;
-
-		/** @copydoc CoreObject::initialize */
-		void initialize() override;
-
-		/** Creates a deep copy of the material and returns the new object. */
-		HMaterial Material::clone();
-
-		/**
-		 * Creates a new empty material.
-		 * 			
-		 * @note	Make sure you call Material::setShader before using it.
-		 */
-		static HMaterial create();
-
-		/** Creates a new material with the specified shader. */
-		static HMaterial create(const HShader& shader);
-
-	private:
-		friend class MaterialManager;
-
-		Material();
-		Material(const HShader& shader);
-
-		/** @copydoc CoreObject::createCore */
-		SPtr<CoreObjectCore> createCore() const override;
-
-		/** @copydoc CoreObject::syncToCore */
-		CoreSyncData syncToCore(FrameAlloc* allocator) override;
-
-		/** @copydoc CoreObject::getCoreDependencies */
-		void getCoreDependencies(Vector<CoreObject*>& dependencies) override;
-
-		/** @copydoc CoreObject::markCoreDirty */
-		void _markCoreDirty() override;
-
-		/** @copydoc CoreObject::markDependenciesDirty */
-		void _markDependenciesDirty() override;
-
-		/** @copydoc IResourceListener::markResourcesDirty */
-		void _markResourcesDirty() override;
-
-		/** @copydoc IResourceListener::getListenerResources */
-		void getListenerResources(Vector<HResource>& resources) override;
-
-		/** @copydoc IResourceListener::notifyResourceLoaded */
-		void notifyResourceLoaded(const HResource& resource) override;
-
-		/** @copydoc IResourceListener::notifyResourceChanged */
-		void notifyResourceChanged(const HResource& resource) override;
-
-		/** @copydoc Resource::getResourceDependencies */
-		void getResourceDependencies(FrameVector<HResource>& dependencies) const override;
-
-		/**	Performs material initialization when all resources are ready. */
-		void initializeIfLoaded();
-
-		/** @copydoc Material::createCachedParams */
-		void createCachedParams(const HShader& shader) override;
-
-		/** @copydoc Material::getCachedParams */
-		SPtr<MaterialParams> getCachedParams() const override { return mCachedParams; }
-
-		/** 
-		 * Uses the provided list of parameters to try to set every parameter in this material. Parameter whose name, type
-		 * or size don't match are ignored and will not be set.
-		 */
-		void setParams(const SPtr<MaterialParams>& params);
-
-		UINT32 mLoadFlags;
-		SPtr<MaterialParams> mCachedParams;
-
-		/************************************************************************/
-		/* 								RTTI		                     		*/
-		/************************************************************************/
-		
-	public:
-		friend class MaterialRTTI;
-		static RTTITypeBase* getRTTIStatic();
-		virtual RTTITypeBase* getRTTI() const override;
-	};
-
-	/** @} */
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+#pragma once
+
+#include "BsCorePrerequisites.h"
+#include "BsResource.h"
+#include "BsIResourceListener.h"
+#include "BsMaterialParam.h"
+#include "BsVector2.h"
+#include "BsVector3.h"
+#include "BsVector4.h"
+#include "BsMatrix3.h"
+#include "BsMatrix4.h"
+
+namespace BansheeEngine
+{
+	/** @addtogroup Implementation
+	 *  @{
+	 */
+
+	class MaterialParams;
+
+	/** Helper class containing parameters for all types of GPU programs used in a pass. */
+	template<bool Core>
+	class TPassParameters
+	{
+	public:
+		typedef typename TGpuParamsPtrType<Core>::Type GpuParamsType;
+
+		/**
+		 * Returns a set of GPU parameters based on an index.
+		 *
+		 * @note	Useful when needing to iterate over all sets of GPU parameters.
+		 */
+		GpuParamsType& getParamByIdx(UINT32 idx)
+		{
+			GpuParamsType* paramArray[] = { &mVertParams, &mFragParams, &mGeomParams, &mHullParams, &mDomainParams, &mComputeParams };
+
+			return *paramArray[idx];
+		}
+
+		/**
+		 * Sets GPU parameters based on an index.
+		 *
+		 * @note	Useful when needing to iterate over all sets of GPU parameters.
+		 */
+		void setParamByIdx(UINT32 idx, const GpuParamsType& params)
+		{
+			GpuParamsType* paramArray[] = { &mVertParams, &mFragParams, &mGeomParams, &mHullParams, &mDomainParams, &mComputeParams };
+
+			(*paramArray[idx]) = params;
+		}
+
+		GpuParamsType mVertParams;
+		GpuParamsType mFragParams;
+		GpuParamsType mGeomParams;
+		GpuParamsType mHullParams;
+		GpuParamsType mDomainParams;
+		GpuParamsType mComputeParams;
+	};
+
+	template<bool Core> struct TGpuParamBlockBufferPtrType { };
+	template<> struct TGpuParamBlockBufferPtrType<false> { typedef SPtr<GpuParamBlockBuffer> Type; };
+	template<> struct TGpuParamBlockBufferPtrType<true> { typedef SPtr<GpuParamBlockBufferCore> Type; };
+
+	template<bool Core> struct TGpuProgramType { };
+	template<> struct TGpuProgramType<false> { typedef GpuProgramPtr Type; };
+	template<> struct TGpuProgramType<true> { typedef SPtr<GpuProgramCore> Type; };
+
+	/** Contains sim thread pass parameters for each shader stage. */
+	class BS_CORE_EXPORT PassParameters : public TPassParameters<false>
+	{
+	public:
+		static const UINT32 NUM_PARAMS;
+	};
+
+	/** Contains core thread pass parameters for each shader stage. */
+	class BS_CORE_EXPORT PassParametersCore : public TPassParameters<true>
+	{
+	public:
+		static const UINT32 NUM_PARAMS;
+	};
+
+	/**
+	 * Material that controls how objects are rendered. It is represented by a shader and parameters used to set up that
+	 * shader. It provides a simple interface for manipulating the parameters.
+	 */
+	class BS_CORE_EXPORT MaterialBase
+	{
+	public:
+		/** Data used to describe a structure defined within a shader. */
+		struct StructData
+		{
+			StructData()
+				:size(0), data(nullptr)
+			{ }
+
+			StructData(UINT32 _size)
+				:size(_size)
+			{
+				data = std::shared_ptr<void>(bs_alloc(_size), &bs_free);
+			}
+
+			/**
+			 * Writes the specified data to the internal buffer. Caller must ensure size of the provided buffer is correct.
+			 */
+			void write(void* _data)
+			{
+				memcpy(data.get(), _data, size);
+			}
+
+			std::shared_ptr<void> data;
+			UINT32 size;
+		};
+
+		virtual ~MaterialBase() { }
+
+	protected:
+		/** Retrieves a list of all shader GPU parameters, and the GPU program variable names they map to. */
+		const Map<String, String>& getValidParamNames() const { return mValidParams; }
+
+		/** @copydoc CoreObject::markCoreDirty */
+		virtual void _markCoreDirty() { }
+
+		/** @copydoc CoreObject::markDependenciesDirty */
+		virtual void _markDependenciesDirty() { }
+
+		/** @copydoc IResourceListener::markResourcesDirty */
+		virtual void _markResourcesDirty() { }
+
+		/** Returns all GPU parameter descriptions in the specified technique. */
+		static Vector<GpuParamDescPtr> getAllParamDescs(const SPtr<Technique>& technique);
+
+		/** Returns all GPU parameter descriptions in the specified technique. */
+		static Vector<GpuParamDescPtr> getAllParamDescs(const SPtr<TechniqueCore>& technique);
+
+		Set<String> mValidShareableParamBlocks;
+		Map<String, String> mValidParams; // Also maps Shader param name -> gpu variable name
+	};
+
+	/** @copydoc MaterialBase */
+	template<bool Core>
+	class BS_CORE_EXPORT TMaterial : public MaterialBase
+	{
+	public:
+		template<bool Core> struct TPassType {};
+		template<> struct TPassType < false > { typedef SPtr<Pass> Type; };
+		template<> struct TPassType < true > { typedef SPtr<PassCore> Type; };
+
+		template<bool Core> struct TTechniqueType {};
+		template<> struct TTechniqueType < false > { typedef SPtr<Technique> Type; };
+		template<> struct TTechniqueType < true > { typedef SPtr<TechniqueCore> Type; };
+
+		template<bool Core> struct TShaderType {};
+		template<> struct TShaderType < false > { typedef HShader Type; };
+		template<> struct TShaderType < true > { typedef SPtr<ShaderCore> Type; };
+
+		template<bool Core> struct TGpuParamBlockBufferType {};
+		template<> struct TGpuParamBlockBufferType < false > { typedef GpuParamBlockBuffer Type; };
+		template<> struct TGpuParamBlockBufferType < true > { typedef GpuParamBlockBufferCore Type; };
+
+		template<bool Core> struct TPassParamsType {};
+		template<> struct TPassParamsType < false > { typedef PassParameters Type; };
+		template<> struct TPassParamsType < true > { typedef PassParametersCore Type; };
+
+		typedef typename TGpuParamsPtrType<Core>::Type GpuParamsType;
+		typedef typename TGpuParamTextureType<Core>::Type TextureType;
+		typedef typename TGpuParamSamplerStateType<Core>::Type SamplerStateType;
+		typedef typename TGpuParamBlockBufferPtrType<Core>::Type ParamBlockPtrType;
+		typedef typename TGpuParamBlockBufferType<Core>::Type ParamBlockType;
+		typedef typename TGpuProgramType<Core>::Type GpuProgramType;
+		typedef typename TPassType<Core>::Type PassType;
+		typedef typename TTechniqueType<Core>::Type TechniqueType;
+		typedef typename TShaderType<Core>::Type ShaderType;
+		typedef typename TPassParamsType<Core>::Type PassParamsType;
+
+		virtual ~TMaterial() { }
+
+		/** Returns the currently active shader. */
+		ShaderType getShader() const { return mShader; }
+
+		/** Returns the number of passes that are used by the shader used in the material. */
+		UINT32 getNumPasses() const;
+
+		/** Retrieves a specific shader pass. */
+		PassType getPass(UINT32 passIdx) const;
+
+		/**   
+		 * Assigns a float value to the shader parameter with the specified name. 
+		 *
+		 * Optionally if the parameter is an array you may provide an array index to assign the value to.
+		 */
+		void setFloat(const String& name, float value, UINT32 arrayIdx = 0)	{ return getParamFloat(name).set(value, arrayIdx); }
+
+		/**   
+		 * Assigns a color to the shader parameter with the specified name. 
+		 *
+		 * Optionally if the parameter is an array you may provide an array index to assign the value to.
+		 */
+		void setColor(const String& name, const Color& value, UINT32 arrayIdx = 0) { return getParamColor(name).set(value, arrayIdx); }
+
+		/**   
+		 * Assigns a 2D vector to the shader parameter with the specified name. 
+		 *
+		 * Optionally if the parameter is an array you may provide an array index to assign the value to.
+		 */
+		void setVec2(const String& name, const Vector2& value, UINT32 arrayIdx = 0)	{ return getParamVec2(name).set(value, arrayIdx); }
+
+		/**   
+		 * Assigns a 3D vector to the shader parameter with the specified name. 
+		 *
+		 * Optionally if the parameter is an array you may provide an array index to assign the value to.
+		 */
+		void setVec3(const String& name, const Vector3& value, UINT32 arrayIdx = 0)	{ return getParamVec3(name).set(value, arrayIdx); }
+
+		/**   
+		 * Assigns a 4D vector to the shader parameter with the specified name. 
+		 *
+		 * Optionally if the parameter is an array you may provide an array index to assign the value to.
+		 */
+		void setVec4(const String& name, const Vector4& value, UINT32 arrayIdx = 0)	{ return getParamVec4(name).set(value, arrayIdx); }
+
+		/**   
+		 * Assigns a 3x3 matrix to the shader parameter with the specified name. 
+		 *
+		 * Optionally if the parameter is an array you may provide an array index to assign the value to.
+		 */
+		void setMat3(const String& name, const Matrix3& value, UINT32 arrayIdx = 0)	{ return getParamMat3(name).set(value, arrayIdx); }
+
+		/**   
+		 * Assigns a 4x4 matrix to the shader parameter with the specified name. 
+		 *
+		 * Optionally if the parameter is an array you may provide an array index to assign the value to.
+		 */
+		void setMat4(const String& name, const Matrix4& value, UINT32 arrayIdx = 0)	{ return getParamMat4(name).set(value, arrayIdx); }
+
+		/**   
+		 * Assigns a structure to the shader parameter with the specified name.
+		 *  		
+		 * Structure is provided as a raw buffer and caller must ensure structure in buffer matches what the shader expects.
+		 *
+		 * Optionally if the parameter is an array you may provide an array index to assign the value to.
+		 */
+		void setStructData(const String& name, void* value, UINT32 size, UINT32 arrayIdx = 0) { return getParamStruct(name).set(value, size, arrayIdx); }
+
+		/** Assigns a texture to the shader parameter with the specified name. */
+		void setTexture(const String& name, const TextureType& value) { return getParamTexture(name).set(value); }
+
+		/** Assigns a texture to be used for random load/store operations to the shader parameter with the specified name. */
+		void setLoadStoreTexture(const String& name, const TextureType& value, const TextureSurface& surface)
+		{ 
+			return getParamLoadStoreTexture(name).set(value, surface); 
+		}
+
+		/** Assigns a sampler state to the shader parameter with the specified name. */
+		void setSamplerState(const String& name, const SamplerStateType& value) { return getParamSamplerState(name).set(value); }
+
+		/**
+		 * Returns a float value assigned with the parameter with the specified name.
+		 *
+		 * Optionally if the parameter is an array you may provide an array index you which to retrieve.
+		 */
+		float getFloat(const String& name, UINT32 arrayIdx = 0) const { return getParamFloat(name).get(arrayIdx); }
+
+		/**
+		 * Returns a color assigned with the parameter with the specified name.
+		 *
+		 * Optionally if the parameter is an array you may provide an array index you which to retrieve.
+		 */
+		Color getColor(const String& name, UINT32 arrayIdx = 0) const { return getParamColor(name).get(arrayIdx); }
+
+		/**
+		 * Returns a 2D vector assigned with the parameter with the specified name.
+		 *
+		 * Optionally if the parameter is an array you may provide an array index you which to retrieve.
+		 */
+		Vector2 getVec2(const String& name, UINT32 arrayIdx = 0) const { return getParamVec2(name).get(arrayIdx); }
+
+		/**
+		 * Returns a 3D vector assigned with the parameter with the specified name.
+		 *
+		 * Optionally if the parameter is an array you may provide an array index you which to retrieve.
+		 */
+		Vector3 getVec3(const String& name, UINT32 arrayIdx = 0) const { return getParamVec3(name).get(arrayIdx); }
+
+		/**
+		 * Returns a 4D vector assigned with the parameter with the specified name.
+		 *
+		 * Optionally if the parameter is an array you may provide an array index you which to retrieve.
+		 */
+		Vector4 getVec4(const String& name, UINT32 arrayIdx = 0) const { return getParamVec4(name).get(arrayIdx); }
+
+		/**
+		 * Returns a 3x3 matrix assigned with the parameter with the specified name.
+		 *
+		 * Optionally if the parameter is an array you may provide an array index you which to retrieve.
+		 */
+		Matrix3 getMat3(const String& name, UINT32 arrayIdx = 0) const { return getParamMat3(name).get(arrayIdx); }
+
+		/**
+		 * Returns a 4x4 matrix assigned with the parameter with the specified name.
+		 *
+		 * Optionally if the parameter is an array you may provide an array index you which to retrieve.
+		 */
+		Matrix4 getMat4(const String& name, UINT32 arrayIdx = 0) const { return getParamMat4(name).get(arrayIdx); }
+
+		/** Returns a texture assigned with the parameter with the specified name. */
+		TextureType getTexture(const String& name) const { return getParamTexture(name).get(); }
+
+		/** Returns a sampler state assigned with the parameter with the specified name. */
+		SamplerStateType getSamplerState(const String& name) const	{ return getParamSamplerState(name).get(); }
+
+		/**
+		 * Returns a buffer representing a structure assigned to the parameter with the specified name.
+		 *
+		 * Optionally if the parameter is an array you may provide an array index you which to retrieve.
+		 */
+		MaterialBase::StructData getStructData(const String& name, UINT32 arrayIdx = 0) const
+		{
+			TMaterialParamStruct<Core> structParam = getParamStruct(name);
+
+			MaterialBase::StructData data(structParam.getElementSize());
+			structParam.get(data.data.get(), structParam.getElementSize(), arrayIdx);
+
+			return data;
+		}
+
+		/**
+		 * Returns a float GPU parameter. This parameter may be used for more efficiently getting/setting GPU parameter 
+		 * values than calling Material::get* / Material::set* methods. 
+		 *
+		 * @note	
+		 * Expected behavior is that you would retrieve this parameter when initially constructing the material, and then 
+		 * use it throughout material lifetime to assign and retrieve parameter values.
+		 * @note			
+		 * If material shader changes this handle will be invalidated.
+		 */
+		TMaterialDataParam<float, Core> getParamFloat(const String& name) const
+		{
+			TMaterialDataParam<float, Core> gpuParam;
+			getParam(name, gpuParam);
+
+			return gpuParam;
+		}
+
+		/**
+		 * Returns a color GPU parameter. This parameter may be used for more efficiently getting/setting GPU parameter 
+		 * values than calling Material::get* / Material::set* methods. 
+		 *
+		 * @note	
+		 * Expected behavior is that you would retrieve this parameter when initially constructing the material, 
+		 * and then use it throughout material lifetime to assign and retrieve parameter values.
+		 * @note
+		 * If material shader changes this handle will be invalidated.
+		 */
+		TMaterialDataParam<Color, Core> getParamColor(const String& name) const
+		{
+			TMaterialDataParam<Color, Core> gpuParam;
+			getParam(name, gpuParam);
+
+			return gpuParam;
+		}
+
+		/**
+		 * Returns a 2D vector GPU parameter. This parameter may be used for more efficiently getting/setting GPU parameter 
+		 * values than calling Material::get* / Material::set* methods. 
+		 *
+		 * @note	
+		 * Expected behavior is that you would retrieve this parameter when initially constructing the material, and then 
+		 * use it throughout material lifetime to assign and retrieve parameter values.
+		 * @note	
+		 * If material shader changes this handle will be invalidated.
+		 */
+		TMaterialDataParam<Vector2, Core> getParamVec2(const String& name) const
+		{
+			TMaterialDataParam<Vector2, Core> gpuParam;
+			getParam(name, gpuParam);
+
+			return gpuParam;
+		}
+
+		/**
+		 * Returns a 3D vector GPU parameter. This parameter may be used for more efficiently getting/setting GPU parameter
+		 * values than calling Material::get* / Material::set* methods. 
+		 *
+		 * @note	
+		 * Expected behavior is that you would retrieve this parameter when initially constructing the material, and then
+		 * use it throughout material lifetime to assign and retrieve parameter values.
+		 * @note			
+		 * If material shader changes this handle will be invalidated.
+		 */
+		TMaterialDataParam<Vector3, Core> getParamVec3(const String& name) const
+		{
+			TMaterialDataParam<Vector3, Core> gpuParam;
+			getParam(name, gpuParam);
+
+			return gpuParam;
+		}
+
+		/**
+		 * Returns a 4D vector GPU parameter. This parameter may be used for more efficiently getting/setting GPU parameter
+		 * values than calling Material::get* / Material::set* methods. 
+		 *
+		 * @note	
+		 * Expected behavior is that you would retrieve this parameter when initially constructing the material, and then 
+		 * use it throughout material lifetime to assign and retrieve parameter values.
+		 * @note	
+		 * If material shader changes this handle will be invalidated.
+		 */
+		TMaterialDataParam<Vector4, Core> getParamVec4(const String& name) const
+		{
+			TMaterialDataParam<Vector4, Core> gpuParam;
+			getParam(name, gpuParam);
+
+			return gpuParam;
+		}
+
+		/**
+		 * Returns a 3x3 matrix GPU parameter. This parameter may be used for more efficiently getting/setting GPU 
+		 * parameter values than calling Material::get* / Material::set* methods. 
+		 *
+		 * @note	
+		 * Expected behavior is that you would retrieve this parameter when initially constructing the material, and then 
+		 * use it throughout material lifetime to assign and retrieve parameter values.
+		 * @note	
+		 * If material shader changes this handle will be invalidated.
+		 */
+		TMaterialDataParam<Matrix3, Core> getParamMat3(const String& name) const
+		{
+			TMaterialDataParam<Matrix3, Core> gpuParam;
+			getParam(name, gpuParam);
+
+			return gpuParam;
+		}
+
+		/**
+		 * Returns a 4x4 matrix GPU parameter. This parameter may be used for more efficiently getting/setting GPU parameter
+		 * values than calling Material::get* / Material::set* methods. 
+		 *
+		 * @note	
+		 * Expected behavior is that you would retrieve this parameter when initially constructing the material, and then 
+		 * use it throughout material lifetime to assign and retrieve parameter values.
+		 * @note	
+		 * If material shader changes this handle will be invalidated.
+		 */
+		TMaterialDataParam<Matrix4, Core> getParamMat4(const String& name) const
+		{
+			TMaterialDataParam<Matrix4, Core> gpuParam;
+			getParam(name, gpuParam);
+
+			return gpuParam;
+		}
+
+		/**
+		 * Returns a structure GPU parameter. This parameter may be used for more efficiently getting/setting GPU parameter
+		 * values than calling Material::get* / Material::set* methods. 
+		 *
+		 * @note	
+		 * Expected behavior is that you would retrieve this parameter when initially constructing the material, and then 
+		 * use it throughout material lifetime to assign and retrieve parameter values.
+		 * @note			
+		 * If material shader changes this handle will be invalidated.
+		 */
+		TMaterialParamStruct<Core> getParamStruct(const String& name) const;
+
+		/**
+		 * Returns a texture GPU parameter. This parameter may be used for more efficiently getting/setting GPU parameter 
+		 * values than calling Material::get* / Material::set* methods. 
+		 *
+		 * @note	
+		 * Expected behavior is that you would retrieve this parameter when initially constructing the material, and then 
+		 * use it throughout material lifetime to assign and retrieve parameter values.
+		 * @note
+		 * If material shader changes this handle will be invalidated.
+		 */
+		TMaterialParamTexture<Core> getParamTexture(const String& name) const;
+
+		/**
+		 * Returns a GPU parameter for binding a load/store texture. This parameter may be used for more efficiently 
+		 * getting/setting GPU parameter values than calling Material::get* / Material::set* methods. 
+		 *
+		 * @note	
+		 * Expected behavior is that you would retrieve this parameter when initially constructing the material, and then 
+		 * use it throughout material lifetime to assign and retrieve parameter values.
+		 * @note			
+		 * If material shader changes this handle will be invalidated.
+		 */
+		TMaterialParamLoadStoreTexture<Core> getParamLoadStoreTexture(const String& name) const;
+
+		/**
+		 * Returns a sampler state GPU parameter. This parameter may be used for more efficiently getting/setting GPU 
+		 * parameter values than calling Material::get* / Material::set* methods. 
+		 *
+		 * @note	
+		 * Expected behavior is that you would retrieve this parameter when initially constructing the material, and then 
+		 * use it throughout material lifetime to assign and retrieve parameter values.
+		 * @note			
+		 * If material shader changes this handle will be invalidated.
+		 */
+		TMaterialParamSampState<Core> getParamSamplerState(const String& name) const;
+
+		/** Returns a set of parameters for all GPU programs in the specified shader pass. */
+		SPtr<PassParamsType> getPassParameters(UINT32 passIdx) const { return mParametersPerPass[passIdx]; }
+
+		/**
+		 * Assign a parameter block buffer with the specified name.
+		 *
+		 * @note	
+		 * Parameter block buffers can be used as quick way of setting multiple parameters on a material at once, or
+		 * potentially sharing parameters between multiple materials. This reduces driver overhead as the parameters
+		 * in the buffers need only be set once and then reused multiple times.
+		 */
+		void setParamBlockBuffer(const String& name, const ParamBlockPtrType& paramBlock);
+
+		/**
+		 * Allows you to retrieve a handle to a parameter that you can then use for quickly setting and retrieving parameter
+		 * data. This allows you to set/get parameter data without all the cost of extra lookups otherwise required.
+		 * 			
+		 * @note	
+		 * All of these handles will be invalidated if material shader ever changes. It is up to the caller to keep track 
+		 * of that.
+		 */
+		template <typename T>
+		void getParam(const String& name, TMaterialDataParam<T, Core>& output) const;
+
+	protected:
+		/** 
+		 * Creates a material param out of multiple GPU params. Caller must ensure all GPU params reference the same 
+		 * parameter. 
+		 */
+		template <typename T>
+		TMaterialDataParam<T, false> createDataParam(const String& name, 
+			const SPtr<Vector<TGpuDataParam<T, false>>>& gpuParams) const
+		{
+			return TMaterialDataParam<T, false>(name, getCachedParams(), gpuParams);
+		}
+
+		/** 
+		 * Creates a material param out of multiple GPU params. Caller must ensure all GPU params reference the same 
+		 * parameter. 
+		 */
+		template <typename T>
+		TMaterialDataParam<T, true> createDataParam(const String& name, 
+			const SPtr<Vector<TGpuDataParam<T, true>>>& gpuParams) const
+		{
+			return TMaterialDataParam<T, true>(gpuParams);
+		}
+
+		/** 
+		 * Creates a material param out of multiple GPU params. Caller must ensure all GPU params reference the same 
+		 * parameter. 
+		 */
+		TMaterialParamStruct<false> createStructParam(const String& name, 
+			const SPtr<Vector<TGpuParamStruct<false>>>& gpuParams) const
+		{
+			return TMaterialParamStruct<false>(name, getCachedParams(), gpuParams);
+		}
+
+		/** 
+		 * Creates a material param out of multiple GPU params. Caller must ensure all GPU params reference the same 
+		 * parameter. 
+		 */
+		TMaterialParamStruct<true> createStructParam(const String& name, 
+			const SPtr<Vector<TGpuParamStruct<true>>>& gpuParams) const
+		{
+			return TMaterialParamStruct<true>(gpuParams);
+		}
+
+		/** 
+		 * Creates a material param out of multiple GPU params. Caller must ensure all GPU params reference the same 
+		 * parameter. 
+		 */
+		TMaterialParamTexture<false> createTextureParam(const String& name, 
+			const SPtr<Vector<TGpuParamTexture<false>>>& gpuParams) const
+		{
+			return TMaterialParamTexture<false>(name, getCachedParams(), gpuParams);
+		}
+
+		/** 
+		 * Creates a material param out of multiple GPU params. Caller must ensure all GPU params reference the same 
+		 * parameter. 
+		 */
+		TMaterialParamTexture<true> createTextureParam(const String& name,
+			const SPtr<Vector<TGpuParamTexture<true>>>& gpuParams) const
+		{
+			return TMaterialParamTexture<true>(gpuParams);
+		}
+
+		/** 
+		 * Creates a material param out of multiple GPU params. Caller must ensure all GPU params reference the same 
+		 * parameter. 
+		 */
+		TMaterialParamLoadStoreTexture<false> createLoadStoreTextureParam(const String& name, 
+			const SPtr<Vector<TGpuParamLoadStoreTexture<false>>>& gpuParams) const
+		{
+			return TMaterialParamLoadStoreTexture<false>(name, getCachedParams(), gpuParams);
+		}
+
+		/** 
+		 * Creates a material param out of multiple GPU params. Caller must ensure all GPU params reference the same 
+		 * parameter. 
+		 */
+		TMaterialParamLoadStoreTexture<true> createLoadStoreTextureParam(const String& name,
+			const SPtr<Vector<TGpuParamLoadStoreTexture<true>>>& gpuParams) const
+		{
+			return TMaterialParamLoadStoreTexture<true>(gpuParams);
+		}
+
+		/** 
+		 * Creates a material param out of multiple GPU params. Caller must ensure all GPU params reference the same 
+		 * parameter. 
+		 */
+		TMaterialParamSampState<false> createSamplerStateParam(const String& name, 
+			const SPtr<Vector<TGpuParamSampState<false>>>& gpuParams) const
+		{
+			return TMaterialParamSampState<false>(name, getCachedParams(), gpuParams);
+		}
+
+		/** 
+		 * Creates a material param out of multiple GPU params. Caller must ensure all GPU params reference the same 
+		 * parameter. 
+		 */
+		TMaterialParamSampState<true> createSamplerStateParam(const String& name,
+			const SPtr<Vector<TGpuParamSampState<true>>>& gpuParams) const
+		{
+			return TMaterialParamSampState<true>(gpuParams);
+		}
+
+		/**
+		 * Assigns a value from a raw buffer to the parameter with the specified name. Buffer must be of sizeof(T) * 
+		 * numElements size and initialized.
+		 *
+		 * @note	Provided parameter must exist, no checking is done.
+		 */
+		template <typename T>
+		void setParamValue(const String& name, UINT8* buffer, UINT32 numElements);
+
+		/** Called during initialization, creates enough space to cache all parameters (not used on core thread). */
+		void createCachedParams(const SPtr<ShaderCore>& shader) { /* Do nothing */}
+
+		/** Called during initialization, creates enough space to cache all parameters. */
+		virtual void createCachedParams(const HShader& shader) { }
+
+		/** Returns a list of all values assigned to material parameters. */
+		virtual SPtr<MaterialParams> getCachedParams() const { return nullptr; }
+
+		/**
+		 * Initializes the material by using the best technique from the currently set shader. Shader must contain the 
+		 * technique that matches the current renderer and render system.
+		 */
+		void initBestTechnique();
+
+		/** Assigns all the default parameters specified in the shader to the material. */
+		void initDefaultParameters();
+
+		/** Throw an exception if no shader is set, or no acceptable technique was found. */
+		void throwIfNotInitialized() const;
+
+		Vector<SPtr<PassParamsType>> mParametersPerPass;
+		ShaderType mShader;
+		TechniqueType mBestTechnique;
+	};
+
+	/** @} */
+
+	/** @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 SPtr<TechniqueCore>& bestTechnique, 
+			const Set<String>& validShareableParamBlocks, const Map<String, String>& validParams, 
+			const Vector<SPtr<PassParametersCore>>& passParams);
+
+		/** @copydoc CoreObjectCore::syncToCore */
+		void syncToCore(const CoreSyncData& data) override;
+	};
+
+	/** @} */
+
+	/** @addtogroup Material
+	 *  @{
+	 */
+
+	/** @copydoc MaterialBase */
+	class BS_CORE_EXPORT Material : public Resource, public TMaterial<false>, public IResourceListener
+	{
+	public:
+		~Material() { }
+
+		/**
+		 * Sets a shader that will be used by the material. Best technique within the provided shader will be used for the 
+		 * material.
+		 *
+		 * @note	
+		 * Shader must be set before doing any other operations with the material.
+		 * @note			
+		 * After setting the shader if you change the implementation of systems that a shader technique is dependent upon 
+		 * (render system, renderer, etc), you will need to call this method again on all your Materials to make sure
+		 * technique used is updated.
+		 */
+		void setShader(const HShader& shader);
+
+		/** Retrieves an implementation of a material usable only from the core thread. */
+		SPtr<MaterialCore> getCore() const;
+
+		/** @copydoc CoreObject::initialize */
+		void initialize() override;
+
+		/** Creates a deep copy of the material and returns the new object. */
+		HMaterial Material::clone();
+
+		/**
+		 * Creates a new empty material.
+		 * 			
+		 * @note	Make sure you call Material::setShader before using it.
+		 */
+		static HMaterial create();
+
+		/** Creates a new material with the specified shader. */
+		static HMaterial create(const HShader& shader);
+
+	private:
+		friend class MaterialManager;
+
+		Material();
+		Material(const HShader& shader);
+
+		/** @copydoc CoreObject::createCore */
+		SPtr<CoreObjectCore> createCore() const override;
+
+		/** @copydoc CoreObject::syncToCore */
+		CoreSyncData syncToCore(FrameAlloc* allocator) override;
+
+		/** @copydoc CoreObject::getCoreDependencies */
+		void getCoreDependencies(Vector<CoreObject*>& dependencies) override;
+
+		/** @copydoc CoreObject::markCoreDirty */
+		void _markCoreDirty() override;
+
+		/** @copydoc CoreObject::markDependenciesDirty */
+		void _markDependenciesDirty() override;
+
+		/** @copydoc IResourceListener::markResourcesDirty */
+		void _markResourcesDirty() override;
+
+		/** @copydoc IResourceListener::getListenerResources */
+		void getListenerResources(Vector<HResource>& resources) override;
+
+		/** @copydoc IResourceListener::notifyResourceLoaded */
+		void notifyResourceLoaded(const HResource& resource) override;
+
+		/** @copydoc IResourceListener::notifyResourceChanged */
+		void notifyResourceChanged(const HResource& resource) override;
+
+		/** @copydoc Resource::getResourceDependencies */
+		void getResourceDependencies(FrameVector<HResource>& dependencies) const override;
+
+		/**	Performs material initialization when all resources are ready. */
+		void initializeIfLoaded();
+
+		/** @copydoc Material::createCachedParams */
+		void createCachedParams(const HShader& shader) override;
+
+		/** @copydoc Material::getCachedParams */
+		SPtr<MaterialParams> getCachedParams() const override { return mCachedParams; }
+
+		/** 
+		 * Uses the provided list of parameters to try to set every parameter in this material. Parameter whose name, type
+		 * or size don't match are ignored and will not be set.
+		 */
+		void setParams(const SPtr<MaterialParams>& params);
+
+		UINT32 mLoadFlags;
+		SPtr<MaterialParams> mCachedParams;
+
+		/************************************************************************/
+		/* 								RTTI		                     		*/
+		/************************************************************************/
+		
+	public:
+		friend class MaterialRTTI;
+		static RTTITypeBase* getRTTIStatic();
+		virtual RTTITypeBase* getRTTI() const override;
+	};
+
+	/** @} */
 }

+ 36 - 38
Source/BansheeCore/Include/BsMaterialManager.h

@@ -1,39 +1,37 @@
-//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
-//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
-#pragma once
-
-#include "BsCorePrerequisites.h"
-#include "BsModule.h"
-
-namespace BansheeEngine
-{
-	/** @cond INTERNAL */
-	/** @addtogroup Material
-	 *  @{
-	 */
-
-	/**	Material manager handles material creation. */
-	class BS_CORE_EXPORT MaterialManager : public Module<MaterialManager>
-	{
-	public:
-		/**
-		 * Creates a new material without any assigned shader.
-		 *
-		 * @note	Make sure to call Material::setShader() before using it.
-		 */
-		MaterialPtr create() const;
-
-		/** Creates a new material with the specified shader. */
-		MaterialPtr create(const HShader& shader) const;
-
-		/**
-		 * Creates a new empty material without initializing it.
-		 *
-		 * @note	You must manually call Material::initialize() after creation.
-		 */
-		MaterialPtr createEmpty() const;
-	};
-
-	/** @} */
-	/** @endcond */
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+#pragma once
+
+#include "BsCorePrerequisites.h"
+#include "BsModule.h"
+
+namespace BansheeEngine
+{
+	/** @addtogroup Material-Internal
+	 *  @{
+	 */
+
+	/**	Material manager handles material creation. */
+	class BS_CORE_EXPORT MaterialManager : public Module<MaterialManager>
+	{
+	public:
+		/**
+		 * Creates a new material without any assigned shader.
+		 *
+		 * @note	Make sure to call Material::setShader() before using it.
+		 */
+		MaterialPtr create() const;
+
+		/** Creates a new material with the specified shader. */
+		MaterialPtr create(const HShader& shader) const;
+
+		/**
+		 * Creates a new empty material without initializing it.
+		 *
+		 * @note	You must manually call Material::initialize() after creation.
+		 */
+		MaterialPtr createEmpty() const;
+	};
+
+	/** @} */
 }

+ 1 - 3
Source/BansheeCore/Include/BsMaterialParams.h

@@ -18,8 +18,7 @@
 
 namespace BansheeEngine
 {
-	/** @cond INTERNAL */
-	/** @addtogroup Material
+	/** @addtogroup Material-Internal
 	 *  @{
 	 */
 
@@ -392,5 +391,4 @@ namespace BansheeEngine
 	/** @endcond */
 
 	/** @} */
-	/** @endcond */
 }

+ 362 - 360
Source/BansheeCore/Include/BsMesh.h

@@ -1,361 +1,363 @@
-//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
-//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
-#pragma once
-
-#include "BsCorePrerequisites.h"
-#include "BsMeshBase.h"
-#include "BsMeshData.h"
-#include "BsVertexData.h"
-#include "BsDrawOps.h"
-#include "BsSubMesh.h"
-#include "BsBounds.h"
-
-namespace BansheeEngine
-{
-	/** @addtogroup Resources
-	 *  @{
-	 */
-
-	/** @cond INTERNAL */
-
-	/**
-	 * Core thread portion of a Mesh.
-	 *
-	 * @note	Core thread.
-	 */
-	class BS_CORE_EXPORT MeshCore : public MeshCoreBase
-	{
-	public:
-		MeshCore(UINT32 numVertices, UINT32 numIndices, const VertexDataDescPtr& vertexDesc,
-			const Vector<SubMesh>& subMeshes, int usage, IndexType indexType,
-			MeshDataPtr initialMeshData);
-
-		~MeshCore();
-
-		/** @copydoc CoreObjectCore::initialize */
-		virtual void initialize() override;
-
-		/** @copydoc MeshCoreBase::getVertexData */
-		virtual SPtr<VertexData> getVertexData() const override;
-
-		/** @copydoc MeshCoreBase::getIndexBuffer */
-		virtual SPtr<IndexBufferCore> getIndexBuffer() const override;
-
-		/** @copydoc MeshCoreBase::getVertexDesc */
-		virtual SPtr<VertexDataDesc> getVertexDesc() const override;
-
-		/**
-		 * Updates a part of the current mesh with the provided data.
-		 *
-		 * @param[in]	subresourceIdx		Index of the subresource to update, if the mesh has more than one.
-		 * @param[in]	data				Data to update the mesh with.
-		 * @param[in]	discardEntireBuffer When true the existing contents of the resource you are updating will be 
-		 *									discarded. This can make the operation faster. Resources with certain buffer 
-		 *									types might require this flag to be in a specific state otherwise the operation 
-		 *									will fail.
-		 * @param[in]	updateBounds		If true the internal bounds of the mesh will be recalculated based on the 
-		 *									provided data.
-		 */
-		virtual void writeSubresource(UINT32 subresourceIdx, const MeshData& data, bool discardEntireBuffer, bool updateBounds = true);
-
-		/**
-		 * Reads a part of the current resource into the provided @p data parameter.	Data buffer needs to be pre-allocated.
-		 *
-		 * @param[in]	subresourceIdx		Index of the subresource to update, if the mesh has more than one.
-		 * @param[out]	data				Buffer that will receive the data. Should be allocated with 
-		 *									allocateSubresourceBuffer() to ensure it is of valid type and size.
-		 */
-		virtual void readSubresource(UINT32 subresourceIdx, MeshData& data);
-
-		/**
-		 * Creates a new empty mesh. Created mesh will have no sub-meshes.
-		 *
-		 * @param[in]	numVertices		Number of vertices in the mesh.
-		 * @param[in]	numIndices		Number of indices in the mesh. 
-		 * @param[in]	vertexDesc		Vertex description structure that describes how are vertices organized in the
-		 *								vertex buffer. When binding a mesh to the pipeline you must ensure vertex 
-		 *								description at least partially matches the input description of the currently 
-		 *								bound vertex GPU program.
-		 * @param[in]	usage			Optimizes performance depending on planned usage of the mesh.
-		 * @param[in]	drawOp			Determines how should the provided indices be interpreted by the pipeline. Default
-		 *								option is a triangle list, where three indices represent a single triangle.
-		 * @param[in]	indexType		Size of indices, use smaller size for better performance, however be careful not to
-		 *								go over the number of vertices limited by the size.
-		 */
-		static SPtr<MeshCore> create(UINT32 numVertices, UINT32 numIndices, const VertexDataDescPtr& vertexDesc, int usage = MU_STATIC,
-			DrawOperationType drawOp = DOT_TRIANGLE_LIST, IndexType indexType = IT_32BIT);
-
-		/**
-		 * Creates a new empty mesh. Created mesh will have specified sub-meshes you may render independently.
-		 *
-		 * @param[in]	numVertices		Number of vertices in the mesh.
-		 * @param[in]	numIndices		Number of indices in the mesh. 
-		 * @param[in]	vertexDesc		Vertex description structure that describes how are vertices organized in the
-		 *								vertex buffer. When binding a mesh to the pipeline you must ensure vertex 
-		 *								description at least partially matches the input description of the currently bound
-		 *								vertex GPU program.
-		 * @param[in]	subMeshes		Defines how are indices separated into sub-meshes, and how are those sub-meshes 
-		 *								rendered. Sub-meshes may be rendered independently.
-		 * @param[in]	usage			Optimizes performance depending on planned usage of the mesh.
-		 * @param[in]	indexType		Size of indices, use smaller size for better performance, however be careful not 
-		 *								to go over the number of vertices limited by the size.
-		 */
-		static SPtr<MeshCore> create(UINT32 numVertices, UINT32 numIndices, const VertexDataDescPtr& vertexDesc, const Vector<SubMesh>& subMeshes,
-			int usage = MU_STATIC, IndexType indexType = IT_32BIT);
-
-		/**
-		 * Creates a new mesh from an existing mesh data. Created mesh will match the vertex and index buffers described
-		 * by the mesh data exactly. Mesh will have no sub-meshes.
-		 *
-		 * @param[in]	initialMeshData	Vertex and index data to initialize the mesh with.
-		 * @param[in]	usage			Optimizes performance depending on planned usage of the mesh.
-		 * @param[in]	drawOp			Determines how should the provided indices be interpreted by the pipeline. Default 
-		 *								option is a triangle strip, where three indices represent a single triangle.
-		 */
-		static SPtr<MeshCore> create(const MeshDataPtr& initialMeshData, int usage = MU_STATIC,
-			DrawOperationType drawOp = DOT_TRIANGLE_LIST);
-
-		/**
-		 * Creates a new mesh from an existing mesh data. Created mesh will match the vertex and index buffers described
-		 * by the mesh data exactly. Mesh will have specified the sub-meshes.
-		 *
-		 * @param[in]	initialMeshData	Vertex and index data used for initializing the mesh. 
-		 * @param[in]	subMeshes		Defines how are indices separated into sub-meshes, and how are those sub-meshes 
-		 *								rendered. Sub-meshes may be rendered independently.
-		 * @param[in]	usage			Optimizes performance depending on planned usage of the mesh.
-		 */
-		static SPtr<MeshCore> create(const MeshDataPtr& initialMeshData, const Vector<SubMesh>& subMeshes, int usage = MU_STATIC);
-
-	protected:
-		friend class Mesh;
-
-		/** Updates bounds by calculating them from the vertices in the provided mesh data object. */
-		void updateBounds(const MeshData& meshData);
-
-		std::shared_ptr<VertexData> mVertexData;
-		SPtr<IndexBufferCore> mIndexBuffer;
-
-		VertexDataDescPtr mVertexDesc;
-		int mUsage;
-		IndexType mIndexType;
-		MeshDataPtr mTempInitialMeshData;
-	};
-
-	/** @endcond */
-
-	/**
-	 * Primary class for holding geometry. Stores data in the form of a vertex buffers and optionally index buffer, which 
-	 * may be bound to the pipeline for drawing. May contain multiple sub-meshes.
-	 *
-	 * @note	Sim thread.
-	 */
-	class BS_CORE_EXPORT Mesh : public MeshBase
-	{
-	public:
-		virtual ~Mesh();
-
-		/** @copydoc MeshBase::initialize */
-		virtual void initialize() override;
-
-		/**
-		 * Updates the mesh with new data. The actual write will be queued for later execution on the core thread. Provided 
-		 * data buffer will be locked until the operation completes.
-		 *
-		 * @param[in]	accessor	Accessor to queue the operation on.
-		 * @return					Async operation object you can use to track operation completion.
-		 *
-		 * @see		MeshCore::writeSubresource
-		 */
-		AsyncOp writeSubresource(CoreAccessor& accessor, UINT32 subresourceIdx, const MeshDataPtr& data, 
-			bool discardEntireBuffer);
-
-		/**
-		 * Reads internal mesh data to the provided previously allocated buffer. The read is queued for execution on the 
-		 * core thread and not executed immediately. Provided data buffer will be locked until the operation completes.
-		 *
-		 * @param[in]	accessor	Accessor to queue the operation on.
-		 * @return					Async operation object you can use to track operation completion.
-		 *
-		 * @see		MeshCore::readSubresource
-		 */
-		AsyncOp readSubresource(CoreAccessor& accessor, UINT32 subresourceIdx, const MeshDataPtr& data);
-
-		/**
-		 * Allocates a buffer you may use for storage when reading a subresource. You need to allocate such a buffer if you
-		 * are calling readSubresource().
-		 * 			
-		 * @param[in]	subresourceIdx	Only 0 is supported. You can only update entire mesh at once.
-		 *
-		 * @note	Thread safe.
-		 */
-		MeshDataPtr allocateSubresourceBuffer(UINT32 subresourceIdx) const;
-
-		/**
-		 * Reads data from the cached system memory mesh buffer into the provided buffer. 
-		 * 		  
-		 * @param[in]	dest		Previously allocated buffer to read data into.
-		 *
-		 * @note	
-		 * The data read is the cached mesh data. Any data written to the mesh from the GPU or core thread will not be 
-		 * reflected in this data. Use readSubresource() if you require those changes. 
-		 * @note
-		 * The mesh must have been created with MU_CPUCACHED usage otherwise this method will not return any data.
-		 */
-		void readData(MeshData& dest);
-
-		/** Retrieves a core implementation of a mesh usable only from the core thread. */
-		SPtr<MeshCore> getCore() const;
-
-		/**	Returns a dummy mesh, containing just one triangle. Don't modify the returned mesh. */
-		static HMesh dummy();
-
-	protected:
-		friend class MeshManager;
-
-		Mesh(UINT32 numVertices, UINT32 numIndices, const VertexDataDescPtr& vertexDesc, 
-			int usage = MU_STATIC, DrawOperationType drawOp = DOT_TRIANGLE_LIST,
-			IndexType indexType = IT_32BIT);
-
-		Mesh(UINT32 numVertices, UINT32 numIndices, const VertexDataDescPtr& vertexDesc,
-			const Vector<SubMesh>& subMeshes, int usage = MU_STATIC,
-			IndexType indexType = IT_32BIT);
-
-		Mesh(const MeshDataPtr& initialMeshData, int usage = MU_STATIC,
-			DrawOperationType drawOp = DOT_TRIANGLE_LIST);
-
-		Mesh(const MeshDataPtr& initialMeshData, const Vector<SubMesh>& subMeshes, int usage = MU_STATIC);
-
-		/**	Updates bounds by calculating them from the vertices in the provided mesh data object. */
-		void updateBounds(const MeshData& meshData);
-
-		/** @copydoc CoreObject::createCore */
-		SPtr<CoreObjectCore> createCore() const override;
-
-		/**
-		 * Creates buffers used for caching of CPU mesh data.
-		 *
-		 * @note	Make sure to initialize all mesh properties before calling this.
-		 */
-		void createCPUBuffer();
-
-		/**	Updates the cached CPU buffers with new data. */
-		void updateCPUBuffer(UINT32 subresourceIdx, const MeshData& data);
-
-		mutable MeshDataPtr mCPUData;
-
-		VertexDataDescPtr mVertexDesc;
-		int mUsage;
-		IndexType mIndexType;
-
-		/************************************************************************/
-		/* 								SERIALIZATION                      		*/
-		/************************************************************************/
-	private:
-		Mesh(); // Serialization only
-
-	public:
-		friend class MeshRTTI;
-		static RTTITypeBase* getRTTIStatic();
-		virtual RTTITypeBase* getRTTI() const override;
-
-		/************************************************************************/
-		/* 								STATICS		                     		*/
-		/************************************************************************/
-		
-	public:
-		/**
-		 * Creates a new empty mesh. Created mesh will have no sub-meshes.
-		 *
-		 * @param[in]	numVertices		Number of vertices in the mesh.
-		 * @param[in]	numIndices		Number of indices in the mesh. 
-		 * @param[in]	vertexDesc		Vertex description structure that describes how are vertices organized in the
-		 *								vertex buffer. When binding a mesh to the pipeline you must ensure vertex 
-		 *								description at least partially matches the input description of the currently bound
-		 *								vertex GPU program.
-		 * @param[in]	usage			Optimizes performance depending on planned usage of the mesh.
-		 * @param[in]	drawOp			Determines how should the provided indices be interpreted by the pipeline. Default 
-		 *								option is a triangle list, where three indices represent a single triangle.
-		 * @param[in]	indexType		Size of indices, use smaller size for better performance, however be careful not to
-		 *								go over the number of vertices limited by the size.
-		 */
-		static HMesh create(UINT32 numVertices, UINT32 numIndices, const VertexDataDescPtr& vertexDesc, int usage = MU_STATIC,
-			DrawOperationType drawOp = DOT_TRIANGLE_LIST, IndexType indexType = IT_32BIT);
-
-		/**
-		 * Creates a new empty mesh. Created mesh will have specified sub-meshes you may render independently.
-		 *
-		 * @param[in]	numVertices		Number of vertices in the mesh.
-		 * @param[in]	numIndices		Number of indices in the mesh. 
-		 * @param[in]	vertexDesc		Vertex description structure that describes how are vertices organized in the
-		 *								vertex buffer. When binding a mesh to the pipeline you must ensure vertex 
-		 *								description at least partially matches the input description of the currently bound
-		 *								vertex GPU program.
-		 * @param[in]	subMeshes		Defines how are indices separated into sub-meshes, and how are those sub-meshes 
-		 *								rendered. Sub-meshes may be rendered independently.
-		 * @param[in]	usage			Optimizes performance depending on planned usage of the mesh.
-		 * @param[in]	indexType		Size of indices, use smaller size for better performance, however be careful not to
-		 *								go over the number of vertices limited by the size.
-		 */
-		static HMesh create(UINT32 numVertices, UINT32 numIndices, const VertexDataDescPtr& vertexDesc, const Vector<SubMesh>& subMeshes,
-			int usage = MU_STATIC, IndexType indexType = IT_32BIT);
-
-		/**
-		 * Creates a new mesh from an existing mesh data. Created mesh will match the vertex and index buffers described
-		 * by the mesh data exactly. Mesh will have no sub-meshes.
-		 *
-		 * @param[in]	initialMeshData	Vertex and index data to initialize the mesh with.
-		 * @param[in]	usage			Optimizes performance depending on planned usage of the mesh.
-		 * @param[in]	drawOp			Determines how should the provided indices be interpreted by the pipeline. Default 
-		 *								option is a triangle strip, where three indices represent a single triangle.
-		 */
-		static HMesh create(const MeshDataPtr& initialMeshData, int usage = MU_STATIC,
-			DrawOperationType drawOp = DOT_TRIANGLE_LIST);
-
-		/**
-		 * Creates a new mesh from an existing mesh data. Created mesh will match the vertex and index buffers described by
-		 * the mesh data exactly. Mesh will have specified the sub-meshes.
-		 *
-		 * @param[in]	initialMeshData	Vertex and index data used for initializing the mesh. 
-		 * @param[in]	subMeshes		Defines how are indices separated into sub-meshes, and how are those sub-meshes 
-		 *								rendered. Sub-meshes may be rendered independently.
-		 * @param[in]	usage			Optimizes performance depending on planned usage of the mesh.
-		 */
-		static HMesh create(const MeshDataPtr& initialMeshData, const Vector<SubMesh>& subMeshes, int usage = MU_STATIC);
-
-		/**
-		 * @copydoc	create(UINT32, UINT32, const VertexDataDescPtr&, int, DrawOperationType, IndexType)
-		 *
-		 * @note	Internal method. Use create() for normal use.
-		 */
-		static MeshPtr _createPtr(UINT32 numVertices, UINT32 numIndices, 
-			const VertexDataDescPtr& vertexDesc, int usage = MU_STATIC,
-			DrawOperationType drawOp = DOT_TRIANGLE_LIST, IndexType indexType = IT_32BIT);
-
-		/**
-		 * @copydoc	create(UINT32, UINT32, const VertexDataDescPtr&, const Vector<SubMesh>&, int, IndexType)
-		 *
-		 * @note	Internal method. Use create() for normal use.
-		 */
-		static MeshPtr _createPtr(UINT32 numVertices, UINT32 numIndices, 
-			const VertexDataDescPtr& vertexDesc, const Vector<SubMesh>& subMeshes,
-			int usage = MU_STATIC, IndexType indexType = IT_32BIT);
-
-		/**
-		 * @copydoc	create(const MeshDataPtr&, int, DrawOperationType)
-		 *
-		 * @note	Internal method. Use create() for normal use.
-		 */
-		static MeshPtr _createPtr(const MeshDataPtr& initialMeshData, int usage = MU_STATIC,
-			DrawOperationType drawOp = DOT_TRIANGLE_LIST);
-
-		/**
-		 * @copydoc	create(const MeshDataPtr&, const Vector<SubMesh>&, int)
-		 *
-		 * @note	Internal method. Use create() for normal use.
-		 */
-		static MeshPtr _createPtr(const MeshDataPtr& initialMeshData, const Vector<SubMesh>& subMeshes,
-			int usage = MU_STATIC);
-	};
-
-	/** @} */
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+#pragma once
+
+#include "BsCorePrerequisites.h"
+#include "BsMeshBase.h"
+#include "BsMeshData.h"
+#include "BsVertexData.h"
+#include "BsDrawOps.h"
+#include "BsSubMesh.h"
+#include "BsBounds.h"
+
+namespace BansheeEngine
+{
+	/** @addtogroup Resources
+	 *  @{
+	 */
+
+	/**
+	 * Primary class for holding geometry. Stores data in the form of a vertex buffers and optionally index buffer, which 
+	 * may be bound to the pipeline for drawing. May contain multiple sub-meshes.
+	 *
+	 * @note	Sim thread.
+	 */
+	class BS_CORE_EXPORT Mesh : public MeshBase
+	{
+	public:
+		virtual ~Mesh();
+
+		/** @copydoc MeshBase::initialize */
+		virtual void initialize() override;
+
+		/**
+		 * Updates the mesh with new data. The actual write will be queued for later execution on the core thread. Provided 
+		 * data buffer will be locked until the operation completes.
+		 *
+		 * @param[in]	accessor	Accessor to queue the operation on.
+		 * @return					Async operation object you can use to track operation completion.
+		 *
+		 * @see		MeshCore::writeSubresource
+		 */
+		AsyncOp writeSubresource(CoreAccessor& accessor, UINT32 subresourceIdx, const MeshDataPtr& data, 
+			bool discardEntireBuffer);
+
+		/**
+		 * Reads internal mesh data to the provided previously allocated buffer. The read is queued for execution on the 
+		 * core thread and not executed immediately. Provided data buffer will be locked until the operation completes.
+		 *
+		 * @param[in]	accessor	Accessor to queue the operation on.
+		 * @return					Async operation object you can use to track operation completion.
+		 *
+		 * @see		MeshCore::readSubresource
+		 */
+		AsyncOp readSubresource(CoreAccessor& accessor, UINT32 subresourceIdx, const MeshDataPtr& data);
+
+		/**
+		 * Allocates a buffer you may use for storage when reading a subresource. You need to allocate such a buffer if you
+		 * are calling readSubresource().
+		 * 			
+		 * @param[in]	subresourceIdx	Only 0 is supported. You can only update entire mesh at once.
+		 *
+		 * @note	Thread safe.
+		 */
+		MeshDataPtr allocateSubresourceBuffer(UINT32 subresourceIdx) const;
+
+		/**
+		 * Reads data from the cached system memory mesh buffer into the provided buffer. 
+		 * 		  
+		 * @param[in]	dest		Previously allocated buffer to read data into.
+		 *
+		 * @note	
+		 * The data read is the cached mesh data. Any data written to the mesh from the GPU or core thread will not be 
+		 * reflected in this data. Use readSubresource() if you require those changes. 
+		 * @note
+		 * The mesh must have been created with MU_CPUCACHED usage otherwise this method will not return any data.
+		 */
+		void readData(MeshData& dest);
+
+		/** Retrieves a core implementation of a mesh usable only from the core thread. */
+		SPtr<MeshCore> getCore() const;
+
+		/**	Returns a dummy mesh, containing just one triangle. Don't modify the returned mesh. */
+		static HMesh dummy();
+
+	protected:
+		friend class MeshManager;
+
+		Mesh(UINT32 numVertices, UINT32 numIndices, const VertexDataDescPtr& vertexDesc, 
+			int usage = MU_STATIC, DrawOperationType drawOp = DOT_TRIANGLE_LIST,
+			IndexType indexType = IT_32BIT);
+
+		Mesh(UINT32 numVertices, UINT32 numIndices, const VertexDataDescPtr& vertexDesc,
+			const Vector<SubMesh>& subMeshes, int usage = MU_STATIC,
+			IndexType indexType = IT_32BIT);
+
+		Mesh(const MeshDataPtr& initialMeshData, int usage = MU_STATIC,
+			DrawOperationType drawOp = DOT_TRIANGLE_LIST);
+
+		Mesh(const MeshDataPtr& initialMeshData, const Vector<SubMesh>& subMeshes, int usage = MU_STATIC);
+
+		/**	Updates bounds by calculating them from the vertices in the provided mesh data object. */
+		void updateBounds(const MeshData& meshData);
+
+		/** @copydoc CoreObject::createCore */
+		SPtr<CoreObjectCore> createCore() const override;
+
+		/**
+		 * Creates buffers used for caching of CPU mesh data.
+		 *
+		 * @note	Make sure to initialize all mesh properties before calling this.
+		 */
+		void createCPUBuffer();
+
+		/**	Updates the cached CPU buffers with new data. */
+		void updateCPUBuffer(UINT32 subresourceIdx, const MeshData& data);
+
+		mutable MeshDataPtr mCPUData;
+
+		VertexDataDescPtr mVertexDesc;
+		int mUsage;
+		IndexType mIndexType;
+
+		/************************************************************************/
+		/* 								SERIALIZATION                      		*/
+		/************************************************************************/
+	private:
+		Mesh(); // Serialization only
+
+	public:
+		friend class MeshRTTI;
+		static RTTITypeBase* getRTTIStatic();
+		virtual RTTITypeBase* getRTTI() const override;
+
+		/************************************************************************/
+		/* 								STATICS		                     		*/
+		/************************************************************************/
+		
+	public:
+		/**
+		 * Creates a new empty mesh. Created mesh will have no sub-meshes.
+		 *
+		 * @param[in]	numVertices		Number of vertices in the mesh.
+		 * @param[in]	numIndices		Number of indices in the mesh. 
+		 * @param[in]	vertexDesc		Vertex description structure that describes how are vertices organized in the
+		 *								vertex buffer. When binding a mesh to the pipeline you must ensure vertex 
+		 *								description at least partially matches the input description of the currently bound
+		 *								vertex GPU program.
+		 * @param[in]	usage			Optimizes performance depending on planned usage of the mesh.
+		 * @param[in]	drawOp			Determines how should the provided indices be interpreted by the pipeline. Default 
+		 *								option is a triangle list, where three indices represent a single triangle.
+		 * @param[in]	indexType		Size of indices, use smaller size for better performance, however be careful not to
+		 *								go over the number of vertices limited by the size.
+		 */
+		static HMesh create(UINT32 numVertices, UINT32 numIndices, const VertexDataDescPtr& vertexDesc, int usage = MU_STATIC,
+			DrawOperationType drawOp = DOT_TRIANGLE_LIST, IndexType indexType = IT_32BIT);
+
+		/**
+		 * Creates a new empty mesh. Created mesh will have specified sub-meshes you may render independently.
+		 *
+		 * @param[in]	numVertices		Number of vertices in the mesh.
+		 * @param[in]	numIndices		Number of indices in the mesh. 
+		 * @param[in]	vertexDesc		Vertex description structure that describes how are vertices organized in the
+		 *								vertex buffer. When binding a mesh to the pipeline you must ensure vertex 
+		 *								description at least partially matches the input description of the currently bound
+		 *								vertex GPU program.
+		 * @param[in]	subMeshes		Defines how are indices separated into sub-meshes, and how are those sub-meshes 
+		 *								rendered. Sub-meshes may be rendered independently.
+		 * @param[in]	usage			Optimizes performance depending on planned usage of the mesh.
+		 * @param[in]	indexType		Size of indices, use smaller size for better performance, however be careful not to
+		 *								go over the number of vertices limited by the size.
+		 */
+		static HMesh create(UINT32 numVertices, UINT32 numIndices, const VertexDataDescPtr& vertexDesc, const Vector<SubMesh>& subMeshes,
+			int usage = MU_STATIC, IndexType indexType = IT_32BIT);
+
+		/**
+		 * Creates a new mesh from an existing mesh data. Created mesh will match the vertex and index buffers described
+		 * by the mesh data exactly. Mesh will have no sub-meshes.
+		 *
+		 * @param[in]	initialMeshData	Vertex and index data to initialize the mesh with.
+		 * @param[in]	usage			Optimizes performance depending on planned usage of the mesh.
+		 * @param[in]	drawOp			Determines how should the provided indices be interpreted by the pipeline. Default 
+		 *								option is a triangle strip, where three indices represent a single triangle.
+		 */
+		static HMesh create(const MeshDataPtr& initialMeshData, int usage = MU_STATIC,
+			DrawOperationType drawOp = DOT_TRIANGLE_LIST);
+
+		/**
+		 * Creates a new mesh from an existing mesh data. Created mesh will match the vertex and index buffers described by
+		 * the mesh data exactly. Mesh will have specified the sub-meshes.
+		 *
+		 * @param[in]	initialMeshData	Vertex and index data used for initializing the mesh. 
+		 * @param[in]	subMeshes		Defines how are indices separated into sub-meshes, and how are those sub-meshes 
+		 *								rendered. Sub-meshes may be rendered independently.
+		 * @param[in]	usage			Optimizes performance depending on planned usage of the mesh.
+		 */
+		static HMesh create(const MeshDataPtr& initialMeshData, const Vector<SubMesh>& subMeshes, int usage = MU_STATIC);
+
+		/**
+		 * @copydoc	create(UINT32, UINT32, const VertexDataDescPtr&, int, DrawOperationType, IndexType)
+		 *
+		 * @note	Internal method. Use create() for normal use.
+		 */
+		static MeshPtr _createPtr(UINT32 numVertices, UINT32 numIndices, 
+			const VertexDataDescPtr& vertexDesc, int usage = MU_STATIC,
+			DrawOperationType drawOp = DOT_TRIANGLE_LIST, IndexType indexType = IT_32BIT);
+
+		/**
+		 * @copydoc	create(UINT32, UINT32, const VertexDataDescPtr&, const Vector<SubMesh>&, int, IndexType)
+		 *
+		 * @note	Internal method. Use create() for normal use.
+		 */
+		static MeshPtr _createPtr(UINT32 numVertices, UINT32 numIndices, 
+			const VertexDataDescPtr& vertexDesc, const Vector<SubMesh>& subMeshes,
+			int usage = MU_STATIC, IndexType indexType = IT_32BIT);
+
+		/**
+		 * @copydoc	create(const MeshDataPtr&, int, DrawOperationType)
+		 *
+		 * @note	Internal method. Use create() for normal use.
+		 */
+		static MeshPtr _createPtr(const MeshDataPtr& initialMeshData, int usage = MU_STATIC,
+			DrawOperationType drawOp = DOT_TRIANGLE_LIST);
+
+		/**
+		 * @copydoc	create(const MeshDataPtr&, const Vector<SubMesh>&, int)
+		 *
+		 * @note	Internal method. Use create() for normal use.
+		 */
+		static MeshPtr _createPtr(const MeshDataPtr& initialMeshData, const Vector<SubMesh>& subMeshes,
+			int usage = MU_STATIC);
+	};
+
+	/** @} */
+
+	/** @addtogroup Resources-Internal
+	 *  @{
+	 */
+
+	/**
+	 * Core thread portion of a Mesh.
+	 *
+	 * @note	Core thread.
+	 */
+	class BS_CORE_EXPORT MeshCore : public MeshCoreBase
+	{
+	public:
+		MeshCore(UINT32 numVertices, UINT32 numIndices, const VertexDataDescPtr& vertexDesc,
+			const Vector<SubMesh>& subMeshes, int usage, IndexType indexType,
+			MeshDataPtr initialMeshData);
+
+		~MeshCore();
+
+		/** @copydoc CoreObjectCore::initialize */
+		virtual void initialize() override;
+
+		/** @copydoc MeshCoreBase::getVertexData */
+		virtual SPtr<VertexData> getVertexData() const override;
+
+		/** @copydoc MeshCoreBase::getIndexBuffer */
+		virtual SPtr<IndexBufferCore> getIndexBuffer() const override;
+
+		/** @copydoc MeshCoreBase::getVertexDesc */
+		virtual SPtr<VertexDataDesc> getVertexDesc() const override;
+
+		/**
+		 * Updates a part of the current mesh with the provided data.
+		 *
+		 * @param[in]	subresourceIdx		Index of the subresource to update, if the mesh has more than one.
+		 * @param[in]	data				Data to update the mesh with.
+		 * @param[in]	discardEntireBuffer When true the existing contents of the resource you are updating will be 
+		 *									discarded. This can make the operation faster. Resources with certain buffer 
+		 *									types might require this flag to be in a specific state otherwise the operation 
+		 *									will fail.
+		 * @param[in]	updateBounds		If true the internal bounds of the mesh will be recalculated based on the 
+		 *									provided data.
+		 */
+		virtual void writeSubresource(UINT32 subresourceIdx, const MeshData& data, bool discardEntireBuffer, bool updateBounds = true);
+
+		/**
+		 * Reads a part of the current resource into the provided @p data parameter.	Data buffer needs to be pre-allocated.
+		 *
+		 * @param[in]	subresourceIdx		Index of the subresource to update, if the mesh has more than one.
+		 * @param[out]	data				Buffer that will receive the data. Should be allocated with 
+		 *									allocateSubresourceBuffer() to ensure it is of valid type and size.
+		 */
+		virtual void readSubresource(UINT32 subresourceIdx, MeshData& data);
+
+		/**
+		 * Creates a new empty mesh. Created mesh will have no sub-meshes.
+		 *
+		 * @param[in]	numVertices		Number of vertices in the mesh.
+		 * @param[in]	numIndices		Number of indices in the mesh. 
+		 * @param[in]	vertexDesc		Vertex description structure that describes how are vertices organized in the
+		 *								vertex buffer. When binding a mesh to the pipeline you must ensure vertex 
+		 *								description at least partially matches the input description of the currently 
+		 *								bound vertex GPU program.
+		 * @param[in]	usage			Optimizes performance depending on planned usage of the mesh.
+		 * @param[in]	drawOp			Determines how should the provided indices be interpreted by the pipeline. Default
+		 *								option is a triangle list, where three indices represent a single triangle.
+		 * @param[in]	indexType		Size of indices, use smaller size for better performance, however be careful not to
+		 *								go over the number of vertices limited by the size.
+		 */
+		static SPtr<MeshCore> create(UINT32 numVertices, UINT32 numIndices, const VertexDataDescPtr& vertexDesc, int usage = MU_STATIC,
+			DrawOperationType drawOp = DOT_TRIANGLE_LIST, IndexType indexType = IT_32BIT);
+
+		/**
+		 * Creates a new empty mesh. Created mesh will have specified sub-meshes you may render independently.
+		 *
+		 * @param[in]	numVertices		Number of vertices in the mesh.
+		 * @param[in]	numIndices		Number of indices in the mesh. 
+		 * @param[in]	vertexDesc		Vertex description structure that describes how are vertices organized in the
+		 *								vertex buffer. When binding a mesh to the pipeline you must ensure vertex 
+		 *								description at least partially matches the input description of the currently bound
+		 *								vertex GPU program.
+		 * @param[in]	subMeshes		Defines how are indices separated into sub-meshes, and how are those sub-meshes 
+		 *								rendered. Sub-meshes may be rendered independently.
+		 * @param[in]	usage			Optimizes performance depending on planned usage of the mesh.
+		 * @param[in]	indexType		Size of indices, use smaller size for better performance, however be careful not 
+		 *								to go over the number of vertices limited by the size.
+		 */
+		static SPtr<MeshCore> create(UINT32 numVertices, UINT32 numIndices, const VertexDataDescPtr& vertexDesc, const Vector<SubMesh>& subMeshes,
+			int usage = MU_STATIC, IndexType indexType = IT_32BIT);
+
+		/**
+		 * Creates a new mesh from an existing mesh data. Created mesh will match the vertex and index buffers described
+		 * by the mesh data exactly. Mesh will have no sub-meshes.
+		 *
+		 * @param[in]	initialMeshData	Vertex and index data to initialize the mesh with.
+		 * @param[in]	usage			Optimizes performance depending on planned usage of the mesh.
+		 * @param[in]	drawOp			Determines how should the provided indices be interpreted by the pipeline. Default 
+		 *								option is a triangle strip, where three indices represent a single triangle.
+		 */
+		static SPtr<MeshCore> create(const MeshDataPtr& initialMeshData, int usage = MU_STATIC,
+			DrawOperationType drawOp = DOT_TRIANGLE_LIST);
+
+		/**
+		 * Creates a new mesh from an existing mesh data. Created mesh will match the vertex and index buffers described
+		 * by the mesh data exactly. Mesh will have specified the sub-meshes.
+		 *
+		 * @param[in]	initialMeshData	Vertex and index data used for initializing the mesh. 
+		 * @param[in]	subMeshes		Defines how are indices separated into sub-meshes, and how are those sub-meshes 
+		 *								rendered. Sub-meshes may be rendered independently.
+		 * @param[in]	usage			Optimizes performance depending on planned usage of the mesh.
+		 */
+		static SPtr<MeshCore> create(const MeshDataPtr& initialMeshData, const Vector<SubMesh>& subMeshes, int usage = MU_STATIC);
+
+	protected:
+		friend class Mesh;
+
+		/** Updates bounds by calculating them from the vertices in the provided mesh data object. */
+		void updateBounds(const MeshData& meshData);
+
+		std::shared_ptr<VertexData> mVertexData;
+		SPtr<IndexBufferCore> mIndexBuffer;
+
+		VertexDataDescPtr mVertexDesc;
+		int mUsage;
+		IndexType mIndexType;
+		MeshDataPtr mTempInitialMeshData;
+	};
+
+	/** @} */
 }

+ 186 - 189
Source/BansheeCore/Include/BsMeshBase.h

@@ -1,190 +1,187 @@
-//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
-//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
-#pragma once
-
-#include "BsCorePrerequisites.h"
-#include "BsResource.h"
-#include "BsBounds.h"
-#include "BsDrawOps.h"
-#include "BsSubMesh.h"
-
-namespace BansheeEngine
-{
-	/** @addtogroup Resources
-	 *  @{
-	 */
-
-	/**
-	 * Planned usage for the mesh. These options usually affect performance and you should specify static if you don't plan
-	 * on modifying the mesh often, otherwise specify dynamic.
-	 */
-	enum MeshUsage
-	{
-		MU_STATIC, /**< Specify for a mesh that is not often updated from the CPU. */
-		MU_DYNAMIC, /**< Specify for a mesh that is often updated from the CPU. */
-		MU_CPUCACHED = 0x1000 /**< All mesh data will also be cached in CPU memory, making it readable with GPU reads. */
-	};
-
-	/** Properties of a Mesh. Shared between sim and core thread versions of a Mesh. */
-	class BS_CORE_EXPORT MeshProperties
-	{
-	public:
-		MeshProperties();
-		MeshProperties(UINT32 numVertices, UINT32 numIndices, DrawOperationType drawOp);
-		MeshProperties(UINT32 numVertices, UINT32 numIndices, const Vector<SubMesh>& subMeshes);
-
-		/**
-		 * Retrieves a sub-mesh containing data used for rendering a certain portion of this mesh. If no sub-meshes are
-		 * specified manually a special sub-mesh containing all indices is returned.
-		 */
-		const SubMesh& getSubMesh(UINT32 subMeshIdx = 0) const;
-
-		/** Retrieves a total number of sub-meshes in this mesh. */
-		UINT32 getNumSubMeshes() const;
-
-		/**	Returns maximum number of vertices the mesh may store. */
-		UINT32 getNumVertices() const { return mNumVertices; }
-
-		/**	Returns maximum number of indices the mesh may store. */
-		UINT32 getNumIndices() const { return mNumIndices; }
-
-		/**	Returns bounds of the geometry contained in the vertex buffers for all sub-meshes. */
-		const Bounds& getBounds() const { return mBounds; }
-
-	protected:
-		friend class MeshBase;
-		friend class MeshCoreBase;
-		friend class Mesh;
-		friend class MeshCore;
-		friend class TransientMesh;
-		friend class TransientMeshCore;
-		friend class MeshBaseRTTI;
-
-		Vector<SubMesh> mSubMeshes;
-		UINT32 mNumVertices;
-		UINT32 mNumIndices;
-		Bounds mBounds;
-	};
-
-	/** @} */
-
-	/** @addtogroup Implementation
-	 *  @{
-	 */
-	/** @cond INTERNAL */
-
-	/**
-	 * 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 */
-		virtual void syncToCore(const CoreSyncData& data) override;
-
-		MeshProperties mProperties;
-	};
-
-	/** @endcond */
-
-	/**
-	 * 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.
-	 *
-	 * @note	Sim thread.
-	 */
-	class BS_CORE_EXPORT MeshBase : public Resource
-	{
-	public:
-		/**
-		 * Constructs a new mesh with no sub-meshes.
-		 *
-		 * @param[in]	numVertices		Number of vertices in the mesh.
-		 * @param[in]	numIndices		Number of indices in the mesh. 
-		 * @param[in]	drawOp			Determines how should the provided indices be interpreted by the pipeline. Default 
-		 *								option is triangles, where three indices represent a single triangle.
-		 */
-		MeshBase(UINT32 numVertices, UINT32 numIndices, DrawOperationType drawOp = DOT_TRIANGLE_LIST);
-
-		/**
-		 * Constructs a new mesh with one or multiple sub-meshes. (When using just one sub-mesh it is equivalent to using
-		 * the other overload).
-		 *
-		 * @param[in]	numVertices		Number of vertices in the mesh.
-		 * @param[in]	numIndices		Number of indices in the mesh.
-		 * @param[in]	subMeshes		Defines how are indices separated into sub-meshes, and how are those sub-meshes 
-		 *								rendered.
-		 */
-		MeshBase(UINT32 numVertices, UINT32 numIndices, const Vector<SubMesh>& subMeshes);
-
-		virtual ~MeshBase();
-
-		/**	Returns properties that contain information about the mesh. */
-		const MeshProperties& getProperties() const { return mProperties; }
-
-		/**	Retrieves a core implementation of a mesh usable only from the core thread. */
-		SPtr<MeshCoreBase> getCore() const;
-
-	protected:
-		/** @copydoc CoreObject::syncToCore */
-		virtual CoreSyncData syncToCore(FrameAlloc* allocator) override;
-
-		MeshProperties mProperties;
-
-		/************************************************************************/
-		/* 								SERIALIZATION                      		*/
-		/************************************************************************/
-	private:
-		MeshBase() { } // Serialization only
-
-	public:
-		friend class MeshBaseRTTI;
-		static RTTITypeBase* getRTTIStatic();
-		virtual RTTITypeBase* getRTTI() const override;
-	};
-
-	/** @} */
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+#pragma once
+
+#include "BsCorePrerequisites.h"
+#include "BsResource.h"
+#include "BsBounds.h"
+#include "BsDrawOps.h"
+#include "BsSubMesh.h"
+
+namespace BansheeEngine
+{
+	/** @addtogroup Resources
+	 *  @{
+	 */
+
+	/**
+	 * Planned usage for the mesh. These options usually affect performance and you should specify static if you don't plan
+	 * on modifying the mesh often, otherwise specify dynamic.
+	 */
+	enum MeshUsage
+	{
+		MU_STATIC, /**< Specify for a mesh that is not often updated from the CPU. */
+		MU_DYNAMIC, /**< Specify for a mesh that is often updated from the CPU. */
+		MU_CPUCACHED = 0x1000 /**< All mesh data will also be cached in CPU memory, making it readable with GPU reads. */
+	};
+
+	/** Properties of a Mesh. Shared between sim and core thread versions of a Mesh. */
+	class BS_CORE_EXPORT MeshProperties
+	{
+	public:
+		MeshProperties();
+		MeshProperties(UINT32 numVertices, UINT32 numIndices, DrawOperationType drawOp);
+		MeshProperties(UINT32 numVertices, UINT32 numIndices, const Vector<SubMesh>& subMeshes);
+
+		/**
+		 * Retrieves a sub-mesh containing data used for rendering a certain portion of this mesh. If no sub-meshes are
+		 * specified manually a special sub-mesh containing all indices is returned.
+		 */
+		const SubMesh& getSubMesh(UINT32 subMeshIdx = 0) const;
+
+		/** Retrieves a total number of sub-meshes in this mesh. */
+		UINT32 getNumSubMeshes() const;
+
+		/**	Returns maximum number of vertices the mesh may store. */
+		UINT32 getNumVertices() const { return mNumVertices; }
+
+		/**	Returns maximum number of indices the mesh may store. */
+		UINT32 getNumIndices() const { return mNumIndices; }
+
+		/**	Returns bounds of the geometry contained in the vertex buffers for all sub-meshes. */
+		const Bounds& getBounds() const { return mBounds; }
+
+	protected:
+		friend class MeshBase;
+		friend class MeshCoreBase;
+		friend class Mesh;
+		friend class MeshCore;
+		friend class TransientMesh;
+		friend class TransientMeshCore;
+		friend class MeshBaseRTTI;
+
+		Vector<SubMesh> mSubMeshes;
+		UINT32 mNumVertices;
+		UINT32 mNumIndices;
+		Bounds mBounds;
+	};
+
+	/** @} */
+
+	/** @addtogroup Implementation
+	 *  @{
+	 */
+
+	/**
+	 * 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 */
+		virtual 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 
+	 * several index or vertex buffers. Different mesh implementations might choose to manage those buffers differently.
+	 *
+	 * @note	Sim thread.
+	 */
+	class BS_CORE_EXPORT MeshBase : public Resource
+	{
+	public:
+		/**
+		 * Constructs a new mesh with no sub-meshes.
+		 *
+		 * @param[in]	numVertices		Number of vertices in the mesh.
+		 * @param[in]	numIndices		Number of indices in the mesh. 
+		 * @param[in]	drawOp			Determines how should the provided indices be interpreted by the pipeline. Default 
+		 *								option is triangles, where three indices represent a single triangle.
+		 */
+		MeshBase(UINT32 numVertices, UINT32 numIndices, DrawOperationType drawOp = DOT_TRIANGLE_LIST);
+
+		/**
+		 * Constructs a new mesh with one or multiple sub-meshes. (When using just one sub-mesh it is equivalent to using
+		 * the other overload).
+		 *
+		 * @param[in]	numVertices		Number of vertices in the mesh.
+		 * @param[in]	numIndices		Number of indices in the mesh.
+		 * @param[in]	subMeshes		Defines how are indices separated into sub-meshes, and how are those sub-meshes 
+		 *								rendered.
+		 */
+		MeshBase(UINT32 numVertices, UINT32 numIndices, const Vector<SubMesh>& subMeshes);
+
+		virtual ~MeshBase();
+
+		/**	Returns properties that contain information about the mesh. */
+		const MeshProperties& getProperties() const { return mProperties; }
+
+		/**	Retrieves a core implementation of a mesh usable only from the core thread. */
+		SPtr<MeshCoreBase> getCore() const;
+
+	protected:
+		/** @copydoc CoreObject::syncToCore */
+		virtual CoreSyncData syncToCore(FrameAlloc* allocator) override;
+
+		MeshProperties mProperties;
+
+		/************************************************************************/
+		/* 								SERIALIZATION                      		*/
+		/************************************************************************/
+	private:
+		MeshBase() { } // Serialization only
+
+	public:
+		friend class MeshBaseRTTI;
+		static RTTITypeBase* getRTTIStatic();
+		virtual RTTITypeBase* getRTTI() const override;
+	};
+
+	/** @} */
 }

+ 5 - 3
Source/BansheeCore/Include/BsMeshHeap.h

@@ -9,8 +9,7 @@
 
 namespace BansheeEngine
 {
-	/** @cond INTERNAL */
-	/** @addtogroup Resources
+	/** @addtogroup Resources-Internal
 	 *  @{
 	 */
 
@@ -162,7 +161,10 @@ namespace BansheeEngine
 		static const float GrowPercent;
 	};
 
-	/** @endcond */
+	/** @} */
+	/** @addtogroup Resources
+	 *  @{
+	 */
 
 	/**
 	 * Mesh heap allows you to quickly allocate and deallocate a large amounts of temporary meshes without the large 

+ 58 - 60
Source/BansheeCore/Include/BsMeshManager.h

@@ -1,61 +1,59 @@
-//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
-//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
-#pragma once
-
-#include "BsCorePrerequisites.h"
-#include "BsModule.h"
-#include "BsMesh.h"
-
-namespace BansheeEngine
-{
-	/** @cond INTERNAL */
-	/** @addtogroup RenderAPI
-	 *  @{
-	 */
-
-	/** Manager that handles creation of Mesh%es. */
-	class BS_CORE_EXPORT MeshManager : public Module<MeshManager>
-	{
-	public:
-		MeshManager();
-		~MeshManager();
-
-		/** @copydoc Mesh::create(UINT32, UINT32, const VertexDataDescPtr&, int, DrawOperationType, IndexType) */
-		MeshPtr create(UINT32 numVertices, UINT32 numIndices, const VertexDataDescPtr& vertexDesc, int usage = MU_STATIC, 
-			DrawOperationType drawOp = DOT_TRIANGLE_LIST, IndexType indexType = IT_32BIT);
-
-		/** @copydoc Mesh::create(UINT32, UINT32, const VertexDataDescPtr&, const Vector<SubMesh>&, int, IndexType) */
-		MeshPtr create(UINT32 numVertices, UINT32 numIndices, const VertexDataDescPtr& vertexDesc, const Vector<SubMesh>& subMeshes, 
-			int usage = MU_STATIC, IndexType indexType = IT_32BIT);
-
-		/** @copyodc Mesh::create(const MeshDataPtr&, int, DrawOperationType) */
-		MeshPtr create(const MeshDataPtr& initialData, int usage = MU_STATIC, DrawOperationType drawOp = DOT_TRIANGLE_LIST);
-
-		/** @copyodc Mesh::create(const MeshDataPtr&, const Vector<SubMesh>&, int) */
-		MeshPtr create(const MeshDataPtr& initialData, const Vector<SubMesh>& subMeshes, int usage = MU_STATIC);
-
-		/**
-		 * Creates a new empty and uninitialized mesh. You will need to manually initialize the mesh before using it.
-		 *	
-		 * @note	This should only be used for special cases and is not meant for normal use.
-		 */
-		MeshPtr createEmpty();
-
-		/** Returns some dummy mesh data with one triangle you may use for initializing a mesh. */
-		MeshDataPtr getDummyMeshData() const { return mDummyMeshData; }
-
-		/**	Returns a dummy mesh containing one triangle. */
-		HMesh getDummyMesh() const { return mDummyMesh; }
-
-	protected:
-		/** @copydoc Module::onStartUp */
-		virtual void onStartUp() override;
-
-	private:
-		MeshDataPtr mDummyMeshData;
-		HMesh mDummyMesh;
-	};
-
-	/** @} */
-	/** @endcond */
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+#pragma once
+
+#include "BsCorePrerequisites.h"
+#include "BsModule.h"
+#include "BsMesh.h"
+
+namespace BansheeEngine
+{
+	/** @addtogroup RenderAPI-Internal
+	 *  @{
+	 */
+
+	/** Manager that handles creation of Mesh%es. */
+	class BS_CORE_EXPORT MeshManager : public Module<MeshManager>
+	{
+	public:
+		MeshManager();
+		~MeshManager();
+
+		/** @copydoc Mesh::create(UINT32, UINT32, const VertexDataDescPtr&, int, DrawOperationType, IndexType) */
+		MeshPtr create(UINT32 numVertices, UINT32 numIndices, const VertexDataDescPtr& vertexDesc, int usage = MU_STATIC, 
+			DrawOperationType drawOp = DOT_TRIANGLE_LIST, IndexType indexType = IT_32BIT);
+
+		/** @copydoc Mesh::create(UINT32, UINT32, const VertexDataDescPtr&, const Vector<SubMesh>&, int, IndexType) */
+		MeshPtr create(UINT32 numVertices, UINT32 numIndices, const VertexDataDescPtr& vertexDesc, const Vector<SubMesh>& subMeshes, 
+			int usage = MU_STATIC, IndexType indexType = IT_32BIT);
+
+		/** @copyodc Mesh::create(const MeshDataPtr&, int, DrawOperationType) */
+		MeshPtr create(const MeshDataPtr& initialData, int usage = MU_STATIC, DrawOperationType drawOp = DOT_TRIANGLE_LIST);
+
+		/** @copyodc Mesh::create(const MeshDataPtr&, const Vector<SubMesh>&, int) */
+		MeshPtr create(const MeshDataPtr& initialData, const Vector<SubMesh>& subMeshes, int usage = MU_STATIC);
+
+		/**
+		 * Creates a new empty and uninitialized mesh. You will need to manually initialize the mesh before using it.
+		 *	
+		 * @note	This should only be used for special cases and is not meant for normal use.
+		 */
+		MeshPtr createEmpty();
+
+		/** Returns some dummy mesh data with one triangle you may use for initializing a mesh. */
+		MeshDataPtr getDummyMeshData() const { return mDummyMeshData; }
+
+		/**	Returns a dummy mesh containing one triangle. */
+		HMesh getDummyMesh() const { return mDummyMesh; }
+
+	protected:
+		/** @copydoc Module::onStartUp */
+		virtual void onStartUp() override;
+
+	private:
+		MeshDataPtr mDummyMeshData;
+		HMesh mDummyMesh;
+	};
+
+	/** @} */
 }

+ 144 - 142
Source/BansheeCore/Include/BsMultiRenderTexture.h

@@ -1,143 +1,145 @@
-//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
-//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
-#pragma once
-
-#include "BsCorePrerequisites.h"
-#include "BsRenderTarget.h"
-
-namespace BansheeEngine
-{
-	/** @addtogroup RenderAPI
-	 *  @{
-	 */
-
-	/**
-	 * Descriptor class used for initializing a MultiRenderTexture. Contains descriptors for each individual color render 
-	 * surface and their common depth/stencil surface.
-	 */
-	struct BS_CORE_EXPORT MULTI_RENDER_TEXTURE_DESC
-	{
-		Vector<RENDER_SURFACE_DESC> colorSurfaces;
-		RENDER_SURFACE_DESC depthStencilSurface;
-	};
-
-	/**
-	 * @see		MULTI_RENDER_TEXTURE_DESC
-	 *
-	 * @note	References core textures instead of texture handles.
-	 */
-	struct BS_CORE_EXPORT MULTI_RENDER_TEXTURE_CORE_DESC
-	{
-		Vector<RENDER_SURFACE_CORE_DESC> colorSurfaces;
-		RENDER_SURFACE_CORE_DESC depthStencilSurface;
-	};
-
-	/** Contains various properties that describe a render texture. */
-	class BS_CORE_EXPORT MultiRenderTextureProperties : public RenderTargetProperties
-	{
-	public:
-		MultiRenderTextureProperties(const MULTI_RENDER_TEXTURE_DESC& desc);
-		MultiRenderTextureProperties(const MULTI_RENDER_TEXTURE_CORE_DESC& desc);
-		virtual ~MultiRenderTextureProperties() { }
-
-	protected:
-		friend class MultiRenderTextureCore;
-		friend class MultiRenderTexture;
-
-		void construct(const TextureProperties* props);
-	};
-
-	/** @cond INTERNAL */
-
-	/**
-	 * Object representing multiple render textures. You may bind this to the pipeline in order to render to all or some 
-	 * of the textures at once.
-	 *
-	 * @note	Core thread only.
-	 */
-	class BS_CORE_EXPORT MultiRenderTextureCore : public RenderTargetCore
-	{
-	public:
-		virtual ~MultiRenderTextureCore();
-
-		/** @copydoc CoreObjectCore::initialize */
-		virtual void initialize() override;
-
-		/** Returns properties that describe the render texture. */
-		const MultiRenderTextureProperties& getProperties() const;
-
-	protected:
-		MultiRenderTextureCore(const MULTI_RENDER_TEXTURE_CORE_DESC& desc);
-
-		/** @copydoc CoreObjectCore::syncToCore */
-		virtual void syncToCore(const CoreSyncData& data) override;
-
-	private:
-		/** Checks that all render surfaces and depth/stencil surface match. If they do not match an exception is thrown. */
-		void throwIfBuffersDontMatch() const;
-
-		// TODO - Not implemented
-		virtual void copyToMemory(PixelData &dst, FrameBuffer buffer = FB_AUTO);
-
-	protected:
-		Vector<TextureViewPtr> mColorSurfaces;
-		TextureViewPtr mDepthStencilSurface;
-
-		MULTI_RENDER_TEXTURE_CORE_DESC mDesc;
-	};
-
-	/** @endcond */
-
-	/**
-	 * Object representing multiple render textures. You may bind this to the pipeline in order to render to all or some of 
-	 * the textures at once.
-	 *
-	 * @note	Sim thread only.
-	 */
-	class BS_CORE_EXPORT MultiRenderTexture : public RenderTarget
-	{
-	public:
-		virtual ~MultiRenderTexture() { }
-
-		/**
-		 * Returns a color surface texture you may bind as an input to an GPU program.
-		 *
-		 * @note	Be aware that you cannot bind a render texture for reading and writing at the same time.
-		 */
-		const HTexture& getBindableColorTexture(UINT32 idx) const { return mBindableColorTex[idx]; }
-
-		/**
-		 * Returns a depth/stencil surface texture you may bind as an input to an GPU program.
-		 *
-		 * @note	Be aware that you cannot bind a render texture for reading and writing at the same time.
-		 */
-		const HTexture& getBindableDepthStencilTexture() const { return mBindableDepthStencilTex; }
-
-		/** Retrieves a core implementation of a render texture usable only from the core thread. */
-		SPtr<MultiRenderTextureCore> getCore() const;
-
-		/** @copydoc TextureManager::createMultiRenderTexture */
-		static MultiRenderTexturePtr create(const MULTI_RENDER_TEXTURE_DESC& desc);
-
-		/**	Returns properties that describe the render texture. */
-		const MultiRenderTextureProperties& getProperties() const;
-
-		/**	Returns the number of color surfaces used by the render texture. */
-		UINT32 getColorSurfaceCount() const;
-
-	protected:
-		MultiRenderTexture(const MULTI_RENDER_TEXTURE_DESC& desc);
-
-		/** @copydoc RenderTarget::createCore */
-		SPtr<CoreObjectCore> createCore() const override;
-
-		/** @copydoc CoreObjectCore::syncToCore */
-		virtual CoreSyncData syncToCore(FrameAlloc* allocator) override;
-
-		MULTI_RENDER_TEXTURE_DESC mDesc;
-		Vector<HTexture> mBindableColorTex;
-		HTexture mBindableDepthStencilTex;
-	};
-
-	/** @} */
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+#pragma once
+
+#include "BsCorePrerequisites.h"
+#include "BsRenderTarget.h"
+
+namespace BansheeEngine
+{
+	/** @addtogroup RenderAPI
+	 *  @{
+	 */
+
+	/**
+	 * Descriptor class used for initializing a MultiRenderTexture. Contains descriptors for each individual color render 
+	 * surface and their common depth/stencil surface.
+	 */
+	struct BS_CORE_EXPORT MULTI_RENDER_TEXTURE_DESC
+	{
+		Vector<RENDER_SURFACE_DESC> colorSurfaces;
+		RENDER_SURFACE_DESC depthStencilSurface;
+	};
+
+	/**
+	 * @see		MULTI_RENDER_TEXTURE_DESC
+	 *
+	 * @note	References core textures instead of texture handles.
+	 */
+	struct BS_CORE_EXPORT MULTI_RENDER_TEXTURE_CORE_DESC
+	{
+		Vector<RENDER_SURFACE_CORE_DESC> colorSurfaces;
+		RENDER_SURFACE_CORE_DESC depthStencilSurface;
+	};
+
+	/** Contains various properties that describe a render texture. */
+	class BS_CORE_EXPORT MultiRenderTextureProperties : public RenderTargetProperties
+	{
+	public:
+		MultiRenderTextureProperties(const MULTI_RENDER_TEXTURE_DESC& desc);
+		MultiRenderTextureProperties(const MULTI_RENDER_TEXTURE_CORE_DESC& desc);
+		virtual ~MultiRenderTextureProperties() { }
+
+	protected:
+		friend class MultiRenderTextureCore;
+		friend class MultiRenderTexture;
+
+		void construct(const TextureProperties* props);
+	};
+
+	/**
+	 * Object representing multiple render textures. You may bind this to the pipeline in order to render to all or some of 
+	 * the textures at once.
+	 *
+	 * @note	Sim thread only.
+	 */
+	class BS_CORE_EXPORT MultiRenderTexture : public RenderTarget
+	{
+	public:
+		virtual ~MultiRenderTexture() { }
+
+		/**
+		 * Returns a color surface texture you may bind as an input to an GPU program.
+		 *
+		 * @note	Be aware that you cannot bind a render texture for reading and writing at the same time.
+		 */
+		const HTexture& getBindableColorTexture(UINT32 idx) const { return mBindableColorTex[idx]; }
+
+		/**
+		 * Returns a depth/stencil surface texture you may bind as an input to an GPU program.
+		 *
+		 * @note	Be aware that you cannot bind a render texture for reading and writing at the same time.
+		 */
+		const HTexture& getBindableDepthStencilTexture() const { return mBindableDepthStencilTex; }
+
+		/** Retrieves a core implementation of a render texture usable only from the core thread. */
+		SPtr<MultiRenderTextureCore> getCore() const;
+
+		/** @copydoc TextureManager::createMultiRenderTexture */
+		static MultiRenderTexturePtr create(const MULTI_RENDER_TEXTURE_DESC& desc);
+
+		/**	Returns properties that describe the render texture. */
+		const MultiRenderTextureProperties& getProperties() const;
+
+		/**	Returns the number of color surfaces used by the render texture. */
+		UINT32 getColorSurfaceCount() const;
+
+	protected:
+		MultiRenderTexture(const MULTI_RENDER_TEXTURE_DESC& desc);
+
+		/** @copydoc RenderTarget::createCore */
+		SPtr<CoreObjectCore> createCore() const override;
+
+		/** @copydoc CoreObjectCore::syncToCore */
+		virtual CoreSyncData syncToCore(FrameAlloc* allocator) override;
+
+		MULTI_RENDER_TEXTURE_DESC mDesc;
+		Vector<HTexture> mBindableColorTex;
+		HTexture mBindableDepthStencilTex;
+	};
+
+	/** @} */
+
+	/** @addtogroup RenderAPI-Internal
+	 *  @{
+	 */
+
+	/**
+	 * Object representing multiple render textures. You may bind this to the pipeline in order to render to all or some 
+	 * of the textures at once.
+	 *
+	 * @note	Core thread only.
+	 */
+	class BS_CORE_EXPORT MultiRenderTextureCore : public RenderTargetCore
+	{
+	public:
+		virtual ~MultiRenderTextureCore();
+
+		/** @copydoc CoreObjectCore::initialize */
+		virtual void initialize() override;
+
+		/** Returns properties that describe the render texture. */
+		const MultiRenderTextureProperties& getProperties() const;
+
+	protected:
+		MultiRenderTextureCore(const MULTI_RENDER_TEXTURE_CORE_DESC& desc);
+
+		/** @copydoc CoreObjectCore::syncToCore */
+		virtual void syncToCore(const CoreSyncData& data) override;
+
+	private:
+		/** Checks that all render surfaces and depth/stencil surface match. If they do not match an exception is thrown. */
+		void throwIfBuffersDontMatch() const;
+
+		// TODO - Not implemented
+		virtual void copyToMemory(PixelData &dst, FrameBuffer buffer = FB_AUTO);
+
+	protected:
+		Vector<TextureViewPtr> mColorSurfaces;
+		TextureViewPtr mDepthStencilSurface;
+
+		MULTI_RENDER_TEXTURE_CORE_DESC mDesc;
+	};
+
+	/** @} */
 }

+ 160 - 162
Source/BansheeCore/Include/BsOSInputHandler.h

@@ -1,163 +1,161 @@
-//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
-//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
-#pragma once
-
-#include "BsCorePrerequisites.h"
-#include "BsPlatform.h"
-#include "BsEvent.h"
-#include "BsVector2I.h"
-
-namespace BansheeEngine
-{
-	/** @cond INTERNAL */
-	/** @addtogroup Input
-	 *  @{
-	 */
-
-	/**
-	 * Represents a specific way of acquiring OS input. Input class (which provides a higher level input) must have at 
-	 * least one OSInputHandler attached. Attach events handler to the provided signals to handle input.
-	 * 			
-	 * @note		
-	 * Unlike RawInputHandler this class receives input from the operating system, and is used for receiving text input, 
-	 * cursor position and similar.
-	 */
-	class BS_CORE_EXPORT OSInputHandler
-	{
-		/**	Contains information regarding a button state change event. */
-		struct ButtonStateChange
-		{
-			Vector2I cursorPos;
-			OSPointerButtonStates btnStates;
-			OSMouseButton button;
-			bool pressed;
-		};
-
-		/**	Contains information regarding a double click event. */
-		struct DoubleClick
-		{
-			Vector2I cursorPos;
-			OSPointerButtonStates btnStates;
-		};
-
-	public:
-		OSInputHandler();
-		virtual ~OSInputHandler();
-
-		/**
-		 * Called once per frame. Capture input here if needed.
-		 * 			
-		 * @note	Internal method.
-		 */
-		virtual void _update();
-
-		/**
-		 * Called whenever the active window changes.
-		 *
-		 * @param[in]	win	Newly active window.
-		 * 				
-		 * @note	Internal method.
-		 */
-		virtual void _inputWindowChanged(const RenderWindow& win) { }
-
-		/**
-		 * Triggers when user inputs a character. The character might be a result of pressing multiple keys, so character 
-		 * input will not necessarily correspond with button presses. Provide character code of the input character.
-		 */
-		Event<void(UINT32)> onCharInput;
-
-		/**
-		 * Triggers whenever user scrolls the mouse wheel. Returns the screen position of the mouse cursor and delta amount 
-		 * of mouse scroll (can be negative or positive).
-		 */
-		Event<void(const Vector2I&, float)> onMouseWheelScrolled;
-
-		/** Triggers whenever user moves the mouse cursor. */
-		Event<void(const PointerEvent&)> onCursorMoved;
-
-		/**	Triggers whenever user presses one of the mouse buttons. */
-		Event<void(const PointerEvent&)> onCursorPressed;
-
-		/**	Triggers whenever user releases one of the mouse buttons. */
-		Event<void(const PointerEvent&)> onCursorReleased;
-
-		/**	Triggers when user clicks a mouse button quickly twice in a row. */
-		Event<void(const PointerEvent&)> onDoubleClick;
-
-		/**	Triggers when user inputa a special input command, like commands user for manipulating text input. */
-		Event<void(InputCommandType)> onInputCommand;
-
-	private:
-		BS_MUTEX(mOSInputMutex);
-		Vector2I mLastCursorPos;
-		Vector2I mCursorPosition;
-		Vector2I mDelta;
-		bool mLastCursorPosSet;
-		float mMouseScroll;
-		WString mInputString;
-		Queue<ButtonStateChange> mButtonStates;
-		Queue<DoubleClick> mDoubleClicks;
-		Queue<InputCommandType> mInputCommands;
-		OSPointerButtonStates mMouseMoveBtnState;
-
-		HEvent mCharInputConn;
-		HEvent mCursorMovedConn;
-		HEvent mCursorPressedConn;
-		HEvent mCursorReleasedConn;
-		HEvent mCursorDoubleClickConn;
-		HEvent mInputCommandConn;
-		HEvent mMouseWheelScrolledConn;
-
-		/**
-		 * Called from the message loop to notify user has entered a character.
-		 * 			
-		 * @see		onCharInput
-		 */
-		void charInput(UINT32 character);
-
-		/**
-		 * Called from the message loop to notify user has moved the cursor.
-		 * 			
-		 * @see		onCursorMoved
-		 */
-		void cursorMoved(const Vector2I& cursorPos, OSPointerButtonStates& btnStates);
-
-		/**
-		 * Called from the message loop to notify user has pressed a mouse button.
-		 * 			
-		 * @see		onCursorPressed
-		 */
-		void cursorPressed(const Vector2I& cursorPos, OSMouseButton button, OSPointerButtonStates& btnStates);
-
-		/**
-		 * Called from the message loop to notify user has released a mouse button.
-		 * 			
-		 * @see		onCursorReleased
-		 */
-		void cursorReleased(const Vector2I& cursorPos, OSMouseButton button, OSPointerButtonStates& btnStates);
-
-		/**
-		 * Called from the message loop to notify user has double-clicked a mouse button.
-		 * 
-		 * @see		onDoubleClick
-		 */
-		void cursorDoubleClick(const Vector2I& cursorPos, OSPointerButtonStates& btnStates);
-
-		/**
-		 * Called from the message loop to notify user has entered an input command.
-		 * 			
-		 * @see		onInputCommand
-		 */
-		void inputCommandEntered(InputCommandType commandType);
-
-		/**
-		 * Called from the message loop to notify user has scrolled the mouse wheel.
-		 * 			
-		 * @see		onMouseWheelScrolled
-		 */
-		void mouseWheelScrolled(float scrollPos);
-	};
-
-	/** @} */
-	/** @endcond */
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+#pragma once
+
+#include "BsCorePrerequisites.h"
+#include "BsPlatform.h"
+#include "BsEvent.h"
+#include "BsVector2I.h"
+
+namespace BansheeEngine
+{
+	/** @addtogroup Input-Internal
+	 *  @{
+	 */
+
+	/**
+	 * Represents a specific way of acquiring OS input. Input class (which provides a higher level input) must have at 
+	 * least one OSInputHandler attached. Attach events handler to the provided signals to handle input.
+	 * 			
+	 * @note		
+	 * Unlike RawInputHandler this class receives input from the operating system, and is used for receiving text input, 
+	 * cursor position and similar.
+	 */
+	class BS_CORE_EXPORT OSInputHandler
+	{
+		/**	Contains information regarding a button state change event. */
+		struct ButtonStateChange
+		{
+			Vector2I cursorPos;
+			OSPointerButtonStates btnStates;
+			OSMouseButton button;
+			bool pressed;
+		};
+
+		/**	Contains information regarding a double click event. */
+		struct DoubleClick
+		{
+			Vector2I cursorPos;
+			OSPointerButtonStates btnStates;
+		};
+
+	public:
+		OSInputHandler();
+		virtual ~OSInputHandler();
+
+		/**
+		 * Called once per frame. Capture input here if needed.
+		 * 			
+		 * @note	Internal method.
+		 */
+		virtual void _update();
+
+		/**
+		 * Called whenever the active window changes.
+		 *
+		 * @param[in]	win	Newly active window.
+		 * 				
+		 * @note	Internal method.
+		 */
+		virtual void _inputWindowChanged(const RenderWindow& win) { }
+
+		/**
+		 * Triggers when user inputs a character. The character might be a result of pressing multiple keys, so character 
+		 * input will not necessarily correspond with button presses. Provide character code of the input character.
+		 */
+		Event<void(UINT32)> onCharInput;
+
+		/**
+		 * Triggers whenever user scrolls the mouse wheel. Returns the screen position of the mouse cursor and delta amount 
+		 * of mouse scroll (can be negative or positive).
+		 */
+		Event<void(const Vector2I&, float)> onMouseWheelScrolled;
+
+		/** Triggers whenever user moves the mouse cursor. */
+		Event<void(const PointerEvent&)> onCursorMoved;
+
+		/**	Triggers whenever user presses one of the mouse buttons. */
+		Event<void(const PointerEvent&)> onCursorPressed;
+
+		/**	Triggers whenever user releases one of the mouse buttons. */
+		Event<void(const PointerEvent&)> onCursorReleased;
+
+		/**	Triggers when user clicks a mouse button quickly twice in a row. */
+		Event<void(const PointerEvent&)> onDoubleClick;
+
+		/**	Triggers when user inputa a special input command, like commands user for manipulating text input. */
+		Event<void(InputCommandType)> onInputCommand;
+
+	private:
+		BS_MUTEX(mOSInputMutex);
+		Vector2I mLastCursorPos;
+		Vector2I mCursorPosition;
+		Vector2I mDelta;
+		bool mLastCursorPosSet;
+		float mMouseScroll;
+		WString mInputString;
+		Queue<ButtonStateChange> mButtonStates;
+		Queue<DoubleClick> mDoubleClicks;
+		Queue<InputCommandType> mInputCommands;
+		OSPointerButtonStates mMouseMoveBtnState;
+
+		HEvent mCharInputConn;
+		HEvent mCursorMovedConn;
+		HEvent mCursorPressedConn;
+		HEvent mCursorReleasedConn;
+		HEvent mCursorDoubleClickConn;
+		HEvent mInputCommandConn;
+		HEvent mMouseWheelScrolledConn;
+
+		/**
+		 * Called from the message loop to notify user has entered a character.
+		 * 			
+		 * @see		onCharInput
+		 */
+		void charInput(UINT32 character);
+
+		/**
+		 * Called from the message loop to notify user has moved the cursor.
+		 * 			
+		 * @see		onCursorMoved
+		 */
+		void cursorMoved(const Vector2I& cursorPos, OSPointerButtonStates& btnStates);
+
+		/**
+		 * Called from the message loop to notify user has pressed a mouse button.
+		 * 			
+		 * @see		onCursorPressed
+		 */
+		void cursorPressed(const Vector2I& cursorPos, OSMouseButton button, OSPointerButtonStates& btnStates);
+
+		/**
+		 * Called from the message loop to notify user has released a mouse button.
+		 * 			
+		 * @see		onCursorReleased
+		 */
+		void cursorReleased(const Vector2I& cursorPos, OSMouseButton button, OSPointerButtonStates& btnStates);
+
+		/**
+		 * Called from the message loop to notify user has double-clicked a mouse button.
+		 * 
+		 * @see		onDoubleClick
+		 */
+		void cursorDoubleClick(const Vector2I& cursorPos, OSPointerButtonStates& btnStates);
+
+		/**
+		 * Called from the message loop to notify user has entered an input command.
+		 * 			
+		 * @see		onInputCommand
+		 */
+		void inputCommandEntered(InputCommandType commandType);
+
+		/**
+		 * Called from the message loop to notify user has scrolled the mouse wheel.
+		 * 			
+		 * @see		onMouseWheelScrolled
+		 */
+		void mouseWheelScrolled(float scrollPos);
+	};
+
+	/** @} */
 }

+ 1 - 3
Source/BansheeCore/Include/BsParamBlocks.h

@@ -10,8 +10,7 @@
 
 namespace BansheeEngine
 {
-	/** @cond INTERNAL */
-	/** @addtogroup Renderer
+	/** @addtogroup Renderer-Internal
 	 *  @{
 	 */
 
@@ -109,5 +108,4 @@ namespace BansheeEngine
 	};
 
 	/** @} */
-	/** @endcond */
 }

+ 11 - 5
Source/BansheeCore/Include/BsPass.h

@@ -29,7 +29,11 @@ namespace BansheeEngine
 		GpuProgramPtr computeProgram;
 	};
 
-	/** @cond INTERNAL */
+	/** @} */
+
+	/** @addtogroup Material-Internal
+	 *  @{
+	 */
 
 	/** Descriptor structure used for initializing a core thread variant of a shader pass. */
 	struct PASS_DESC_CORE
@@ -47,7 +51,6 @@ namespace BansheeEngine
 		SPtr<GpuProgramCore> computeProgram;
 	};
 
-	/** @endcond */
 	/** @} */
 
 	/** @addtogroup Implementation
@@ -132,10 +135,9 @@ namespace BansheeEngine
 
 	/** @} */
 
-	/** @addtogroup Material
+	/** @addtogroup Material-Internal
 	 *  @{
 	 */
-	/** @cond INTERNAL */
 
 	/**
 	 * @copydoc	TPass
@@ -160,7 +162,11 @@ namespace BansheeEngine
 		/** @copydoc CoreObjectCore::syncToCore */
 		void syncToCore(const CoreSyncData& data) override;
     };
-	/** @endcond */
+
+	/** @} */
+	/** @addtogroup Material
+	 *  @{
+	 */
 
 	/**
 	 * @copydoc	TPass

+ 46 - 48
Source/BansheeCore/Include/BsPhysicsManager.h

@@ -1,49 +1,47 @@
-//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
-//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
-#pragma once
-
-#include "BsCorePrerequisites.h"
-#include "BsModule.h"
-
-namespace BansheeEngine
-{
-	/** @cond INTERNAL */
-	/** @addtogroup Physics
-	 *  @{
-	 */
-
-	/** Creates and destroys a specific physics implementation. */
-	class BS_CORE_EXPORT PhysicsFactory
-	{
-	public:
-		virtual ~PhysicsFactory() { }
-
-		/** Initializes the physics system. */
-		virtual void startUp(bool cooking) = 0;
-
-		/** Shuts down the physics system. */
-		virtual void shutDown() = 0;
-	};
-
-	/** Takes care of loading, initializing and shutting down of a particular physics implementation. */
-	class BS_CORE_EXPORT PhysicsManager : public Module<PhysicsManager>
-	{
-	public:
-		/** 
-		 * Initializes the physics manager and a particular physics implementation. 
-		 *
-		 * @param[in]	pluginName	Name of the plugin containing a physics implementation.
-		 * @param[in]	cookign		Should the cooking library be initialized with physics (normally only needed for 
-		 *							editor).
-		 */
-		PhysicsManager(const String& pluginName, bool cooking);
-		~PhysicsManager();
-
-	private:
-		DynLib* mPlugin;
-		PhysicsFactory* mFactory;
-	};
-
-	/** @} */
-	/** @endcond */
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+#pragma once
+
+#include "BsCorePrerequisites.h"
+#include "BsModule.h"
+
+namespace BansheeEngine
+{
+	/** @addtogroup Physics-Internal
+	 *  @{
+	 */
+
+	/** Creates and destroys a specific physics implementation. */
+	class BS_CORE_EXPORT PhysicsFactory
+	{
+	public:
+		virtual ~PhysicsFactory() { }
+
+		/** Initializes the physics system. */
+		virtual void startUp(bool cooking) = 0;
+
+		/** Shuts down the physics system. */
+		virtual void shutDown() = 0;
+	};
+
+	/** Takes care of loading, initializing and shutting down of a particular physics implementation. */
+	class BS_CORE_EXPORT PhysicsManager : public Module<PhysicsManager>
+	{
+	public:
+		/** 
+		 * Initializes the physics manager and a particular physics implementation. 
+		 *
+		 * @param[in]	pluginName	Name of the plugin containing a physics implementation.
+		 * @param[in]	cookign		Should the cooking library be initialized with physics (normally only needed for 
+		 *							editor).
+		 */
+		PhysicsManager(const String& pluginName, bool cooking);
+		~PhysicsManager();
+
+	private:
+		DynLib* mPlugin;
+		PhysicsFactory* mFactory;
+	};
+
+	/** @} */
 }

+ 4 - 3
Source/BansheeCore/Include/BsPhysicsMesh.h

@@ -71,7 +71,10 @@ namespace BansheeEngine
 		RTTITypeBase* getRTTI() const override;
 	};
 
-	/** @cond INTERNAL */
+	/** @} */
+	/** @addtogroup Physics-Internal
+	 *  @{
+	 */
 
 	/** Foundation that contains a specific implementation of a PhysicsMesh. */
 	class BS_CORE_EXPORT FPhysicsMesh : public IReflectable
@@ -97,7 +100,5 @@ namespace BansheeEngine
 		RTTITypeBase* getRTTI() const override;
 	};
 
-	/** @endcond */
-
 	/** @} */
 }

+ 90 - 92
Source/BansheeCore/Include/BsPixelBuffer.h

@@ -1,93 +1,91 @@
-//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
-//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
-#pragma once
-
-#include "BsCorePrerequisites.h"
-#include "BsHardwareBuffer.h"
-#include "BsPixelUtil.h"
-
-namespace BansheeEngine 
-{
-	/** @cond INTERNAL */
-	/** @addtogroup RenderAPI
-	 *  @{
-	 */
-
-	/**
-	 * Represents a hardware buffer that stores a single pixel surface. This may be a 1D, 2D or 3D surface, but unlike a 
-	 * texture it consists only of a single surface (no mip maps, cube map faces or similar).
-	 *
-	 * @note	Core thread only
-	 */
-    class BS_CORE_EXPORT PixelBuffer : public HardwareBuffer
-    {
-    public:
-		/**
-		 * Constructs a new pixel buffer with the provided settings.
-		 *
-		 * @param[in]	width			Width of the pixel buffer in pixels.
-		 * @param[in]	height			Height of the pixel buffer in pixels.
-		 * @param[in]	depth			Depth of the pixel buffer in pixels (number of 2D slices).
-		 * @param[in]	format			Format of each pixel in the buffer.
-		 * @param[in]	usage			Usage signaling the render system how we plan on using the buffer.
-		 * @param[in]	useSystemMemory	True if buffer should be allocated in system memory.
-		 */
-        PixelBuffer(UINT32 width, UINT32 height, UINT32 depth, PixelFormat format, 
-			GpuBufferUsage usage, bool useSystemMemory);
-        ~PixelBuffer();
-
-		// Make the other lock overloads visible.
-        using HardwareBuffer::lock;	
-
-		/**
-		 * Locks a certain region of the pixel buffer for reading and returns a pointer to the locked region.
-		 *
-		 * @param[in]	lockBox		Region of the surface to lock.
-		 * @param[in]	options		Lock options that hint the hardware on what you intend to do with the locked data.
-		 *
-		 * @note	Returned object is only valid while the lock is active.
-		 */
-		virtual const PixelData& lock(const PixelVolume& lockBox, GpuLockOptions options);
-		
-		/** @copydoc HardwareBuffer::lock */
-        virtual void* lock(UINT32 offset, UINT32 length, GpuLockOptions options);
-		
-		/** @copydoc HardwareBuffer::readData */
-		virtual void readData(UINT32 offset, UINT32 length, void* pDest);
-
-		/** @copydoc HardwareBuffer::writeData */
-		virtual void writeData(UINT32 offset, UINT32 length, const void* pSource, BufferWriteType writeFlags = BufferWriteType::Normal);
-
-		/**	Returns width of the surface in pixels. */
-        UINT32 getWidth() const { return mWidth; }
-
-		/**	Returns height of the surface in pixels. */
-        UINT32 getHeight() const { return mHeight; }
-
-		/**	Returns depth of the surface in pixels. */
-        UINT32 getDepth() const { return mDepth; }
-
-		/**	Returns format of the pixels in the surface. */
-        PixelFormat getFormat() const { return mFormat; }
-
-	protected:
-		friend class RenderTexture;
-
-		/**	Internal implementation of the lock() method. */
-		virtual PixelData lockImpl(PixelVolume lockBox, GpuLockOptions options) = 0;
-
-		/** @copydoc HardwareBuffer::lockImpl */
-		virtual void* lockImpl(UINT32 offset, UINT32 length, GpuLockOptions options);
-
-	protected:
-		UINT32 mWidth, mHeight, mDepth;
-		UINT32 mRowPitch, mSlicePitch;
-		PixelFormat mFormat;
-
-		PixelData mCurrentLock;
-		PixelVolume mLockedBox;
-    };
-
-	/** @} */
-	/** @endcond */
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+#pragma once
+
+#include "BsCorePrerequisites.h"
+#include "BsHardwareBuffer.h"
+#include "BsPixelUtil.h"
+
+namespace BansheeEngine 
+{
+	/** @addtogroup RenderAPI-Internal
+	 *  @{
+	 */
+
+	/**
+	 * Represents a hardware buffer that stores a single pixel surface. This may be a 1D, 2D or 3D surface, but unlike a 
+	 * texture it consists only of a single surface (no mip maps, cube map faces or similar).
+	 *
+	 * @note	Core thread only
+	 */
+    class BS_CORE_EXPORT PixelBuffer : public HardwareBuffer
+    {
+    public:
+		/**
+		 * Constructs a new pixel buffer with the provided settings.
+		 *
+		 * @param[in]	width			Width of the pixel buffer in pixels.
+		 * @param[in]	height			Height of the pixel buffer in pixels.
+		 * @param[in]	depth			Depth of the pixel buffer in pixels (number of 2D slices).
+		 * @param[in]	format			Format of each pixel in the buffer.
+		 * @param[in]	usage			Usage signaling the render system how we plan on using the buffer.
+		 * @param[in]	useSystemMemory	True if buffer should be allocated in system memory.
+		 */
+        PixelBuffer(UINT32 width, UINT32 height, UINT32 depth, PixelFormat format, 
+			GpuBufferUsage usage, bool useSystemMemory);
+        ~PixelBuffer();
+
+		// Make the other lock overloads visible.
+        using HardwareBuffer::lock;	
+
+		/**
+		 * Locks a certain region of the pixel buffer for reading and returns a pointer to the locked region.
+		 *
+		 * @param[in]	lockBox		Region of the surface to lock.
+		 * @param[in]	options		Lock options that hint the hardware on what you intend to do with the locked data.
+		 *
+		 * @note	Returned object is only valid while the lock is active.
+		 */
+		virtual const PixelData& lock(const PixelVolume& lockBox, GpuLockOptions options);
+		
+		/** @copydoc HardwareBuffer::lock */
+        virtual void* lock(UINT32 offset, UINT32 length, GpuLockOptions options);
+		
+		/** @copydoc HardwareBuffer::readData */
+		virtual void readData(UINT32 offset, UINT32 length, void* pDest);
+
+		/** @copydoc HardwareBuffer::writeData */
+		virtual void writeData(UINT32 offset, UINT32 length, const void* pSource, BufferWriteType writeFlags = BufferWriteType::Normal);
+
+		/**	Returns width of the surface in pixels. */
+        UINT32 getWidth() const { return mWidth; }
+
+		/**	Returns height of the surface in pixels. */
+        UINT32 getHeight() const { return mHeight; }
+
+		/**	Returns depth of the surface in pixels. */
+        UINT32 getDepth() const { return mDepth; }
+
+		/**	Returns format of the pixels in the surface. */
+        PixelFormat getFormat() const { return mFormat; }
+
+	protected:
+		friend class RenderTexture;
+
+		/**	Internal implementation of the lock() method. */
+		virtual PixelData lockImpl(PixelVolume lockBox, GpuLockOptions options) = 0;
+
+		/** @copydoc HardwareBuffer::lockImpl */
+		virtual void* lockImpl(UINT32 offset, UINT32 length, GpuLockOptions options);
+
+	protected:
+		UINT32 mWidth, mHeight, mDepth;
+		UINT32 mRowPitch, mSlicePitch;
+		PixelFormat mFormat;
+
+		PixelData mCurrentLock;
+		PixelVolume mLockedBox;
+    };
+
+	/** @} */
 }

+ 1 - 3
Source/BansheeCore/Include/BsPlatform.h

@@ -10,8 +10,7 @@
 
 namespace BansheeEngine
 {
-	/** @cond INTERNAL */
-	/** @addtogroup Platform
+	/** @addtogroup Platform-Internal
 	 *  @{
 	 */
 
@@ -446,5 +445,4 @@ namespace BansheeEngine
 	};
 
 	/** @} */
-	/** @endcond */
 }

+ 155 - 157
Source/BansheeCore/Include/BsPrefabDiff.h

@@ -1,158 +1,156 @@
-//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
-//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
-#pragma once
-
-#include "BsCorePrerequisites.h"
-#include "BsIReflectable.h"
-#include "BsGameObject.h"
-#include "BsVector3.h"
-#include "BsQuaternion.h"
-
-namespace BansheeEngine
-{
-	/** @cond INTERNAL */
-	/** @addtogroup Scene
-	 *  @{
-	 */
-
-	/**
-	 * Contains differences between two components of the same type.
-	 *
-	 * @see		PrefabDiff
-	 */
-	struct BS_CORE_EXPORT PrefabComponentDiff : public IReflectable
-	{
-		INT32 id;
-		SPtr<SerializedObject> data;
-
-		/************************************************************************/
-		/* 								RTTI		                     		*/
-		/************************************************************************/
-
-	public:
-		friend class PrefabComponentDiffRTTI;
-		static RTTITypeBase* getRTTIStatic();
-		virtual RTTITypeBase* getRTTI() const override;
-	};
-
-	/** Flags that mark which portion of a scene-object is modified. */
-	enum class SceneObjectDiffFlags
-	{
-		Name = 0x01,
-		Position = 0x02,
-		Rotation = 0x04,
-		Scale = 0x08,
-		Active = 0x10
-	};
-
-	/**
-	 * Contains a set of prefab differences for a single scene object.
-	 *
-	 * @see		PrefabDiff
-	 */
-	struct BS_CORE_EXPORT PrefabObjectDiff : public IReflectable
-	{
-		UINT32 id = 0;
-
-		String name;
-		Vector3 position;
-		Quaternion rotation;
-		Vector3 scale;
-		bool isActive = false;
-		UINT32 soFlags = 0;
-
-		Vector<SPtr<PrefabComponentDiff>> componentDiffs;
-		Vector<UINT32> removedComponents;
-		Vector<SPtr<SerializedObject>> addedComponents;
-
-		Vector<SPtr<PrefabObjectDiff>> childDiffs;
-		Vector<UINT32> removedChildren;
-		Vector<SPtr<SerializedObject>> addedChildren;
-
-		/************************************************************************/
-		/* 								RTTI		                     		*/
-		/************************************************************************/
-
-	public:
-		friend class PrefabObjectDiffRTTI;
-		static RTTITypeBase* getRTTIStatic();
-		virtual RTTITypeBase* getRTTI() const override;
-	};
-
-	/**
-	 * Contains modifications between an prefab and its instance. The modifications are a set of added/removed children or
-	 * components and per-field "diffs" of their components.
-	 */
-	class BS_CORE_EXPORT PrefabDiff : public IReflectable
-	{
-	public:
-		/**
-		 * Creates a new prefab diff by comparing the provided instanced scene object hierarchy with the prefab scene 
-		 * object hierarchy.
-		 */
-		static SPtr<PrefabDiff> create(const HSceneObject& prefab, const HSceneObject& instance);
-
-		/**
-		 * Applies the internal prefab diff to the provided object. The object should have similar hierarchy as the prefab
-		 * the diff was created for, otherwise the results are undefined.
-		 */
-		void apply(const HSceneObject& object);
-
-	private:
-		/** A reference to a renamed game object instance data, and its original ID so it may be restored later. */
-		struct RenamedGameObject
-		{
-			GameObjectInstanceDataPtr instanceData;
-			UINT64 originalId;
-		};
-
-		/**
-		 * Recurses over every scene object in the prefab a generates differences between itself and the instanced version.
-		 *
-		 * @see		create
-		 */
-		static SPtr<PrefabObjectDiff> generateDiff(const HSceneObject& prefab, const HSceneObject& instance);
-
-		/**
-		 * Recursively applies a per-object set of prefab differences to a specific object.
-		 *
-		 * @see		apply			
-		 */
-		static void applyDiff(const SPtr<PrefabObjectDiff>& diff, const HSceneObject& object);
-
-		/**
-		 * Renames all game objects in the provided instance so that IDs of the objects will match the IDs of their 
-		 * counterparts in the prefab. 
-		 *
-		 * @note	
-		 * This is a temporary action and should be undone by calling restoreInstanceIds() and providing  it with the 
-		 * output of this method. 
-		 * @note
-		 * By doing this before calling generateDiff() we ensure that any game object handles pointing to objects within 
-		 * the prefab instance hierarchy aren't recorded by the diff system, since we want those to remain as they are 
-		 * after applying the diff.
-		 */
-		static void renameInstanceIds(const HSceneObject& prefab, const HSceneObject& instance, Vector<RenamedGameObject>& output);
-
-		/**
-		 * Restores any instance IDs that were modified by the renameInstanceIds() method.
-		 *
-		 * @see		renameInstanceIds
-		 */
-		static void restoreInstanceIds(const Vector<RenamedGameObject>& renamedObjects);
-
-		SPtr<PrefabObjectDiff> mRoot;
-
-		/************************************************************************/
-		/* 								RTTI		                     		*/
-		/************************************************************************/
-
-	public:
-		friend class PrefabDiffRTTI;
-		static RTTITypeBase* getRTTIStatic();
-		virtual RTTITypeBase* getRTTI() const override;
-	};
-
-	/** @} */
-	/** @endcond */
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+#pragma once
+
+#include "BsCorePrerequisites.h"
+#include "BsIReflectable.h"
+#include "BsGameObject.h"
+#include "BsVector3.h"
+#include "BsQuaternion.h"
+
+namespace BansheeEngine
+{
+	/** @addtogroup Scene-Internal
+	 *  @{
+	 */
+
+	/**
+	 * Contains differences between two components of the same type.
+	 *
+	 * @see		PrefabDiff
+	 */
+	struct BS_CORE_EXPORT PrefabComponentDiff : public IReflectable
+	{
+		INT32 id;
+		SPtr<SerializedObject> data;
+
+		/************************************************************************/
+		/* 								RTTI		                     		*/
+		/************************************************************************/
+
+	public:
+		friend class PrefabComponentDiffRTTI;
+		static RTTITypeBase* getRTTIStatic();
+		virtual RTTITypeBase* getRTTI() const override;
+	};
+
+	/** Flags that mark which portion of a scene-object is modified. */
+	enum class SceneObjectDiffFlags
+	{
+		Name = 0x01,
+		Position = 0x02,
+		Rotation = 0x04,
+		Scale = 0x08,
+		Active = 0x10
+	};
+
+	/**
+	 * Contains a set of prefab differences for a single scene object.
+	 *
+	 * @see		PrefabDiff
+	 */
+	struct BS_CORE_EXPORT PrefabObjectDiff : public IReflectable
+	{
+		UINT32 id = 0;
+
+		String name;
+		Vector3 position;
+		Quaternion rotation;
+		Vector3 scale;
+		bool isActive = false;
+		UINT32 soFlags = 0;
+
+		Vector<SPtr<PrefabComponentDiff>> componentDiffs;
+		Vector<UINT32> removedComponents;
+		Vector<SPtr<SerializedObject>> addedComponents;
+
+		Vector<SPtr<PrefabObjectDiff>> childDiffs;
+		Vector<UINT32> removedChildren;
+		Vector<SPtr<SerializedObject>> addedChildren;
+
+		/************************************************************************/
+		/* 								RTTI		                     		*/
+		/************************************************************************/
+
+	public:
+		friend class PrefabObjectDiffRTTI;
+		static RTTITypeBase* getRTTIStatic();
+		virtual RTTITypeBase* getRTTI() const override;
+	};
+
+	/**
+	 * Contains modifications between an prefab and its instance. The modifications are a set of added/removed children or
+	 * components and per-field "diffs" of their components.
+	 */
+	class BS_CORE_EXPORT PrefabDiff : public IReflectable
+	{
+	public:
+		/**
+		 * Creates a new prefab diff by comparing the provided instanced scene object hierarchy with the prefab scene 
+		 * object hierarchy.
+		 */
+		static SPtr<PrefabDiff> create(const HSceneObject& prefab, const HSceneObject& instance);
+
+		/**
+		 * Applies the internal prefab diff to the provided object. The object should have similar hierarchy as the prefab
+		 * the diff was created for, otherwise the results are undefined.
+		 */
+		void apply(const HSceneObject& object);
+
+	private:
+		/** A reference to a renamed game object instance data, and its original ID so it may be restored later. */
+		struct RenamedGameObject
+		{
+			GameObjectInstanceDataPtr instanceData;
+			UINT64 originalId;
+		};
+
+		/**
+		 * Recurses over every scene object in the prefab a generates differences between itself and the instanced version.
+		 *
+		 * @see		create
+		 */
+		static SPtr<PrefabObjectDiff> generateDiff(const HSceneObject& prefab, const HSceneObject& instance);
+
+		/**
+		 * Recursively applies a per-object set of prefab differences to a specific object.
+		 *
+		 * @see		apply			
+		 */
+		static void applyDiff(const SPtr<PrefabObjectDiff>& diff, const HSceneObject& object);
+
+		/**
+		 * Renames all game objects in the provided instance so that IDs of the objects will match the IDs of their 
+		 * counterparts in the prefab. 
+		 *
+		 * @note	
+		 * This is a temporary action and should be undone by calling restoreInstanceIds() and providing  it with the 
+		 * output of this method. 
+		 * @note
+		 * By doing this before calling generateDiff() we ensure that any game object handles pointing to objects within 
+		 * the prefab instance hierarchy aren't recorded by the diff system, since we want those to remain as they are 
+		 * after applying the diff.
+		 */
+		static void renameInstanceIds(const HSceneObject& prefab, const HSceneObject& instance, Vector<RenamedGameObject>& output);
+
+		/**
+		 * Restores any instance IDs that were modified by the renameInstanceIds() method.
+		 *
+		 * @see		renameInstanceIds
+		 */
+		static void restoreInstanceIds(const Vector<RenamedGameObject>& renamedObjects);
+
+		SPtr<PrefabObjectDiff> mRoot;
+
+		/************************************************************************/
+		/* 								RTTI		                     		*/
+		/************************************************************************/
+
+	public:
+		friend class PrefabDiffRTTI;
+		static RTTITypeBase* getRTTIStatic();
+		virtual RTTITypeBase* getRTTI() const override;
+	};
+
+	/** @} */
 }

+ 75 - 77
Source/BansheeCore/Include/BsProfilingManager.h

@@ -1,78 +1,76 @@
-//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
-//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
-#pragma once
-
-#include "BsCorePrerequisites.h"
-#include "BsModule.h"
-#include "BsProfilerCPU.h"
-
-namespace BansheeEngine
-{
-	/** @cond INTERNAL */
-	/** @addtogroup Profiling
-	 *  @{
-	 */
-
-	/**	Contains data about a profiling session. */
-	struct ProfilerReport
-	{
-		CPUProfilerReport cpuReport;
-	};
-
-	/**	Type of thread used by the profiler. */
-	enum class ProfiledThread
-	{
-		Sim,
-		Core
-	};
-
-	/**
-	 * Tracks CPU profiling information with each frame for sim and core threads.
-	 *
-	 * @note	Sim thread only unless specified otherwise.
-	 */
-	class BS_CORE_EXPORT ProfilingManager : public Module<ProfilingManager>
-	{
-	public:
-		ProfilingManager();
-		~ProfilingManager();
-
-		/** Called every frame. */
-		void _update();
-
-		/**
-		 * Called every frame from the core thread.
-		 * 			
-		 * @note	Core thread only.
-		 */
-		void _updateCore();
-
-		/**
-		 * Returns a profiler report for the specified frame, for the specified thread.
-		 *
-		 * @param[in]	Profiler report index, ranging [0, NUM_SAVED_FRAMES]. 0 always returns the latest  report. 
-		 *				Increasing indexes return reports for older and older frames. Out of range  indexes will be clamped.
-		 *
-		 * @note	
-		 * Profiler reports get updated every frame. Oldest reports that no longer fit in the saved reports buffer are 
-		 * discarded.
-		 */
-		const ProfilerReport& getReport(ProfiledThread thread, UINT32 idx = 0) const;
-
-	private:
-		static const UINT32 NUM_SAVED_FRAMES;
-		ProfilerReport* mSavedSimReports;
-		UINT32 mNextSimReportIdx;
-
-		ProfilerReport* mSavedCoreReports;
-		UINT32 mNextCoreReportIdx;
-
-		BS_MUTEX(mSync);
-	};
-
-	/** Easy way to access ProfilingManager. */
-	BS_CORE_EXPORT ProfilingManager& gProfiler();
-
-	/** @} */
-	/** @endcond */
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+#pragma once
+
+#include "BsCorePrerequisites.h"
+#include "BsModule.h"
+#include "BsProfilerCPU.h"
+
+namespace BansheeEngine
+{
+	/** @addtogroup Profiling-Internal
+	 *  @{
+	 */
+
+	/**	Contains data about a profiling session. */
+	struct ProfilerReport
+	{
+		CPUProfilerReport cpuReport;
+	};
+
+	/**	Type of thread used by the profiler. */
+	enum class ProfiledThread
+	{
+		Sim,
+		Core
+	};
+
+	/**
+	 * Tracks CPU profiling information with each frame for sim and core threads.
+	 *
+	 * @note	Sim thread only unless specified otherwise.
+	 */
+	class BS_CORE_EXPORT ProfilingManager : public Module<ProfilingManager>
+	{
+	public:
+		ProfilingManager();
+		~ProfilingManager();
+
+		/** Called every frame. */
+		void _update();
+
+		/**
+		 * Called every frame from the core thread.
+		 * 			
+		 * @note	Core thread only.
+		 */
+		void _updateCore();
+
+		/**
+		 * Returns a profiler report for the specified frame, for the specified thread.
+		 *
+		 * @param[in]	Profiler report index, ranging [0, NUM_SAVED_FRAMES]. 0 always returns the latest  report. 
+		 *				Increasing indexes return reports for older and older frames. Out of range  indexes will be clamped.
+		 *
+		 * @note	
+		 * Profiler reports get updated every frame. Oldest reports that no longer fit in the saved reports buffer are 
+		 * discarded.
+		 */
+		const ProfilerReport& getReport(ProfiledThread thread, UINT32 idx = 0) const;
+
+	private:
+		static const UINT32 NUM_SAVED_FRAMES;
+		ProfilerReport* mSavedSimReports;
+		UINT32 mNextSimReportIdx;
+
+		ProfilerReport* mSavedCoreReports;
+		UINT32 mNextCoreReportIdx;
+
+		BS_MUTEX(mSync);
+	};
+
+	/** Easy way to access ProfilingManager. */
+	BS_CORE_EXPORT ProfilingManager& gProfiler();
+
+	/** @} */
 }

+ 84 - 86
Source/BansheeCore/Include/BsQueryManager.h

@@ -1,87 +1,85 @@
-//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
-//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
-#pragma once
-
-#include "BsCorePrerequisites.h"
-#include "BsEventQuery.h"
-#include "BsModule.h"
-
-namespace BansheeEngine
-{
-	/** @cond INTERNAL */
-	/** @addtogroup RenderAPI
-	 *  @{
-	 */
-
-	/**
-	 * Handles creation and destruction of GPU queries.
-	 * 			
-	 * @note	Core thread only.
-	 */
-	class BS_CORE_EXPORT QueryManager : public Module<QueryManager>
-	{
-	public:
-		QueryManager();
-		~QueryManager();
-
-		/** Creates a new event query that allows you to get notified when GPU starts executing the query. */
-		virtual EventQueryPtr createEventQuery() const = 0;
-
-		/**
-		 * Creates a new timer query that allows you to get notified of how much time has passed between query start and end.
-		 */
-		virtual TimerQueryPtr createTimerQuery() const = 0;
-
-		/**
-		 * Creates a new occlusion query that allows you to know how many fragments were rendered between query start and 
-		 * end.
-		 *
-		 * @param[in] binary	If query is binary it will not give you an exact count of fragments rendered, but will 
-		 *						instead just return 0 (no fragments were rendered) or 1 (one or more fragments were 
-		 *						rendered). Binary queries can return sooner as they potentially do not need to wait until 
-		 *						all of the geometry is rendered.
-		 */
-		virtual OcclusionQueryPtr createOcclusionQuery(bool binary) const = 0;
-
-		/** Triggers completed queries. Should be called every frame. */
-		void _update();
-
-	protected:
-		friend class EventQuery;
-		friend class TimerQuery;
-		friend class OcclusionQuery;
-
-		/**
-		 * Deletes an Event query. Always use this method and don't delete them manually. Actual deletion will be delayed 
-		 * until next update.
-		 */
-		static void deleteEventQuery(EventQuery* query);
-
-		/**
-		 * Deletes a Timer query. Always use this method and don't delete them manually. Actual deletion will be delayed 
-		 * until next update.
-		 */
-		static void deleteTimerQuery(TimerQuery* query);
-
-		/**
-		 * Deletes an Occlusion query. Always use this method and don't delete them manually. Actual deletion will be 
-		 * delayed until next update.
-		 */
-		static void deleteOcclusionQuery(OcclusionQuery* query);
-
-		/** Deletes any queued queries. */
-		void processDeletedQueue();
-
-	protected:
-		mutable Vector<EventQuery*> mEventQueries;
-		mutable Vector<TimerQuery*> mTimerQueries;
-		mutable Vector<OcclusionQuery*> mOcclusionQueries;
-
-		mutable Vector<EventQuery*> mDeletedEventQueries;
-		mutable Vector<TimerQuery*> mDeletedTimerQueries;
-		mutable Vector<OcclusionQuery*> mDeletedOcclusionQueries;
-	};
-
-	/** @} */
-	/** @endcond */
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+#pragma once
+
+#include "BsCorePrerequisites.h"
+#include "BsEventQuery.h"
+#include "BsModule.h"
+
+namespace BansheeEngine
+{
+	/** @addtogroup RenderAPI-Internal
+	 *  @{
+	 */
+
+	/**
+	 * Handles creation and destruction of GPU queries.
+	 * 			
+	 * @note	Core thread only.
+	 */
+	class BS_CORE_EXPORT QueryManager : public Module<QueryManager>
+	{
+	public:
+		QueryManager();
+		~QueryManager();
+
+		/** Creates a new event query that allows you to get notified when GPU starts executing the query. */
+		virtual EventQueryPtr createEventQuery() const = 0;
+
+		/**
+		 * Creates a new timer query that allows you to get notified of how much time has passed between query start and end.
+		 */
+		virtual TimerQueryPtr createTimerQuery() const = 0;
+
+		/**
+		 * Creates a new occlusion query that allows you to know how many fragments were rendered between query start and 
+		 * end.
+		 *
+		 * @param[in] binary	If query is binary it will not give you an exact count of fragments rendered, but will 
+		 *						instead just return 0 (no fragments were rendered) or 1 (one or more fragments were 
+		 *						rendered). Binary queries can return sooner as they potentially do not need to wait until 
+		 *						all of the geometry is rendered.
+		 */
+		virtual OcclusionQueryPtr createOcclusionQuery(bool binary) const = 0;
+
+		/** Triggers completed queries. Should be called every frame. */
+		void _update();
+
+	protected:
+		friend class EventQuery;
+		friend class TimerQuery;
+		friend class OcclusionQuery;
+
+		/**
+		 * Deletes an Event query. Always use this method and don't delete them manually. Actual deletion will be delayed 
+		 * until next update.
+		 */
+		static void deleteEventQuery(EventQuery* query);
+
+		/**
+		 * Deletes a Timer query. Always use this method and don't delete them manually. Actual deletion will be delayed 
+		 * until next update.
+		 */
+		static void deleteTimerQuery(TimerQuery* query);
+
+		/**
+		 * Deletes an Occlusion query. Always use this method and don't delete them manually. Actual deletion will be 
+		 * delayed until next update.
+		 */
+		static void deleteOcclusionQuery(OcclusionQuery* query);
+
+		/** Deletes any queued queries. */
+		void processDeletedQueue();
+
+	protected:
+		mutable Vector<EventQuery*> mEventQueries;
+		mutable Vector<TimerQuery*> mTimerQueries;
+		mutable Vector<OcclusionQuery*> mOcclusionQueries;
+
+		mutable Vector<EventQuery*> mDeletedEventQueries;
+		mutable Vector<TimerQuery*> mDeletedTimerQueries;
+		mutable Vector<OcclusionQuery*> mDeletedOcclusionQueries;
+	};
+
+	/** @} */
 }

+ 40 - 38
Source/BansheeCore/Include/BsRasterizerState.h

@@ -118,44 +118,6 @@ namespace BansheeEngine
 		UINT64 mHash;
 	};
 
-	/** @cond INTERNAL */
-
-	/**
-	 * Core thread version of RasterizerState.
-	 *
-	 * @note	Core thread.
-	 */
-	class BS_CORE_EXPORT RasterizerStateCore : public CoreObjectCore
-	{
-	public:
-		virtual ~RasterizerStateCore();
-
-		/** Returns information about the rasterizer state. */
-		const RasterizerProperties& getProperties() const;
-
-		/**	Returns a unique state ID. Only the lowest 10 bits are used. */
-		UINT32 getId() const { return mId; }
-
-		/** Returns the default rasterizer state. */
-		static const SPtr<RasterizerStateCore>& getDefault();
-
-	protected:
-		friend class RenderStateCoreManager;
-
-		RasterizerStateCore(const RASTERIZER_STATE_DESC& desc, UINT32 id);
-
-		/** @copydoc CoreObjectCore::initialize */
-		void initialize() override;
-
-		/**	Creates any API-specific state objects. */
-		virtual void createInternal() { }
-
-		RasterizerProperties mProperties;
-		UINT32 mId;
-	};
-
-	/** @endcond */
-
 	/**
 	 * Render system pipeline state that allows you to modify how an object is rasterized (how are polygons converted
 	 * to pixels).
@@ -204,6 +166,46 @@ namespace BansheeEngine
 	};
 
 	/** @} */
+
+	/** @addtogroup RenderAPI-Internal
+	 *  @{
+	 */
+
+	/**
+	 * Core thread version of RasterizerState.
+	 *
+	 * @note	Core thread.
+	 */
+	class BS_CORE_EXPORT RasterizerStateCore : public CoreObjectCore
+	{
+	public:
+		virtual ~RasterizerStateCore();
+
+		/** Returns information about the rasterizer state. */
+		const RasterizerProperties& getProperties() const;
+
+		/**	Returns a unique state ID. Only the lowest 10 bits are used. */
+		UINT32 getId() const { return mId; }
+
+		/** Returns the default rasterizer state. */
+		static const SPtr<RasterizerStateCore>& getDefault();
+
+	protected:
+		friend class RenderStateCoreManager;
+
+		RasterizerStateCore(const RASTERIZER_STATE_DESC& desc, UINT32 id);
+
+		/** @copydoc CoreObjectCore::initialize */
+		void initialize() override;
+
+		/**	Creates any API-specific state objects. */
+		virtual void createInternal() { }
+
+		RasterizerProperties mProperties;
+		UINT32 mId;
+	};
+
+	/** @} */
 }
 
 /** @cond STDLIB */

+ 84 - 86
Source/BansheeCore/Include/BsRawInputHandler.h

@@ -1,87 +1,85 @@
-//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
-//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
-#pragma once
-
-#include "BsCorePrerequisites.h"
-#include "BsInputFwd.h"
-#include "BsEvent.h"
-
-namespace BansheeEngine
-{
-	/** @cond INTERNAL */
-	/** @addtogroup Input
-	 *  @{
-	 */
-
-	/**
-	 * Contains relative and absolute position of an input axis. Relative state represents the difference between current 
-	 * and last state.
-	 */
-	struct RawAxisState
-	{
-		RawAxisState()
-		 :rel(0.0f), abs(0.0f)
-		{ }
-
-		float rel;
-		float abs;
-	};
-
-	/**
-	 * Represents a specific way of acquiring low-level input. Input class (which provides a higher level input) must have 
-	 * at least one RawInputHandler attached. Raw input handlers receive input as sent by the hardware without OS 
-	 * modifications.
-	 */
-	class BS_CORE_EXPORT RawInputHandler
-	{
-	public:
-		RawInputHandler()
-			:mMouseSmoothingEnabled(false) 
-		{}
-
-		virtual ~RawInputHandler() {}
-
-		/**
-		 * Triggered when user presses a button. Parameters include device index, button code of the pressed button, 
-		 * and a timestamp of the button press event.
-		 */
-		Event<void(UINT32, ButtonCode, UINT64)> onButtonDown;
-
-		/**
-		 * Triggered when user releases a button. Parameters include device index, button code of the released button, 
-		 * and a timestamp of the button release event.
-		 */
-		Event<void(UINT32, ButtonCode, UINT64)> onButtonUp;
-
-		/**
-		 * Triggered whenever the specified axis state changes. Parameters include device index, axis state data, and axis 
-		 * type.
-		 */
-		Event<void(UINT32, const RawAxisState&, UINT32)> onAxisMoved;
-
-		/**
-		 * Called once per frame. Capture input here if needed.
-		 * 			
-		 * @note	Internal method.
-		 */
-		virtual void _update() {}
-
-		/**
-		 * Called whenever the active window changes.
-		 *
-		 * @param[in]	win	Newly active window.
-		 * 				
-		 * @note	Internal method.
-		 */
-		virtual void _inputWindowChanged(const RenderWindow& win) {}
-
-		/** Enables or disables mouse smoothing. Smoothing makes the changes to mouse axes more gradual. */
-		void setMouseSmoothing(bool enabled) { mMouseSmoothingEnabled = enabled; }
-
-	protected:
-		bool mMouseSmoothingEnabled;
-	};
-
-	/** @} */
-	/** @endcond */
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+#pragma once
+
+#include "BsCorePrerequisites.h"
+#include "BsInputFwd.h"
+#include "BsEvent.h"
+
+namespace BansheeEngine
+{
+	/** @addtogroup Input-Internal
+	 *  @{
+	 */
+
+	/**
+	 * Contains relative and absolute position of an input axis. Relative state represents the difference between current 
+	 * and last state.
+	 */
+	struct RawAxisState
+	{
+		RawAxisState()
+		 :rel(0.0f), abs(0.0f)
+		{ }
+
+		float rel;
+		float abs;
+	};
+
+	/**
+	 * Represents a specific way of acquiring low-level input. Input class (which provides a higher level input) must have 
+	 * at least one RawInputHandler attached. Raw input handlers receive input as sent by the hardware without OS 
+	 * modifications.
+	 */
+	class BS_CORE_EXPORT RawInputHandler
+	{
+	public:
+		RawInputHandler()
+			:mMouseSmoothingEnabled(false) 
+		{}
+
+		virtual ~RawInputHandler() {}
+
+		/**
+		 * Triggered when user presses a button. Parameters include device index, button code of the pressed button, 
+		 * and a timestamp of the button press event.
+		 */
+		Event<void(UINT32, ButtonCode, UINT64)> onButtonDown;
+
+		/**
+		 * Triggered when user releases a button. Parameters include device index, button code of the released button, 
+		 * and a timestamp of the button release event.
+		 */
+		Event<void(UINT32, ButtonCode, UINT64)> onButtonUp;
+
+		/**
+		 * Triggered whenever the specified axis state changes. Parameters include device index, axis state data, and axis 
+		 * type.
+		 */
+		Event<void(UINT32, const RawAxisState&, UINT32)> onAxisMoved;
+
+		/**
+		 * Called once per frame. Capture input here if needed.
+		 * 			
+		 * @note	Internal method.
+		 */
+		virtual void _update() {}
+
+		/**
+		 * Called whenever the active window changes.
+		 *
+		 * @param[in]	win	Newly active window.
+		 * 				
+		 * @note	Internal method.
+		 */
+		virtual void _inputWindowChanged(const RenderWindow& win) {}
+
+		/** Enables or disables mouse smoothing. Smoothing makes the changes to mouse axes more gradual. */
+		void setMouseSmoothing(bool enabled) { mMouseSmoothingEnabled = enabled; }
+
+	protected:
+		bool mMouseSmoothingEnabled;
+	};
+
+	/** @} */
 }

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

@@ -185,7 +185,10 @@ namespace BansheeEngine
 		bool mColumnMajorMatrices = false;
 	};
 
-	/** @cond INTERNAL */
+	/** @} */
+	/** @addtogroup RenderAPI-Internal
+	 *  @{
+	 */
 
 	/**
 	 * Render system provides base functionality for a rendering API like DirectX or OpenGL. Most of the class is abstract
@@ -501,6 +504,5 @@ namespace BansheeEngine
 		VideoModeInfoPtr mVideoModeInfo;
 	};
 
-	/** @endcond */
 	/** @} */
 }

+ 534 - 536
Source/BansheeCore/Include/BsRenderAPICapabilities.h

@@ -1,537 +1,535 @@
-//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
-//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
-#pragma once
-
-#include "BsCorePrerequisites.h"
-#include "BsGpuProgram.h"
-
-#define CAPS_CATEGORY_SIZE 8i64
-#define BS_CAPS_BITSHIFT (64i64 - CAPS_CATEGORY_SIZE)
-#define CAPS_CATEGORY_MASK (((1i64 << CAPS_CATEGORY_SIZE) - 1i64) << BS_CAPS_BITSHIFT)
-#define BS_CAPS_VALUE(cat, val) ((cat << BS_CAPS_BITSHIFT) | (1i64 << val))
-
-#define MAX_BOUND_VERTEX_BUFFERS 32
-
-namespace BansheeEngine 
-{
-	/** @cond INTERNAL */
-	/** @addtogroup RenderAPI
-	 *  @{
-	 */
-
-	/** Categories of render API capabilities. */
-	enum CapabilitiesCategory : UINT64
-	{
-		CAPS_CATEGORY_COMMON = 0,
-		CAPS_CATEGORY_D3D9 = 1,
-		CAPS_CATEGORY_GL = 2,
-		CAPS_CATEGORY_D3D11 = 3,
-		CAPS_CATEGORY_COUNT = 32 /**< Maximum number of categories. */
-	};
-
-	/** Enum describing the different hardware capabilities we can check for. */
-	enum Capabilities : UINT64
-	{
-		RSC_AUTOMIPMAP				= BS_CAPS_VALUE(CAPS_CATEGORY_COMMON, 0), /**< Supports generating mipmaps in hardware. */
-		RSC_ANISOTROPY				= BS_CAPS_VALUE(CAPS_CATEGORY_COMMON, 1), /**< Supports anisotropic texture filtering. */
-		RSC_CUBEMAPPING				= BS_CAPS_VALUE(CAPS_CATEGORY_COMMON, 2), /**< Supports cube mapping. */
-		RSC_TWO_SIDED_STENCIL		= BS_CAPS_VALUE(CAPS_CATEGORY_COMMON, 3), /**< Supports separate stencil updates for both front and back faces. */
-		RSC_STENCIL_WRAP			= BS_CAPS_VALUE(CAPS_CATEGORY_COMMON, 4), /**< Supports wrapping the stencil value at the range extremes. */
-		RSC_HWOCCLUSION				= BS_CAPS_VALUE(CAPS_CATEGORY_COMMON, 5), /**< Supports hardware occlusion queries. */
-		RSC_USER_CLIP_PLANES		= BS_CAPS_VALUE(CAPS_CATEGORY_COMMON, 6), /**< Supports user clipping planes. */
-		RSC_VERTEX_FORMAT_UBYTE4	= BS_CAPS_VALUE(CAPS_CATEGORY_COMMON, 7), /**< Supports the VET_UBYTE4 vertex element type. */
-		RSC_INFINITE_FAR_PLANE		= BS_CAPS_VALUE(CAPS_CATEGORY_COMMON, 8), /**< Supports infinite far plane projection. */
-		RSC_HWRENDER_TO_TEXTURE		= BS_CAPS_VALUE(CAPS_CATEGORY_COMMON, 9), /**< Supports hardware render-to-texture. */
-		RSC_TEXTURE_FLOAT			= BS_CAPS_VALUE(CAPS_CATEGORY_COMMON, 10), /**< Supports float textures and render targets. */
-		RSC_NON_POWER_OF_2_TEXTURES = BS_CAPS_VALUE(CAPS_CATEGORY_COMMON, 11), /**< Supports non-power of two textures. */
-		RSC_TEXTURE_3D				= BS_CAPS_VALUE(CAPS_CATEGORY_COMMON, 12), /**< Supports 3d (volume) textures. */
-		RSC_POINT_SPRITES			= BS_CAPS_VALUE(CAPS_CATEGORY_COMMON, 13), /**< Supports basic point sprite rendering. */
-
-		RSC_POINT_EXTENDED_PARAMETERS	= BS_CAPS_VALUE(CAPS_CATEGORY_COMMON, 14), /**< Supports extra point parameters (minsize, maxsize, attenuation). */
-		RSC_VERTEX_TEXTURE_FETCH		= BS_CAPS_VALUE(CAPS_CATEGORY_COMMON, 15), /**< Supports vertex texture fetch. */
-		RSC_MIPMAP_LOD_BIAS				= BS_CAPS_VALUE(CAPS_CATEGORY_COMMON, 16), /**< Supports mipmap LOD biasing. */
-		RSC_GEOMETRY_PROGRAM			= BS_CAPS_VALUE(CAPS_CATEGORY_COMMON, 17), /**< Supports hardware geometry programs. */
-
-		RSC_TEXTURE_COMPRESSION			= BS_CAPS_VALUE(CAPS_CATEGORY_COMMON, 18), /**< Supports compressed textures. */
-		RSC_TEXTURE_COMPRESSION_DXT		= BS_CAPS_VALUE(CAPS_CATEGORY_COMMON, 19), /**< Supports compressed textures in the DXT/ST3C formats. */
-		RSC_TEXTURE_COMPRESSION_VTC		= BS_CAPS_VALUE(CAPS_CATEGORY_COMMON, 20), /**< Supports compressed textures in the VTC format. */
-		RSC_TEXTURE_COMPRESSION_PVRTC	= BS_CAPS_VALUE(CAPS_CATEGORY_COMMON, 21), /**< Supports compressed textures in the PVRTC format. */
-		RSC_MRT_DIFFERENT_BIT_DEPTHS	= BS_CAPS_VALUE(CAPS_CATEGORY_COMMON, 22), /**< Supports multiple render targets with different bit depths. */
-		RSC_ALPHA_TO_COVERAGE			= BS_CAPS_VALUE(CAPS_CATEGORY_COMMON, 23), /**< Supports Alpha to Coverage. */
-		RSC_ADVANCED_BLEND_OPERATIONS	= BS_CAPS_VALUE(CAPS_CATEGORY_COMMON, 24), /**< Supports blend operations like subtract, min, max. */
-		RSC_SHADER_SUBROUTINE			= BS_CAPS_VALUE(CAPS_CATEGORY_COMMON, 25), /**< Supports dynamic shader linking. */
-		RSC_HWOCCLUSION_ASYNCHRONOUS	= BS_CAPS_VALUE(CAPS_CATEGORY_COMMON, 26), /**< Support for async occlusion queries. */
-		RSC_HWRENDER_TO_VERTEX_BUFFER	= BS_CAPS_VALUE(CAPS_CATEGORY_COMMON, 27), /**< Supports rendering to vertex buffers. */
-		RSC_TESSELLATION_PROGRAM		= BS_CAPS_VALUE(CAPS_CATEGORY_COMMON, 28), /**< Supports hardware tessellation programs. */
-		RSC_COMPUTE_PROGRAM				= BS_CAPS_VALUE(CAPS_CATEGORY_COMMON, 29), /**< Supports hardware compute programs. */
-
-		// ***** DirectX 9 specific caps *****
-		RSC_PERSTAGECONSTANT = BS_CAPS_VALUE(CAPS_CATEGORY_D3D9, 0), /**< Are per stage constants supported. */
-
-		// ***** GL Specific caps *****
-		RSC_FBO              = BS_CAPS_VALUE(CAPS_CATEGORY_GL, 0), /**< Support for Frame Buffer Objects. */
-		RSC_PBUFFER			 = BS_CAPS_VALUE(CAPS_CATEGORY_GL, 1), /**< Support for PBuffers. */
-	};
-
-	/** Holds data about render system driver version. */
-	struct BS_CORE_EXPORT DriverVersion 
-	{
-		int major;
-		int minor;
-		int release;
-		int build;
-
-		DriverVersion() 
-		{
-			major = minor = release = build = 0;
-		}
-
-		/**	Returns the driver version as a single string. */
-		String toString() const 
-		{
-			StringStream str;
-			str << major << "." << minor << "." << release << "." << build;
-			return str.str();
-		}
-
-		/** Parses a string in the major.minor.release.build format and stores the version numbers. */
-		void fromString(const String& versionString)
-		{
-			Vector<BansheeEngine::String> tokens = StringUtil::split(versionString, ".");
-			if(!tokens.empty())
-			{
-				major = parseINT32(tokens[0]);
-				if (tokens.size() > 1)
-					minor = parseINT32(tokens[1]);
-				if (tokens.size() > 2)
-					release = parseINT32(tokens[2]);
-				if (tokens.size() > 3)
-					build = parseINT32(tokens[3]);
-			}
-
-		}
-	};
-
-	/** Types of GPU vendors. */
-	enum GPUVendor
-	{
-		GPU_UNKNOWN = 0,
-		GPU_NVIDIA = 1,
-		GPU_AMD = 2, 
-		GPU_INTEL = 3,
-		GPU_VENDOR_COUNT = 4
-	};
-
-	/**
-	 * Holds information about render hardware and driver capabilities and allows you to easily set and query those 
-	 * capabilities.
-	 */
-	class BS_CORE_EXPORT RenderAPICapabilities
-	{
-	public:	
-		RenderAPICapabilities ();
-		virtual ~RenderAPICapabilities ();
-
-		/** Sets the current driver version. */
-		void setDriverVersion(const DriverVersion& version)
-		{
-			mDriverVersion = version;
-		}
-		
-		/**	Returns current driver version. */
-		DriverVersion getDriverVersion() const
-		{
-			return mDriverVersion;
-		}
-
-		/**	Returns vendor of the currently used GPU. */
-		GPUVendor getVendor() const
-		{
-			return mVendor;
-		}
-
-		/**	Sets the GPU vendor. */
-		void setVendor(GPUVendor v)
-		{
-			mVendor = v;
-		}
-
-		/** Parses a vendor string and returns an enum with the vendor if parsed succesfully. */
-		static GPUVendor vendorFromString(const String& vendorString);
-
-		/** Converts a vendor enum to a string. */
-		static String vendorToString(GPUVendor v);
-
-		/**	Sets the maximum number of texture units per pipeline stage. */
-		void setNumTextureUnits(GpuProgramType type, UINT16 num)
-		{
-			mNumTextureUnitsPerStage[type] = num;
-		}
-
-		/** Sets the maximum number of texture units in all pipeline stages. */
-		void setNumCombinedTextureUnits(UINT16 num)
-		{
-			mNumCombinedTextureUnits = num;
-		}
-
-		/**	Sets the maximum number of GPU param block buffers per pipeline stage. */
-		void setNumGpuParamBlockBuffers(GpuProgramType type, UINT16 num)
-		{
-			mNumGpuParamBlocksPerStage[type] = num;
-		}
-
-		/**	Sets the maximum number of GPU param block buffers in all pipeline stages. */
-		void setNumCombinedGpuParamBlockBuffers(UINT16 num)
-		{
-			mNumCombinedUniformBlocks = num;
-		}
-
-		/**	Sets maximum stencil buffer depth in bits. */
-		void setStencilBufferBitDepth(UINT16 num)
-		{
-			mStencilBufferBitDepth = num;
-		}
-
-		/**	Sets maximum number of bound vertex buffers. */
-		void setMaxBoundVertexBuffers(UINT32 num)
-		{
-			mMaxBoundVertexBuffers = num;
-		}
-
-		/**	Sets maximum number of simultaneously set render targets. */
-		void setNumMultiRenderTargets(UINT16 num)
-		{
-			mNumMultiRenderTargets = num;
-		}
-
-		/**	Returns the number of texture units supported per pipeline stage. */
-		UINT16 getNumTextureUnits(GpuProgramType type) const
-		{
-			auto iterFind = mNumTextureUnitsPerStage.find(type);
-			if(iterFind != mNumTextureUnitsPerStage.end())
-				return iterFind->second;
-			else
-				return 0;
-		}
-
-		/**	Returns the number of texture units supported in all pipeline stages. */
-		UINT16 getNumCombinedTextureUnits() const
-		{
-			return mNumCombinedTextureUnits;
-		}
-
-		/**	Returns the maximum number of bound GPU program param block buffers per pipeline stage. */
-		UINT16 getNumGpuParamBlockBuffers(GpuProgramType type) const
-		{
-			auto iterFind = mNumGpuParamBlocksPerStage.find(type);
-			if(iterFind != mNumGpuParamBlocksPerStage.end())
-				return iterFind->second;
-			else
-				return 0;
-		}
-
-		/** Returns the maximum number of bound GPU program param block buffers in all pipeline stages. */
-		UINT16 getNumCombinedGpuParamBlockBuffers() const
-		{
-			return mNumCombinedUniformBlocks;
-		}
-
-		/** Returns the maximum number of bits available for the stencil buffer. */
-		UINT16 getStencilBufferBitDepth() const
-		{
-			return mStencilBufferBitDepth;
-		}
-
-		/** Returns the maximum number of vertex buffers that can be bound at once. */
-		UINT32 getMaxBoundVertexBuffers() const
-		{
-			return mMaxBoundVertexBuffers;
-		}
-
-		/**	Returns the maximum number of render targets we can render to simultaneously. */
-		UINT16 getNumMultiRenderTargets() const
-		{
-			return mNumMultiRenderTargets;
-		}
-
-		/**	Sets a capability flag indicating this capability is supported. */
-		void setCapability(const Capabilities c) 
-		{ 
-			UINT64 index = (CAPS_CATEGORY_MASK & c) >> BS_CAPS_BITSHIFT;
-			mCapabilities[index] |= (c & ~CAPS_CATEGORY_MASK);
-		}
-
-		/**	Remove a capability flag indicating this capability is not supported (default). */
-		void unsetCapability(const Capabilities c) 
-		{ 
-			UINT64 index = (CAPS_CATEGORY_MASK & c) >> BS_CAPS_BITSHIFT;
-			mCapabilities[index] &= (~c | CAPS_CATEGORY_MASK);
-		}
-
-		/**	Checks is the specified capability supported. */
-		bool hasCapability(const Capabilities c) const
-		{
-			UINT64 index = (CAPS_CATEGORY_MASK & c) >> BS_CAPS_BITSHIFT;
-
-			return (mCapabilities[index] & (c & ~CAPS_CATEGORY_MASK)) != 0;
-		}
-
-		/**	Adds a shader profile to the list of render-system specific supported profiles. */
-		void addShaderProfile(const String& profile)
-		{
-			mSupportedShaderProfiles.insert(profile);
-		}
-
-		/**	Adds a mapping between GPU program profile enum and render-system specific profile name. */
-		void addGpuProgramProfile(GpuProgramProfile gpuProgProfile, const String& rsSpecificProfile)
-		{
-			mGenericToSpecificShaderProfileMap[gpuProgProfile] = rsSpecificProfile;
-		}
-
-		/**	Returns true if the provided profile is supported. */
-		bool isShaderProfileSupported(const String& profile) const
-		{
-			return (mSupportedShaderProfiles.end() != mSupportedShaderProfiles.find(profile));
-		}
-
-		/**	Returns a set of all supported shader profiles. */
-		const Set<String>& getSupportedShaderProfiles() const
-		{
-			return mSupportedShaderProfiles;
-		}
-
-		/**
-		 * Converts a generic GpuProgramProfile identifier into a render-system specific one. Returns an empty string if 
-		 * conversion cannot be done.
-		 */
-		String gpuProgProfileToRSSpecificProfile(GpuProgramProfile gpuProgProfile) const
-		{
-			auto iterFind = mGenericToSpecificShaderProfileMap.find(gpuProgProfile);
-			if(mGenericToSpecificShaderProfileMap.end() != iterFind)
-			{
-				return iterFind->second;
-			}
-
-			return "";
-		}
-
-		/** Gets the number of floating-point constants vertex programs support. */
-		UINT16 getVertexProgramConstantFloatCount() const
-		{
-			return mVertexProgramConstantFloatCount;           
-		}
-
-		/**	Gets the number of integer constants vertex programs support. */
-		UINT16 getVertexProgramConstantIntCount() const
-		{
-			return mVertexProgramConstantIntCount;           
-		}
-
-		/**	Gets the number of boolean constants vertex programs support. */
-		UINT16 getVertexProgramConstantBoolCount() const
-		{
-			return mVertexProgramConstantBoolCount;           
-		}
-
-		/**	Gets the number of floating-point constants geometry programs support. */
-		UINT16 getGeometryProgramConstantFloatCount() const
-		{
-			return mGeometryProgramConstantFloatCount;           
-		}
-
-		/**	 Gets the number of integer constants geometry programs support. */
-		UINT16 getGeometryProgramConstantIntCount() const
-		{
-			return mGeometryProgramConstantIntCount;           
-		}
-
-		/**	 Gets the number of boolean constants geometry programs support. */
-		UINT16 getGeometryProgramConstantBoolCount() const
-		{
-			return mGeometryProgramConstantBoolCount;           
-		}
-
-		/**	Gets the number of floating-point constants fragment programs support. */
-		UINT16 getFragmentProgramConstantFloatCount() const
-		{
-			return mFragmentProgramConstantFloatCount;           
-		}
-
-		/**	Gets the number of integer constants fragment programs support. */
-		UINT16 getFragmentProgramConstantIntCount() const
-		{
-			return mFragmentProgramConstantIntCount;           
-		}
-		
-		/** Gets the number of boolean constants fragment programs support. */
-		UINT16 getFragmentProgramConstantBoolCount() const
-		{
-			return mFragmentProgramConstantBoolCount;           
-		}
-
-		/**	Sets the current GPU device name. */
-		void setDeviceName(const String& name)
-		{
-			mDeviceName = name;
-		}
-
-		/**	Gets the current GPU device name. */
-		String getDeviceName() const
-		{
-			return mDeviceName;
-		}
-
-		/**	Sets the number of floating-point constants vertex programs support. */
-		void setVertexProgramConstantFloatCount(UINT16 c)
-		{
-			mVertexProgramConstantFloatCount = c;           
-		}
-
-		/**	Sets the number of integer constants vertex programs support. */
-		void setVertexProgramConstantIntCount(UINT16 c)
-		{
-			mVertexProgramConstantIntCount = c;           
-		}
-
-		/**	Sets the number of boolean constants vertex programs support. */
-		void setVertexProgramConstantBoolCount(UINT16 c)
-		{
-			mVertexProgramConstantBoolCount = c;           
-		}
-
-		/**	Sets the number of floating-point constants geometry programs support. */
-		void setGeometryProgramConstantFloatCount(UINT16 c)
-		{
-			mGeometryProgramConstantFloatCount = c;           
-		}
-
-		/**	Sets the number of integer constants geometry programs support. */
-		void setGeometryProgramConstantIntCount(UINT16 c)
-		{
-			mGeometryProgramConstantIntCount = c;           
-		}
-
-		/**	Sets the number of boolean constants geometry programs support. */
-		void setGeometryProgramConstantBoolCount(UINT16 c)
-		{
-			mGeometryProgramConstantBoolCount = c;           
-		}
-
-		/**	Sets the number of floating-point constants fragment programs support. */
-		void setFragmentProgramConstantFloatCount(UINT16 c)
-		{
-			mFragmentProgramConstantFloatCount = c;           
-		}
-
-		/**	Sets the number of integer constants fragment programs support. */
-		void setFragmentProgramConstantIntCount(UINT16 c)
-		{
-			mFragmentProgramConstantIntCount = c;           
-		}
-
-		/**	Sets the number of boolean constants fragment programs support. */
-		void setFragmentProgramConstantBoolCount(UINT16 c)
-		{
-			mFragmentProgramConstantBoolCount = c;           
-		}
-
-		/**	Sets the maximum point screen size in pixels. */
-		void setMaxPointSize(float s)
-		{
-			mMaxPointSize = s;
-		}
-
-		/**	Gets the maximum point screen size in pixels. */
-		float getMaxPointSize(void) const
-		{
-			return mMaxPointSize;
-		}
-
-		/**	Sets the number of vertices a single geometry program run can emit. */
-		void setGeometryProgramNumOutputVertices(int numOutputVertices)
-		{
-			mGeometryProgramNumOutputVertices = numOutputVertices;
-		}
-
-		/**	Gets the number of vertices a single geometry program run can emit. */
-		int getGeometryProgramNumOutputVertices(void) const
-		{
-			return mGeometryProgramNumOutputVertices;
-		}
-
-		/**	Get the identifier of the render system from which these capabilities were generated. */
-		StringID getRenderAPIName() const
-		{
-			return mRenderAPIName;
-		}
-
-		/**	Set the identifier of the render system from which these capabilities were generated. */
-		void setRenderAPIName(const StringID& rs)
-		{
-			mRenderAPIName = rs;
-		}
-
-	private:
-		/**	Initializes vendor enum -> vendor name mappings. */
-		static void initVendorStrings();
-
-	private:
-		static Vector<String> msGPUVendorStrings;
-
-		DriverVersion mDriverVersion;
-		GPUVendor mVendor = GPU_UNKNOWN;
-
-		// The number of texture units available per stage
-		Map<GpuProgramType, UINT16> mNumTextureUnitsPerStage;
-		// Total number of texture units available
-		UINT16 mNumCombinedTextureUnits = 0;
-		// The number of uniform blocks available per stage
-		Map<GpuProgramType, UINT16> mNumGpuParamBlocksPerStage;
-		// Total number of uniform blocks available
-		UINT16 mNumCombinedUniformBlocks = 0;
-		// The stencil buffer bit depth
-		UINT16 mStencilBufferBitDepth = 0;
-		// Maximum number of vertex buffers we can bind at once
-		UINT32 mMaxBoundVertexBuffers = 0;
-		// Stores the capabilities flags.
-		UINT32 mCapabilities[CAPS_CATEGORY_COUNT];
-		// The name of the device as reported by the render system
-		String mDeviceName;
-		// The identifier associated with the render API for which these capabilities are valid
-		StringID mRenderAPIName;
-
-		// The number of floating-point constants vertex programs support
-		UINT16 mVertexProgramConstantFloatCount = 0;
-		// The number of integer constants vertex programs support
-		UINT16 mVertexProgramConstantIntCount = 0;
-		// The number of boolean constants vertex programs support
-		UINT16 mVertexProgramConstantBoolCount = 0;
-		// The number of floating-point constants geometry programs support
-		UINT16 mGeometryProgramConstantFloatCount = 0;
-		// The number of integer constants vertex geometry support
-		UINT16 mGeometryProgramConstantIntCount = 0;
-		// The number of boolean constants vertex geometry support
-		UINT16 mGeometryProgramConstantBoolCount = 0;
-		// The number of floating-point constants fragment programs support
-		UINT16 mFragmentProgramConstantFloatCount = 0;
-		// The number of integer constants fragment programs support
-		UINT16 mFragmentProgramConstantIntCount = 0;
-		// The number of boolean constants fragment programs support
-		UINT16 mFragmentProgramConstantBoolCount = 0;
-		// The number of simultaneous render targets supported
-		UINT16 mNumMultiRenderTargets = 0;
-		// The maximum point size in pixels
-		float mMaxPointSize = 0.0f;
-		// The number of vertices a geometry program can emit in a single run
-		UINT32 mGeometryProgramNumOutputVertices = 0;
-
-		// The list of supported shader profiles
-		Set<String> mSupportedShaderProfiles;
-
-		// Allows us to convert a generic shader profile to a render-system specific one
-		UnorderedMap<GpuProgramProfile, String> mGenericToSpecificShaderProfileMap;
-	};
-
-	/** @} */
-	/** @endcond */
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+#pragma once
+
+#include "BsCorePrerequisites.h"
+#include "BsGpuProgram.h"
+
+#define CAPS_CATEGORY_SIZE 8i64
+#define BS_CAPS_BITSHIFT (64i64 - CAPS_CATEGORY_SIZE)
+#define CAPS_CATEGORY_MASK (((1i64 << CAPS_CATEGORY_SIZE) - 1i64) << BS_CAPS_BITSHIFT)
+#define BS_CAPS_VALUE(cat, val) ((cat << BS_CAPS_BITSHIFT) | (1i64 << val))
+
+#define MAX_BOUND_VERTEX_BUFFERS 32
+
+namespace BansheeEngine 
+{
+	/** @addtogroup RenderAPI-Internal
+	 *  @{
+	 */
+
+	/** Categories of render API capabilities. */
+	enum CapabilitiesCategory : UINT64
+	{
+		CAPS_CATEGORY_COMMON = 0,
+		CAPS_CATEGORY_D3D9 = 1,
+		CAPS_CATEGORY_GL = 2,
+		CAPS_CATEGORY_D3D11 = 3,
+		CAPS_CATEGORY_COUNT = 32 /**< Maximum number of categories. */
+	};
+
+	/** Enum describing the different hardware capabilities we can check for. */
+	enum Capabilities : UINT64
+	{
+		RSC_AUTOMIPMAP				= BS_CAPS_VALUE(CAPS_CATEGORY_COMMON, 0), /**< Supports generating mipmaps in hardware. */
+		RSC_ANISOTROPY				= BS_CAPS_VALUE(CAPS_CATEGORY_COMMON, 1), /**< Supports anisotropic texture filtering. */
+		RSC_CUBEMAPPING				= BS_CAPS_VALUE(CAPS_CATEGORY_COMMON, 2), /**< Supports cube mapping. */
+		RSC_TWO_SIDED_STENCIL		= BS_CAPS_VALUE(CAPS_CATEGORY_COMMON, 3), /**< Supports separate stencil updates for both front and back faces. */
+		RSC_STENCIL_WRAP			= BS_CAPS_VALUE(CAPS_CATEGORY_COMMON, 4), /**< Supports wrapping the stencil value at the range extremes. */
+		RSC_HWOCCLUSION				= BS_CAPS_VALUE(CAPS_CATEGORY_COMMON, 5), /**< Supports hardware occlusion queries. */
+		RSC_USER_CLIP_PLANES		= BS_CAPS_VALUE(CAPS_CATEGORY_COMMON, 6), /**< Supports user clipping planes. */
+		RSC_VERTEX_FORMAT_UBYTE4	= BS_CAPS_VALUE(CAPS_CATEGORY_COMMON, 7), /**< Supports the VET_UBYTE4 vertex element type. */
+		RSC_INFINITE_FAR_PLANE		= BS_CAPS_VALUE(CAPS_CATEGORY_COMMON, 8), /**< Supports infinite far plane projection. */
+		RSC_HWRENDER_TO_TEXTURE		= BS_CAPS_VALUE(CAPS_CATEGORY_COMMON, 9), /**< Supports hardware render-to-texture. */
+		RSC_TEXTURE_FLOAT			= BS_CAPS_VALUE(CAPS_CATEGORY_COMMON, 10), /**< Supports float textures and render targets. */
+		RSC_NON_POWER_OF_2_TEXTURES = BS_CAPS_VALUE(CAPS_CATEGORY_COMMON, 11), /**< Supports non-power of two textures. */
+		RSC_TEXTURE_3D				= BS_CAPS_VALUE(CAPS_CATEGORY_COMMON, 12), /**< Supports 3d (volume) textures. */
+		RSC_POINT_SPRITES			= BS_CAPS_VALUE(CAPS_CATEGORY_COMMON, 13), /**< Supports basic point sprite rendering. */
+
+		RSC_POINT_EXTENDED_PARAMETERS	= BS_CAPS_VALUE(CAPS_CATEGORY_COMMON, 14), /**< Supports extra point parameters (minsize, maxsize, attenuation). */
+		RSC_VERTEX_TEXTURE_FETCH		= BS_CAPS_VALUE(CAPS_CATEGORY_COMMON, 15), /**< Supports vertex texture fetch. */
+		RSC_MIPMAP_LOD_BIAS				= BS_CAPS_VALUE(CAPS_CATEGORY_COMMON, 16), /**< Supports mipmap LOD biasing. */
+		RSC_GEOMETRY_PROGRAM			= BS_CAPS_VALUE(CAPS_CATEGORY_COMMON, 17), /**< Supports hardware geometry programs. */
+
+		RSC_TEXTURE_COMPRESSION			= BS_CAPS_VALUE(CAPS_CATEGORY_COMMON, 18), /**< Supports compressed textures. */
+		RSC_TEXTURE_COMPRESSION_DXT		= BS_CAPS_VALUE(CAPS_CATEGORY_COMMON, 19), /**< Supports compressed textures in the DXT/ST3C formats. */
+		RSC_TEXTURE_COMPRESSION_VTC		= BS_CAPS_VALUE(CAPS_CATEGORY_COMMON, 20), /**< Supports compressed textures in the VTC format. */
+		RSC_TEXTURE_COMPRESSION_PVRTC	= BS_CAPS_VALUE(CAPS_CATEGORY_COMMON, 21), /**< Supports compressed textures in the PVRTC format. */
+		RSC_MRT_DIFFERENT_BIT_DEPTHS	= BS_CAPS_VALUE(CAPS_CATEGORY_COMMON, 22), /**< Supports multiple render targets with different bit depths. */
+		RSC_ALPHA_TO_COVERAGE			= BS_CAPS_VALUE(CAPS_CATEGORY_COMMON, 23), /**< Supports Alpha to Coverage. */
+		RSC_ADVANCED_BLEND_OPERATIONS	= BS_CAPS_VALUE(CAPS_CATEGORY_COMMON, 24), /**< Supports blend operations like subtract, min, max. */
+		RSC_SHADER_SUBROUTINE			= BS_CAPS_VALUE(CAPS_CATEGORY_COMMON, 25), /**< Supports dynamic shader linking. */
+		RSC_HWOCCLUSION_ASYNCHRONOUS	= BS_CAPS_VALUE(CAPS_CATEGORY_COMMON, 26), /**< Support for async occlusion queries. */
+		RSC_HWRENDER_TO_VERTEX_BUFFER	= BS_CAPS_VALUE(CAPS_CATEGORY_COMMON, 27), /**< Supports rendering to vertex buffers. */
+		RSC_TESSELLATION_PROGRAM		= BS_CAPS_VALUE(CAPS_CATEGORY_COMMON, 28), /**< Supports hardware tessellation programs. */
+		RSC_COMPUTE_PROGRAM				= BS_CAPS_VALUE(CAPS_CATEGORY_COMMON, 29), /**< Supports hardware compute programs. */
+
+		// ***** DirectX 9 specific caps *****
+		RSC_PERSTAGECONSTANT = BS_CAPS_VALUE(CAPS_CATEGORY_D3D9, 0), /**< Are per stage constants supported. */
+
+		// ***** GL Specific caps *****
+		RSC_FBO              = BS_CAPS_VALUE(CAPS_CATEGORY_GL, 0), /**< Support for Frame Buffer Objects. */
+		RSC_PBUFFER			 = BS_CAPS_VALUE(CAPS_CATEGORY_GL, 1), /**< Support for PBuffers. */
+	};
+
+	/** Holds data about render system driver version. */
+	struct BS_CORE_EXPORT DriverVersion 
+	{
+		int major;
+		int minor;
+		int release;
+		int build;
+
+		DriverVersion() 
+		{
+			major = minor = release = build = 0;
+		}
+
+		/**	Returns the driver version as a single string. */
+		String toString() const 
+		{
+			StringStream str;
+			str << major << "." << minor << "." << release << "." << build;
+			return str.str();
+		}
+
+		/** Parses a string in the major.minor.release.build format and stores the version numbers. */
+		void fromString(const String& versionString)
+		{
+			Vector<BansheeEngine::String> tokens = StringUtil::split(versionString, ".");
+			if(!tokens.empty())
+			{
+				major = parseINT32(tokens[0]);
+				if (tokens.size() > 1)
+					minor = parseINT32(tokens[1]);
+				if (tokens.size() > 2)
+					release = parseINT32(tokens[2]);
+				if (tokens.size() > 3)
+					build = parseINT32(tokens[3]);
+			}
+
+		}
+	};
+
+	/** Types of GPU vendors. */
+	enum GPUVendor
+	{
+		GPU_UNKNOWN = 0,
+		GPU_NVIDIA = 1,
+		GPU_AMD = 2, 
+		GPU_INTEL = 3,
+		GPU_VENDOR_COUNT = 4
+	};
+
+	/**
+	 * Holds information about render hardware and driver capabilities and allows you to easily set and query those 
+	 * capabilities.
+	 */
+	class BS_CORE_EXPORT RenderAPICapabilities
+	{
+	public:	
+		RenderAPICapabilities ();
+		virtual ~RenderAPICapabilities ();
+
+		/** Sets the current driver version. */
+		void setDriverVersion(const DriverVersion& version)
+		{
+			mDriverVersion = version;
+		}
+		
+		/**	Returns current driver version. */
+		DriverVersion getDriverVersion() const
+		{
+			return mDriverVersion;
+		}
+
+		/**	Returns vendor of the currently used GPU. */
+		GPUVendor getVendor() const
+		{
+			return mVendor;
+		}
+
+		/**	Sets the GPU vendor. */
+		void setVendor(GPUVendor v)
+		{
+			mVendor = v;
+		}
+
+		/** Parses a vendor string and returns an enum with the vendor if parsed succesfully. */
+		static GPUVendor vendorFromString(const String& vendorString);
+
+		/** Converts a vendor enum to a string. */
+		static String vendorToString(GPUVendor v);
+
+		/**	Sets the maximum number of texture units per pipeline stage. */
+		void setNumTextureUnits(GpuProgramType type, UINT16 num)
+		{
+			mNumTextureUnitsPerStage[type] = num;
+		}
+
+		/** Sets the maximum number of texture units in all pipeline stages. */
+		void setNumCombinedTextureUnits(UINT16 num)
+		{
+			mNumCombinedTextureUnits = num;
+		}
+
+		/**	Sets the maximum number of GPU param block buffers per pipeline stage. */
+		void setNumGpuParamBlockBuffers(GpuProgramType type, UINT16 num)
+		{
+			mNumGpuParamBlocksPerStage[type] = num;
+		}
+
+		/**	Sets the maximum number of GPU param block buffers in all pipeline stages. */
+		void setNumCombinedGpuParamBlockBuffers(UINT16 num)
+		{
+			mNumCombinedUniformBlocks = num;
+		}
+
+		/**	Sets maximum stencil buffer depth in bits. */
+		void setStencilBufferBitDepth(UINT16 num)
+		{
+			mStencilBufferBitDepth = num;
+		}
+
+		/**	Sets maximum number of bound vertex buffers. */
+		void setMaxBoundVertexBuffers(UINT32 num)
+		{
+			mMaxBoundVertexBuffers = num;
+		}
+
+		/**	Sets maximum number of simultaneously set render targets. */
+		void setNumMultiRenderTargets(UINT16 num)
+		{
+			mNumMultiRenderTargets = num;
+		}
+
+		/**	Returns the number of texture units supported per pipeline stage. */
+		UINT16 getNumTextureUnits(GpuProgramType type) const
+		{
+			auto iterFind = mNumTextureUnitsPerStage.find(type);
+			if(iterFind != mNumTextureUnitsPerStage.end())
+				return iterFind->second;
+			else
+				return 0;
+		}
+
+		/**	Returns the number of texture units supported in all pipeline stages. */
+		UINT16 getNumCombinedTextureUnits() const
+		{
+			return mNumCombinedTextureUnits;
+		}
+
+		/**	Returns the maximum number of bound GPU program param block buffers per pipeline stage. */
+		UINT16 getNumGpuParamBlockBuffers(GpuProgramType type) const
+		{
+			auto iterFind = mNumGpuParamBlocksPerStage.find(type);
+			if(iterFind != mNumGpuParamBlocksPerStage.end())
+				return iterFind->second;
+			else
+				return 0;
+		}
+
+		/** Returns the maximum number of bound GPU program param block buffers in all pipeline stages. */
+		UINT16 getNumCombinedGpuParamBlockBuffers() const
+		{
+			return mNumCombinedUniformBlocks;
+		}
+
+		/** Returns the maximum number of bits available for the stencil buffer. */
+		UINT16 getStencilBufferBitDepth() const
+		{
+			return mStencilBufferBitDepth;
+		}
+
+		/** Returns the maximum number of vertex buffers that can be bound at once. */
+		UINT32 getMaxBoundVertexBuffers() const
+		{
+			return mMaxBoundVertexBuffers;
+		}
+
+		/**	Returns the maximum number of render targets we can render to simultaneously. */
+		UINT16 getNumMultiRenderTargets() const
+		{
+			return mNumMultiRenderTargets;
+		}
+
+		/**	Sets a capability flag indicating this capability is supported. */
+		void setCapability(const Capabilities c) 
+		{ 
+			UINT64 index = (CAPS_CATEGORY_MASK & c) >> BS_CAPS_BITSHIFT;
+			mCapabilities[index] |= (c & ~CAPS_CATEGORY_MASK);
+		}
+
+		/**	Remove a capability flag indicating this capability is not supported (default). */
+		void unsetCapability(const Capabilities c) 
+		{ 
+			UINT64 index = (CAPS_CATEGORY_MASK & c) >> BS_CAPS_BITSHIFT;
+			mCapabilities[index] &= (~c | CAPS_CATEGORY_MASK);
+		}
+
+		/**	Checks is the specified capability supported. */
+		bool hasCapability(const Capabilities c) const
+		{
+			UINT64 index = (CAPS_CATEGORY_MASK & c) >> BS_CAPS_BITSHIFT;
+
+			return (mCapabilities[index] & (c & ~CAPS_CATEGORY_MASK)) != 0;
+		}
+
+		/**	Adds a shader profile to the list of render-system specific supported profiles. */
+		void addShaderProfile(const String& profile)
+		{
+			mSupportedShaderProfiles.insert(profile);
+		}
+
+		/**	Adds a mapping between GPU program profile enum and render-system specific profile name. */
+		void addGpuProgramProfile(GpuProgramProfile gpuProgProfile, const String& rsSpecificProfile)
+		{
+			mGenericToSpecificShaderProfileMap[gpuProgProfile] = rsSpecificProfile;
+		}
+
+		/**	Returns true if the provided profile is supported. */
+		bool isShaderProfileSupported(const String& profile) const
+		{
+			return (mSupportedShaderProfiles.end() != mSupportedShaderProfiles.find(profile));
+		}
+
+		/**	Returns a set of all supported shader profiles. */
+		const Set<String>& getSupportedShaderProfiles() const
+		{
+			return mSupportedShaderProfiles;
+		}
+
+		/**
+		 * Converts a generic GpuProgramProfile identifier into a render-system specific one. Returns an empty string if 
+		 * conversion cannot be done.
+		 */
+		String gpuProgProfileToRSSpecificProfile(GpuProgramProfile gpuProgProfile) const
+		{
+			auto iterFind = mGenericToSpecificShaderProfileMap.find(gpuProgProfile);
+			if(mGenericToSpecificShaderProfileMap.end() != iterFind)
+			{
+				return iterFind->second;
+			}
+
+			return "";
+		}
+
+		/** Gets the number of floating-point constants vertex programs support. */
+		UINT16 getVertexProgramConstantFloatCount() const
+		{
+			return mVertexProgramConstantFloatCount;           
+		}
+
+		/**	Gets the number of integer constants vertex programs support. */
+		UINT16 getVertexProgramConstantIntCount() const
+		{
+			return mVertexProgramConstantIntCount;           
+		}
+
+		/**	Gets the number of boolean constants vertex programs support. */
+		UINT16 getVertexProgramConstantBoolCount() const
+		{
+			return mVertexProgramConstantBoolCount;           
+		}
+
+		/**	Gets the number of floating-point constants geometry programs support. */
+		UINT16 getGeometryProgramConstantFloatCount() const
+		{
+			return mGeometryProgramConstantFloatCount;           
+		}
+
+		/**	 Gets the number of integer constants geometry programs support. */
+		UINT16 getGeometryProgramConstantIntCount() const
+		{
+			return mGeometryProgramConstantIntCount;           
+		}
+
+		/**	 Gets the number of boolean constants geometry programs support. */
+		UINT16 getGeometryProgramConstantBoolCount() const
+		{
+			return mGeometryProgramConstantBoolCount;           
+		}
+
+		/**	Gets the number of floating-point constants fragment programs support. */
+		UINT16 getFragmentProgramConstantFloatCount() const
+		{
+			return mFragmentProgramConstantFloatCount;           
+		}
+
+		/**	Gets the number of integer constants fragment programs support. */
+		UINT16 getFragmentProgramConstantIntCount() const
+		{
+			return mFragmentProgramConstantIntCount;           
+		}
+		
+		/** Gets the number of boolean constants fragment programs support. */
+		UINT16 getFragmentProgramConstantBoolCount() const
+		{
+			return mFragmentProgramConstantBoolCount;           
+		}
+
+		/**	Sets the current GPU device name. */
+		void setDeviceName(const String& name)
+		{
+			mDeviceName = name;
+		}
+
+		/**	Gets the current GPU device name. */
+		String getDeviceName() const
+		{
+			return mDeviceName;
+		}
+
+		/**	Sets the number of floating-point constants vertex programs support. */
+		void setVertexProgramConstantFloatCount(UINT16 c)
+		{
+			mVertexProgramConstantFloatCount = c;           
+		}
+
+		/**	Sets the number of integer constants vertex programs support. */
+		void setVertexProgramConstantIntCount(UINT16 c)
+		{
+			mVertexProgramConstantIntCount = c;           
+		}
+
+		/**	Sets the number of boolean constants vertex programs support. */
+		void setVertexProgramConstantBoolCount(UINT16 c)
+		{
+			mVertexProgramConstantBoolCount = c;           
+		}
+
+		/**	Sets the number of floating-point constants geometry programs support. */
+		void setGeometryProgramConstantFloatCount(UINT16 c)
+		{
+			mGeometryProgramConstantFloatCount = c;           
+		}
+
+		/**	Sets the number of integer constants geometry programs support. */
+		void setGeometryProgramConstantIntCount(UINT16 c)
+		{
+			mGeometryProgramConstantIntCount = c;           
+		}
+
+		/**	Sets the number of boolean constants geometry programs support. */
+		void setGeometryProgramConstantBoolCount(UINT16 c)
+		{
+			mGeometryProgramConstantBoolCount = c;           
+		}
+
+		/**	Sets the number of floating-point constants fragment programs support. */
+		void setFragmentProgramConstantFloatCount(UINT16 c)
+		{
+			mFragmentProgramConstantFloatCount = c;           
+		}
+
+		/**	Sets the number of integer constants fragment programs support. */
+		void setFragmentProgramConstantIntCount(UINT16 c)
+		{
+			mFragmentProgramConstantIntCount = c;           
+		}
+
+		/**	Sets the number of boolean constants fragment programs support. */
+		void setFragmentProgramConstantBoolCount(UINT16 c)
+		{
+			mFragmentProgramConstantBoolCount = c;           
+		}
+
+		/**	Sets the maximum point screen size in pixels. */
+		void setMaxPointSize(float s)
+		{
+			mMaxPointSize = s;
+		}
+
+		/**	Gets the maximum point screen size in pixels. */
+		float getMaxPointSize(void) const
+		{
+			return mMaxPointSize;
+		}
+
+		/**	Sets the number of vertices a single geometry program run can emit. */
+		void setGeometryProgramNumOutputVertices(int numOutputVertices)
+		{
+			mGeometryProgramNumOutputVertices = numOutputVertices;
+		}
+
+		/**	Gets the number of vertices a single geometry program run can emit. */
+		int getGeometryProgramNumOutputVertices(void) const
+		{
+			return mGeometryProgramNumOutputVertices;
+		}
+
+		/**	Get the identifier of the render system from which these capabilities were generated. */
+		StringID getRenderAPIName() const
+		{
+			return mRenderAPIName;
+		}
+
+		/**	Set the identifier of the render system from which these capabilities were generated. */
+		void setRenderAPIName(const StringID& rs)
+		{
+			mRenderAPIName = rs;
+		}
+
+	private:
+		/**	Initializes vendor enum -> vendor name mappings. */
+		static void initVendorStrings();
+
+	private:
+		static Vector<String> msGPUVendorStrings;
+
+		DriverVersion mDriverVersion;
+		GPUVendor mVendor = GPU_UNKNOWN;
+
+		// The number of texture units available per stage
+		Map<GpuProgramType, UINT16> mNumTextureUnitsPerStage;
+		// Total number of texture units available
+		UINT16 mNumCombinedTextureUnits = 0;
+		// The number of uniform blocks available per stage
+		Map<GpuProgramType, UINT16> mNumGpuParamBlocksPerStage;
+		// Total number of uniform blocks available
+		UINT16 mNumCombinedUniformBlocks = 0;
+		// The stencil buffer bit depth
+		UINT16 mStencilBufferBitDepth = 0;
+		// Maximum number of vertex buffers we can bind at once
+		UINT32 mMaxBoundVertexBuffers = 0;
+		// Stores the capabilities flags.
+		UINT32 mCapabilities[CAPS_CATEGORY_COUNT];
+		// The name of the device as reported by the render system
+		String mDeviceName;
+		// The identifier associated with the render API for which these capabilities are valid
+		StringID mRenderAPIName;
+
+		// The number of floating-point constants vertex programs support
+		UINT16 mVertexProgramConstantFloatCount = 0;
+		// The number of integer constants vertex programs support
+		UINT16 mVertexProgramConstantIntCount = 0;
+		// The number of boolean constants vertex programs support
+		UINT16 mVertexProgramConstantBoolCount = 0;
+		// The number of floating-point constants geometry programs support
+		UINT16 mGeometryProgramConstantFloatCount = 0;
+		// The number of integer constants vertex geometry support
+		UINT16 mGeometryProgramConstantIntCount = 0;
+		// The number of boolean constants vertex geometry support
+		UINT16 mGeometryProgramConstantBoolCount = 0;
+		// The number of floating-point constants fragment programs support
+		UINT16 mFragmentProgramConstantFloatCount = 0;
+		// The number of integer constants fragment programs support
+		UINT16 mFragmentProgramConstantIntCount = 0;
+		// The number of boolean constants fragment programs support
+		UINT16 mFragmentProgramConstantBoolCount = 0;
+		// The number of simultaneous render targets supported
+		UINT16 mNumMultiRenderTargets = 0;
+		// The maximum point size in pixels
+		float mMaxPointSize = 0.0f;
+		// The number of vertices a geometry program can emit in a single run
+		UINT32 mGeometryProgramNumOutputVertices = 0;
+
+		// The list of supported shader profiles
+		Set<String> mSupportedShaderProfiles;
+
+		// Allows us to convert a generic shader profile to a render-system specific one
+		UnorderedMap<GpuProgramProfile, String> mGenericToSpecificShaderProfileMap;
+	};
+
+	/** @} */
 }

+ 1 - 3
Source/BansheeCore/Include/BsRenderAPIFactory.h

@@ -6,8 +6,7 @@
 
 namespace BansheeEngine
 {
-	/** @cond INTERNAL */
-	/** @addtogroup RenderAPI
+	/** @addtogroup RenderAPI-Internal
 	 *  @{
 	 */
 
@@ -25,5 +24,4 @@ namespace BansheeEngine
 	};
 
 	/** @} */
-	/** @endcond */
 }

+ 41 - 43
Source/BansheeCore/Include/BsRenderAPIManager.h

@@ -1,43 +1,41 @@
-//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
-//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
-#pragma once
-
-#include "BsCorePrerequisites.h"
-#include "BsModule.h"
-#include "BsRenderAPIFactory.h"
-
-namespace BansheeEngine
-{
-	/** @cond INTERNAL */
-	/** @addtogroup RenderAPI
-	 *  @{
-	 */
-
-	/** Manager that handles render system start up. */
-	class BS_CORE_EXPORT RenderAPIManager : public Module<RenderAPIManager>
-	{
-	public:
-		RenderAPIManager();
-		~RenderAPIManager();
-
-		/**
-		 * Starts the render API with the provided name and creates the primary render window.
-		 *
-		 * @param[in]	name				Name of the render system to start. Factory for this render system must be 
-		 *									previously registered.
-		 * @param[in]	primaryWindowDesc	Contains options used for creating the primary window.
-		 * @return							Created render window if initialization is successful, null otherwise.
-		 */
-		RenderWindowPtr initialize(const String& name, RENDER_WINDOW_DESC& primaryWindowDesc);
-
-		/**	Registers a new render API factory responsible for creating a specific render system type. */
-		void registerFactory(RenderAPIFactoryPtr factory);
-	private:
-		Vector<RenderAPIFactoryPtr> mAvailableFactories;
-		bool mRenderAPIInitialized;
-	};
-
-	/** @} */
-	/** @endcond */
-}
-
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+#pragma once
+
+#include "BsCorePrerequisites.h"
+#include "BsModule.h"
+#include "BsRenderAPIFactory.h"
+
+namespace BansheeEngine
+{
+	/** @addtogroup RenderAPI-Internal
+	 *  @{
+	 */
+
+	/** Manager that handles render system start up. */
+	class BS_CORE_EXPORT RenderAPIManager : public Module<RenderAPIManager>
+	{
+	public:
+		RenderAPIManager();
+		~RenderAPIManager();
+
+		/**
+		 * Starts the render API with the provided name and creates the primary render window.
+		 *
+		 * @param[in]	name				Name of the render system to start. Factory for this render system must be 
+		 *									previously registered.
+		 * @param[in]	primaryWindowDesc	Contains options used for creating the primary window.
+		 * @return							Created render window if initialization is successful, null otherwise.
+		 */
+		RenderWindowPtr initialize(const String& name, RENDER_WINDOW_DESC& primaryWindowDesc);
+
+		/**	Registers a new render API factory responsible for creating a specific render system type. */
+		void registerFactory(RenderAPIFactoryPtr factory);
+	private:
+		Vector<RenderAPIFactoryPtr> mAvailableFactories;
+		bool mRenderAPIInitialized;
+	};
+
+	/** @} */
+}
+

+ 258 - 260
Source/BansheeCore/Include/BsRenderStateManager.h

@@ -1,261 +1,259 @@
-//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
-//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
-#pragma once
-
-#include "BsCorePrerequisites.h"
-#include "BsModule.h"
-#include "BsBlendState.h"
-#include "BsRasterizerState.h"
-#include "BsDepthStencilState.h"
-#include "BsSamplerState.h"
-
-namespace BansheeEngine
-{
-	/** @cond INTERNAL */
-	/** @addtogroup RenderAPI
-	 *  @{
-	 */
-
-	/** Handles creation of various render states. */
-	class BS_CORE_EXPORT RenderStateManager : public Module <RenderStateManager>
-	{
-	public:
-		/**	Creates and initializes a new SamplerState. */
-		SamplerStatePtr createSamplerState(const SAMPLER_STATE_DESC& desc) const;
-
-		/** Creates and initializes a new DepthStencilState. */
-		DepthStencilStatePtr createDepthStencilState(const DEPTH_STENCIL_STATE_DESC& desc) const;
-
-		/**	Creates and initializes a new RasterizerState. */
-		RasterizerStatePtr createRasterizerState(const RASTERIZER_STATE_DESC& desc) const;
-
-		/**	Creates and initializes a new BlendState. */
-		BlendStatePtr createBlendState(const BLEND_STATE_DESC& desc) const;
-
-		/**
-		 * Creates an uninitialized sampler state. Requires manual initialization after creation.
-		 *
-		 * @note	Internal method.
-		 */
-		SamplerStatePtr _createSamplerStatePtr(const SAMPLER_STATE_DESC& desc) const;
-
-		/**
-		 * Creates an uninitialized depth-stencil state. Requires manual initialization after creation.
-		 *
-		 * @note	Internal method.
-		 */
-		DepthStencilStatePtr _createDepthStencilStatePtr(const DEPTH_STENCIL_STATE_DESC& desc) const;
-
-		/**
-		 * Creates an uninitialized rasterizer state. Requires manual initialization after creation.
-		 *
-		 * @note	Internal method.
-		 */
-		RasterizerStatePtr _createRasterizerStatePtr(const RASTERIZER_STATE_DESC& desc) const;
-
-		/**
-		 * Creates an uninitialized blend state. Requires manual initialization	after creation.
-		 *
-		 * @note	Internal method.
-		 */
-		BlendStatePtr _createBlendStatePtr(const BLEND_STATE_DESC& desc) const;
-
-		/** Gets a sampler state initialized with default options. */
-		const SamplerStatePtr& getDefaultSamplerState() const;
-
-		/**	Gets a blend state initialized with default options. */
-		const BlendStatePtr& getDefaultBlendState() const;
-
-		/**	Gets a rasterizer state initialized with default options. */
-		const RasterizerStatePtr& getDefaultRasterizerState() const;
-
-		/**	Gets a depth stencil state initialized with default options. */
-		const DepthStencilStatePtr& getDefaultDepthStencilState() const;
-
-	private:
-		friend class SamplerState;
-		friend class BlendState;
-		friend class RasterizerState;
-		friend class DepthStencilState;
-
-		mutable SamplerStatePtr mDefaultSamplerState;
-		mutable BlendStatePtr mDefaultBlendState;
-		mutable RasterizerStatePtr mDefaultRasterizerState;
-		mutable DepthStencilStatePtr mDefaultDepthStencilState;
-	};
-
-	/**	Handles creation of various render states. */
-	class BS_CORE_EXPORT RenderStateCoreManager : public Module<RenderStateCoreManager>
-	{
-	private:
-		/**	Contains data about a cached blend state. */
-		struct CachedBlendState
-		{
-			CachedBlendState()
-				:id(0)
-			{ }
-
-			CachedBlendState(UINT32 id)
-				:id(id)
-			{ }
-
-			std::weak_ptr<BlendStateCore> state;
-			UINT32 id;
-		};
-
-		/**	Contains data about a cached rasterizer state. */
-		struct CachedRasterizerState
-		{
-			CachedRasterizerState()
-				:id(0)
-			{ }
-
-			CachedRasterizerState(UINT32 id)
-				:id(id)
-			{ }
-
-			std::weak_ptr<RasterizerStateCore> state;
-			UINT32 id;
-		};
-
-		/** Contains data about a cached depth stencil state. */
-		struct CachedDepthStencilState
-		{
-			CachedDepthStencilState()
-				:id(0)
-			{ }
-
-			CachedDepthStencilState(UINT32 id)
-				:id(id)
-			{ }
-
-			std::weak_ptr<DepthStencilStateCore> state;
-			UINT32 id;
-		};
-
-	public:
-		RenderStateCoreManager();
-
-		/** @copydoc RenderStateManager::createSamplerState */
-		SPtr<SamplerStateCore> createSamplerState(const SAMPLER_STATE_DESC& desc) const;
-
-		/** @copydoc RenderStateManager::createDepthStencilState */
-		SPtr<DepthStencilStateCore> createDepthStencilState(const DEPTH_STENCIL_STATE_DESC& desc) const;
-
-		/** @copydoc RenderStateManager::createRasterizerState */
-		SPtr<RasterizerStateCore> createRasterizerState(const RASTERIZER_STATE_DESC& desc) const;
-
-		/** @copydoc RenderStateManager::createBlendState */
-		SPtr<BlendStateCore> createBlendState(const BLEND_STATE_DESC& desc) const;
-
-		/** Creates an uninitialized sampler state. Requires manual initialization after creation. */
-		SPtr<SamplerStateCore> _createSamplerState(const SAMPLER_STATE_DESC& desc) const;
-
-		/** Creates an uninitialized depth-stencil state. Requires manual initialization after creation. */
-		SPtr<DepthStencilStateCore> _createDepthStencilState(const DEPTH_STENCIL_STATE_DESC& desc) const;
-
-		/** Creates an uninitialized rasterizer state. Requires manual initialization after creation. */
-		SPtr<RasterizerStateCore> _createRasterizerState(const RASTERIZER_STATE_DESC& desc) const;
-
-		/** Creates an uninitialized blend state. Requires manual initialization after creation. */
-		SPtr<BlendStateCore> _createBlendState(const BLEND_STATE_DESC& desc) const;
-
-		/** Gets a sampler state initialized with default options. */
-		const SPtr<SamplerStateCore>& getDefaultSamplerState() const;
-
-		/**	Gets a blend state initialized with default options. */
-		const SPtr<BlendStateCore>& getDefaultBlendState() const;
-
-		/**	Gets a rasterizer state initialized with default options. */
-		const SPtr<RasterizerStateCore>& getDefaultRasterizerState() const;
-
-		/**	Gets a depth stencil state initialized with default options. */
-		const SPtr<DepthStencilStateCore>& getDefaultDepthStencilState() const;
-
-	protected:
-		friend class SamplerState;
-		friend class BlendState;
-		friend class RasterizerState;
-		friend class DepthStencilState;
-		friend class SamplerStateCore;
-		friend class BlendStateCore;
-		friend class RasterizerStateCore;
-		friend class DepthStencilStateCore;
-
-		/** @copydoc Module::onShutDown */
-		void onShutDown() override;
-
-		/** @copydoc createSamplerState */
-		virtual SPtr<SamplerStateCore> createSamplerStateInternal(const SAMPLER_STATE_DESC& desc) const;
-
-		/** @copydoc createBlendState */
-		virtual SPtr<BlendStateCore> createBlendStateInternal(const BLEND_STATE_DESC& desc, UINT32 id) const;
-
-		/** @copydoc createRasterizerState */
-		virtual SPtr<RasterizerStateCore> createRasterizerStateInternal(const RASTERIZER_STATE_DESC& desc, UINT32 id) const;
-
-		/** @copydoc createDepthStencilState */
-		virtual SPtr<DepthStencilStateCore> createDepthStencilStateInternal(const DEPTH_STENCIL_STATE_DESC& desc, UINT32 id) const;
-
-	private:
-		/**	Triggered when a new sampler state is created. */
-		void notifySamplerStateCreated(const SAMPLER_STATE_DESC& desc, const SPtr<SamplerStateCore>& state) const;
-
-		/**	Triggered when a new sampler state is created. */
-		void notifyBlendStateCreated(const BLEND_STATE_DESC& desc, const CachedBlendState& state) const;
-
-		/**	Triggered when a new sampler state is created. */
-		void notifyRasterizerStateCreated(const RASTERIZER_STATE_DESC& desc, const CachedRasterizerState& state) const;
-
-		/**	Triggered when a new sampler state is created. */
-		void notifyDepthStencilStateCreated(const DEPTH_STENCIL_STATE_DESC& desc, const CachedDepthStencilState& state) const;
-
-		/**
-		 * Triggered when the last reference to a specific sampler state is destroyed, which means we must clear our cached
-		 * version as well.
-		 */
-		void notifySamplerStateDestroyed(const SAMPLER_STATE_DESC& desc) const;
-
-		/**
-		 * Attempts to find a cached sampler state corresponding to the provided descriptor. Returns null if one doesn't 
-		 * exist.
-		 */
-		SPtr<SamplerStateCore> findCachedState(const SAMPLER_STATE_DESC& desc) const;
-
-		/**
-		 * Attempts to find a cached blend state corresponding to the provided descriptor. Returns null if one doesn't exist.
-		 */
-		SPtr<BlendStateCore> findCachedState(const BLEND_STATE_DESC& desc, UINT32& id) const;
-
-		/**
-		 * Attempts to find a cached rasterizer state corresponding to the provided descriptor. Returns null if one doesn't 
-		 * exist.
-		 */
-		SPtr<RasterizerStateCore> findCachedState(const RASTERIZER_STATE_DESC& desc, UINT32& id) const;
-
-		/**
-		 * Attempts to find a cached depth-stencil state corresponding to the provided descriptor. Returns null if one 
-		 * doesn't exist.
-		 */
-		SPtr<DepthStencilStateCore> findCachedState(const DEPTH_STENCIL_STATE_DESC& desc, UINT32& id) const;
-
-		mutable SPtr<SamplerStateCore> mDefaultSamplerState;
-		mutable SPtr<BlendStateCore> mDefaultBlendState;
-		mutable SPtr<RasterizerStateCore> mDefaultRasterizerState;
-		mutable SPtr<DepthStencilStateCore> mDefaultDepthStencilState;
-
-		mutable UnorderedMap<SAMPLER_STATE_DESC, std::weak_ptr<SamplerStateCore>> mCachedSamplerStates;
-		mutable UnorderedMap<BLEND_STATE_DESC, CachedBlendState> mCachedBlendStates;
-		mutable UnorderedMap<RASTERIZER_STATE_DESC, CachedRasterizerState> mCachedRasterizerStates;
-		mutable UnorderedMap<DEPTH_STENCIL_STATE_DESC, CachedDepthStencilState> mCachedDepthStencilStates;
-
-		mutable UINT32 mNextBlendStateId;
-		mutable UINT32 mNextRasterizerStateId;
-		mutable UINT32 mNextDepthStencilStateId;
-
-		BS_MUTEX(mMutex);
-	};
-
-	/** @} */
-	/** @endcond */
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+#pragma once
+
+#include "BsCorePrerequisites.h"
+#include "BsModule.h"
+#include "BsBlendState.h"
+#include "BsRasterizerState.h"
+#include "BsDepthStencilState.h"
+#include "BsSamplerState.h"
+
+namespace BansheeEngine
+{
+	/** @addtogroup RenderAPI-Internal
+	 *  @{
+	 */
+
+	/** Handles creation of various render states. */
+	class BS_CORE_EXPORT RenderStateManager : public Module <RenderStateManager>
+	{
+	public:
+		/**	Creates and initializes a new SamplerState. */
+		SamplerStatePtr createSamplerState(const SAMPLER_STATE_DESC& desc) const;
+
+		/** Creates and initializes a new DepthStencilState. */
+		DepthStencilStatePtr createDepthStencilState(const DEPTH_STENCIL_STATE_DESC& desc) const;
+
+		/**	Creates and initializes a new RasterizerState. */
+		RasterizerStatePtr createRasterizerState(const RASTERIZER_STATE_DESC& desc) const;
+
+		/**	Creates and initializes a new BlendState. */
+		BlendStatePtr createBlendState(const BLEND_STATE_DESC& desc) const;
+
+		/**
+		 * Creates an uninitialized sampler state. Requires manual initialization after creation.
+		 *
+		 * @note	Internal method.
+		 */
+		SamplerStatePtr _createSamplerStatePtr(const SAMPLER_STATE_DESC& desc) const;
+
+		/**
+		 * Creates an uninitialized depth-stencil state. Requires manual initialization after creation.
+		 *
+		 * @note	Internal method.
+		 */
+		DepthStencilStatePtr _createDepthStencilStatePtr(const DEPTH_STENCIL_STATE_DESC& desc) const;
+
+		/**
+		 * Creates an uninitialized rasterizer state. Requires manual initialization after creation.
+		 *
+		 * @note	Internal method.
+		 */
+		RasterizerStatePtr _createRasterizerStatePtr(const RASTERIZER_STATE_DESC& desc) const;
+
+		/**
+		 * Creates an uninitialized blend state. Requires manual initialization	after creation.
+		 *
+		 * @note	Internal method.
+		 */
+		BlendStatePtr _createBlendStatePtr(const BLEND_STATE_DESC& desc) const;
+
+		/** Gets a sampler state initialized with default options. */
+		const SamplerStatePtr& getDefaultSamplerState() const;
+
+		/**	Gets a blend state initialized with default options. */
+		const BlendStatePtr& getDefaultBlendState() const;
+
+		/**	Gets a rasterizer state initialized with default options. */
+		const RasterizerStatePtr& getDefaultRasterizerState() const;
+
+		/**	Gets a depth stencil state initialized with default options. */
+		const DepthStencilStatePtr& getDefaultDepthStencilState() const;
+
+	private:
+		friend class SamplerState;
+		friend class BlendState;
+		friend class RasterizerState;
+		friend class DepthStencilState;
+
+		mutable SamplerStatePtr mDefaultSamplerState;
+		mutable BlendStatePtr mDefaultBlendState;
+		mutable RasterizerStatePtr mDefaultRasterizerState;
+		mutable DepthStencilStatePtr mDefaultDepthStencilState;
+	};
+
+	/**	Handles creation of various render states. */
+	class BS_CORE_EXPORT RenderStateCoreManager : public Module<RenderStateCoreManager>
+	{
+	private:
+		/**	Contains data about a cached blend state. */
+		struct CachedBlendState
+		{
+			CachedBlendState()
+				:id(0)
+			{ }
+
+			CachedBlendState(UINT32 id)
+				:id(id)
+			{ }
+
+			std::weak_ptr<BlendStateCore> state;
+			UINT32 id;
+		};
+
+		/**	Contains data about a cached rasterizer state. */
+		struct CachedRasterizerState
+		{
+			CachedRasterizerState()
+				:id(0)
+			{ }
+
+			CachedRasterizerState(UINT32 id)
+				:id(id)
+			{ }
+
+			std::weak_ptr<RasterizerStateCore> state;
+			UINT32 id;
+		};
+
+		/** Contains data about a cached depth stencil state. */
+		struct CachedDepthStencilState
+		{
+			CachedDepthStencilState()
+				:id(0)
+			{ }
+
+			CachedDepthStencilState(UINT32 id)
+				:id(id)
+			{ }
+
+			std::weak_ptr<DepthStencilStateCore> state;
+			UINT32 id;
+		};
+
+	public:
+		RenderStateCoreManager();
+
+		/** @copydoc RenderStateManager::createSamplerState */
+		SPtr<SamplerStateCore> createSamplerState(const SAMPLER_STATE_DESC& desc) const;
+
+		/** @copydoc RenderStateManager::createDepthStencilState */
+		SPtr<DepthStencilStateCore> createDepthStencilState(const DEPTH_STENCIL_STATE_DESC& desc) const;
+
+		/** @copydoc RenderStateManager::createRasterizerState */
+		SPtr<RasterizerStateCore> createRasterizerState(const RASTERIZER_STATE_DESC& desc) const;
+
+		/** @copydoc RenderStateManager::createBlendState */
+		SPtr<BlendStateCore> createBlendState(const BLEND_STATE_DESC& desc) const;
+
+		/** Creates an uninitialized sampler state. Requires manual initialization after creation. */
+		SPtr<SamplerStateCore> _createSamplerState(const SAMPLER_STATE_DESC& desc) const;
+
+		/** Creates an uninitialized depth-stencil state. Requires manual initialization after creation. */
+		SPtr<DepthStencilStateCore> _createDepthStencilState(const DEPTH_STENCIL_STATE_DESC& desc) const;
+
+		/** Creates an uninitialized rasterizer state. Requires manual initialization after creation. */
+		SPtr<RasterizerStateCore> _createRasterizerState(const RASTERIZER_STATE_DESC& desc) const;
+
+		/** Creates an uninitialized blend state. Requires manual initialization after creation. */
+		SPtr<BlendStateCore> _createBlendState(const BLEND_STATE_DESC& desc) const;
+
+		/** Gets a sampler state initialized with default options. */
+		const SPtr<SamplerStateCore>& getDefaultSamplerState() const;
+
+		/**	Gets a blend state initialized with default options. */
+		const SPtr<BlendStateCore>& getDefaultBlendState() const;
+
+		/**	Gets a rasterizer state initialized with default options. */
+		const SPtr<RasterizerStateCore>& getDefaultRasterizerState() const;
+
+		/**	Gets a depth stencil state initialized with default options. */
+		const SPtr<DepthStencilStateCore>& getDefaultDepthStencilState() const;
+
+	protected:
+		friend class SamplerState;
+		friend class BlendState;
+		friend class RasterizerState;
+		friend class DepthStencilState;
+		friend class SamplerStateCore;
+		friend class BlendStateCore;
+		friend class RasterizerStateCore;
+		friend class DepthStencilStateCore;
+
+		/** @copydoc Module::onShutDown */
+		void onShutDown() override;
+
+		/** @copydoc createSamplerState */
+		virtual SPtr<SamplerStateCore> createSamplerStateInternal(const SAMPLER_STATE_DESC& desc) const;
+
+		/** @copydoc createBlendState */
+		virtual SPtr<BlendStateCore> createBlendStateInternal(const BLEND_STATE_DESC& desc, UINT32 id) const;
+
+		/** @copydoc createRasterizerState */
+		virtual SPtr<RasterizerStateCore> createRasterizerStateInternal(const RASTERIZER_STATE_DESC& desc, UINT32 id) const;
+
+		/** @copydoc createDepthStencilState */
+		virtual SPtr<DepthStencilStateCore> createDepthStencilStateInternal(const DEPTH_STENCIL_STATE_DESC& desc, UINT32 id) const;
+
+	private:
+		/**	Triggered when a new sampler state is created. */
+		void notifySamplerStateCreated(const SAMPLER_STATE_DESC& desc, const SPtr<SamplerStateCore>& state) const;
+
+		/**	Triggered when a new sampler state is created. */
+		void notifyBlendStateCreated(const BLEND_STATE_DESC& desc, const CachedBlendState& state) const;
+
+		/**	Triggered when a new sampler state is created. */
+		void notifyRasterizerStateCreated(const RASTERIZER_STATE_DESC& desc, const CachedRasterizerState& state) const;
+
+		/**	Triggered when a new sampler state is created. */
+		void notifyDepthStencilStateCreated(const DEPTH_STENCIL_STATE_DESC& desc, const CachedDepthStencilState& state) const;
+
+		/**
+		 * Triggered when the last reference to a specific sampler state is destroyed, which means we must clear our cached
+		 * version as well.
+		 */
+		void notifySamplerStateDestroyed(const SAMPLER_STATE_DESC& desc) const;
+
+		/**
+		 * Attempts to find a cached sampler state corresponding to the provided descriptor. Returns null if one doesn't 
+		 * exist.
+		 */
+		SPtr<SamplerStateCore> findCachedState(const SAMPLER_STATE_DESC& desc) const;
+
+		/**
+		 * Attempts to find a cached blend state corresponding to the provided descriptor. Returns null if one doesn't exist.
+		 */
+		SPtr<BlendStateCore> findCachedState(const BLEND_STATE_DESC& desc, UINT32& id) const;
+
+		/**
+		 * Attempts to find a cached rasterizer state corresponding to the provided descriptor. Returns null if one doesn't 
+		 * exist.
+		 */
+		SPtr<RasterizerStateCore> findCachedState(const RASTERIZER_STATE_DESC& desc, UINT32& id) const;
+
+		/**
+		 * Attempts to find a cached depth-stencil state corresponding to the provided descriptor. Returns null if one 
+		 * doesn't exist.
+		 */
+		SPtr<DepthStencilStateCore> findCachedState(const DEPTH_STENCIL_STATE_DESC& desc, UINT32& id) const;
+
+		mutable SPtr<SamplerStateCore> mDefaultSamplerState;
+		mutable SPtr<BlendStateCore> mDefaultBlendState;
+		mutable SPtr<RasterizerStateCore> mDefaultRasterizerState;
+		mutable SPtr<DepthStencilStateCore> mDefaultDepthStencilState;
+
+		mutable UnorderedMap<SAMPLER_STATE_DESC, std::weak_ptr<SamplerStateCore>> mCachedSamplerStates;
+		mutable UnorderedMap<BLEND_STATE_DESC, CachedBlendState> mCachedBlendStates;
+		mutable UnorderedMap<RASTERIZER_STATE_DESC, CachedRasterizerState> mCachedRasterizerStates;
+		mutable UnorderedMap<DEPTH_STENCIL_STATE_DESC, CachedDepthStencilState> mCachedDepthStencilStates;
+
+		mutable UINT32 mNextBlendStateId;
+		mutable UINT32 mNextRasterizerStateId;
+		mutable UINT32 mNextDepthStencilStateId;
+
+		BS_MUTEX(mMutex);
+	};
+
+	/** @} */
 }

+ 192 - 194
Source/BansheeCore/Include/BsRenderStats.h

@@ -1,195 +1,193 @@
-//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
-//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
-#pragma once
-
-#include "BsCorePrerequisites.h"
-#include "BsModule.h"
-
-namespace BansheeEngine
-{
-	/** @cond INTERNAL */
-	/** @addtogroup Profiling
-	 *  @{
-	 */
-
-	/**	Common object types to track resource statistics for. */
-	enum RenderStatResourceType
-	{
-		RenderStatObject_IndexBuffer,
-		RenderStatObject_VertexBuffer,
-		RenderStatObject_GpuBuffer,
-		RenderStatObject_GpuParamBuffer,
-		RenderStatObject_Texture,
-		RenderStatObject_GpuProgram,
-		RenderStatObject_Query
-	};
-
-	/** Object that stores various render statistics. */
-	struct BS_CORE_EXPORT RenderStatsData
-	{
-		RenderStatsData()
-		: numDrawCalls(0), numComputeCalls(0), numRenderTargetChanges(0), numPresents(0), numClears(0),
-		  numVertices(0), numPrimitives(0), numBlendStateChanges(0), numRasterizerStateChanges(0), 
-		  numDepthStencilStateChanges(0), numTextureBinds(0), numSamplerBinds(0), numVertexBufferBinds(0), 
-		  numIndexBufferBinds(0), numGpuParamBufferBinds(0), numGpuProgramBinds(0)
-		{ }
-
-		UINT64 numDrawCalls;
-		UINT64 numComputeCalls;
-		UINT64 numRenderTargetChanges;
-		UINT64 numPresents;
-		UINT64 numClears;
-
-		UINT64 numVertices;
-		UINT64 numPrimitives;
-
-		UINT64 numBlendStateChanges; 
-		UINT64 numRasterizerStateChanges; 
-		UINT64 numDepthStencilStateChanges;
-
-		UINT64 numTextureBinds; 
-		UINT64 numSamplerBinds; 
-		UINT64 numVertexBufferBinds; 
-		UINT64 numIndexBufferBinds;
-		UINT64 numGpuParamBufferBinds;
-		UINT64 numGpuProgramBinds; 
-
-		UINT64 numResourceWrites;
-		UINT64 numResourceReads;
-
-		UINT64 numObjectsCreated; 
-		UINT64 numObjectsDestroyed;
-	};
-
-	/**
-	 * Tracks various render system statistics.
-	 *
-	 * @note	Core thread only.
-	 */
-	class BS_CORE_EXPORT RenderStats : public Module<RenderStats>
-	{
-	public:
-		/** Increments draw call counter indicating how many times were render system API Draw methods called. */
-		void incNumDrawCalls() { mData.numDrawCalls++; }
-
-		/** Increments compute call counter indicating how many times were compute shaders dispatched. */
-		void incNumComputeCalls() { mData.numComputeCalls++; }
-
-		/** Increments render target change counter indicating how many times did the active render target change. */
-		void incNumRenderTargetChanges() { mData.numRenderTargetChanges++; }
-
-		/** Increments render target present counter indicating how many times did the buffer swap happen. */
-		void incNumPresents() { mData.numPresents++; }
-
-		/** 
-		 * Increments render target clear counter indicating how many times did the target the cleared, entirely or 
-		 * partially. 
-		 */
-		void incNumClears() { mData.numClears++; }
-
-		/** Increments vertex draw counter indicating how many vertices were sent to the pipeline. */
-		void addNumVertices(UINT32 count) { mData.numVertices += count; }
-
-		/** Increments primitive draw counter indicating how many primitives were sent to the pipeline. */
-		void addNumPrimitives(UINT32 count) { mData.numPrimitives += count; }
-
-		/** Increments blend state change counter indicating how many times was a blend state bound to the pipeline. */
-		void incNumBlendStateChanges() { mData.numBlendStateChanges++; }
-
-		/** 
-		 * Increments rasterizer state change counter indicating how many times was a rasterizer state bound to the 
-		 * pipeline.
-		 */
-		void incNumRasterizerStateChanges() { mData.numRasterizerStateChanges++; }
-
-		/** 
-		 * Increments depth/stencil state change counter indicating how many times was a depth/stencil state bound to the 
-		 * pipeline. 
-		 */
-		void incNumDepthStencilStateChanges() { mData.numDepthStencilStateChanges++; }
-
-		/** Increments texture change counter indicating how many times was a texture bound to the pipeline. */
-		void incNumTextureBinds() { mData.numTextureBinds++; }
-
-		/** Increments sampler state change counter indicating how many times was a sampler state bound to the pipeline. */
-		void incNumSamplerBinds() { mData.numSamplerBinds++; }
-
-		/** Increments vertex buffer change counter indicating how many times was a vertex buffer bound to the pipeline. */
-		void incNumVertexBufferBinds() { mData.numVertexBufferBinds++; }
-
-		/** Increments index buffer change counter indicating how many times was a index buffer bound to the pipeline. */
-		void incNumIndexBufferBinds() { mData.numIndexBufferBinds++; }
-
-		/** 
-		 * Increments GPU parameter buffer change counter indicating how many times was a GPU parameter buffer bound to the 
-		 * pipeline.
-		 */
-		void incNumGpuParamBufferBinds() { mData.numGpuParamBufferBinds++; }
-
-		/** Increments GPU program change counter indicating how many times was a GPU program bound to the pipeline. */
-		void incNumGpuProgramBinds() { mData.numGpuProgramBinds++; }
-
-		/**
-		 * Increments created GPU resource counter. 
-		 *
-		 * @param[in]	category	Category of the resource.
-		 */
-		void incResCreated(UINT32 category) 
-		{
-			// TODO - I'm ignoring resourceType for now. Later I will want to
-			// count object creation/destruction/read/write per type. I will
-			// also want to allow the caller to assign names to specific "resourceType" id.
-			// (Since many types will be RenderAPI specific).
-
-			// TODO - I should also track number of active GPU objects using this method, instead
-			// of just keeping track of how many were created and destroyed during the frame.
-
-			mData.numObjectsCreated++;
-		}
-
-		/**
-		 * Increments destroyed GPU resource counter. 
-		 *
-		 * @param[in]	category	Category of the resource.
-		 */
-		void incResDestroyed(UINT32 category) { mData.numObjectsDestroyed++; }
-
-		/**
-		 * Increments GPU resource read counter. 
-		 *
-		 * @param[in]	category	Category of the resource.
-		 */
-		void incResRead(UINT32 category) { mData.numResourceReads++; }
-
-		/**
-		 * Increments GPU resource write counter. 
-		 *
-		 * @param[in]	category	Category of the resource.
-		 */
-		void incResWrite(UINT32 category) { mData.numResourceWrites++; }
-
-		/**
-		 * Returns an object containing various rendering statistics.
-		 *			
-		 * @note	
-		 * Do not modify the returned state unless you know what you are doing, it will change the actual internal object.
-		 */
-		RenderStatsData& getData() { return mData; }
-
-	private:
-		RenderStatsData mData;
-	};
-
-#if BS_PROFILING_ENABLED
-	#define BS_INC_RENDER_STAT_CAT(Stat, Category) RenderStats::instance().inc##Stat##((UINT32)##Category##)
-	#define BS_INC_RENDER_STAT(Stat) RenderStats::instance().inc##Stat##()
-	#define BS_ADD_RENDER_STAT(Stat, Count) RenderStats::instance().add##Stat##(##Count##)
-#else
-	#define BS_INC_RENDER_STAT_CAT(Stat, Category)
-	#define BS_INC_RENDER_STAT(Stat)
-	#define BS_ADD_RENDER_STAT(Stat, Count)
-#endif
-
-	/** @} */
-	/** @endcond */
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+#pragma once
+
+#include "BsCorePrerequisites.h"
+#include "BsModule.h"
+
+namespace BansheeEngine
+{
+	/** @addtogroup Profiling-Internal
+	 *  @{
+	 */
+
+	/**	Common object types to track resource statistics for. */
+	enum RenderStatResourceType
+	{
+		RenderStatObject_IndexBuffer,
+		RenderStatObject_VertexBuffer,
+		RenderStatObject_GpuBuffer,
+		RenderStatObject_GpuParamBuffer,
+		RenderStatObject_Texture,
+		RenderStatObject_GpuProgram,
+		RenderStatObject_Query
+	};
+
+	/** Object that stores various render statistics. */
+	struct BS_CORE_EXPORT RenderStatsData
+	{
+		RenderStatsData()
+		: numDrawCalls(0), numComputeCalls(0), numRenderTargetChanges(0), numPresents(0), numClears(0),
+		  numVertices(0), numPrimitives(0), numBlendStateChanges(0), numRasterizerStateChanges(0), 
+		  numDepthStencilStateChanges(0), numTextureBinds(0), numSamplerBinds(0), numVertexBufferBinds(0), 
+		  numIndexBufferBinds(0), numGpuParamBufferBinds(0), numGpuProgramBinds(0)
+		{ }
+
+		UINT64 numDrawCalls;
+		UINT64 numComputeCalls;
+		UINT64 numRenderTargetChanges;
+		UINT64 numPresents;
+		UINT64 numClears;
+
+		UINT64 numVertices;
+		UINT64 numPrimitives;
+
+		UINT64 numBlendStateChanges; 
+		UINT64 numRasterizerStateChanges; 
+		UINT64 numDepthStencilStateChanges;
+
+		UINT64 numTextureBinds; 
+		UINT64 numSamplerBinds; 
+		UINT64 numVertexBufferBinds; 
+		UINT64 numIndexBufferBinds;
+		UINT64 numGpuParamBufferBinds;
+		UINT64 numGpuProgramBinds; 
+
+		UINT64 numResourceWrites;
+		UINT64 numResourceReads;
+
+		UINT64 numObjectsCreated; 
+		UINT64 numObjectsDestroyed;
+	};
+
+	/**
+	 * Tracks various render system statistics.
+	 *
+	 * @note	Core thread only.
+	 */
+	class BS_CORE_EXPORT RenderStats : public Module<RenderStats>
+	{
+	public:
+		/** Increments draw call counter indicating how many times were render system API Draw methods called. */
+		void incNumDrawCalls() { mData.numDrawCalls++; }
+
+		/** Increments compute call counter indicating how many times were compute shaders dispatched. */
+		void incNumComputeCalls() { mData.numComputeCalls++; }
+
+		/** Increments render target change counter indicating how many times did the active render target change. */
+		void incNumRenderTargetChanges() { mData.numRenderTargetChanges++; }
+
+		/** Increments render target present counter indicating how many times did the buffer swap happen. */
+		void incNumPresents() { mData.numPresents++; }
+
+		/** 
+		 * Increments render target clear counter indicating how many times did the target the cleared, entirely or 
+		 * partially. 
+		 */
+		void incNumClears() { mData.numClears++; }
+
+		/** Increments vertex draw counter indicating how many vertices were sent to the pipeline. */
+		void addNumVertices(UINT32 count) { mData.numVertices += count; }
+
+		/** Increments primitive draw counter indicating how many primitives were sent to the pipeline. */
+		void addNumPrimitives(UINT32 count) { mData.numPrimitives += count; }
+
+		/** Increments blend state change counter indicating how many times was a blend state bound to the pipeline. */
+		void incNumBlendStateChanges() { mData.numBlendStateChanges++; }
+
+		/** 
+		 * Increments rasterizer state change counter indicating how many times was a rasterizer state bound to the 
+		 * pipeline.
+		 */
+		void incNumRasterizerStateChanges() { mData.numRasterizerStateChanges++; }
+
+		/** 
+		 * Increments depth/stencil state change counter indicating how many times was a depth/stencil state bound to the 
+		 * pipeline. 
+		 */
+		void incNumDepthStencilStateChanges() { mData.numDepthStencilStateChanges++; }
+
+		/** Increments texture change counter indicating how many times was a texture bound to the pipeline. */
+		void incNumTextureBinds() { mData.numTextureBinds++; }
+
+		/** Increments sampler state change counter indicating how many times was a sampler state bound to the pipeline. */
+		void incNumSamplerBinds() { mData.numSamplerBinds++; }
+
+		/** Increments vertex buffer change counter indicating how many times was a vertex buffer bound to the pipeline. */
+		void incNumVertexBufferBinds() { mData.numVertexBufferBinds++; }
+
+		/** Increments index buffer change counter indicating how many times was a index buffer bound to the pipeline. */
+		void incNumIndexBufferBinds() { mData.numIndexBufferBinds++; }
+
+		/** 
+		 * Increments GPU parameter buffer change counter indicating how many times was a GPU parameter buffer bound to the 
+		 * pipeline.
+		 */
+		void incNumGpuParamBufferBinds() { mData.numGpuParamBufferBinds++; }
+
+		/** Increments GPU program change counter indicating how many times was a GPU program bound to the pipeline. */
+		void incNumGpuProgramBinds() { mData.numGpuProgramBinds++; }
+
+		/**
+		 * Increments created GPU resource counter. 
+		 *
+		 * @param[in]	category	Category of the resource.
+		 */
+		void incResCreated(UINT32 category) 
+		{
+			// TODO - I'm ignoring resourceType for now. Later I will want to
+			// count object creation/destruction/read/write per type. I will
+			// also want to allow the caller to assign names to specific "resourceType" id.
+			// (Since many types will be RenderAPI specific).
+
+			// TODO - I should also track number of active GPU objects using this method, instead
+			// of just keeping track of how many were created and destroyed during the frame.
+
+			mData.numObjectsCreated++;
+		}
+
+		/**
+		 * Increments destroyed GPU resource counter. 
+		 *
+		 * @param[in]	category	Category of the resource.
+		 */
+		void incResDestroyed(UINT32 category) { mData.numObjectsDestroyed++; }
+
+		/**
+		 * Increments GPU resource read counter. 
+		 *
+		 * @param[in]	category	Category of the resource.
+		 */
+		void incResRead(UINT32 category) { mData.numResourceReads++; }
+
+		/**
+		 * Increments GPU resource write counter. 
+		 *
+		 * @param[in]	category	Category of the resource.
+		 */
+		void incResWrite(UINT32 category) { mData.numResourceWrites++; }
+
+		/**
+		 * Returns an object containing various rendering statistics.
+		 *			
+		 * @note	
+		 * Do not modify the returned state unless you know what you are doing, it will change the actual internal object.
+		 */
+		RenderStatsData& getData() { return mData; }
+
+	private:
+		RenderStatsData mData;
+	};
+
+#if BS_PROFILING_ENABLED
+	#define BS_INC_RENDER_STAT_CAT(Stat, Category) RenderStats::instance().inc##Stat##((UINT32)##Category##)
+	#define BS_INC_RENDER_STAT(Stat) RenderStats::instance().inc##Stat##()
+	#define BS_ADD_RENDER_STAT(Stat, Count) RenderStats::instance().add##Stat##(##Count##)
+#else
+	#define BS_INC_RENDER_STAT_CAT(Stat, Category)
+	#define BS_INC_RENDER_STAT(Stat)
+	#define BS_ADD_RENDER_STAT(Stat, Count)
+#endif
+
+	/** @} */
 }

+ 47 - 45
Source/BansheeCore/Include/BsRenderTarget.h

@@ -115,7 +115,53 @@ namespace BansheeEngine
 		UINT32 mMultisampleCount = 0;
 	};
 
-	/** @cond INTERNAL */
+	/**
+	 * Render target is a frame buffer or a texture that the render system renders the scene to.
+	 *
+	 * @note	
+	 * Sim thread unless noted otherwise. Retrieve core implementation from getCore() for core thread only functionality.
+	 */
+    class BS_CORE_EXPORT RenderTarget : public CoreObject
+    {
+    public:
+		RenderTarget();
+		virtual ~RenderTarget() { }
+
+		/** Queries the render target for a custom attribute. This may be anything and is implementation specific. */
+		virtual void getCustomAttribute(const String& name, void* pData) const;
+
+		/** @copydoc RenderTargetCore::setPriority */
+		void setPriority(CoreAccessor& accessor, INT32 priority);
+
+		/**
+		 * Returns properties that describe the render target.
+		 *
+		 * @note	Sim thread only.
+		 */
+		const RenderTargetProperties& getProperties() const;
+
+		/** Retrieves a core implementation of a render target usable only from the core thread. */
+		SPtr<RenderTargetCore> getCore() const;
+
+		/**
+		 * Event that gets triggered whenever the render target is resized.
+		 *
+		 * @note	Sim thread only.
+		 */
+		mutable Event<void()> onResized;
+
+    protected:
+		friend class RenderTargetCore;
+
+		/**	Returns properties that describe the render target. */
+		virtual const RenderTargetProperties& getPropertiesInternal() const = 0;
+    };
+
+	/** @} */
+
+	/** @addtogroup RenderAPI-Internal
+	 *  @{
+	 */
 
 	/**
 	 * Provides access to internal render target implementation usable only from the core thread.
@@ -159,49 +205,5 @@ namespace BansheeEngine
 		virtual const RenderTargetProperties& getPropertiesInternal() const = 0;
 	};
 
-	/** @endcond */
-
-	/**
-	 * Render target is a frame buffer or a texture that the render system renders the scene to.
-	 *
-	 * @note	
-	 * Sim thread unless noted otherwise. Retrieve core implementation from getCore() for core thread only functionality.
-	 */
-    class BS_CORE_EXPORT RenderTarget : public CoreObject
-    {
-    public:
-		RenderTarget();
-		virtual ~RenderTarget() { }
-
-		/** Queries the render target for a custom attribute. This may be anything and is implementation specific. */
-		virtual void getCustomAttribute(const String& name, void* pData) const;
-
-		/** @copydoc RenderTargetCore::setPriority */
-		void setPriority(CoreAccessor& accessor, INT32 priority);
-
-		/**
-		 * Returns properties that describe the render target.
-		 *
-		 * @note	Sim thread only.
-		 */
-		const RenderTargetProperties& getProperties() const;
-
-		/** Retrieves a core implementation of a render target usable only from the core thread. */
-		SPtr<RenderTargetCore> getCore() const;
-
-		/**
-		 * Event that gets triggered whenever the render target is resized.
-		 *
-		 * @note	Sim thread only.
-		 */
-		mutable Event<void()> onResized;
-
-    protected:
-		friend class RenderTargetCore;
-
-		/**	Returns properties that describe the render target. */
-		virtual const RenderTargetProperties& getPropertiesInternal() const = 0;
-    };
-
 	/** @} */
 }

+ 178 - 176
Source/BansheeCore/Include/BsRenderTexture.h

@@ -1,177 +1,179 @@
-//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
-//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
-#pragma once
-
-#include "BsCorePrerequisites.h"
-#include "BsTexture.h"
-#include "BsRenderTarget.h"
-
-namespace BansheeEngine
-{    
-	/** @addtogroup RenderAPI
-	 *  @{
-	 */
-
-	/**	Structure that describes a render texture color and depth/stencil surfaces. */
-	struct BS_CORE_EXPORT RENDER_TEXTURE_DESC
-	{
-		RENDER_SURFACE_DESC colorSurface;
-		RENDER_SURFACE_DESC depthStencilSurface;
-	};
-
-	struct RENDER_TEXTURE_CORE_DESC;
-
-	/**	Contains various properties that describe a render texture. */
-	class BS_CORE_EXPORT RenderTextureProperties : public RenderTargetProperties
-	{
-	public:
-		RenderTextureProperties(const RENDER_TEXTURE_DESC& desc, bool requiresFlipping);
-		RenderTextureProperties(const RENDER_TEXTURE_CORE_DESC& desc, bool requiresFlipping);
-		virtual ~RenderTextureProperties() { }
-
-	private:
-		void construct(const TextureProperties* textureProps, bool requiresFlipping);
-
-		friend class RenderTextureCore;
-		friend class RenderTexture;
-	};
-
-	/** @cond INTERNAL */
-
-	/**
-	 * @see		RENDER_TEXTURE_DESC
-	 *
-	 * @note	References core textures instead of texture handles.
-	 */
-	struct BS_CORE_EXPORT RENDER_TEXTURE_CORE_DESC
-	{
-		RENDER_SURFACE_CORE_DESC colorSurface;
-		RENDER_SURFACE_CORE_DESC depthStencilSurface;
-	};
-
-	/**
-	 * Provides access to internal render texture implementation usable only from the core thread.
-	 *
-	 * @note	Core thread only.
-	 */
-	class BS_CORE_EXPORT RenderTextureCore : public RenderTargetCore
-	{
-	public:
-		RenderTextureCore(const RENDER_TEXTURE_CORE_DESC& desc);
-		virtual ~RenderTextureCore();
-
-		/** @copydoc CoreObjectCore::initialize */
-		virtual void initialize();
-
-		/** @copydoc TextureCoreManager::createRenderTexture(const RENDER_TEXTURE_DESC&) */
-		static SPtr<RenderTextureCore> create(const RENDER_TEXTURE_CORE_DESC& desc);
-
-		/**
-		 * Returns a color surface texture you may bind as an input to an GPU program.
-		 *
-		 * @note	Be aware that you cannot bind a render texture for reading and writing at the same time.
-		 */
-		SPtr<TextureCore> getBindableColorTexture() const { return mDesc.colorSurface.texture; }
-
-		/**
-		 * Returns a depth/stencil surface texture you may bind as an input to an GPU program.
-		 *
-		 * @note	Be aware that you cannot bind a render texture for reading and writing at the same time.
-		 */
-		SPtr<TextureCore> getBindableDepthStencilTexture() const { return mDesc.depthStencilSurface.texture; }
-
-		/**	Returns properties that describe the render texture. */
-		const RenderTextureProperties& getProperties() const;
-
-	protected:
-		/** @copydoc CoreObjectCore::syncToCore */
-		virtual void syncToCore(const CoreSyncData& data) override;
-
-	private:
-		/**	Throws an exception of the color and depth/stencil buffers aren't compatible. */
-		void throwIfBuffersDontMatch() const;
-
-	protected:
-		friend class RenderTexture;
-
-		TextureViewPtr mColorSurface;
-		TextureViewPtr mDepthStencilSurface;
-
-		RENDER_TEXTURE_CORE_DESC mDesc;
-	};
-
-	/** @endcond */
-
-	/**
-	 * Render target specialization that allows you to render into a texture you may later bind in further render operations.
-	 *
-	 * @note	Sim thread only. Retrieve core implementation from getCore() for core thread only functionality.
-	 */
-    class BS_CORE_EXPORT RenderTexture : public RenderTarget
-    {
-	public:
-		virtual ~RenderTexture() { }
-
-		/**
-		 * Creates a new render texture with color and optionally depth/stencil surfaces.
-		 *
-		 * @param[in]	textureType			Type of texture to render to.
-		 * @param[in]	width				Width of the render texture, in pixels.
-		 * @param[in]	height				Height of the render texture, in pixels.
-		 * @param[in]	format				Pixel format used by the texture color surface.
-		 * @param[in]	hwGamma				Should the written pixels be gamma corrected.
-		 * @param[in]	multisampleCount	If higher than 1, texture containing multiple samples per pixel is created.
-		 * @param[in]	createDepth			Should a depth/stencil surface be created along with the color surface.
-		 * @param[in]	depthStencilFormat	Format used by the depth stencil surface, if one is created.
-		 */
-		static RenderTexturePtr create(TextureType textureType, UINT32 width, UINT32 height, 
-			PixelFormat format = PF_R8G8B8A8, bool hwGamma = false, UINT32 multisampleCount = 0, 
-			bool createDepth = true, PixelFormat depthStencilFormat = PF_D24S8);
-
-		/** @copydoc TextureManager::createRenderTexture(const RENDER_TEXTURE_DESC&) */
-		static RenderTexturePtr create(const RENDER_TEXTURE_DESC& desc);
-
-		/**
-		 * Returns a color surface texture you may bind as an input to an GPU program.
-		 *
-		 * @note	Be aware that you cannot bind a render texture for reading and writing at the same time.
-		 */
-		const HTexture& getBindableColorTexture() const { return mBindableColorTex; }
-
-		/**
-		 * Returns a depth/stencil surface texture you may bind as an input to an GPU program.
-		 *
-		 * @note	Be aware that you cannot bind a render texture for reading and writing at the same time.
-		 */
-		const HTexture& getBindableDepthStencilTexture() const { return mBindableDepthStencilTex; }
-
-		/**
-		 * Retrieves a core implementation of a render texture usable only from the core thread.
-		 *
-		 * @note	Core thread only.
-		 */
-		SPtr<RenderTextureCore> getCore() const;
-
-		/**	Returns properties that describe the render texture. */
-		const RenderTextureProperties& getProperties() const;
-
-	protected:
-		friend class TextureManager;
-
-		RenderTexture(const RENDER_TEXTURE_DESC& desc);
-
-		/** @copydoc RenderTexture::createCore */
-		virtual SPtr<CoreObjectCore> createCore() const override;
-
-		/** @copydoc CoreObjectCore::syncToCore */
-		virtual CoreSyncData syncToCore(FrameAlloc* allocator) override;
-
-	protected:
-		HTexture mBindableColorTex;
-		HTexture mBindableDepthStencilTex;
-
-		RENDER_TEXTURE_DESC mDesc;
-	};
-
-	/** @} */
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+#pragma once
+
+#include "BsCorePrerequisites.h"
+#include "BsTexture.h"
+#include "BsRenderTarget.h"
+
+namespace BansheeEngine
+{    
+	/** @addtogroup RenderAPI
+	 *  @{
+	 */
+
+	/**	Structure that describes a render texture color and depth/stencil surfaces. */
+	struct BS_CORE_EXPORT RENDER_TEXTURE_DESC
+	{
+		RENDER_SURFACE_DESC colorSurface;
+		RENDER_SURFACE_DESC depthStencilSurface;
+	};
+
+	struct RENDER_TEXTURE_CORE_DESC;
+
+	/**	Contains various properties that describe a render texture. */
+	class BS_CORE_EXPORT RenderTextureProperties : public RenderTargetProperties
+	{
+	public:
+		RenderTextureProperties(const RENDER_TEXTURE_DESC& desc, bool requiresFlipping);
+		RenderTextureProperties(const RENDER_TEXTURE_CORE_DESC& desc, bool requiresFlipping);
+		virtual ~RenderTextureProperties() { }
+
+	private:
+		void construct(const TextureProperties* textureProps, bool requiresFlipping);
+
+		friend class RenderTextureCore;
+		friend class RenderTexture;
+	};
+
+	/**
+	 * Render target specialization that allows you to render into a texture you may later bind in further render operations.
+	 *
+	 * @note	Sim thread only. Retrieve core implementation from getCore() for core thread only functionality.
+	 */
+    class BS_CORE_EXPORT RenderTexture : public RenderTarget
+    {
+	public:
+		virtual ~RenderTexture() { }
+
+		/**
+		 * Creates a new render texture with color and optionally depth/stencil surfaces.
+		 *
+		 * @param[in]	textureType			Type of texture to render to.
+		 * @param[in]	width				Width of the render texture, in pixels.
+		 * @param[in]	height				Height of the render texture, in pixels.
+		 * @param[in]	format				Pixel format used by the texture color surface.
+		 * @param[in]	hwGamma				Should the written pixels be gamma corrected.
+		 * @param[in]	multisampleCount	If higher than 1, texture containing multiple samples per pixel is created.
+		 * @param[in]	createDepth			Should a depth/stencil surface be created along with the color surface.
+		 * @param[in]	depthStencilFormat	Format used by the depth stencil surface, if one is created.
+		 */
+		static RenderTexturePtr create(TextureType textureType, UINT32 width, UINT32 height, 
+			PixelFormat format = PF_R8G8B8A8, bool hwGamma = false, UINT32 multisampleCount = 0, 
+			bool createDepth = true, PixelFormat depthStencilFormat = PF_D24S8);
+
+		/** @copydoc TextureManager::createRenderTexture(const RENDER_TEXTURE_DESC&) */
+		static RenderTexturePtr create(const RENDER_TEXTURE_DESC& desc);
+
+		/**
+		 * Returns a color surface texture you may bind as an input to an GPU program.
+		 *
+		 * @note	Be aware that you cannot bind a render texture for reading and writing at the same time.
+		 */
+		const HTexture& getBindableColorTexture() const { return mBindableColorTex; }
+
+		/**
+		 * Returns a depth/stencil surface texture you may bind as an input to an GPU program.
+		 *
+		 * @note	Be aware that you cannot bind a render texture for reading and writing at the same time.
+		 */
+		const HTexture& getBindableDepthStencilTexture() const { return mBindableDepthStencilTex; }
+
+		/**
+		 * Retrieves a core implementation of a render texture usable only from the core thread.
+		 *
+		 * @note	Core thread only.
+		 */
+		SPtr<RenderTextureCore> getCore() const;
+
+		/**	Returns properties that describe the render texture. */
+		const RenderTextureProperties& getProperties() const;
+
+	protected:
+		friend class TextureManager;
+
+		RenderTexture(const RENDER_TEXTURE_DESC& desc);
+
+		/** @copydoc RenderTexture::createCore */
+		virtual SPtr<CoreObjectCore> createCore() const override;
+
+		/** @copydoc CoreObjectCore::syncToCore */
+		virtual CoreSyncData syncToCore(FrameAlloc* allocator) override;
+
+	protected:
+		HTexture mBindableColorTex;
+		HTexture mBindableDepthStencilTex;
+
+		RENDER_TEXTURE_DESC mDesc;
+	};
+
+	/** @} */
+
+/** @addtogroup RenderAPI-Internal
+	 *  @{
+	 */
+
+	/**
+	 * @see		RENDER_TEXTURE_DESC
+	 *
+	 * @note	References core textures instead of texture handles.
+	 */
+	struct BS_CORE_EXPORT RENDER_TEXTURE_CORE_DESC
+	{
+		RENDER_SURFACE_CORE_DESC colorSurface;
+		RENDER_SURFACE_CORE_DESC depthStencilSurface;
+	};
+
+	/**
+	 * Provides access to internal render texture implementation usable only from the core thread.
+	 *
+	 * @note	Core thread only.
+	 */
+	class BS_CORE_EXPORT RenderTextureCore : public RenderTargetCore
+	{
+	public:
+		RenderTextureCore(const RENDER_TEXTURE_CORE_DESC& desc);
+		virtual ~RenderTextureCore();
+
+		/** @copydoc CoreObjectCore::initialize */
+		virtual void initialize();
+
+		/** @copydoc TextureCoreManager::createRenderTexture(const RENDER_TEXTURE_DESC&) */
+		static SPtr<RenderTextureCore> create(const RENDER_TEXTURE_CORE_DESC& desc);
+
+		/**
+		 * Returns a color surface texture you may bind as an input to an GPU program.
+		 *
+		 * @note	Be aware that you cannot bind a render texture for reading and writing at the same time.
+		 */
+		SPtr<TextureCore> getBindableColorTexture() const { return mDesc.colorSurface.texture; }
+
+		/**
+		 * Returns a depth/stencil surface texture you may bind as an input to an GPU program.
+		 *
+		 * @note	Be aware that you cannot bind a render texture for reading and writing at the same time.
+		 */
+		SPtr<TextureCore> getBindableDepthStencilTexture() const { return mDesc.depthStencilSurface.texture; }
+
+		/**	Returns properties that describe the render texture. */
+		const RenderTextureProperties& getProperties() const;
+
+	protected:
+		/** @copydoc CoreObjectCore::syncToCore */
+		virtual void syncToCore(const CoreSyncData& data) override;
+
+	private:
+		/**	Throws an exception of the color and depth/stencil buffers aren't compatible. */
+		void throwIfBuffersDontMatch() const;
+
+	protected:
+		friend class RenderTexture;
+
+		TextureViewPtr mColorSurface;
+		TextureViewPtr mDepthStencilSurface;
+
+		RENDER_TEXTURE_CORE_DESC mDesc;
+	};
+
+	/** @} */
 }

+ 85 - 83
Source/BansheeCore/Include/BsRenderWindow.h

@@ -86,7 +86,91 @@ namespace BansheeEngine
 		bool mIsMaximized = false;
 	};
 
-	/** @cond INTERNAL */
+	/**
+	 * Render target specialization that allows you to render into window frame buffer(s).
+	 *
+	 * @note	Sim thread only. Retrieve core implementation from getCore() for core thread only functionality.
+	 */
+    class BS_CORE_EXPORT RenderWindow : public RenderTarget
+    {
+    public:
+		virtual ~RenderWindow() { }
+
+		/** @copydoc RenderTarget::destroy */
+		virtual void destroy() override;	
+
+		/**	Converts screen position into window local position. */
+		virtual Vector2I screenToWindowPos(const Vector2I& screenPos) const = 0;
+
+		/**	Converts window local position to screen position. */
+		virtual Vector2I windowToScreenPos(const Vector2I& windowPos) const = 0;
+
+		/**	Resize the window to specified width and height in pixels. */
+		void resize(CoreAccessor& accessor, UINT32 width, UINT32 height);
+
+		/**	Move the window to specified screen coordinates. */
+		void move(CoreAccessor& accessor, INT32 left, INT32 top);
+
+		/**	Hide the window. (Does not destroy it, just hides it). */
+		void hide(CoreAccessor& accessor);
+
+		/**	Shows a previously hidden window. */
+		void show(CoreAccessor& accessor);
+
+		/** @copydoc RenderWindowCore::minimize */
+		void minimize(CoreAccessor& accessor);
+
+		/** @copydoc RenderWindowCore::maximize */
+		void maximize(CoreAccessor& accessor);
+
+		/** @copydoc RenderWindowCore::restore */
+		void restore(CoreAccessor& accessor);
+
+		/** @copydoc RenderWindowCore::setFullscreen(UINT32, UINT32, float, UINT32) */
+		void setFullscreen(CoreAccessor& accessor, UINT32 width, UINT32 height, float refreshRate = 60.0f, UINT32 monitorIdx = 0);
+
+		/** @copydoc RenderWindowCore::setFullscreen(const VideoMode&) */
+		void setFullscreen(CoreAccessor& accessor, const VideoMode& mode);
+
+		/** @copydoc RenderWindowCore::setWindowed */
+		void setWindowed(CoreAccessor& accessor, UINT32 width, UINT32 height);
+
+		/**	Retrieves a core implementation of a render window usable only from the core thread. */
+		SPtr<RenderWindowCore> getCore() const;
+
+		/**	Returns properties that describe the render window. */
+		const RenderWindowProperties& getProperties() const;
+
+		/**
+		 * Creates a new render window using the specified options. Optionally makes the created window a child of another 
+		 * window.
+		 */
+		static RenderWindowPtr create(RENDER_WINDOW_DESC& desc, RenderWindowPtr parentWindow = nullptr);
+
+    protected:
+		friend class RenderWindowManager;
+
+		RenderWindow(const RENDER_WINDOW_DESC& desc, UINT32 windowId);
+
+		/** Returns render window properties that may be edited. */
+		RenderWindowProperties& getMutableProperties();
+
+		/** @copydoc RenderTarget::createCore */
+		SPtr<CoreObjectCore> createCore() const override;
+
+		/**	Updates window properties from the synced property data. */
+		virtual void syncProperties() = 0;
+
+	protected:
+		RENDER_WINDOW_DESC mDesc;
+		UINT32 mWindowId;
+    };
+
+	/** @} */
+
+	/** @addtogroup RenderAPI-Internal
+	 *  @{
+	 */
 
 	/**
 	 * Provides access to internal render window implementation usable only from the core thread.
@@ -215,87 +299,5 @@ namespace BansheeEngine
 		UINT32 mWindowId;
 	};
 
-	/** @endcond */
-
-	/**
-	 * Render target specialization that allows you to render into window frame buffer(s).
-	 *
-	 * @note	Sim thread only. Retrieve core implementation from getCore() for core thread only functionality.
-	 */
-    class BS_CORE_EXPORT RenderWindow : public RenderTarget
-    {
-    public:
-		virtual ~RenderWindow() { }
-
-		/** @copydoc RenderTarget::destroy */
-		virtual void destroy() override;	
-
-		/**	Converts screen position into window local position. */
-		virtual Vector2I screenToWindowPos(const Vector2I& screenPos) const = 0;
-
-		/**	Converts window local position to screen position. */
-		virtual Vector2I windowToScreenPos(const Vector2I& windowPos) const = 0;
-
-		/**	Resize the window to specified width and height in pixels. */
-		void resize(CoreAccessor& accessor, UINT32 width, UINT32 height);
-
-		/**	Move the window to specified screen coordinates. */
-		void move(CoreAccessor& accessor, INT32 left, INT32 top);
-
-		/**	Hide the window. (Does not destroy it, just hides it). */
-		void hide(CoreAccessor& accessor);
-
-		/**	Shows a previously hidden window. */
-		void show(CoreAccessor& accessor);
-
-		/** @copydoc RenderWindowCore::minimize */
-		void minimize(CoreAccessor& accessor);
-
-		/** @copydoc RenderWindowCore::maximize */
-		void maximize(CoreAccessor& accessor);
-
-		/** @copydoc RenderWindowCore::restore */
-		void restore(CoreAccessor& accessor);
-
-		/** @copydoc RenderWindowCore::setFullscreen(UINT32, UINT32, float, UINT32) */
-		void setFullscreen(CoreAccessor& accessor, UINT32 width, UINT32 height, float refreshRate = 60.0f, UINT32 monitorIdx = 0);
-
-		/** @copydoc RenderWindowCore::setFullscreen(const VideoMode&) */
-		void setFullscreen(CoreAccessor& accessor, const VideoMode& mode);
-
-		/** @copydoc RenderWindowCore::setWindowed */
-		void setWindowed(CoreAccessor& accessor, UINT32 width, UINT32 height);
-
-		/**	Retrieves a core implementation of a render window usable only from the core thread. */
-		SPtr<RenderWindowCore> getCore() const;
-
-		/**	Returns properties that describe the render window. */
-		const RenderWindowProperties& getProperties() const;
-
-		/**
-		 * Creates a new render window using the specified options. Optionally makes the created window a child of another 
-		 * window.
-		 */
-		static RenderWindowPtr create(RENDER_WINDOW_DESC& desc, RenderWindowPtr parentWindow = nullptr);
-
-    protected:
-		friend class RenderWindowManager;
-
-		RenderWindow(const RENDER_WINDOW_DESC& desc, UINT32 windowId);
-
-		/** Returns render window properties that may be edited. */
-		RenderWindowProperties& getMutableProperties();
-
-		/** @copydoc RenderTarget::createCore */
-		SPtr<CoreObjectCore> createCore() const override;
-
-		/**	Updates window properties from the synced property data. */
-		virtual void syncProperties() = 0;
-
-	protected:
-		RENDER_WINDOW_DESC mDesc;
-		UINT32 mWindowId;
-    };
-
 	/** @} */
 }

+ 131 - 133
Source/BansheeCore/Include/BsRenderWindowManager.h

@@ -1,134 +1,132 @@
-//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
-//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
-#pragma once
-
-#include "BsCorePrerequisites.h"
-#include "BsModule.h"
-#include "BsRenderWindow.h"
-#include "BsEvent.h"
-
-namespace BansheeEngine
-{
-	/** @cond INTERNAL */
-	/** @addtogroup RenderAPI
-	 *  @{
-	 */
-
-	/** Handles creation and internal updates relating to render windows. */
-	class BS_CORE_EXPORT RenderWindowManager : public Module<RenderWindowManager>
-	{
-		/**	Holds information about a window that was moved or resized. */
-		struct MoveOrResizeData
-		{
-			INT32 x, y;
-			UINT32 width, height;
-			RenderWindow* window;
-		};
-
-	public:
-		RenderWindowManager();
-		~RenderWindowManager();
-
-		/**
-		 * Creates a new render window using the specified options. Optionally makes the created window a child of another
-		 * window.
-		 */
-		RenderWindowPtr create(RENDER_WINDOW_DESC& desc, RenderWindowPtr parentWindow);
-
-		/** Called once per frame. Dispatches events. */
-		void _update();
-
-		/** Called by the core thread when window is destroyed. */
-		void notifyWindowDestroyed(RenderWindow* window);
-
-		/**	Called by the core thread when window receives focus. */
-		void notifyFocusReceived(RenderWindowCore* window);
-
-		/**	Called by the core thread when window loses focus. */
-		void notifyFocusLost(RenderWindowCore* window);
-
-		/**	Called by the core thread when window is moved or resized. */
-		void notifyMovedOrResized(RenderWindowCore* window);
-
-		/**	Called by the sim thread when window properties change. */
-		void notifySyncDataDirty(RenderWindowCore* coreWindow);
-
-		/**	Returns a list of all open render windows. */
-		Vector<RenderWindow*> getRenderWindows() const;
-
-		/** Event that is triggered when a window gains focus. */
-		Event<void(RenderWindow&)> onFocusGained;
-
-		/**	Event that is triggered when a window loses focus. */
-		Event<void(RenderWindow&)> onFocusLost;
-
-		/**	Event that is triggered when mouse leaves a window. */
-		Event<void(RenderWindow&)> onMouseLeftWindow;
-	protected:
-		friend class RenderWindow;
-
-		/**	Called by the core thread when mouse leaves a window. */
-		void windowMouseLeft(RenderWindowCore* window);
-
-		/**	Finds a sim thread equivalent of the provided core thread window implementation. */
-		RenderWindow* getNonCore(const RenderWindowCore* window) const;
-
-		/** @copydoc create */
-		virtual RenderWindowPtr createImpl(RENDER_WINDOW_DESC& desc, UINT32 windowId, const RenderWindowPtr& parentWindow) = 0;
-
-	protected:
-		BS_MUTEX(mWindowMutex);
-		Map<UINT32, RenderWindow*> mWindows;
-
-		RenderWindow* mWindowInFocus;
-		RenderWindow* mNewWindowInFocus;
-		Vector<MoveOrResizeData> mMovedOrResizedWindows;
-		Vector<RenderWindow*> mMouseLeftWindows;
-		UnorderedSet<RenderWindow*> mDirtyProperties;
-	};
-
-	/**
-	 * Handles creation and internal updates relating to render windows.
-	 *
-	 * @note	Core thread only.
-	 */
-	class BS_CORE_EXPORT RenderWindowCoreManager : public Module<RenderWindowCoreManager>
-	{
-	public:
-		RenderWindowCoreManager();
-
-		/** @copydoc RenderWindowCoreManager::create */
-		SPtr<RenderWindowCore> create(RENDER_WINDOW_DESC& desc);
-
-		/** Called once per frame. Dispatches events. */
-		void _update();
-
-		/**	Called by the core thread when window properties change. */
-		void notifySyncDataDirty(RenderWindowCore* window);
-
-		/**	Returns a list of all open render windows. */
-		Vector<RenderWindowCore*> getRenderWindows() const;
-
-	protected:
-		friend class RenderWindowCore;
-		friend class RenderWindow;
-		friend class RenderWindowManager;
-
-		/** @copydoc create */
-		virtual SPtr<RenderWindowCore> createInternal(RENDER_WINDOW_DESC& desc, UINT32 windowId) = 0;
-
-		/**	Called whenever a window is created. */
-		void windowCreated(RenderWindowCore* window);
-
-		/**	Called by the core thread when window is destroyed. */
-		void windowDestroyed(RenderWindowCore* window);
-
-		BS_MUTEX(mWindowMutex);
-		Vector<RenderWindowCore*> mCreatedWindows;
-		UnorderedSet<RenderWindowCore*> mDirtyProperties;
-		std::atomic_uint mNextWindowId;
-	};
-
-	/** @} */
-	/** @endcond */
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+#pragma once
+
+#include "BsCorePrerequisites.h"
+#include "BsModule.h"
+#include "BsRenderWindow.h"
+#include "BsEvent.h"
+
+namespace BansheeEngine
+{
+	/** @addtogroup RenderAPI-Internal
+	 *  @{
+	 */
+
+	/** Handles creation and internal updates relating to render windows. */
+	class BS_CORE_EXPORT RenderWindowManager : public Module<RenderWindowManager>
+	{
+		/**	Holds information about a window that was moved or resized. */
+		struct MoveOrResizeData
+		{
+			INT32 x, y;
+			UINT32 width, height;
+			RenderWindow* window;
+		};
+
+	public:
+		RenderWindowManager();
+		~RenderWindowManager();
+
+		/**
+		 * Creates a new render window using the specified options. Optionally makes the created window a child of another
+		 * window.
+		 */
+		RenderWindowPtr create(RENDER_WINDOW_DESC& desc, RenderWindowPtr parentWindow);
+
+		/** Called once per frame. Dispatches events. */
+		void _update();
+
+		/** Called by the core thread when window is destroyed. */
+		void notifyWindowDestroyed(RenderWindow* window);
+
+		/**	Called by the core thread when window receives focus. */
+		void notifyFocusReceived(RenderWindowCore* window);
+
+		/**	Called by the core thread when window loses focus. */
+		void notifyFocusLost(RenderWindowCore* window);
+
+		/**	Called by the core thread when window is moved or resized. */
+		void notifyMovedOrResized(RenderWindowCore* window);
+
+		/**	Called by the sim thread when window properties change. */
+		void notifySyncDataDirty(RenderWindowCore* coreWindow);
+
+		/**	Returns a list of all open render windows. */
+		Vector<RenderWindow*> getRenderWindows() const;
+
+		/** Event that is triggered when a window gains focus. */
+		Event<void(RenderWindow&)> onFocusGained;
+
+		/**	Event that is triggered when a window loses focus. */
+		Event<void(RenderWindow&)> onFocusLost;
+
+		/**	Event that is triggered when mouse leaves a window. */
+		Event<void(RenderWindow&)> onMouseLeftWindow;
+	protected:
+		friend class RenderWindow;
+
+		/**	Called by the core thread when mouse leaves a window. */
+		void windowMouseLeft(RenderWindowCore* window);
+
+		/**	Finds a sim thread equivalent of the provided core thread window implementation. */
+		RenderWindow* getNonCore(const RenderWindowCore* window) const;
+
+		/** @copydoc create */
+		virtual RenderWindowPtr createImpl(RENDER_WINDOW_DESC& desc, UINT32 windowId, const RenderWindowPtr& parentWindow) = 0;
+
+	protected:
+		BS_MUTEX(mWindowMutex);
+		Map<UINT32, RenderWindow*> mWindows;
+
+		RenderWindow* mWindowInFocus;
+		RenderWindow* mNewWindowInFocus;
+		Vector<MoveOrResizeData> mMovedOrResizedWindows;
+		Vector<RenderWindow*> mMouseLeftWindows;
+		UnorderedSet<RenderWindow*> mDirtyProperties;
+	};
+
+	/**
+	 * Handles creation and internal updates relating to render windows.
+	 *
+	 * @note	Core thread only.
+	 */
+	class BS_CORE_EXPORT RenderWindowCoreManager : public Module<RenderWindowCoreManager>
+	{
+	public:
+		RenderWindowCoreManager();
+
+		/** @copydoc RenderWindowCoreManager::create */
+		SPtr<RenderWindowCore> create(RENDER_WINDOW_DESC& desc);
+
+		/** Called once per frame. Dispatches events. */
+		void _update();
+
+		/**	Called by the core thread when window properties change. */
+		void notifySyncDataDirty(RenderWindowCore* window);
+
+		/**	Returns a list of all open render windows. */
+		Vector<RenderWindowCore*> getRenderWindows() const;
+
+	protected:
+		friend class RenderWindowCore;
+		friend class RenderWindow;
+		friend class RenderWindowManager;
+
+		/** @copydoc create */
+		virtual SPtr<RenderWindowCore> createInternal(RENDER_WINDOW_DESC& desc, UINT32 windowId) = 0;
+
+		/**	Called whenever a window is created. */
+		void windowCreated(RenderWindowCore* window);
+
+		/**	Called by the core thread when window is destroyed. */
+		void windowDestroyed(RenderWindowCore* window);
+
+		BS_MUTEX(mWindowMutex);
+		Vector<RenderWindowCore*> mCreatedWindows;
+		UnorderedSet<RenderWindowCore*> mDirtyProperties;
+		std::atomic_uint mNextWindowId;
+	};
+
+	/** @} */
 }

+ 31 - 33
Source/BansheeCore/Include/BsRendererFactory.h

@@ -1,34 +1,32 @@
-//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
-//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
-#pragma once
-
-#include "BsCorePrerequisites.h"
-
-namespace BansheeEngine
-{
-	/** @cond INTERNAL */
-	/** @addtogroup Renderer
-	 *  @{
-	 */
-
-	/**
-	 * Factory class for creating Renderer objects. Implement this class for any custom renderer classes you may have, and 
-	 * register it with renderer manager.
-	 * 			
-	 * @see		RendererManager
-	 */
-	class BS_CORE_EXPORT RendererFactory
-	{
-	public:
-		virtual ~RendererFactory() { }
-
-		/**	Creates a new instance of the renderer. */
-		virtual CoreRendererPtr create() = 0;
-
-		/**	Returns the name of the renderer this factory creates. */
-		virtual const String& name() const = 0;
-	};
-
-	/** @} */
-	/** @endcond */
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+#pragma once
+
+#include "BsCorePrerequisites.h"
+
+namespace BansheeEngine
+{
+	/** @addtogroup Renderer-Internal
+	 *  @{
+	 */
+
+	/**
+	 * Factory class for creating Renderer objects. Implement this class for any custom renderer classes you may have, and 
+	 * register it with renderer manager.
+	 * 			
+	 * @see		RendererManager
+	 */
+	class BS_CORE_EXPORT RendererFactory
+	{
+	public:
+		virtual ~RendererFactory() { }
+
+		/**	Creates a new instance of the renderer. */
+		virtual CoreRendererPtr create() = 0;
+
+		/**	Returns the name of the renderer this factory creates. */
+		virtual const String& name() const = 0;
+	};
+
+	/** @} */
 }

+ 51 - 53
Source/BansheeCore/Include/BsRendererManager.h

@@ -1,53 +1,51 @@
-//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
-//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
-#pragma once
-
-#include "BsCorePrerequisites.h"
-#include "BsModule.h"
-
-namespace BansheeEngine
-{
-	/** @cond INTERNAL */
-	/** @addtogroup Renderer
-	 *  @{
-	 */
-
-	/**
-	 * Allows you to change and retrieve the active renderer. Active renderer will be used for rendering all objects in 
-	 * the following frame.
-	 * 			
-	 * @note	No renderer is active by default. You must make a renderer active before doing any rendering.
-	 */
-	class BS_CORE_EXPORT RendererManager : public Module<RendererManager>
-	{
-	public:
-		~RendererManager();
-
-		/**
-		 * Attempts to find a renderer with the specified name and makes it active. Exception is thrown if renderer with 
-		 * the specified name doesn't exist. You must call initialize() after setting the active renderer to properly 
-		 * activate it.
-		 */
-		void setActive(const String& name);
-
-		/** Initializes the currently active renderer, making it ready to render. */
-		void initialize();
-
-		/**	Returns the currently active renderer. Null if no renderer is active. */
-		CoreRendererPtr getActive() { return mActiveRenderer; }
-
-		/**
-		 * Registers a new renderer factory. Any renderer you try to make active with setActive() you will need to have 
-		 * previously registered here.
-		 */
-		void _registerFactory(RendererFactoryPtr factory);
-	private:
-		Vector<RendererFactoryPtr> mAvailableFactories;
-
-		CoreRendererPtr mActiveRenderer;
-	};
-
-	/** @} */
-	/** @endcond */
-}
-
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+#pragma once
+
+#include "BsCorePrerequisites.h"
+#include "BsModule.h"
+
+namespace BansheeEngine
+{
+	/** @addtogroup Renderer-Internal
+	 *  @{
+	 */
+
+	/**
+	 * Allows you to change and retrieve the active renderer. Active renderer will be used for rendering all objects in 
+	 * the following frame.
+	 * 			
+	 * @note	No renderer is active by default. You must make a renderer active before doing any rendering.
+	 */
+	class BS_CORE_EXPORT RendererManager : public Module<RendererManager>
+	{
+	public:
+		~RendererManager();
+
+		/**
+		 * Attempts to find a renderer with the specified name and makes it active. Exception is thrown if renderer with 
+		 * the specified name doesn't exist. You must call initialize() after setting the active renderer to properly 
+		 * activate it.
+		 */
+		void setActive(const String& name);
+
+		/** Initializes the currently active renderer, making it ready to render. */
+		void initialize();
+
+		/**	Returns the currently active renderer. Null if no renderer is active. */
+		CoreRendererPtr getActive() { return mActiveRenderer; }
+
+		/**
+		 * Registers a new renderer factory. Any renderer you try to make active with setActive() you will need to have 
+		 * previously registered here.
+		 */
+		void _registerFactory(RendererFactoryPtr factory);
+	private:
+		Vector<RendererFactoryPtr> mAvailableFactories;
+
+		CoreRendererPtr mActiveRenderer;
+	};
+
+	/** @} */
+}
+

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

@@ -10,8 +10,6 @@ namespace BansheeEngine
 	 *  @{
 	 */
 
-	/** @cond INTERNAL */
-
 	/**	Data that is shared between all resource handles. */
 	struct BS_CORE_EXPORT ResourceHandleData
 	{
@@ -25,8 +23,6 @@ namespace BansheeEngine
 		UINT32 mRefCount;
 	};
 
-	/** @endcond */
-
 	/**
 	 * Represents a handle to a resource. Handles are similar to a smart pointers, but they have two advantages:
 	 *	- When loading a resource asynchronously you can be immediately returned the handle that you may use throughout

+ 1 - 3
Source/BansheeCore/Include/BsResourceListenerManager.h

@@ -7,8 +7,7 @@
 
 namespace BansheeEngine
 {
-	/** @cond INTERNAL */
-	/** @addtogroup Resources
+	/** @addtogroup Resources-Internal
 	 *  @{
 	 */
 
@@ -84,5 +83,4 @@ namespace BansheeEngine
 	};
 
 	/** @} */
-	/** @endcond */
 }

+ 97 - 99
Source/BansheeCore/Include/BsResourceManifest.h

@@ -1,100 +1,98 @@
-//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
-//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
-#pragma once
-
-#include "BsCorePrerequisites.h"
-#include "BsIReflectable.h"
-
-namespace BansheeEngine
-{
-	/** @cond INTERNAL */
-	/** @addtogroup Resources
-	 *  @{
-	 */
-
-	/**
-	 * Serializable class that contains UUID <-> file path mapping for resources.
-	 * 			
-	 * @note	
-	 * This class allows you to reference resources between sessions. At the end of a session save the resource manifest, 
-	 * and then restore it at the start of a new session. This way ensures that resource UUIDs stay consistent and anything 
-	 * referencing them can find the resources.
-	 * @note
-	 * Thread safe.
-	 */
-	class BS_CORE_EXPORT ResourceManifest : public IReflectable
-	{
-		struct ConstructPrivately {};
-	public:
-		explicit ResourceManifest(const ConstructPrivately& dummy);
-		ResourceManifest(const String& name);
-
-		/**	Returns an unique name of the resource manifest. */
-		const String& getName() const { return mName; }
-
-		/**	Registers a new resource in the manifest. */
-		void registerResource(const String& uuid, const Path& filePath);
-
-		/**	Removes a resource from the manifest. */
-		void unregisterResource(const String& uuid);
-
-		/**
-		 * Attempts to find a resource with the provided UUID and outputs the path to the resource if found. Returns true
-		 * if UUID was found, false otherwise.
-		 */
-		bool uuidToFilePath(const String& uuid, Path& filePath) const;
-
-		/**
-		 * Attempts to find a resource with the provided path and outputs the UUID to the resource if found. Returns true
-		 * if path was found, false otherwise.
-		 */
-		bool filePathToUUID(const Path& filePath, String& outUUID) const;
-
-		/**	Checks if provided UUID exists in the manifest. */
-		bool uuidExists(const String& uuid) const;
-
-		/**	Checks if the provided path exists in the manifest. */
-		bool filePathExists(const Path& filePath) const;
-
-		/**
-		 * Saves the resource manifest to the specified location.
-		 *
-		 * @param[in]	manifest		Manifest to save.
-		 * @param[in]	path			Full pathname of the file to save the manifest in.
-		 * @param[in]	relativePath	If not empty, all pathnames in the manifest will be stored as if relative to this 
-		 *								path.
-		 */
-		static void save(const ResourceManifestPtr& manifest, const Path& path, const Path& relativePath);
-
-		/**
-		 * Loads the resource manifest from the specified location.
-		 *
-		 * @param[in]	path			Full pathname of the file to load the manifest from.
-		 * @param[in]	relativePath	If not empty, all loaded pathnames will have this path prepended.
-		 */
-		static ResourceManifestPtr load(const Path& path, const Path& relativePath);
-
-		/** Creates a new empty resource manifest. Provided name should be unique among manifests. */
-		static ResourceManifestPtr create(const String& name);
-
-	private:
-		String mName;
-		UnorderedMap<String, Path> mUUIDToFilePath;
-		UnorderedMap<Path, String> mFilePathToUUID;
-
-		/************************************************************************/
-		/* 								RTTI		                     		*/
-		/************************************************************************/
-
-		/**	Creates a new empty resource manifest. */
-		static ResourceManifestPtr createEmpty();
-
-	public:
-		friend class ResourceManifestRTTI;
-		static RTTITypeBase* getRTTIStatic();
-		virtual RTTITypeBase* getRTTI() const override;
-	};
-
-	/** @} */
-	/** @endcond */
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+#pragma once
+
+#include "BsCorePrerequisites.h"
+#include "BsIReflectable.h"
+
+namespace BansheeEngine
+{
+	/** @addtogroup Resources-Internal
+	 *  @{
+	 */
+
+	/**
+	 * Serializable class that contains UUID <-> file path mapping for resources.
+	 * 			
+	 * @note	
+	 * This class allows you to reference resources between sessions. At the end of a session save the resource manifest, 
+	 * and then restore it at the start of a new session. This way ensures that resource UUIDs stay consistent and anything 
+	 * referencing them can find the resources.
+	 * @note
+	 * Thread safe.
+	 */
+	class BS_CORE_EXPORT ResourceManifest : public IReflectable
+	{
+		struct ConstructPrivately {};
+	public:
+		explicit ResourceManifest(const ConstructPrivately& dummy);
+		ResourceManifest(const String& name);
+
+		/**	Returns an unique name of the resource manifest. */
+		const String& getName() const { return mName; }
+
+		/**	Registers a new resource in the manifest. */
+		void registerResource(const String& uuid, const Path& filePath);
+
+		/**	Removes a resource from the manifest. */
+		void unregisterResource(const String& uuid);
+
+		/**
+		 * Attempts to find a resource with the provided UUID and outputs the path to the resource if found. Returns true
+		 * if UUID was found, false otherwise.
+		 */
+		bool uuidToFilePath(const String& uuid, Path& filePath) const;
+
+		/**
+		 * Attempts to find a resource with the provided path and outputs the UUID to the resource if found. Returns true
+		 * if path was found, false otherwise.
+		 */
+		bool filePathToUUID(const Path& filePath, String& outUUID) const;
+
+		/**	Checks if provided UUID exists in the manifest. */
+		bool uuidExists(const String& uuid) const;
+
+		/**	Checks if the provided path exists in the manifest. */
+		bool filePathExists(const Path& filePath) const;
+
+		/**
+		 * Saves the resource manifest to the specified location.
+		 *
+		 * @param[in]	manifest		Manifest to save.
+		 * @param[in]	path			Full pathname of the file to save the manifest in.
+		 * @param[in]	relativePath	If not empty, all pathnames in the manifest will be stored as if relative to this 
+		 *								path.
+		 */
+		static void save(const ResourceManifestPtr& manifest, const Path& path, const Path& relativePath);
+
+		/**
+		 * Loads the resource manifest from the specified location.
+		 *
+		 * @param[in]	path			Full pathname of the file to load the manifest from.
+		 * @param[in]	relativePath	If not empty, all loaded pathnames will have this path prepended.
+		 */
+		static ResourceManifestPtr load(const Path& path, const Path& relativePath);
+
+		/** Creates a new empty resource manifest. Provided name should be unique among manifests. */
+		static ResourceManifestPtr create(const String& name);
+
+	private:
+		String mName;
+		UnorderedMap<String, Path> mUUIDToFilePath;
+		UnorderedMap<Path, String> mFilePathToUUID;
+
+		/************************************************************************/
+		/* 								RTTI		                     		*/
+		/************************************************************************/
+
+		/**	Creates a new empty resource manifest. */
+		static ResourceManifestPtr createEmpty();
+
+	public:
+		friend class ResourceManifestRTTI;
+		static RTTITypeBase* getRTTIStatic();
+		virtual RTTITypeBase* getRTTI() const override;
+	};
+
+	/** @} */
 }

+ 204 - 202
Source/BansheeCore/Include/BsSamplerState.h

@@ -1,203 +1,205 @@
-//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
-//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
-#pragma once
-
-#include "BsCorePrerequisites.h"
-#include "BsColor.h"
-#include "BsIReflectable.h"
-#include "BsCoreObject.h"
-
-namespace BansheeEngine 
-{
-	/** @addtogroup RenderAPI
-	 *  @{
-	 */
-
-	/**
-	 * Structure used for initializing a SamplerState.
-	 *
-	 * @see		SamplerState
-	 */
-	struct BS_CORE_EXPORT SAMPLER_STATE_DESC
-	{
-		SAMPLER_STATE_DESC()
-			: minFilter(FO_LINEAR), magFilter(FO_LINEAR), mipFilter(FO_POINT), 
-			maxAniso(0), mipmapBias(0), comparisonFunc(CMPF_ALWAYS_FAIL), mipMin(-FLT_MAX), 
-			mipMax(FLT_MAX), borderColor(Color::White)
-		{ }
-
-		bool operator==(const SAMPLER_STATE_DESC& rhs) const;
-
-		UVWAddressingMode addressMode;
-		FilterOptions minFilter;
-		FilterOptions magFilter;
-		FilterOptions mipFilter;
-		UINT32 maxAniso;
-		float mipmapBias;
-		float mipMin;
-		float mipMax;
-		Color borderColor;
-		CompareFunction comparisonFunc;
-	};
-
-	/** Properties of SamplerState. Shared between sim and core thread versions of SamplerState. */
-	class BS_CORE_EXPORT SamplerProperties
-	{
-	public:
-		SamplerProperties(const SAMPLER_STATE_DESC& desc);
-
-		/**
-		 * Returns texture addressing mode for each possible texture coordinate. Addressing modes determine how are texture
-		 * coordinates outside of [0, 1] range handled.
-		 */
-		const UVWAddressingMode& getTextureAddressingMode() const { return mData.addressMode; }
-
-		/** Gets the filtering used when sampling from a texture. */
-        FilterOptions getTextureFiltering(FilterType ftpye) const;
-
-		/**
-		 * Gets the anisotropy level. Higher anisotropy means better filtering for textures displayed on an angled slope 
-		 * relative to the viewer.
-		 */
-		unsigned int getTextureAnisotropy() const { return mData.maxAniso; }
-
-		/** Gets a function that compares sampled data with existing sampled data. */
-		CompareFunction getComparisonFunction() const { return mData.comparisonFunc; }
-
-		/**
-		 * Mipmap bias allows you to adjust the mipmap selection calculation. Negative values  force a larger mipmap to be
-		 * used, and positive values smaller. Units are in values of mip levels, so -1 means use a mipmap one level higher 
-		 * than default.
-		 */
-		float getTextureMipmapBias() const { return mData.mipmapBias; }
-
-		/** Returns the minimum mip map level. */
-		float getMinimumMip() const { return mData.mipMin; }
-
-		/** Returns the maximum mip map level. */
-		float getMaximumMip() const { return mData.mipMax; }
-
-		/**
-		 * Gets the border color that will be used when border texture addressing is used and texture address is outside of
-		 * the valid range.
-		 */
-		const Color& getBorderColor() const;
-
-		/**	Returns the hash value generated from the sampler state properties. */
-		UINT64 getHash() const { return mHash; }
-
-		/**	Returns the descriptor originally used for creating the sampler state. */
-		SAMPLER_STATE_DESC getDesc() const { return mData; }
-
-	protected:
-		friend class SamplerState;
-		friend class SamplerStateCore;
-		friend class SamplerStateRTTI;
-
-		SAMPLER_STATE_DESC mData;
-		UINT64 mHash;
-	};
-
-	/** @cond INTERNAL */
-
-	/**
-	 * Core thread version of SamplerState.
-	 *
-	 * @note	Core thread.
-	 */
-	class BS_CORE_EXPORT SamplerStateCore : public CoreObjectCore
-	{
-	public:
-		virtual ~SamplerStateCore();
-
-		/**	Returns information about the sampler state. */
-		const SamplerProperties& getProperties() const;
-
-		/**	Returns the default sampler state. */
-		static const SPtr<SamplerStateCore>& getDefault();
-
-	protected:
-		friend class RenderStateCoreManager;
-
-		SamplerStateCore(const SAMPLER_STATE_DESC& desc);
-
-		/** @copydoc CoreObjectCore::initialize */
-		void initialize() override;
-
-		/**	Creates any API-specific state objects. */
-		virtual void createInternal() { }
-
-		SamplerProperties mProperties;
-	};
-
-	/** @endcond */
-
-	/**
-	 * Class representing the state of a texture sampler.
-	 *	
-	 * @note	
-	 * Sampler units are used for retrieving and filtering data from textures set in a GPU program. Sampler states are 
-	 * immutable.
-	 * @note
-	 * Sim thread.
-	 */
-	class BS_CORE_EXPORT SamplerState : public IReflectable, public CoreObject
-    {
-    public:
-		virtual ~SamplerState();
-
-		/**	Returns information about the sampler state. */
-		const SamplerProperties& getProperties() const;
-
-		/**	Retrieves a core implementation of the sampler state usable only from the core thread. */
-		SPtr<SamplerStateCore> getCore() const;
-
-		/**	Creates a new sampler state using the provided descriptor structure. */
-		static SamplerStatePtr create(const SAMPLER_STATE_DESC& desc);
-
-		/**	Returns the default sampler state. */
-		static const SamplerStatePtr& getDefault();
-
-		/**	Generates a hash value from a sampler state descriptor. */
-		static UINT64 generateHash(const SAMPLER_STATE_DESC& desc);
-
-	protected:
-		SamplerState(const SAMPLER_STATE_DESC& desc);
-
-		/** @copydoc CoreObjectCore::createCore */
-		SPtr<CoreObjectCore> createCore() const override;
-
-		SamplerProperties mProperties;
-
-		friend class RenderStateManager;
-
-		/************************************************************************/
-		/* 								RTTI		                     		*/
-		/************************************************************************/
-
-	public:
-		friend class SamplerStateRTTI;
-		static RTTITypeBase* getRTTIStatic();
-		virtual RTTITypeBase* getRTTI() const override;
-    };
-
-	/** @} */
-}
-
-/** @cond STDLIB */
-/** @addtogroup RenderAPI
- *  @{
- */
-
-/**	Hash value generator for SAMPLER_STATE_DESC. */
-template<>
-struct std::hash<BansheeEngine::SAMPLER_STATE_DESC>
-{
-	size_t operator()(const BansheeEngine::SAMPLER_STATE_DESC& value) const
-	{
-		return (size_t)BansheeEngine::SamplerState::generateHash(value);
-	}
-};
-
-/** @} */
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+#pragma once
+
+#include "BsCorePrerequisites.h"
+#include "BsColor.h"
+#include "BsIReflectable.h"
+#include "BsCoreObject.h"
+
+namespace BansheeEngine 
+{
+	/** @addtogroup RenderAPI
+	 *  @{
+	 */
+
+	/**
+	 * Structure used for initializing a SamplerState.
+	 *
+	 * @see		SamplerState
+	 */
+	struct BS_CORE_EXPORT SAMPLER_STATE_DESC
+	{
+		SAMPLER_STATE_DESC()
+			: minFilter(FO_LINEAR), magFilter(FO_LINEAR), mipFilter(FO_POINT), 
+			maxAniso(0), mipmapBias(0), comparisonFunc(CMPF_ALWAYS_FAIL), mipMin(-FLT_MAX), 
+			mipMax(FLT_MAX), borderColor(Color::White)
+		{ }
+
+		bool operator==(const SAMPLER_STATE_DESC& rhs) const;
+
+		UVWAddressingMode addressMode;
+		FilterOptions minFilter;
+		FilterOptions magFilter;
+		FilterOptions mipFilter;
+		UINT32 maxAniso;
+		float mipmapBias;
+		float mipMin;
+		float mipMax;
+		Color borderColor;
+		CompareFunction comparisonFunc;
+	};
+
+	/** Properties of SamplerState. Shared between sim and core thread versions of SamplerState. */
+	class BS_CORE_EXPORT SamplerProperties
+	{
+	public:
+		SamplerProperties(const SAMPLER_STATE_DESC& desc);
+
+		/**
+		 * Returns texture addressing mode for each possible texture coordinate. Addressing modes determine how are texture
+		 * coordinates outside of [0, 1] range handled.
+		 */
+		const UVWAddressingMode& getTextureAddressingMode() const { return mData.addressMode; }
+
+		/** Gets the filtering used when sampling from a texture. */
+        FilterOptions getTextureFiltering(FilterType ftpye) const;
+
+		/**
+		 * Gets the anisotropy level. Higher anisotropy means better filtering for textures displayed on an angled slope 
+		 * relative to the viewer.
+		 */
+		unsigned int getTextureAnisotropy() const { return mData.maxAniso; }
+
+		/** Gets a function that compares sampled data with existing sampled data. */
+		CompareFunction getComparisonFunction() const { return mData.comparisonFunc; }
+
+		/**
+		 * Mipmap bias allows you to adjust the mipmap selection calculation. Negative values  force a larger mipmap to be
+		 * used, and positive values smaller. Units are in values of mip levels, so -1 means use a mipmap one level higher 
+		 * than default.
+		 */
+		float getTextureMipmapBias() const { return mData.mipmapBias; }
+
+		/** Returns the minimum mip map level. */
+		float getMinimumMip() const { return mData.mipMin; }
+
+		/** Returns the maximum mip map level. */
+		float getMaximumMip() const { return mData.mipMax; }
+
+		/**
+		 * Gets the border color that will be used when border texture addressing is used and texture address is outside of
+		 * the valid range.
+		 */
+		const Color& getBorderColor() const;
+
+		/**	Returns the hash value generated from the sampler state properties. */
+		UINT64 getHash() const { return mHash; }
+
+		/**	Returns the descriptor originally used for creating the sampler state. */
+		SAMPLER_STATE_DESC getDesc() const { return mData; }
+
+	protected:
+		friend class SamplerState;
+		friend class SamplerStateCore;
+		friend class SamplerStateRTTI;
+
+		SAMPLER_STATE_DESC mData;
+		UINT64 mHash;
+	};
+
+	/**
+	 * Class representing the state of a texture sampler.
+	 *	
+	 * @note	
+	 * Sampler units are used for retrieving and filtering data from textures set in a GPU program. Sampler states are 
+	 * immutable.
+	 * @note
+	 * Sim thread.
+	 */
+	class BS_CORE_EXPORT SamplerState : public IReflectable, public CoreObject
+    {
+    public:
+		virtual ~SamplerState();
+
+		/**	Returns information about the sampler state. */
+		const SamplerProperties& getProperties() const;
+
+		/**	Retrieves a core implementation of the sampler state usable only from the core thread. */
+		SPtr<SamplerStateCore> getCore() const;
+
+		/**	Creates a new sampler state using the provided descriptor structure. */
+		static SamplerStatePtr create(const SAMPLER_STATE_DESC& desc);
+
+		/**	Returns the default sampler state. */
+		static const SamplerStatePtr& getDefault();
+
+		/**	Generates a hash value from a sampler state descriptor. */
+		static UINT64 generateHash(const SAMPLER_STATE_DESC& desc);
+
+	protected:
+		SamplerState(const SAMPLER_STATE_DESC& desc);
+
+		/** @copydoc CoreObjectCore::createCore */
+		SPtr<CoreObjectCore> createCore() const override;
+
+		SamplerProperties mProperties;
+
+		friend class RenderStateManager;
+
+		/************************************************************************/
+		/* 								RTTI		                     		*/
+		/************************************************************************/
+
+	public:
+		friend class SamplerStateRTTI;
+		static RTTITypeBase* getRTTIStatic();
+		virtual RTTITypeBase* getRTTI() const override;
+    };
+
+	/** @} */
+
+	/** @addtogroup RenderAPI-Internal
+	 *  @{
+	 */
+
+	/**
+	 * Core thread version of SamplerState.
+	 *
+	 * @note	Core thread.
+	 */
+	class BS_CORE_EXPORT SamplerStateCore : public CoreObjectCore
+	{
+	public:
+		virtual ~SamplerStateCore();
+
+		/**	Returns information about the sampler state. */
+		const SamplerProperties& getProperties() const;
+
+		/**	Returns the default sampler state. */
+		static const SPtr<SamplerStateCore>& getDefault();
+
+	protected:
+		friend class RenderStateCoreManager;
+
+		SamplerStateCore(const SAMPLER_STATE_DESC& desc);
+
+		/** @copydoc CoreObjectCore::initialize */
+		void initialize() override;
+
+		/**	Creates any API-specific state objects. */
+		virtual void createInternal() { }
+
+		SamplerProperties mProperties;
+	};
+
+	/** @} */
+}
+
+/** @cond STDLIB */
+/** @addtogroup RenderAPI
+ *  @{
+ */
+
+/**	Hash value generator for SAMPLER_STATE_DESC. */
+template<>
+struct std::hash<BansheeEngine::SAMPLER_STATE_DESC>
+{
+	size_t operator()(const BansheeEngine::SAMPLER_STATE_DESC& value) const
+	{
+		return (size_t)BansheeEngine::SamplerState::generateHash(value);
+	}
+};
+
+/** @} */
 /** @endcond */

+ 44 - 46
Source/BansheeCore/Include/BsSavedResourceData.h

@@ -1,47 +1,45 @@
-//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
-//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
-#pragma once
-
-#include "BsCorePrerequisites.h"
-#include "BsIReflectable.h"
-
-namespace BansheeEngine
-{
-	/** @cond INTERNAL */
-	/** @addtogroup Resources
-	 *  @{
-	 */
-
-	/**
-	 * Contains information about a resource saved to the disk.
-	 *
-	 * @note Purpose of this class is primarily to be a wrapper around a list of objects to make serialization easier.
-	 */
-	class BS_CORE_EXPORT SavedResourceData : public IReflectable
-	{
-	public:
-		SavedResourceData();
-		SavedResourceData(const Vector<String>& dependencies, bool allowAsync);
-
-		/**	Returns a list of all resource dependencies. */
-		const Vector<String>& getDependencies() const { return mDependencies; }
-
-		/**	Returns true if this resource is allow to be asynchronously loaded. */
-		bool allowAsyncLoading() const { return mAllowAsync; }
-
-	private:
-		Vector<String> mDependencies;
-		bool mAllowAsync;
-
-	/************************************************************************/
-	/* 								SERIALIZATION                      		*/
-	/************************************************************************/
-	public:
-		friend class SavedResourceDataRTTI;
-		static RTTITypeBase* getRTTIStatic();
-		virtual RTTITypeBase* getRTTI() const override;
-	};
-
-	/** @} */
-	/** @endcond */
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+#pragma once
+
+#include "BsCorePrerequisites.h"
+#include "BsIReflectable.h"
+
+namespace BansheeEngine
+{
+	/** @addtogroup Resources-Internal
+	 *  @{
+	 */
+
+	/**
+	 * Contains information about a resource saved to the disk.
+	 *
+	 * @note Purpose of this class is primarily to be a wrapper around a list of objects to make serialization easier.
+	 */
+	class BS_CORE_EXPORT SavedResourceData : public IReflectable
+	{
+	public:
+		SavedResourceData();
+		SavedResourceData(const Vector<String>& dependencies, bool allowAsync);
+
+		/**	Returns a list of all resource dependencies. */
+		const Vector<String>& getDependencies() const { return mDependencies; }
+
+		/**	Returns true if this resource is allow to be asynchronously loaded. */
+		bool allowAsyncLoading() const { return mAllowAsync; }
+
+	private:
+		Vector<String> mDependencies;
+		bool mAllowAsync;
+
+	/************************************************************************/
+	/* 								SERIALIZATION                      		*/
+	/************************************************************************/
+	public:
+		friend class SavedResourceDataRTTI;
+		static RTTITypeBase* getRTTIStatic();
+		virtual RTTITypeBase* getRTTI() const override;
+	};
+
+	/** @} */
 }

+ 9 - 6
Source/BansheeCore/Include/BsShader.h

@@ -366,12 +366,10 @@ namespace BansheeEngine
 
 	/** @} */
 
-	/** @addtogroup Material
+	/** @addtogroup Material-Internal
 	 *  @{
 	 */
 
-	/** @cond INTERNAL */
-
 	typedef TSHADER_DESC<true> SHADER_DESC_CORE;
 	
 	/** @copydoc TShader */
@@ -389,7 +387,10 @@ namespace BansheeEngine
 		static std::atomic<UINT32> mNextShaderId;
 	};
 
-	/** @endcond */
+	/** @} */
+	/** @addtogroup Material
+	 *  @{
+	 */
 
 	typedef TSHADER_DESC<false> SHADER_DESC;
 
@@ -469,7 +470,10 @@ namespace BansheeEngine
 		virtual RTTITypeBase* getRTTI() const override;
 	};
 
-	/** @cond INTERNAL */
+	/** @} */
+	/** @addtogroup Material
+	 *  @{
+	 */
 
 	/** Shader specific resource meta-data containing information about referenced include files. */
 	class BS_CORE_EXPORT ShaderMetaData : public ResourceMetaData
@@ -486,6 +490,5 @@ namespace BansheeEngine
 		virtual RTTITypeBase* getRTTI() const override;
 	};
 
-	/** @endcond */
 	/** @} */
 }

+ 1 - 3
Source/BansheeCore/Include/BsShaderDefines.h

@@ -6,8 +6,7 @@
 
 namespace BansheeEngine
 {
-	/** @cond INTERNAL */
-	/** @addtogroup Material
+	/** @addtogroup Material-Internal
 	 *  @{
 	 */
 
@@ -35,5 +34,4 @@ namespace BansheeEngine
 	};
 
 	/** @} */
-	/** @endcond */
 }

+ 60 - 62
Source/BansheeCore/Include/BsShaderManager.h

@@ -1,63 +1,61 @@
-//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
-//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
-#pragma once
-
-#include "BsCorePrerequisites.h"
-#include "BsModule.h"
-
-namespace BansheeEngine
-{
-	/** @cond INTERNAL */
-	/** @addtogroup Material
-	 *  @{
-	 */
-
-	/**
-	 * Interface that provides a method for finding a shader include resource based on the name of the include that was 
-	 * provided in a shader file.
-	 */
-	class BS_CORE_EXPORT IShaderIncludeHandler
-	{
-	public:
-		virtual ~IShaderIncludeHandler() { }
-
-		/** Attempts to find a shader include resource based on its name. */
-		virtual HShaderInclude findInclude(const String& name) const = 0;
-	};
-
-	/**
-	 * Implements shader include finding by converting the shader include name into a path that the resource will be loaded 
-	 * from.
-	 */
-	class BS_CORE_EXPORT DefaultShaderIncludeHandler : public IShaderIncludeHandler
-	{
-	public:
-		/** @copydoc IShaderIncludeHandler::findInclude */
-		virtual HShaderInclude findInclude(const String& name) const override;
-	};
-
-	/**	A global manager that handles various shader specific operations. */
-	class BS_CORE_EXPORT ShaderManager : public Module <ShaderManager>
-	{
-	public:
-		ShaderManager(const ShaderIncludeHandlerPtr& handler) { mIncludeHandler = handler; }
-
-		/**
-		 * Attempts to find a shader include based on the include name.
-		 *
-		 * @note	
-		 * The name is usually a path to the resource relative to the working folder, but can be other things depending on 
-		 * active handler.
-		 */
-		HShaderInclude findInclude(const String& name) const;
-
-		/** Changes the active include handler that determines how is a shader include name mapped to the actual resource. */
-		void setIncludeHandler(const ShaderIncludeHandlerPtr& handler) { mIncludeHandler = handler; }
-
-	private:
-		ShaderIncludeHandlerPtr mIncludeHandler;
-	};
-
-	/** @} */
-	/** @endcond */
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+#pragma once
+
+#include "BsCorePrerequisites.h"
+#include "BsModule.h"
+
+namespace BansheeEngine
+{
+	/** @addtogroup Material-Internal
+	 *  @{
+	 */
+
+	/**
+	 * Interface that provides a method for finding a shader include resource based on the name of the include that was 
+	 * provided in a shader file.
+	 */
+	class BS_CORE_EXPORT IShaderIncludeHandler
+	{
+	public:
+		virtual ~IShaderIncludeHandler() { }
+
+		/** Attempts to find a shader include resource based on its name. */
+		virtual HShaderInclude findInclude(const String& name) const = 0;
+	};
+
+	/**
+	 * Implements shader include finding by converting the shader include name into a path that the resource will be loaded 
+	 * from.
+	 */
+	class BS_CORE_EXPORT DefaultShaderIncludeHandler : public IShaderIncludeHandler
+	{
+	public:
+		/** @copydoc IShaderIncludeHandler::findInclude */
+		virtual HShaderInclude findInclude(const String& name) const override;
+	};
+
+	/**	A global manager that handles various shader specific operations. */
+	class BS_CORE_EXPORT ShaderManager : public Module <ShaderManager>
+	{
+	public:
+		ShaderManager(const ShaderIncludeHandlerPtr& handler) { mIncludeHandler = handler; }
+
+		/**
+		 * Attempts to find a shader include based on the include name.
+		 *
+		 * @note	
+		 * The name is usually a path to the resource relative to the working folder, but can be other things depending on 
+		 * active handler.
+		 */
+		HShaderInclude findInclude(const String& name) const;
+
+		/** Changes the active include handler that determines how is a shader include name mapped to the actual resource. */
+		void setIncludeHandler(const ShaderIncludeHandlerPtr& handler) { mIncludeHandler = handler; }
+
+	private:
+		ShaderIncludeHandlerPtr mIncludeHandler;
+	};
+
+	/** @} */
 }

+ 1 - 3
Source/BansheeCore/Include/BsSpecificImporter.h

@@ -6,8 +6,7 @@
 
 namespace BansheeEngine
 {
-	/** @cond INTERNAL */
-	/** @addtogroup Importer
+	/** @addtogroup Importer-Internal
 	 *  @{
 	 */
 
@@ -81,5 +80,4 @@ namespace BansheeEngine
 	};
 
 	/** @} */
-	/** @endcond */
 }

+ 7 - 2
Source/BansheeCore/Include/BsStringTable.h

@@ -202,7 +202,9 @@ namespace BansheeEngine
 		Count // Number of entries
 	};
 
-	/** @cond INTERNAL */
+	/** @addtogroup Localization-Internal
+	 *  @{
+	 */
 
 	/**
 	 * Internal data used for representing a localized string instance. for example a specific instance of a localized
@@ -241,7 +243,10 @@ namespace BansheeEngine
 		UnorderedMap<WString, SPtr<LocalizedStringData>> strings;
 	};
 
-	/** @endcond */
+	/** @} */
+	/** @addtogroup Localization
+	 *  @{
+	 */
 
 	/** Used for string localization. Stores strings and their translations in various languages. */
 	class BS_CORE_EXPORT StringTable : public Resource

+ 5 - 4
Source/BansheeCore/Include/BsTechnique.h

@@ -66,12 +66,10 @@ namespace BansheeEngine
 
 	/** @} */
 
-	/** @addtogroup Material
+	/** @addtogroup Material-Internal
 	 *  @{
 	 */
 
-	/** @cond INTERNAL */
-
 	/**
 	 * @copydoc	TechniqueBase
 	 *
@@ -86,7 +84,10 @@ namespace BansheeEngine
 		static SPtr<TechniqueCore> create(const StringID& renderAPI, const StringID& renderer, const Vector<SPtr<PassCore>>& passes);
 	};
 
-	/** @endcond */
+	/** @} */
+	/** @addtogroup Material
+	 *  @{
+	 */
 
 	/**
 	 * @copydoc	TechniqueBase

+ 0 - 2
Source/BansheeCore/Include/BsTextData.h

@@ -8,7 +8,6 @@
 
 namespace BansheeEngine
 {
-	/** @cond INTERNAL */
 	/** @addtogroup Implementation
 	 *  @{
 	 */
@@ -373,5 +372,4 @@ namespace BansheeEngine
 	};
 
 	/** @} */
-	/** @endcond */
 }

+ 168 - 166
Source/BansheeCore/Include/BsTexture.h

@@ -131,172 +131,6 @@ namespace BansheeEngine
 		int mUsage;
 	};
 
-	/** @cond INTERNAL */
-
-	/**
-	 * Core thread version of a Texture.
-	 *
-	 * @note	Core thread.
-	 */
-	class BS_CORE_EXPORT TextureCore : public CoreObjectCore
-	{
-	public:
-		TextureCore(TextureType textureType, UINT32 width, UINT32 height, UINT32 depth, UINT32 numMipmaps,
-			PixelFormat format, int usage, bool hwGamma, UINT32 multisampleCount, const PixelDataPtr& initData);
-		virtual ~TextureCore() {}
-
-
-		/** @copydoc CoreObjectCore::initialize */
-		virtual void initialize() override;
-
-		/**
-		 * Updates a part of the texture with the provided data.
-		 *
-		 * @param[in]	subresourceIdx		Index of the subresource to update, if the texture has more than one.
-		 * @param[in]	data				Data to update the texture with.
-		 * @param[in]	discardEntireBuffer When true the existing contents of the resource you are updating will be 
-		 *									discarded. This can make the operation faster. Resources with certain buffer 
-		 *									types might require this flag to be in a specific state otherwise the operation 
-		 *									will fail.
-		 */
-		virtual void writeSubresource(UINT32 subresourceIdx, const PixelData& data, bool discardEntireBuffer);
-
-		/**
-		 * Reads a part of the current resource into the provided @p data parameter.
-		 * 			Data buffer needs to be pre-allocated.
-		 *
-		 * @param[in]	subresourceIdx		Index of the subresource to update, if the texture has more than one.
-		 * @param[out]	data				Buffer that will receive the data. Should be allocated with 
-		 *									allocateSubresourceBuffer() to ensure it is of valid type and size.
-		 */
-		virtual void readSubresource(UINT32 subresourceIdx, PixelData& data);
-
-		/**
-		 * Locks the buffer for reading or writing.
-		 *
-		 * @param[in]	options 	Options for controlling what you may do with the locked data.
-		 * @param[in]	mipLevel	(optional) Mipmap level to lock.
-		 * @param[in]	face		(optional) Texture face to lock.					
-		 * @return					Pointer to the buffer data. Only valid until you call unlock().
-		 * 			
-		 * @note	
-		 * If you are just reading or writing one block of data use readData()/writeData() methods as they can be much faster
-		 * in certain situations.
-		 */
-		PixelData lock(GpuLockOptions options, UINT32 mipLevel = 0, UINT32 face = 0);
-
-		/** 
-		 * Unlocks a previously locked buffer. After the buffer is unlocked, any data returned by lock becomes invalid. 
-		 *
-		 * @see	lock()
-		 */
-		void unlock();
-
-		/**
-		 * Copies the contents a subresource in this texture to another texture. Texture format and size of the subresource
-		 * must match.
-		 *
-		 * You are allowed to copy from a multisampled to non-multisampled surface, which will resolve the multisampled
-		 * surface before copying.
-		 *
-		 * @param[in]	srcSubresourceIdx	Index of the subresource to copy from.
-		 * @param[in]	destSubresourceIdx	Index of the subresource to copy to.
-		 * @param[in]	target				Texture that contains the destination subresource.
-		 */
-		void copy(UINT32 srcSubresourceIdx, UINT32 destSubresourceIdx, const SPtr<TextureCore>& target);
-
-		/**
-		 * Reads data from the texture buffer into the provided buffer.
-		 * 		  
-		 * @param[out]	dest		Previously allocated buffer to read data into.
-		 * @param[in]	mipLevel	(optional) Mipmap level to read from.
-		 * @param[in]	face		(optional) Texture face to read from.
-		 */
-		virtual void readData(PixelData& dest, UINT32 mipLevel = 0, UINT32 face = 0) = 0;
-
-		/**
-		 * Writes data from the provided buffer into the texture buffer.
-		 * 		  
-		 * @param[in]	dest				Buffer to retrieve the data from.
-		 * @param[in]	mipLevel			(optional) Mipmap level to write into.
-		 * @param[in]	face				(optional) Texture face to write into.
-		 * @param[in]	discardWholeBuffer	(optional) If true any existing texture data will be discard. This can improve 
-		 *									performance of the write operation.
-		 */
-		virtual void writeData(const PixelData& src, UINT32 mipLevel = 0, UINT32 face = 0, bool discardWholeBuffer = false) = 0;
-
-		/**
-		 * Returns true if the texture can be bound to a shader.
-		 *
-		 * @note	This is only false for some rare special cases (for example AA render texture in DX9). Internal method.
-		 */
-		virtual bool isBindableAsShaderResource() const { return true; }
-
-		/**	Returns properties that contain information about the texture. */
-		const TextureProperties& getProperties() const { return mProperties; }
-
-		/************************************************************************/
-		/* 								TEXTURE VIEW                      		*/
-		/************************************************************************/
-
-		/**
-		 * Requests a texture view for the specified mip and array ranges. Returns an existing view of one for the specified
-		 * ranges already exists, otherwise creates a new one. You must release all views by calling releaseView() when done.
-		 *
-		 * @note	Core thread only.
-		 */
-		static TextureViewPtr requestView(const SPtr<TextureCore>& texture, UINT32 mostDetailMip, UINT32 numMips,
-			UINT32 firstArraySlice, UINT32 numArraySlices, GpuViewUsage usage);
-
-		/**
-		 * Releases the view. View won't actually get destroyed until all references to it are released.
-		 *
-		 * @note	Core thread only.
-		 */
-		static void releaseView(const TextureViewPtr& view);
-
-	protected:
-		/** @copydoc lock */
-		virtual PixelData lockImpl(GpuLockOptions options, UINT32 mipLevel = 0, UINT32 face = 0) = 0;
-
-		/** @copydoc unlock */
-		virtual void unlockImpl() = 0;
-
-		/** @copydoc copy */
-		virtual void copyImpl(UINT32 srcFace, UINT32 srcMipLevel, UINT32 destFace, UINT32 destMipLevel, 
-			const SPtr<TextureCore>& target) = 0;
-
-		/************************************************************************/
-		/* 								TEXTURE VIEW                      		*/
-		/************************************************************************/
-
-		/**	Creates a new empty/undefined texture view. */
-		virtual TextureViewPtr createView(const SPtr<TextureCore>& texture, const TEXTURE_VIEW_DESC& desc);
-
-		/**
-		 * Releases all internal texture view references. Views won't get destroyed if there are external references still 
-		 * held.
-		 */
-		void clearBufferViews();
-
-		/** Holds a single texture view with a usage reference count. */
-		struct TextureViewReference
-		{
-			TextureViewReference(TextureViewPtr _view)
-				:view(_view), refCount(0)
-			{ }
-
-			TextureViewPtr view;
-			UINT32 refCount;
-		};
-
-		UnorderedMap<TEXTURE_VIEW_DESC, TextureViewReference*, TextureView::HashFunction, TextureView::EqualFunction> mTextureViews;
-		TextureProperties mProperties;
-		PixelDataPtr mInitData;
-	};
-
-	/** @endcond */
-
 	/**
 	 * Abstract class representing a texture. Specific render systems have their own Texture implementations. Internally
 	 * represented as one or more surfaces with pixels in a certain number of dimensions, backed by a hardware buffer.
@@ -468,4 +302,172 @@ namespace BansheeEngine
     };
 
 	/** @} */
+
+	/** @addtogroup Resources-Internal
+	 *  @{
+	 */
+
+	/**
+	 * Core thread version of a Texture.
+	 *
+	 * @note	Core thread.
+	 */
+	class BS_CORE_EXPORT TextureCore : public CoreObjectCore
+	{
+	public:
+		TextureCore(TextureType textureType, UINT32 width, UINT32 height, UINT32 depth, UINT32 numMipmaps,
+			PixelFormat format, int usage, bool hwGamma, UINT32 multisampleCount, const PixelDataPtr& initData);
+		virtual ~TextureCore() {}
+
+
+		/** @copydoc CoreObjectCore::initialize */
+		virtual void initialize() override;
+
+		/**
+		 * Updates a part of the texture with the provided data.
+		 *
+		 * @param[in]	subresourceIdx		Index of the subresource to update, if the texture has more than one.
+		 * @param[in]	data				Data to update the texture with.
+		 * @param[in]	discardEntireBuffer When true the existing contents of the resource you are updating will be 
+		 *									discarded. This can make the operation faster. Resources with certain buffer 
+		 *									types might require this flag to be in a specific state otherwise the operation 
+		 *									will fail.
+		 */
+		virtual void writeSubresource(UINT32 subresourceIdx, const PixelData& data, bool discardEntireBuffer);
+
+		/**
+		 * Reads a part of the current resource into the provided @p data parameter.
+		 * 			Data buffer needs to be pre-allocated.
+		 *
+		 * @param[in]	subresourceIdx		Index of the subresource to update, if the texture has more than one.
+		 * @param[out]	data				Buffer that will receive the data. Should be allocated with 
+		 *									allocateSubresourceBuffer() to ensure it is of valid type and size.
+		 */
+		virtual void readSubresource(UINT32 subresourceIdx, PixelData& data);
+
+		/**
+		 * Locks the buffer for reading or writing.
+		 *
+		 * @param[in]	options 	Options for controlling what you may do with the locked data.
+		 * @param[in]	mipLevel	(optional) Mipmap level to lock.
+		 * @param[in]	face		(optional) Texture face to lock.					
+		 * @return					Pointer to the buffer data. Only valid until you call unlock().
+		 * 			
+		 * @note	
+		 * If you are just reading or writing one block of data use readData()/writeData() methods as they can be much faster
+		 * in certain situations.
+		 */
+		PixelData lock(GpuLockOptions options, UINT32 mipLevel = 0, UINT32 face = 0);
+
+		/** 
+		 * Unlocks a previously locked buffer. After the buffer is unlocked, any data returned by lock becomes invalid. 
+		 *
+		 * @see	lock()
+		 */
+		void unlock();
+
+		/**
+		 * Copies the contents a subresource in this texture to another texture. Texture format and size of the subresource
+		 * must match.
+		 *
+		 * You are allowed to copy from a multisampled to non-multisampled surface, which will resolve the multisampled
+		 * surface before copying.
+		 *
+		 * @param[in]	srcSubresourceIdx	Index of the subresource to copy from.
+		 * @param[in]	destSubresourceIdx	Index of the subresource to copy to.
+		 * @param[in]	target				Texture that contains the destination subresource.
+		 */
+		void copy(UINT32 srcSubresourceIdx, UINT32 destSubresourceIdx, const SPtr<TextureCore>& target);
+
+		/**
+		 * Reads data from the texture buffer into the provided buffer.
+		 * 		  
+		 * @param[out]	dest		Previously allocated buffer to read data into.
+		 * @param[in]	mipLevel	(optional) Mipmap level to read from.
+		 * @param[in]	face		(optional) Texture face to read from.
+		 */
+		virtual void readData(PixelData& dest, UINT32 mipLevel = 0, UINT32 face = 0) = 0;
+
+		/**
+		 * Writes data from the provided buffer into the texture buffer.
+		 * 		  
+		 * @param[in]	dest				Buffer to retrieve the data from.
+		 * @param[in]	mipLevel			(optional) Mipmap level to write into.
+		 * @param[in]	face				(optional) Texture face to write into.
+		 * @param[in]	discardWholeBuffer	(optional) If true any existing texture data will be discard. This can improve 
+		 *									performance of the write operation.
+		 */
+		virtual void writeData(const PixelData& src, UINT32 mipLevel = 0, UINT32 face = 0, bool discardWholeBuffer = false) = 0;
+
+		/**
+		 * Returns true if the texture can be bound to a shader.
+		 *
+		 * @note	This is only false for some rare special cases (for example AA render texture in DX9). Internal method.
+		 */
+		virtual bool isBindableAsShaderResource() const { return true; }
+
+		/**	Returns properties that contain information about the texture. */
+		const TextureProperties& getProperties() const { return mProperties; }
+
+		/************************************************************************/
+		/* 								TEXTURE VIEW                      		*/
+		/************************************************************************/
+
+		/**
+		 * Requests a texture view for the specified mip and array ranges. Returns an existing view of one for the specified
+		 * ranges already exists, otherwise creates a new one. You must release all views by calling releaseView() when done.
+		 *
+		 * @note	Core thread only.
+		 */
+		static TextureViewPtr requestView(const SPtr<TextureCore>& texture, UINT32 mostDetailMip, UINT32 numMips,
+			UINT32 firstArraySlice, UINT32 numArraySlices, GpuViewUsage usage);
+
+		/**
+		 * Releases the view. View won't actually get destroyed until all references to it are released.
+		 *
+		 * @note	Core thread only.
+		 */
+		static void releaseView(const TextureViewPtr& view);
+
+	protected:
+		/** @copydoc lock */
+		virtual PixelData lockImpl(GpuLockOptions options, UINT32 mipLevel = 0, UINT32 face = 0) = 0;
+
+		/** @copydoc unlock */
+		virtual void unlockImpl() = 0;
+
+		/** @copydoc copy */
+		virtual void copyImpl(UINT32 srcFace, UINT32 srcMipLevel, UINT32 destFace, UINT32 destMipLevel, 
+			const SPtr<TextureCore>& target) = 0;
+
+		/************************************************************************/
+		/* 								TEXTURE VIEW                      		*/
+		/************************************************************************/
+
+		/**	Creates a new empty/undefined texture view. */
+		virtual TextureViewPtr createView(const SPtr<TextureCore>& texture, const TEXTURE_VIEW_DESC& desc);
+
+		/**
+		 * Releases all internal texture view references. Views won't get destroyed if there are external references still 
+		 * held.
+		 */
+		void clearBufferViews();
+
+		/** Holds a single texture view with a usage reference count. */
+		struct TextureViewReference
+		{
+			TextureViewReference(TextureViewPtr _view)
+				:view(_view), refCount(0)
+			{ }
+
+			TextureViewPtr view;
+			UINT32 refCount;
+		};
+
+		UnorderedMap<TEXTURE_VIEW_DESC, TextureViewReference*, TextureView::HashFunction, TextureView::EqualFunction> mTextureViews;
+		TextureProperties mProperties;
+		PixelDataPtr mInitData;
+	};
+
+	/** @} */
 }

+ 146 - 148
Source/BansheeCore/Include/BsTextureManager.h

@@ -1,149 +1,147 @@
-//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
-//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
-#pragma once
-
-#include "BsCorePrerequisites.h"
-#include "BsTexture.h"
-#include "BsRenderTexture.h"
-#include "BsMultiRenderTexture.h"
-#include "BsModule.h"
-
-namespace BansheeEngine 
-{
-	/** @cond INTERNAL */
-	/** @addtogroup Resources
-	 *  @{
-	 */
-
-    /**
-     * Defines interface for creation of textures. Render systems provide their own implementations.
-	 *
-	 * @note	Sim thread only.
-     */
-    class BS_CORE_EXPORT TextureManager : public Module<TextureManager>
-    {
-    public:
-		virtual ~TextureManager() { }
-
-		/** @copydoc Texture::create(TextureType, UINT32, UINT32, UINT32, int, PixelFormat, int, bool, UINT32) */
-        TexturePtr createTexture(TextureType texType, UINT32 width, UINT32 height, UINT32 depth, 
-			int numMips, PixelFormat format, int usage = TU_DEFAULT, bool hwGammaCorrection = false, 
-			UINT32 multisampleCount = 0);
-			
-		/** @copydoc Texture::create(TextureType, UINT32, UINT32, int, PixelFormat, int, bool, UINT32) */
-		TexturePtr createTexture(TextureType texType, UINT32 width, UINT32 height, int numMips,
-			PixelFormat format, int usage = TU_DEFAULT, bool hwGammaCorrection = false, UINT32 multisampleCount = 0)
-		{
-			return createTexture(texType, width, height, 1, 
-				numMips, format, usage, hwGammaCorrection, multisampleCount);
-		}
-
-		/** @copydoc Texture::create(const PixelDataPtr&, int, bool) */
-		TexturePtr createTexture(const PixelDataPtr& pixelData, int usage = TU_DEFAULT, bool hwGammaCorrection = false);
-
-		/**
-		 * Creates a completely empty and uninitialized Texture.
-		 *
-		 * @note	
-		 * Internal method. Should only be used for very specific purposes, like deserialization, as it requires additional
-		 * manual initialization that is not required normally.
-		 */
-		TexturePtr _createEmpty();
-
-		/**
-		 * Creates a new RenderTexture and automatically generates a color surface and (optionally) a depth/stencil surface.
-		 *
-		 * @param[in]	texType				Type of the texture.
-		 * @param[in]	width				Width of the texture in pixels.
-		 * @param[in]	height				Height of the texture in pixels.
-		 * @param[in]	format				Format of the pixels.
-		 * @param[in]	hwGamma				If true, any color data will be gamma corrected before being written into the 
-		 *									texture.
-		 * @param[in]	multisampleCount	If higher than 1, texture containing multiple samples per pixel is created.
-		 * @param[in]	multisampleHint		Hint about what kind of multisampling to use. Render system specific.
-		 * @param[in]	createDepth			Determines will a depth/stencil buffer of the same size as the color buffer be
-		 *									created for the render texture.
-		 * @param[in]	depthStencilFormat	Format of the depth/stencil buffer if enabled.
-		 */
-		virtual RenderTexturePtr createRenderTexture(TextureType textureType, UINT32 width, UINT32 height, 
-			PixelFormat format = PF_R8G8B8A8, bool hwGamma = false, UINT32 multisampleCount = 0, 
-			bool createDepth = true, PixelFormat depthStencilFormat = PF_D24S8);
-
-		/** Creates a RenderTexture using the description struct. */
-		virtual RenderTexturePtr createRenderTexture(const RENDER_TEXTURE_DESC& desc);
-
-		/** 
-		 * Creates a new multi render texture. You may use this type of texture to render to multiple output textures at 
-		 * once.
-		 */
-		virtual MultiRenderTexturePtr createMultiRenderTexture(const MULTI_RENDER_TEXTURE_DESC& desc);
-
-		/**
-		 * Gets the format which will be natively used for a requested format given the constraints of the current device.
-		 *
-		 * @note	Thread safe.
-		 */
-		virtual PixelFormat getNativeFormat(TextureType ttype, PixelFormat format, int usage, bool hwGamma) = 0;
-
-	protected:
-		/**
-		 * Creates an empty and uninitialized render texture of a specific type. This is to be implemented by render 
-		 * systems with their own implementations.
-		 */
-		virtual RenderTexturePtr createRenderTextureImpl(const RENDER_TEXTURE_DESC& desc) = 0;
-
-		/**
-		 * Creates an empty and uninitialized multi render texture of a specific type. This is to be implemented by render
-		 * systems with their own implementations.
-		 */
-		virtual MultiRenderTexturePtr createMultiRenderTextureImpl(const MULTI_RENDER_TEXTURE_DESC& desc) = 0;
-
-		mutable HTexture mDummyTexture;
-    };
-
-	/**
-     * Defines interface for creation of textures. Render systems provide their own implementations.
-	 *
-	 * @note	Core thread only.
-     */
-    class BS_CORE_EXPORT TextureCoreManager : public Module<TextureCoreManager>
-    {
-    public:
-		virtual ~TextureCoreManager() { }
-
-		/**
-		 * @copydoc	TextureManager::createTexture(TextureType, UINT32, UINT32, UINT32, int, PixelFormat, int, bool, UINT32)
-		 */
-		SPtr<TextureCore> createTexture(TextureType texType, UINT32 width, UINT32 height, UINT32 depth,
-			int numMips, PixelFormat format, int usage = TU_DEFAULT, bool hwGammaCorrection = false, 
-			UINT32 multisampleCount = 0);
-
-		/** @copydoc	TextureManager::createRenderTexture(const RENDER_TEXTURE_DESC&) */
-		SPtr<RenderTextureCore> createRenderTexture(const RENDER_TEXTURE_CORE_DESC& desc);
-
-		/** @copydoc	TextureManager::createMultiRenderTexture(const MULTI_RENDER_TEXTURE_DESC&) */
-		SPtr<MultiRenderTextureCore> createMultiRenderTexture(const MULTI_RENDER_TEXTURE_CORE_DESC& desc);
-
-	protected:
-		friend class Texture;
-		friend class RenderTexture;
-		friend class MultiRenderTexture;
-
-		/**
-		 * Creates an empty and uninitialized texture of a specific type. This is to be implemented	by render systems with
-		 * their own implementations.
-		 */
-		virtual SPtr<TextureCore> createTextureInternal(TextureType texType, UINT32 width, UINT32 height, UINT32 depth,
-			int numMips, PixelFormat format, int usage = TU_DEFAULT, bool hwGammaCorrection = false,
-			UINT32 multisampleCount = 0, const PixelDataPtr& initialData = nullptr) = 0;
-
-		/** @copydoc TextureManager::createRenderTextureImpl */
-		virtual SPtr<RenderTextureCore> createRenderTextureInternal(const RENDER_TEXTURE_CORE_DESC& desc) = 0;
-
-		/** @copydoc TextureManager::createMultiRenderTextureImpl */
-		virtual SPtr<MultiRenderTextureCore> createMultiRenderTextureInternal(const MULTI_RENDER_TEXTURE_CORE_DESC& desc) = 0;
-    };
-
-	/** @} */
-	/** @endcond */
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+#pragma once
+
+#include "BsCorePrerequisites.h"
+#include "BsTexture.h"
+#include "BsRenderTexture.h"
+#include "BsMultiRenderTexture.h"
+#include "BsModule.h"
+
+namespace BansheeEngine 
+{
+	/** @addtogroup Resources-Internal
+	 *  @{
+	 */
+
+    /**
+     * Defines interface for creation of textures. Render systems provide their own implementations.
+	 *
+	 * @note	Sim thread only.
+     */
+    class BS_CORE_EXPORT TextureManager : public Module<TextureManager>
+    {
+    public:
+		virtual ~TextureManager() { }
+
+		/** @copydoc Texture::create(TextureType, UINT32, UINT32, UINT32, int, PixelFormat, int, bool, UINT32) */
+        TexturePtr createTexture(TextureType texType, UINT32 width, UINT32 height, UINT32 depth, 
+			int numMips, PixelFormat format, int usage = TU_DEFAULT, bool hwGammaCorrection = false, 
+			UINT32 multisampleCount = 0);
+			
+		/** @copydoc Texture::create(TextureType, UINT32, UINT32, int, PixelFormat, int, bool, UINT32) */
+		TexturePtr createTexture(TextureType texType, UINT32 width, UINT32 height, int numMips,
+			PixelFormat format, int usage = TU_DEFAULT, bool hwGammaCorrection = false, UINT32 multisampleCount = 0)
+		{
+			return createTexture(texType, width, height, 1, 
+				numMips, format, usage, hwGammaCorrection, multisampleCount);
+		}
+
+		/** @copydoc Texture::create(const PixelDataPtr&, int, bool) */
+		TexturePtr createTexture(const PixelDataPtr& pixelData, int usage = TU_DEFAULT, bool hwGammaCorrection = false);
+
+		/**
+		 * Creates a completely empty and uninitialized Texture.
+		 *
+		 * @note	
+		 * Internal method. Should only be used for very specific purposes, like deserialization, as it requires additional
+		 * manual initialization that is not required normally.
+		 */
+		TexturePtr _createEmpty();
+
+		/**
+		 * Creates a new RenderTexture and automatically generates a color surface and (optionally) a depth/stencil surface.
+		 *
+		 * @param[in]	texType				Type of the texture.
+		 * @param[in]	width				Width of the texture in pixels.
+		 * @param[in]	height				Height of the texture in pixels.
+		 * @param[in]	format				Format of the pixels.
+		 * @param[in]	hwGamma				If true, any color data will be gamma corrected before being written into the 
+		 *									texture.
+		 * @param[in]	multisampleCount	If higher than 1, texture containing multiple samples per pixel is created.
+		 * @param[in]	multisampleHint		Hint about what kind of multisampling to use. Render system specific.
+		 * @param[in]	createDepth			Determines will a depth/stencil buffer of the same size as the color buffer be
+		 *									created for the render texture.
+		 * @param[in]	depthStencilFormat	Format of the depth/stencil buffer if enabled.
+		 */
+		virtual RenderTexturePtr createRenderTexture(TextureType textureType, UINT32 width, UINT32 height, 
+			PixelFormat format = PF_R8G8B8A8, bool hwGamma = false, UINT32 multisampleCount = 0, 
+			bool createDepth = true, PixelFormat depthStencilFormat = PF_D24S8);
+
+		/** Creates a RenderTexture using the description struct. */
+		virtual RenderTexturePtr createRenderTexture(const RENDER_TEXTURE_DESC& desc);
+
+		/** 
+		 * Creates a new multi render texture. You may use this type of texture to render to multiple output textures at 
+		 * once.
+		 */
+		virtual MultiRenderTexturePtr createMultiRenderTexture(const MULTI_RENDER_TEXTURE_DESC& desc);
+
+		/**
+		 * Gets the format which will be natively used for a requested format given the constraints of the current device.
+		 *
+		 * @note	Thread safe.
+		 */
+		virtual PixelFormat getNativeFormat(TextureType ttype, PixelFormat format, int usage, bool hwGamma) = 0;
+
+	protected:
+		/**
+		 * Creates an empty and uninitialized render texture of a specific type. This is to be implemented by render 
+		 * systems with their own implementations.
+		 */
+		virtual RenderTexturePtr createRenderTextureImpl(const RENDER_TEXTURE_DESC& desc) = 0;
+
+		/**
+		 * Creates an empty and uninitialized multi render texture of a specific type. This is to be implemented by render
+		 * systems with their own implementations.
+		 */
+		virtual MultiRenderTexturePtr createMultiRenderTextureImpl(const MULTI_RENDER_TEXTURE_DESC& desc) = 0;
+
+		mutable HTexture mDummyTexture;
+    };
+
+	/**
+     * Defines interface for creation of textures. Render systems provide their own implementations.
+	 *
+	 * @note	Core thread only.
+     */
+    class BS_CORE_EXPORT TextureCoreManager : public Module<TextureCoreManager>
+    {
+    public:
+		virtual ~TextureCoreManager() { }
+
+		/**
+		 * @copydoc	TextureManager::createTexture(TextureType, UINT32, UINT32, UINT32, int, PixelFormat, int, bool, UINT32)
+		 */
+		SPtr<TextureCore> createTexture(TextureType texType, UINT32 width, UINT32 height, UINT32 depth,
+			int numMips, PixelFormat format, int usage = TU_DEFAULT, bool hwGammaCorrection = false, 
+			UINT32 multisampleCount = 0);
+
+		/** @copydoc	TextureManager::createRenderTexture(const RENDER_TEXTURE_DESC&) */
+		SPtr<RenderTextureCore> createRenderTexture(const RENDER_TEXTURE_CORE_DESC& desc);
+
+		/** @copydoc	TextureManager::createMultiRenderTexture(const MULTI_RENDER_TEXTURE_DESC&) */
+		SPtr<MultiRenderTextureCore> createMultiRenderTexture(const MULTI_RENDER_TEXTURE_CORE_DESC& desc);
+
+	protected:
+		friend class Texture;
+		friend class RenderTexture;
+		friend class MultiRenderTexture;
+
+		/**
+		 * Creates an empty and uninitialized texture of a specific type. This is to be implemented	by render systems with
+		 * their own implementations.
+		 */
+		virtual SPtr<TextureCore> createTextureInternal(TextureType texType, UINT32 width, UINT32 height, UINT32 depth,
+			int numMips, PixelFormat format, int usage = TU_DEFAULT, bool hwGammaCorrection = false,
+			UINT32 multisampleCount = 0, const PixelDataPtr& initialData = nullptr) = 0;
+
+		/** @copydoc TextureManager::createRenderTextureImpl */
+		virtual SPtr<RenderTextureCore> createRenderTextureInternal(const RENDER_TEXTURE_CORE_DESC& desc) = 0;
+
+		/** @copydoc TextureManager::createMultiRenderTextureImpl */
+		virtual SPtr<MultiRenderTextureCore> createMultiRenderTextureInternal(const MULTI_RENDER_TEXTURE_CORE_DESC& desc) = 0;
+    };
+
+	/** @} */
 }

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

@@ -6,8 +6,7 @@
 
 namespace BansheeEngine
 {
-	/** @cond INTERNAL */
-	/** @addtogroup RenderAPI
+	/** @addtogroup RenderAPI-Internal
 	 *  @{
 	 */
 
@@ -96,5 +95,4 @@ namespace BansheeEngine
 	};
 
 	/** @} */
-	/** @endcond */
 }

+ 63 - 65
Source/BansheeCore/Include/BsTimerQuery.h

@@ -1,66 +1,64 @@
-//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
-//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
-#pragma once
-
-#include "BsCorePrerequisites.h"
-
-namespace BansheeEngine
-{
-	/** @cond INTERNAL */
-	/** @addtogroup RenderAPI
-	 *  @{
-	 */
-
-	/**
-	 * Represents a GPU query that measures execution time of GPU operations. The query will measure any GPU operations 
-	 * that take place between its begin() and end() calls.
-	 * 			
-	 * @note	Core thread only.
-	 */
-	class BS_CORE_EXPORT TimerQuery
-	{
-	public:
-		virtual ~TimerQuery() {}
-
-		/**
-		 * Starts the counter. 
-		 * 			
-		 * @note	Place any commands you want to measure after this call. Call "end" when done.
-		 */
-		virtual void begin() = 0;
-
-		/**	Stops the counter. */
-		virtual void end() = 0;
-
-		/**	Check if GPU has processed the query. */
-		virtual bool isReady() const = 0;
-
-		/**
-		 * Returns the time it took for the query to execute.
-		 *
-		 * @return	The time milliseconds.
-		 * 			
-		 * @note	Only valid after isReady() returns true.
-		 */
-		virtual float getTimeMs() = 0;
-
-		/** Triggered when GPU processes the query. As a parameter it provides query duration in milliseconds. */
-		Event<void(float)> onTriggered;
-
-		/**	Creates a new query, but does not schedule it on GPU. */
-		static TimerQueryPtr create();
-
-	protected:
-		friend class QueryManager;
-
-		/**	Returns true if the has still not been completed by the GPU. */
-		bool isActive() const { return mActive; }
-		void setActive(bool active) { mActive = active; }
-
-	protected:
-		bool mActive;
-	};
-
-	/** @} */
-	/** @endcond */
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+#pragma once
+
+#include "BsCorePrerequisites.h"
+
+namespace BansheeEngine
+{
+	/** @addtogroup RenderAPI-Internal
+	 *  @{
+	 */
+
+	/**
+	 * Represents a GPU query that measures execution time of GPU operations. The query will measure any GPU operations 
+	 * that take place between its begin() and end() calls.
+	 * 			
+	 * @note	Core thread only.
+	 */
+	class BS_CORE_EXPORT TimerQuery
+	{
+	public:
+		virtual ~TimerQuery() {}
+
+		/**
+		 * Starts the counter. 
+		 * 			
+		 * @note	Place any commands you want to measure after this call. Call "end" when done.
+		 */
+		virtual void begin() = 0;
+
+		/**	Stops the counter. */
+		virtual void end() = 0;
+
+		/**	Check if GPU has processed the query. */
+		virtual bool isReady() const = 0;
+
+		/**
+		 * Returns the time it took for the query to execute.
+		 *
+		 * @return	The time milliseconds.
+		 * 			
+		 * @note	Only valid after isReady() returns true.
+		 */
+		virtual float getTimeMs() = 0;
+
+		/** Triggered when GPU processes the query. As a parameter it provides query duration in milliseconds. */
+		Event<void(float)> onTriggered;
+
+		/**	Creates a new query, but does not schedule it on GPU. */
+		static TimerQueryPtr create();
+
+	protected:
+		friend class QueryManager;
+
+		/**	Returns true if the has still not been completed by the GPU. */
+		bool isActive() const { return mActive; }
+		void setActive(bool active) { mActive = active; }
+
+	protected:
+		bool mActive;
+	};
+
+	/** @} */
 }

+ 98 - 96
Source/BansheeCore/Include/BsTransientMesh.h

@@ -1,97 +1,99 @@
-//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
-//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
-#pragma once
-
-#include "BsCorePrerequisites.h"
-#include "BsMeshBase.h"
-
-namespace BansheeEngine
-{
-	/** @addtogroup Resources
-	 *  @{
-	 */
-
-	/** @cond INTERNAL */
-
-	/**
-	 * Core thread portion of a TransientMesh.
-	 *
-	 * @note	Core thread.
-	 */
-	class BS_CORE_EXPORT TransientMeshCore : public MeshCoreBase
-	{
-	public:
-		TransientMeshCore(const SPtr<MeshHeapCore>& parentHeap, UINT32 id, UINT32 numVertices,
-			UINT32 numIndices, const Vector<SubMesh>& subMeshes);
-
-		/** @copydoc MeshCoreBase::getVertexData */
-		SPtr<VertexData> getVertexData() const override;
-
-		 /** @copydoc MeshCoreBase::getIndexData */
-		SPtr<IndexBufferCore> getIndexBuffer() const override;
-
-		/** @copydoc MeshCoreBase::getVertexDesc */
-		SPtr<VertexDataDesc> getVertexDesc() const override;
-
-		/**	Returns the ID that uniquely identifies this mesh in the parent heap. */
-		UINT32 getMeshHeapId() const { return mId; }
-
-		/** @copydoc MeshCoreBase::getVertexOffset */
-		virtual UINT32 getVertexOffset() const override;
-
-		 /** @copydoc MeshCoreBase::getIndexOffset */
-		virtual UINT32 getIndexOffset() const override;
-
-		 /** @copydoc MeshCoreBase::notifyUsedOnGPU */
-		virtual void _notifyUsedOnGPU() override;
-
-	protected:
-		friend class TransientMesh;
-
-		SPtr<MeshHeapCore> mParentHeap;
-		UINT32 mId;
-	};
-
-	/** @endcond */
-
-	/**
-	 * Represents a single mesh entry in the MeshHeap. This can be used as a normal mesh but due to the nature of the 
-	 * mesh heap it is not the type of mesh you should use for storing static data.
-	 *
-	 * Transient meshes don't keep internal index/vertex buffers but instead use the ones provided by their parent mesh heap.
-	 *
-	 * @note	Sim thread.
-	 */
-	class BS_CORE_EXPORT TransientMesh : public MeshBase
-	{
-	public:
-		virtual ~TransientMesh();
-
-		/** Retrieves a core implementation of a mesh usable only from the core thread. */
-		SPtr<TransientMeshCore> getCore() const;
-
-	protected:
-		friend class MeshHeap;
-
-		/**
-		 * Constructs a new transient mesh.
-		 *
-		 * @see		MeshHeap::alloc
-		 */
-		TransientMesh(const MeshHeapPtr& parentHeap, UINT32 id, UINT32 numVertices,
-			UINT32 numIndices, DrawOperationType drawOp = DOT_TRIANGLE_LIST);
-
-		/** Marks the mesh as destroyed so we know that we don't need to destroy it ourselves. */
-		void markAsDestroyed() { mIsDestroyed = true; }
-
-		/** @copydoc RenderTarget::createCore */
-		SPtr<CoreObjectCore> createCore() const override;
-
-	protected:
-		bool mIsDestroyed;
-		MeshHeapPtr mParentHeap;
-		UINT32 mId;
-	};
-
-	/** @} */
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+#pragma once
+
+#include "BsCorePrerequisites.h"
+#include "BsMeshBase.h"
+
+namespace BansheeEngine
+{
+	/** @addtogroup Resources
+	 *  @{
+	 */
+
+	/**
+	 * Represents a single mesh entry in the MeshHeap. This can be used as a normal mesh but due to the nature of the 
+	 * mesh heap it is not the type of mesh you should use for storing static data.
+	 *
+	 * Transient meshes don't keep internal index/vertex buffers but instead use the ones provided by their parent mesh heap.
+	 *
+	 * @note	Sim thread.
+	 */
+	class BS_CORE_EXPORT TransientMesh : public MeshBase
+	{
+	public:
+		virtual ~TransientMesh();
+
+		/** Retrieves a core implementation of a mesh usable only from the core thread. */
+		SPtr<TransientMeshCore> getCore() const;
+
+	protected:
+		friend class MeshHeap;
+
+		/**
+		 * Constructs a new transient mesh.
+		 *
+		 * @see		MeshHeap::alloc
+		 */
+		TransientMesh(const MeshHeapPtr& parentHeap, UINT32 id, UINT32 numVertices,
+			UINT32 numIndices, DrawOperationType drawOp = DOT_TRIANGLE_LIST);
+
+		/** Marks the mesh as destroyed so we know that we don't need to destroy it ourselves. */
+		void markAsDestroyed() { mIsDestroyed = true; }
+
+		/** @copydoc RenderTarget::createCore */
+		SPtr<CoreObjectCore> createCore() const override;
+
+	protected:
+		bool mIsDestroyed;
+		MeshHeapPtr mParentHeap;
+		UINT32 mId;
+	};
+
+	/** @} */
+
+	/** @addtogroup Resources-Internal
+	 *  @{
+	 */
+
+	/**
+	 * Core thread portion of a TransientMesh.
+	 *
+	 * @note	Core thread.
+	 */
+	class BS_CORE_EXPORT TransientMeshCore : public MeshCoreBase
+	{
+	public:
+		TransientMeshCore(const SPtr<MeshHeapCore>& parentHeap, UINT32 id, UINT32 numVertices,
+			UINT32 numIndices, const Vector<SubMesh>& subMeshes);
+
+		/** @copydoc MeshCoreBase::getVertexData */
+		SPtr<VertexData> getVertexData() const override;
+
+		 /** @copydoc MeshCoreBase::getIndexBuffer */
+		SPtr<IndexBufferCore> getIndexBuffer() const override;
+
+		/** @copydoc MeshCoreBase::getVertexDesc */
+		SPtr<VertexDataDesc> getVertexDesc() const override;
+
+		/**	Returns the ID that uniquely identifies this mesh in the parent heap. */
+		UINT32 getMeshHeapId() const { return mId; }
+
+		/** @copydoc MeshCoreBase::getVertexOffset */
+		virtual UINT32 getVertexOffset() const override;
+
+		 /** @copydoc MeshCoreBase::getIndexOffset */
+		virtual UINT32 getIndexOffset() const override;
+
+		 /** @copydoc MeshCoreBase::_notifyUsedOnGPU */
+		virtual void _notifyUsedOnGPU() override;
+
+	protected:
+		friend class TransientMesh;
+
+		SPtr<MeshHeapCore> mParentHeap;
+		UINT32 mId;
+	};
+
+	/** @} */
 }

+ 56 - 58
Source/BansheeCore/Include/BsUtility.h

@@ -1,59 +1,57 @@
-//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
-//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
-#pragma once
-
-#include "BsCorePrerequisites.h"
-
-namespace BansheeEngine
-{
-	/** @cond INTERNAL */
-	/** @addtogroup Utility-Core
-	 *  @{
-	 */
-
-	/** Contains information about a resource dependency, including the dependant resource and number of references to it. */
-	struct ResourceDependency
-	{
-		ResourceDependency()
-			:numReferences(0)
-		{ }
-
-		HResource resource;
-		UINT32 numReferences;
-	};
-
-	/** Static class containing various utility methods that do not fit anywhere else. */
-	class BS_CORE_EXPORT Utility
-	{
-	public:
-		/**
-		 * Finds all resources referenced by the specified object.
-		 *
-		 * @param[in]	object		Object to search for resource dependencies.
-		 * @param[in]	recursive	Determines whether or not child objects will also be searched (if the object has any
-		 *							children).
-		 * @return					A list of unique, non-null resources.
-		 */
-		static Vector<ResourceDependency> findResourceDependencies(IReflectable& object, bool recursive = true);
-
-		/** Calculates how deep in the scene object hierarchy is the provided object. Zero means root. */
-		static UINT32 getSceneObjectDepth(const HSceneObject& so);
-
-	private:
-		/**
-		 * Helper method for for recursion when finding resource dependencies.
-		 *
-		 * @see	findDependencies
-		 */
-		static void findResourceDependenciesInternal(IReflectable& object, bool recursive, Map<String, ResourceDependency>& dependencies);
-
-		/**
-		 * Checks if the specified type (or any of its derived classes) have any IReflectable pointer or value types as 
-		 * their fields.
-		 */
-		static bool hasReflectableChildren(RTTITypeBase* type);
-	};
-
-	/** @} */
-	/** @endcond */
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+#pragma once
+
+#include "BsCorePrerequisites.h"
+
+namespace BansheeEngine
+{
+	/** @addtogroup Utility-Core-Internal
+	 *  @{
+	 */
+
+	/** Contains information about a resource dependency, including the dependant resource and number of references to it. */
+	struct ResourceDependency
+	{
+		ResourceDependency()
+			:numReferences(0)
+		{ }
+
+		HResource resource;
+		UINT32 numReferences;
+	};
+
+	/** Static class containing various utility methods that do not fit anywhere else. */
+	class BS_CORE_EXPORT Utility
+	{
+	public:
+		/**
+		 * Finds all resources referenced by the specified object.
+		 *
+		 * @param[in]	object		Object to search for resource dependencies.
+		 * @param[in]	recursive	Determines whether or not child objects will also be searched (if the object has any
+		 *							children).
+		 * @return					A list of unique, non-null resources.
+		 */
+		static Vector<ResourceDependency> findResourceDependencies(IReflectable& object, bool recursive = true);
+
+		/** Calculates how deep in the scene object hierarchy is the provided object. Zero means root. */
+		static UINT32 getSceneObjectDepth(const HSceneObject& so);
+
+	private:
+		/**
+		 * Helper method for for recursion when finding resource dependencies.
+		 *
+		 * @see	findDependencies
+		 */
+		static void findResourceDependenciesInternal(IReflectable& object, bool recursive, Map<String, ResourceDependency>& dependencies);
+
+		/**
+		 * Checks if the specified type (or any of its derived classes) have any IReflectable pointer or value types as 
+		 * their fields.
+		 */
+		static bool hasReflectableChildren(RTTITypeBase* type);
+	};
+
+	/** @} */
 }

+ 86 - 84
Source/BansheeCore/Include/BsVertexBuffer.h

@@ -1,85 +1,87 @@
-//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
-//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
-#pragma once
-
-#include "BsCorePrerequisites.h"
-#include "BsHardwareBuffer.h"
-#include "BsCoreObject.h"
-
-namespace BansheeEngine 
-{
-	/** @addtogroup RenderAPI
-	 *  @{
-	 */
-
-	/** Contains information about a vertex buffer buffer. */
-	class BS_CORE_EXPORT VertexBufferProperties
-	{
-	public:
-		VertexBufferProperties(UINT32 numVertices, UINT32 vertexSize);
-
-		/**	Gets the size in bytes of a single vertex in this buffer. */
-        UINT32 getVertexSize() const { return mVertexSize; }
-
-		/**	Get the number of vertices in this buffer. */
-        UINT32 getNumVertices() const { return mNumVertices; }
-
-	protected:
-		friend class VertexBuffer;
-		friend class VertexBufferCore;
-
-		UINT32 mNumVertices;
-		UINT32 mVertexSize;
-	};
-
-	/** @cond INTERNAL */
-
-	/** Core thread specific implementation of a VertexBuffer. */
-	class BS_CORE_EXPORT VertexBufferCore : public CoreObjectCore, public HardwareBuffer
-	{
-	public:
-		VertexBufferCore(UINT32 vertexSize, UINT32 numVertices, GpuBufferUsage usage, bool streamOut);
-		virtual ~VertexBufferCore() { }
-
-		/**	Returns information about the vertex buffer. */
-		const VertexBufferProperties& getProperties() const { return mProperties; }
-
-	protected:
-		VertexBufferProperties mProperties;
-	};
-
-	/** @endcond */
-
-	/**	Specialization of a hardware buffer used for holding vertex data. */
-    class BS_CORE_EXPORT VertexBuffer : public CoreObject
-    {
-	public:
-		virtual ~VertexBuffer() { }
-
-		/**
-		 * Retrieves a core implementation of a vertex buffer usable only from the core thread.
-		 *
-		 * @note	Core thread only.
-		 */
-		SPtr<VertexBufferCore> getCore() const;
-
-		/** @copydoc HardwareBufferManager::createVertexBuffer */
-		static VertexBufferPtr create(UINT32 vertexSize, UINT32 numVerts, GpuBufferUsage usage, bool streamOut = false);
-
-		static const int MAX_SEMANTIC_IDX = 8;
-	protected:
-		friend class HardwareBufferManager;
-
-		VertexBuffer(UINT32 vertexSize, UINT32 numVertices, GpuBufferUsage usage, bool streamOut = false);
-
-		/** @copydoc CoreObject::createCore */
-		virtual SPtr<CoreObjectCore> createCore() const;
-
-	protected:
-		VertexBufferProperties mProperties;
-		GpuBufferUsage mUsage;
-		bool mStreamOut;
-    };
-
-	/** @} */
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+#pragma once
+
+#include "BsCorePrerequisites.h"
+#include "BsHardwareBuffer.h"
+#include "BsCoreObject.h"
+
+namespace BansheeEngine 
+{
+	/** @addtogroup RenderAPI
+	 *  @{
+	 */
+
+	/** Contains information about a vertex buffer buffer. */
+	class BS_CORE_EXPORT VertexBufferProperties
+	{
+	public:
+		VertexBufferProperties(UINT32 numVertices, UINT32 vertexSize);
+
+		/**	Gets the size in bytes of a single vertex in this buffer. */
+        UINT32 getVertexSize() const { return mVertexSize; }
+
+		/**	Get the number of vertices in this buffer. */
+        UINT32 getNumVertices() const { return mNumVertices; }
+
+	protected:
+		friend class VertexBuffer;
+		friend class VertexBufferCore;
+
+		UINT32 mNumVertices;
+		UINT32 mVertexSize;
+	};
+
+	/**	Specialization of a hardware buffer used for holding vertex data. */
+    class BS_CORE_EXPORT VertexBuffer : public CoreObject
+    {
+	public:
+		virtual ~VertexBuffer() { }
+
+		/**
+		 * Retrieves a core implementation of a vertex buffer usable only from the core thread.
+		 *
+		 * @note	Core thread only.
+		 */
+		SPtr<VertexBufferCore> getCore() const;
+
+		/** @copydoc HardwareBufferManager::createVertexBuffer */
+		static VertexBufferPtr create(UINT32 vertexSize, UINT32 numVerts, GpuBufferUsage usage, bool streamOut = false);
+
+		static const int MAX_SEMANTIC_IDX = 8;
+	protected:
+		friend class HardwareBufferManager;
+
+		VertexBuffer(UINT32 vertexSize, UINT32 numVertices, GpuBufferUsage usage, bool streamOut = false);
+
+		/** @copydoc CoreObject::createCore */
+		virtual SPtr<CoreObjectCore> createCore() const;
+
+	protected:
+		VertexBufferProperties mProperties;
+		GpuBufferUsage mUsage;
+		bool mStreamOut;
+    };
+
+	/** @} */
+
+	/** @addtogroup RenderAPI-Internal
+	 *  @{
+	 */
+
+	/** Core thread specific implementation of a VertexBuffer. */
+	class BS_CORE_EXPORT VertexBufferCore : public CoreObjectCore, public HardwareBuffer
+	{
+	public:
+		VertexBufferCore(UINT32 vertexSize, UINT32 numVertices, GpuBufferUsage usage, bool streamOut);
+		virtual ~VertexBufferCore() { }
+
+		/**	Returns information about the vertex buffer. */
+		const VertexBufferProperties& getProperties() const { return mProperties; }
+
+	protected:
+		VertexBufferProperties mProperties;
+	};
+
+	/** @} */
 }

+ 48 - 46
Source/BansheeCore/Include/BsVertexDeclaration.h

@@ -136,52 +136,6 @@ namespace BansheeEngine
 		List<VertexElement> mElementList;
 	};
 
-	/** @cond INTERNAL */
-
-	/**
-	 * Core thread portion of a VertexDeclaration.
-	 *
-	 * @note	Core thread.
-	 */
-	class BS_CORE_EXPORT VertexDeclarationCore : public CoreObjectCore
-    {
-	public:
-		virtual ~VertexDeclarationCore() { }
-
-		/** @copydoc CoreObjectCore::initialize */
-		void initialize() override;
-
-		/**	Returns properties describing the vertex declaration. */
-		const VertexDeclarationProperties& getProperties() const { return mProperties; }
-
-		/**	Returns an ID unique to this declaration. */
-		UINT32 getId() const { return mId; }
-
-		/**
-		 * Checks can a vertex buffer declared with this declaration be bound to a shader defined with the provided 
-		 * declaration.
-		 */
-		bool isCompatible(const SPtr<VertexDeclarationCore>& shaderDecl);
-
-		/**
-		 * Returns a list of vertex elements that the provided shader's vertex declaration expects but aren't present in 
-		 * this vertex declaration.
-		 */
-		Vector<VertexElement> getMissingElements(const SPtr<VertexDeclarationCore>& shaderDecl);
-
-    protected:
-		friend class HardwareBufferCoreManager;
-
-		VertexDeclarationCore(const List<VertexElement>& elements);
-
-		VertexDeclarationProperties mProperties;
-		UINT32 mId;
-
-		static UINT32 NextFreeId;
-    };
-
-	/** @endcond */
-
 	/**
 	 * Describes a set of vertex elements, used for describing contents of a vertex buffer or inputs to a vertex GPU program.
 	 *
@@ -228,4 +182,52 @@ namespace BansheeEngine
 	BS_CORE_EXPORT WString toWString(const VertexElementSemantic& val);
 
 	/** @} */
+
+	/** @addtogroup RenderAPI-Internal
+	 *  @{
+	 */
+
+	/**
+	 * Core thread portion of a VertexDeclaration.
+	 *
+	 * @note	Core thread.
+	 */
+	class BS_CORE_EXPORT VertexDeclarationCore : public CoreObjectCore
+    {
+	public:
+		virtual ~VertexDeclarationCore() { }
+
+		/** @copydoc CoreObjectCore::initialize */
+		void initialize() override;
+
+		/**	Returns properties describing the vertex declaration. */
+		const VertexDeclarationProperties& getProperties() const { return mProperties; }
+
+		/**	Returns an ID unique to this declaration. */
+		UINT32 getId() const { return mId; }
+
+		/**
+		 * Checks can a vertex buffer declared with this declaration be bound to a shader defined with the provided 
+		 * declaration.
+		 */
+		bool isCompatible(const SPtr<VertexDeclarationCore>& shaderDecl);
+
+		/**
+		 * Returns a list of vertex elements that the provided shader's vertex declaration expects but aren't present in 
+		 * this vertex declaration.
+		 */
+		Vector<VertexElement> getMissingElements(const SPtr<VertexDeclarationCore>& shaderDecl);
+
+    protected:
+		friend class HardwareBufferCoreManager;
+
+		VertexDeclarationCore(const List<VertexElement>& elements);
+
+		VertexDeclarationProperties mProperties;
+		UINT32 mId;
+
+		static UINT32 NextFreeId;
+    };
+
+	/** @} */
 }

+ 42 - 41
Source/BansheeCore/Include/BsViewport.h

@@ -94,11 +94,6 @@ namespace BansheeEngine
 		bool getRequiresStencilClear() const { return mRequiresStencilClear; }
 
     protected:
-        /**
-         * Constructs a new viewport.
-         *
-         * @note	Viewport coordinates are normalized in [0, 1] range.
-         */
 		ViewportBase(float x = 0.0f, float y = 0.0f, float width = 1.0f, float height = 1.0f);
 
 		/** @copydoc CoreObject::markCoreDirty */
@@ -128,40 +123,6 @@ namespace BansheeEngine
 	/** @addtogroup RenderAPI
 	 *  @{
 	 */
-	/** @cond INTERNAL */
-
-	/** @copydoc ViewportBase */
-	class BS_CORE_EXPORT ViewportCore : public CoreObjectCore, public ViewportBase
-    {
-    public:       
-        /**	Returns the render target the viewport is associated with. */
-		SPtr<RenderTargetCore> getTarget() const { return mTarget; }
-
-		/**	Sets the render target the viewport will be associated with. */
-		void setTarget(const SPtr<RenderTargetCore>& target) { mTarget = target; }
-
-		/** @copydoc ViewportBase::ViewportBase */
-		static SPtr<ViewportCore> create(const SPtr<RenderTargetCore>& target, float x = 0.0f, float y = 0.0f, float width = 1.0f, float height = 1.0f);
-
-    protected:
-		friend class Viewport;
-
-		/** @copydoc ViewportBase::ViewportBase */
-		ViewportCore(const SPtr<RenderTargetCore>& target, float x = 0.0f, float y = 0.0f, float width = 1.0f, float height = 1.0f);
-
-		/** @copydoc CoreObject::getTargetWidth */
-		UINT32 getTargetWidth() const override;
-
-		/** @copydoc CoreObject::getTargetHeight */
-		UINT32 getTargetHeight() const override;
-
-		/** @copydoc	CoreObject::syncToCore */
-		void syncToCore(const CoreSyncData& data) override;
-
-		SPtr<RenderTargetCore> mTarget;
-    };
-
-	/** @endcond */
 
 	/** @copydoc ViewportBase */
 	class BS_CORE_EXPORT Viewport : public IReflectable, public CoreObject, public ViewportBase
@@ -176,12 +137,15 @@ namespace BansheeEngine
 		/**	Retrieves a core implementation of a viewport usable only from the core thread. */
 		SPtr<ViewportCore> getCore() const;
 
-		/** @copydoc ViewportBase::ViewportBase */
+	    /**
+         * Creates a new viewport.
+         *
+         * @note	Viewport coordinates are normalized in [0, 1] range.
+         */	
 		static ViewportPtr create(const RenderTargetPtr& target, float x = 0.0f, float y = 0.0f, 
 			float width = 1.0f, float height = 1.0f);
 
     protected:
-		/** @copydoc ViewportBase::ViewportBase */
         Viewport(const RenderTargetPtr& target, float x = 0.0f, float y = 0.0f, float width = 1.0f, float height = 1.0f);
 
 		/** @copydoc CoreObject::markCoreDirty */
@@ -218,4 +182,41 @@ namespace BansheeEngine
     };
 
 	/** @} */
+
+	/** @addtogroup RenderAPI-Internal
+	 *  @{
+	 */
+
+	/** @copydoc ViewportBase */
+	class BS_CORE_EXPORT ViewportCore : public CoreObjectCore, public ViewportBase
+    {
+    public:       
+        /**	Returns the render target the viewport is associated with. */
+		SPtr<RenderTargetCore> getTarget() const { return mTarget; }
+
+		/**	Sets the render target the viewport will be associated with. */
+		void setTarget(const SPtr<RenderTargetCore>& target) { mTarget = target; }
+
+		/** @copydoc Viewport::create() */
+		static SPtr<ViewportCore> create(const SPtr<RenderTargetCore>& target, float x = 0.0f, float y = 0.0f, 
+			float width = 1.0f, float height = 1.0f);
+
+    protected:
+		friend class Viewport;
+
+		ViewportCore(const SPtr<RenderTargetCore>& target, float x = 0.0f, float y = 0.0f, float width = 1.0f, float height = 1.0f);
+
+		/** @copydoc CoreObject::getTargetWidth */
+		UINT32 getTargetWidth() const override;
+
+		/** @copydoc CoreObject::getTargetHeight */
+		UINT32 getTargetHeight() const override;
+
+		/** @copydoc	CoreObject::syncToCore */
+		void syncToCore(const CoreSyncData& data) override;
+
+		SPtr<RenderTargetCore> mTarget;
+    };
+
+	/** @} */
 }

+ 43 - 45
Source/BansheeCore/Include/Win32/BSWin32PlatformData.h

@@ -1,46 +1,44 @@
-//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
-//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
-#include "BsPlatform.h"
-#include "Win32/BsWin32Defs.h"
-#include "Win32/BsWin32DropTarget.h"
-
-namespace BansheeEngine
-{
-	/** @cond INTERNAL */
-	/** @addtogroup Platform
-	 *  @{
-	 */
-
-	/** Encapsulate native cursor data so we can avoid including windows.h as it pollutes the global namespace. */
-	struct BS_CORE_EXPORT NativeCursorData
-	{
-		HCURSOR cursor;
-	};
-
-	/**	Encapsulate drop target data so we can avoid including windows.h as it pollutes the global namespace. */
-	struct BS_CORE_EXPORT NativeDropTargetData
-	{
-		Map<const RenderWindow*, Win32DropTarget*> dropTargetsPerWindow;
-		Vector<Win32DropTarget*> dropTargetsToInitialize;
-		Vector<Win32DropTarget*> dropTargetsToDestroy;
-	};
-
-	struct Platform::Pimpl
-	{
-		bool mIsCursorHidden = false;
-		NativeCursorData mCursor;
-		bool mUsingCustomCursor = false;
-		Map<const RenderWindowCore*, WindowNonClientAreaData> mNonClientAreas;
-
-		bool mIsTrackingMouse = false;
-		NativeDropTargetData mDropTargets;
-
-		bool mRequiresStartUp = false;
-		bool mRequiresShutDown = false;
-
-		BS_MUTEX(mSync);
-	};
-
-	/** @} */
-	/** @endcond */
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+#include "BsPlatform.h"
+#include "Win32/BsWin32Defs.h"
+#include "Win32/BsWin32DropTarget.h"
+
+namespace BansheeEngine
+{
+	/** @addtogroup Platform-Internal
+	 *  @{
+	 */
+
+	/** Encapsulate native cursor data so we can avoid including windows.h as it pollutes the global namespace. */
+	struct BS_CORE_EXPORT NativeCursorData
+	{
+		HCURSOR cursor;
+	};
+
+	/**	Encapsulate drop target data so we can avoid including windows.h as it pollutes the global namespace. */
+	struct BS_CORE_EXPORT NativeDropTargetData
+	{
+		Map<const RenderWindow*, Win32DropTarget*> dropTargetsPerWindow;
+		Vector<Win32DropTarget*> dropTargetsToInitialize;
+		Vector<Win32DropTarget*> dropTargetsToDestroy;
+	};
+
+	struct Platform::Pimpl
+	{
+		bool mIsCursorHidden = false;
+		NativeCursorData mCursor;
+		bool mUsingCustomCursor = false;
+		Map<const RenderWindowCore*, WindowNonClientAreaData> mNonClientAreas;
+
+		bool mIsTrackingMouse = false;
+		NativeDropTargetData mDropTargets;
+
+		bool mRequiresStartUp = false;
+		bool mRequiresShutDown = false;
+
+		BS_MUTEX(mSync);
+	};
+
+	/** @} */
 }

+ 1 - 3
Source/BansheeCore/Include/Win32/BsWin32DropTarget.h

@@ -8,8 +8,7 @@
 
 namespace BansheeEngine
 {
-	/** @cond INTERNAL */
-	/** @addtogroup Platform
+	/** @addtogroup Platform-Internal
 	 *  @{
 	 */
 
@@ -384,5 +383,4 @@ namespace BansheeEngine
 	};
 
 	/** @} */
-	/** @endcond */
 }

+ 85 - 87
Source/BansheeCore/Include/Win32/BsWin32FolderMonitor.h

@@ -1,88 +1,86 @@
-//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
-//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
-#pragma once
-
-#include "BsCorePrerequisites.h"
-
-namespace BansheeEngine
-{
-	/** @cond INTERNAL */
-	/** @addtogroup Platform
-	 *  @{
-	 */
-
-	/** Types of notifications we would like to receive when we start a FolderMonitor on a certain folder. */
-	enum class FolderChange
-	{
-		FileName = 0x0001, /**< Called when filename changes. */
-		DirName = 0x0002, /**< Called when directory name changes. */
-		Attributes = 0x0004, /**< Called when attributes changes. */
-		Size = 0x0008, /**< Called when file size changes. */
-		LastWrite = 0x0010, /**< Called when file is written to. */
-		LastAccess = 0x0020, /**< Called when file is accessed. */
-		Creation = 0x0040, /**< Called when file is created. */
-		Security = 0x0080 /**< Called when file security descriptor changes. */
-	};
-
-	/**
-	 * Allows monitoring a file system folder for changes. Depending on the flags set this monitor can notify you when file
-	 * is changed/moved/renamed and similar.
-	 */
-	class BS_CORE_EXPORT FolderMonitor
-	{
-		struct Pimpl;
-		class FileNotifyInfo;
-		struct FolderWatchInfo;
-	public:
-		FolderMonitor();
-		~FolderMonitor();
-
-		/**
-		 * Starts monitoring a folder at the specified path.
-		 *
-		 * @param[in]	folderPath		Absolute path to the folder you want to monitor.
-		 * @param[in]	subdirectories	If true, provided folder and all of its subdirectories will be monitored for 
-		 *								changes. Otherwise only the provided folder will be monitored.
-		 * @param[in]	changeFilter	A set of flags you may OR together. Different notification events will trigger 
-		 *								depending on which flags you set.
-		 */
-		void startMonitor(const Path& folderPath, bool subdirectories, FolderChange changeFilter);
-
-		/** Stops monitoring the folder at the specified path. */
-		void stopMonitor(const Path& folderPath);
-
-		/**	Stops monitoring all folders that are currently being monitored. */
-		void stopMonitorAll();
-
-		/**
-		 * Callbacks will only get fired after update is called().
-		 * 			
-		 * @note	Internal method.
-		 */
-		void _update();
-
-		/** Triggers when a file in the monitored folder is modified. Provides absolute path to the file. */
-		Event<void(const Path&)> onModified;
-
-		/**	Triggers when a file/folder is added in the monitored folder. Provides absolute path to the file/folder. */
-		Event<void(const Path&)> onAdded;
-
-		/**	Triggers when a file/folder is removed from the monitored folder. Provides absolute path to the file/folder. */
-		Event<void(const Path&)> onRemoved;
-
-		/**	Triggers when a file/folder is renamed in the monitored folder. Provides absolute path with old and new names. */
-		Event<void(const Path&, const Path&)> onRenamed;
-
-	private:
-		/**	Worker method that monitors the IO ports for any modification notifications. */
-		void workerThreadMain();
-
-		/**	Called by the worker thread whenever a modification notification is received. */
-		void handleNotifications(FileNotifyInfo& notifyInfo, FolderWatchInfo& watchInfo);
-
-		Pimpl* mPimpl;
-	};
-
-	/** @} */
-	/** @endcond */
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+#pragma once
+
+#include "BsCorePrerequisites.h"
+
+namespace BansheeEngine
+{
+	/** @addtogroup Platform-Internal
+	 *  @{
+	 */
+
+	/** Types of notifications we would like to receive when we start a FolderMonitor on a certain folder. */
+	enum class FolderChange
+	{
+		FileName = 0x0001, /**< Called when filename changes. */
+		DirName = 0x0002, /**< Called when directory name changes. */
+		Attributes = 0x0004, /**< Called when attributes changes. */
+		Size = 0x0008, /**< Called when file size changes. */
+		LastWrite = 0x0010, /**< Called when file is written to. */
+		LastAccess = 0x0020, /**< Called when file is accessed. */
+		Creation = 0x0040, /**< Called when file is created. */
+		Security = 0x0080 /**< Called when file security descriptor changes. */
+	};
+
+	/**
+	 * Allows monitoring a file system folder for changes. Depending on the flags set this monitor can notify you when file
+	 * is changed/moved/renamed and similar.
+	 */
+	class BS_CORE_EXPORT FolderMonitor
+	{
+		struct Pimpl;
+		class FileNotifyInfo;
+		struct FolderWatchInfo;
+	public:
+		FolderMonitor();
+		~FolderMonitor();
+
+		/**
+		 * Starts monitoring a folder at the specified path.
+		 *
+		 * @param[in]	folderPath		Absolute path to the folder you want to monitor.
+		 * @param[in]	subdirectories	If true, provided folder and all of its subdirectories will be monitored for 
+		 *								changes. Otherwise only the provided folder will be monitored.
+		 * @param[in]	changeFilter	A set of flags you may OR together. Different notification events will trigger 
+		 *								depending on which flags you set.
+		 */
+		void startMonitor(const Path& folderPath, bool subdirectories, FolderChange changeFilter);
+
+		/** Stops monitoring the folder at the specified path. */
+		void stopMonitor(const Path& folderPath);
+
+		/**	Stops monitoring all folders that are currently being monitored. */
+		void stopMonitorAll();
+
+		/**
+		 * Callbacks will only get fired after update is called().
+		 * 			
+		 * @note	Internal method.
+		 */
+		void _update();
+
+		/** Triggers when a file in the monitored folder is modified. Provides absolute path to the file. */
+		Event<void(const Path&)> onModified;
+
+		/**	Triggers when a file/folder is added in the monitored folder. Provides absolute path to the file/folder. */
+		Event<void(const Path&)> onAdded;
+
+		/**	Triggers when a file/folder is removed from the monitored folder. Provides absolute path to the file/folder. */
+		Event<void(const Path&)> onRemoved;
+
+		/**	Triggers when a file/folder is renamed in the monitored folder. Provides absolute path with old and new names. */
+		Event<void(const Path&, const Path&)> onRenamed;
+
+	private:
+		/**	Worker method that monitors the IO ports for any modification notifications. */
+		void workerThreadMain();
+
+		/**	Called by the worker thread whenever a modification notification is received. */
+		void handleNotifications(FileNotifyInfo& notifyInfo, FolderWatchInfo& watchInfo);
+
+		Pimpl* mPimpl;
+	};
+
+	/** @} */
 }

+ 28 - 30
Source/BansheeCore/Include/Win32/BsWin32Platform.h

@@ -1,31 +1,29 @@
-//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
-//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
-#pragma once
-
-#include "BsPlatform.h"
-#include "BsWin32Defs.h"
-
-namespace BansheeEngine
-{
-	/** @cond INTERNAL */
-	/** @addtogroup Platform
-	 *  @{
-	 */
-
-	/**
-	 * Contains the main message loop.
-	 *
-	 * @note	
-	 * This is separated from the main Platform because we don't want to include various Windows defines in a lot of our 
-	 * code that includes "Platform.h".
-	 */
-	class BS_CORE_EXPORT Win32Platform : public Platform
-	{
-	public:
-		/** Main message loop callback that processes messages received from windows. */
-		static LRESULT CALLBACK _win32WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
-	};
-
-	/** @} */
-	/** @endcond */
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+#pragma once
+
+#include "BsPlatform.h"
+#include "BsWin32Defs.h"
+
+namespace BansheeEngine
+{
+	/** @addtogroup Platform-Internal
+	 *  @{
+	 */
+
+	/**
+	 * Contains the main message loop.
+	 *
+	 * @note	
+	 * This is separated from the main Platform because we don't want to include various Windows defines in a lot of our 
+	 * code that includes "Platform.h".
+	 */
+	class BS_CORE_EXPORT Win32Platform : public Platform
+	{
+	public:
+		/** Main message loop callback that processes messages received from windows. */
+		static LRESULT CALLBACK _win32WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
+	};
+
+	/** @} */
 }

+ 6 - 0
Source/BansheeUtility/Include/BsIReflectable.h

@@ -55,6 +55,10 @@ namespace BansheeEngine
 		/** Creates an empty instance of a class from a type identifier. */
 		static std::shared_ptr<IReflectable> createInstanceFromTypeId(UINT32 rttiTypeId);
 
+		/** @name Internal
+		 *  @{
+		 */
+
 		/**
 		 * Called by each type deriving from IReflectable, on program load.
 		 *
@@ -86,6 +90,8 @@ namespace BansheeEngine
 		 */
 		static void _checkForCircularReferences();
 
+		/** @} */
+
 	protected:
 		Any mRTTIData; /**< Temporary per-instance data storage used during various RTTI operations.
 					    Needed since there is one RTTI class instance per type and sometimes we need per-instance data. */

+ 3 - 5
Source/BansheeUtility/Include/BsPrerequisitesUtil.h

@@ -69,7 +69,7 @@
 
 /** @cond RTTI */
 /** @defgroup RTTI-Impl-Utility RTTI types
- *  Types containing RTTI for specific classes.
+ *  RTTI implementations for classes within the utility layer.
  */
 /** @endcond */
 
@@ -123,10 +123,8 @@
  *	Implementations of various systems defined in the core layers.
  */
 
-/** @defgroup Implementation Implementation
- *	Contains various base and helper types that used by an implementation of some other type. These shouldn't even be part
- *  of the class list but due to limitations in the documentation generation system they need to be somewhere. All elements 
- *  listed here should instead be found by browsing the public interfaces of the types that use them.
+/** @defgroup Implementation [IMPLEMENTATION]
+ *	Very specialized base classes, templates and helper code used for construction of more concrete types.
  */
 
 // 0 - No thread support