Преглед на файлове

More work on preparing the documentation for Doxygen generation

BearishSun преди 10 години
родител
ревизия
1b9490426d
променени са 44 файла, в които са добавени 4753 реда и са изтрити 5524 реда
  1. 10 0
      BansheeCore/Include/BsCorePrerequisites.h
  2. 37 61
      BansheeCore/Include/BsCoreRenderer.h
  3. 97 105
      BansheeCore/Include/BsGpuResourceData.h
  4. 133 149
      BansheeCore/Include/BsHardwareBufferManager.h
  5. 38 42
      BansheeCore/Include/BsIResourceListener.h
  6. 91 108
      BansheeCore/Include/BsIndexBuffer.h
  7. 358 372
      BansheeCore/Include/BsMesh.h
  8. 187 206
      BansheeCore/Include/BsMeshBase.h
  9. 295 336
      BansheeCore/Include/BsMeshData.h
  10. 58 66
      BansheeCore/Include/BsMeshManager.h
  11. 30 45
      BansheeCore/Include/BsMultiRenderTexture.h
  12. 73 75
      BansheeCore/Include/BsOcclusionQuery.h
  13. 109 94
      BansheeCore/Include/BsParamBlocks.h
  14. 90 102
      BansheeCore/Include/BsPixelBuffer.h
  15. 84 83
      BansheeCore/Include/BsQueryManager.h
  16. 55 81
      BansheeCore/Include/BsRasterizerState.h
  17. 99 142
      BansheeCore/Include/BsRenderAPI.h
  18. 73 192
      BansheeCore/Include/BsRenderAPICapabilities.h
  19. 24 23
      BansheeCore/Include/BsRenderAPIFactory.h
  20. 41 40
      BansheeCore/Include/BsRenderAPIManager.h
  21. 258 335
      BansheeCore/Include/BsRenderStateManager.h
  22. 205 232
      BansheeCore/Include/BsRenderTarget.h
  23. 49 61
      BansheeCore/Include/BsRenderTexture.h
  24. 70 139
      BansheeCore/Include/BsRenderWindow.h
  25. 131 173
      BansheeCore/Include/BsRenderWindowManager.h
  26. 31 30
      BansheeCore/Include/BsRendererFactory.h
  27. 51 50
      BansheeCore/Include/BsRendererManager.h
  28. 229 249
      BansheeCore/Include/BsRendererMeshData.h
  29. 24 16
      BansheeCore/Include/BsRendererUtility.h
  30. 54 75
      BansheeCore/Include/BsSamplerState.h
  31. 28 24
      BansheeCore/Include/BsSubMesh.h
  32. 97 114
      BansheeCore/Include/BsTextureView.h
  33. 63 66
      BansheeCore/Include/BsTimerQuery.h
  34. 82 92
      BansheeCore/Include/BsVertexBuffer.h
  35. 55 68
      BansheeCore/Include/BsVertexData.h
  36. 228 276
      BansheeCore/Include/BsVertexDeclaration.h
  37. 110 130
      BansheeCore/Include/BsVideoModeInfo.h
  38. 220 285
      BansheeCore/Include/BsViewport.h
  39. 1 1
      BansheeCore/Source/BsInput.cpp
  40. 49 48
      BansheeCore/Source/BsRendererManager.cpp
  41. 145 148
      BansheeCore/Source/BsSamplerState.cpp
  42. 589 589
      BansheeD3D9RenderAPI/Source/BsD3D9Mappings.cpp
  43. 1 1
      BansheeGLRenderAPI/Include/BsGLRenderAPI.h
  44. 1 0
      BansheeSL/Source/BsSLFXCompiler.cpp

+ 10 - 0
BansheeCore/Include/BsCorePrerequisites.h

@@ -40,6 +40,14 @@
   *	Functionality for interacting with underlying render API (e.g. DirectX, OpenGL).
   *	Functionality for interacting with underlying render API (e.g. DirectX, OpenGL).
   */
   */
 
 
+/** @defgroup Renderer Renderer
+  *	Abstract interface and helper functionality for rendering scene objects.
+  */
+
+/** @defgroup Resources Resources
+  *	Contains core resource types and resource management functionality (loading, saving, etc.).
+  */
+
 /** @} */
 /** @} */
 
 
 #define BS_MAX_MULTIPLE_RENDER_TARGETS 8
 #define BS_MAX_MULTIPLE_RENDER_TARGETS 8
@@ -223,6 +231,7 @@ namespace BansheeEngine
 	class LightCore;
 	class LightCore;
 	class Light;
 	class Light;
 	class Win32Window;
 	class Win32Window;
+	class RenderAPIFactory;
 	// Asset import
 	// Asset import
 	class SpecificImporter;
 	class SpecificImporter;
 	class Importer;
 	class Importer;
@@ -322,6 +331,7 @@ namespace BansheeEngine
 	typedef std::shared_ptr<Prefab> PrefabPtr;
 	typedef std::shared_ptr<Prefab> PrefabPtr;
 	typedef std::shared_ptr<PrefabDiff> PrefabDiffPtr;
 	typedef std::shared_ptr<PrefabDiff> PrefabDiffPtr;
 	typedef std::shared_ptr<RendererMeshData> RendererMeshDataPtr;
 	typedef std::shared_ptr<RendererMeshData> RendererMeshDataPtr;
+	typedef std::shared_ptr<RenderAPIFactory> RenderAPIFactoryPtr;
 }
 }
 
 
 /************************************************************************/
 /************************************************************************/

+ 37 - 61
BansheeCore/Include/BsCoreRenderer.h

@@ -1,16 +1,19 @@
 #pragma once
 #pragma once
 
 
 #include "BsCorePrerequisites.h"
 #include "BsCorePrerequisites.h"
-#include "BsGameObject.h"
-#include "BsEvent.h"
 #include "BsStringID.h"
 #include "BsStringID.h"
 #include "BsRendererMeshData.h"
 #include "BsRendererMeshData.h"
 
 
 namespace BansheeEngine
 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.
+	 * 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_Static = "Static";
 	static StringID RBS_PerCamera = "PerCamera";
 	static StringID RBS_PerCamera = "PerCamera";
@@ -18,8 +21,7 @@ namespace BansheeEngine
 	static StringID RBS_PerObject = "PerObject";
 	static StringID RBS_PerObject = "PerObject";
 
 
 	/**
 	/**
-	 * Available parameter semantics that allow the renderer to identify
-	 * the use of a GPU parameter specified in a shader.
+	 * 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_WorldViewProjTfrm = "WVP";
 	static StringID RPS_ViewProjTfrm = "VP";
 	static StringID RPS_ViewProjTfrm = "VP";
@@ -33,20 +35,18 @@ namespace BansheeEngine
 	static StringID RPS_Diffuse = "Diffuse";
 	static StringID RPS_Diffuse = "Diffuse";
 	static StringID RPS_ViewDir = "ViewDir";
 	static StringID RPS_ViewDir = "ViewDir";
 
 
-	/**
-	 * @brief	Set of options that can be used for controlling the renderer.
-	 */	
+	/**	Set of options that can be used for controlling the renderer. */	
 	struct BS_CORE_EXPORT CoreRendererOptions
 	struct BS_CORE_EXPORT CoreRendererOptions
 	{
 	{
 		virtual ~CoreRendererOptions() { }
 		virtual ~CoreRendererOptions() { }
 	};
 	};
 
 
 	/**
 	/**
-	 * @brief	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.
+	 * 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.
+	 * @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
 	class BS_CORE_EXPORT CoreRenderer
 	{
 	{
@@ -54,105 +54,78 @@ namespace BansheeEngine
 		CoreRenderer();
 		CoreRenderer();
 		virtual ~CoreRenderer() { }
 		virtual ~CoreRenderer() { }
 
 
-		/**
-		 * @brief	Initializes the renderer. Must be called before using the renderer.
-		 *
-		 * @note	Internal method.
-		 */
+		/** Initializes the renderer. Must be called before using the renderer. */
 		virtual void initialize() { }
 		virtual void initialize() { }
 
 
-		/**
-		 * @brief	Cleans up the renderer. Must be called before the renderer is deleted.
-		 *
-		 * @note	Internal method.
-		 */
+		/**	Cleans up the renderer. Must be called before the renderer is deleted. */
 		virtual void destroy() { }
 		virtual void destroy() { }
 
 
-		/**
-		 * @brief	Name of the renderer. Used by materials to find 
-		 * 			an appropriate technique for this renderer.
-		 */
+		/** Name of the renderer. Used by materials to find an appropriate technique for this renderer. */
 		virtual const StringID& getName() const = 0;
 		virtual const StringID& getName() const = 0;
 
 
-		/**
-		 * @brief	Called in order to render all currently active cameras.
-		 */
+		/** Called in order to render all currently active cameras. */
 		virtual void renderAll() = 0;
 		virtual void renderAll() = 0;
 
 
 		/**
 		/**
-		 * @brief	Called whenever a new camera is created.
+		 * Called whenever a new camera is created.
 		 *
 		 *
 		 * @note	Core thread.
 		 * @note	Core thread.
-		 *			Internal method.
 		 */
 		 */
 		virtual void _notifyCameraAdded(const CameraCore* camera) { }
 		virtual void _notifyCameraAdded(const CameraCore* camera) { }
 
 
 		/**
 		/**
-		 * @brief	Called whenever a camera is destroyed.
+		 * Called whenever a camera is destroyed.
 		 *
 		 *
 		 * @note	Core thread.
 		 * @note	Core thread.
-		 *			Internal method.
 		 */
 		 */
 		virtual void _notifyCameraRemoved(const CameraCore* camera) { }
 		virtual void _notifyCameraRemoved(const CameraCore* camera) { }
 
 
 		/**
 		/**
-		 * @brief	Creates a new empty renderer mesh data.
+		 * Creates a new empty renderer mesh data.
 		 *
 		 *
 		 * @note	Sim thread.
 		 * @note	Sim thread.
-		 *			Internal method.
 		 *			
 		 *			
 		 * @see		RendererMeshData
 		 * @see		RendererMeshData
 		 */
 		 */
 		virtual RendererMeshDataPtr _createMeshData(UINT32 numVertices, UINT32 numIndices, VertexLayout layout, IndexType indexType = IT_32BIT);
 		virtual RendererMeshDataPtr _createMeshData(UINT32 numVertices, UINT32 numIndices, VertexLayout layout, IndexType indexType = IT_32BIT);
 
 
 		/**
 		/**
-		 * @brief	Creates a new renderer mesh data using an existing generic mesh data buffer.
+		 * Creates a new renderer mesh data using an existing generic mesh data buffer.
 		 *
 		 *
 		 * @note	Sim thread.
 		 * @note	Sim thread.
-		 *			Internal method.
 		 *			
 		 *			
 		 * @see		RendererMeshData
 		 * @see		RendererMeshData
 		 */
 		 */
 		virtual RendererMeshDataPtr _createMeshData(const MeshDataPtr& meshData);
 		virtual RendererMeshDataPtr _createMeshData(const MeshDataPtr& meshData);
 
 
 		/**
 		/**
-		 * @brief	Registers a new callback that will be executed when the the specify camera is being rendered.
+		 * Registers a new callback that will be executed when the the specify camera is being rendered.
 		 *
 		 *
-		 * @param	camera			Camera for which to trigger the callback.
-		 * @param	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	callback		Callback to trigger when the specified camera is being rendered.
-		 * @param	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). 
-		 * 							
+		 * @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.
 		 *							Overlay callbacks are always rendered after all other callbacks, even if their index is negative.
 		 *
 		 *
 		 * @note	Core thread.
 		 * @note	Core thread.
-		 *			Internal method.
 		 */
 		 */
 		void _registerRenderCallback(const CameraCore* camera, INT32 index, const std::function<void()>& callback, bool isOverlay = false);
 		void _registerRenderCallback(const CameraCore* camera, INT32 index, const std::function<void()>& callback, bool isOverlay = false);
 
 
-		/**
-		 * @brief	Removes a previously registered callback registered with "_registerRenderCallback".
-		 */
+		/** Removes a previously registered callback registered with _registerRenderCallback(). */
 		void _unregisterRenderCallback(const CameraCore* camera, INT32 index);
 		void _unregisterRenderCallback(const CameraCore* camera, INT32 index);
 
 
-		/**
-		 * @brief	Sets options used for controlling the rendering.
-		 */
+		/**	Sets options used for controlling the rendering. */
 		virtual void setOptions(const SPtr<CoreRendererOptions>& options) { }
 		virtual void setOptions(const SPtr<CoreRendererOptions>& options) { }
 
 
-		/**
-		 * @brief	Returns current set of options used for controlling the rendering.
-		 */
+		/**	Returns current set of options used for controlling the rendering. */
 		virtual SPtr<CoreRendererOptions> getOptions() const { return SPtr<CoreRendererOptions>(); }
 		virtual SPtr<CoreRendererOptions> getOptions() const { return SPtr<CoreRendererOptions>(); }
 
 
 	protected:
 	protected:
-		/**
-		 * @brief	Contains information about a render callback.
-		 */
+		/**	Contains information about a render callback. */
 		struct RenderCallbackData
 		struct RenderCallbackData
 		{
 		{
 			bool overlay;
 			bool overlay;
@@ -161,4 +134,7 @@ namespace BansheeEngine
 
 
 		UnorderedMap<const CameraCore*, Map<INT32, RenderCallbackData>> mRenderCallbacks;
 		UnorderedMap<const CameraCore*, Map<INT32, RenderCallbackData>> mRenderCallbacks;
 	};
 	};
+
+	/** @} */
+	/** @endcond */
 }
 }

+ 97 - 105
BansheeCore/Include/BsGpuResourceData.h

@@ -1,106 +1,98 @@
-#pragma once
-
-#include "BsCorePrerequisites.h"
-
-namespace BansheeEngine
-{
-	/**
-	 * @brief	You can use this class as a storage for reading and writing from/to various GPU resources. 
-	 *			It is meant to be created on sim thread and used on the core thread. This class is abstract
-	 *			and specific resource types need to implement their own type of GpuResourceData.
-	 * 			
-	 * @note	Normal use of this class involves requesting an instance of GpuResourceData from a GpuResource,
-	 *			then scheduling a read or write on that resource using the provided instance.
-	 *			Instance will be locked while it is used by the core thread and sim thread will be allowed to
-	 *			access it when the operation ends. Caller can track AsyncOps regarding the read/write operation
-	 *			to be notified when it is complete.
-	 *
-	 *			If you allocate an internal buffer to store the resource data, the ownership of the buffer
-	 * 			will always remain with the initial instance of the class. If that initial instance
-	 * 			is deleted, any potential copies will point to garbage data.
-	 */
-	class BS_CORE_EXPORT GpuResourceData : public IReflectable
-	{
-	public:
-		GpuResourceData();
-		GpuResourceData(const GpuResourceData& copy);
-		virtual ~GpuResourceData();
-
-		GpuResourceData& operator=(const GpuResourceData& rhs);
-
-		/**
-		 * @brief	Returns pointer to the internal buffer.
-		 */
-		UINT8* getData() const;
-
-		/**
-		 * @brief	Allocates an internal buffer of a certain size. If there is another
-		 * 			buffer already allocated, it will be freed and new one will be allocated.
-		 * 			Buffer size is determined based on parameters used for initializing the class.
-		 */
-		void allocateInternalBuffer();
-
-		/**
-		 * @brief	Allocates an internal buffer of a certain size. If there is another
-		 * 			buffer already allocated, it will be freed and new one will be allocated.
-		 *
-		 * @param	size	The size of the buffer in bytes.
-		 */
-		void allocateInternalBuffer(UINT32 size);
-
-		/**
-		 * @brief	Frees the internal buffer that was allocated using "allocateInternal". Called automatically
-		 * 			when the instance of the class is destroyed.
-		 */
-		void freeInternalBuffer();
-
-		/**
-		 * @brief	Makes the internal data pointer point to some external data. No copying is done, 
-		 * 			so you must ensure that external data exists as long as this class uses it. You are also
-		 * 			responsible for deleting the data when you are done with it.
-		 *
-		 * @note	If any internal data is allocated, it is freed.
-		 */
-		void setExternalBuffer(UINT8* data);
-
-		/**
-		 * @brief	Checks if the internal buffer is locked due to some other thread
-		 *			using it.
-		 */
-		bool isLocked() const { return mLocked; }
-
-		/**
-		 * @brief	Locks the data and makes it available only to the core thread. 
-		 *
-		 * @note	Internal method.
-		 */
-		void _lock() const;
-
-		/**
-		 * @brief	Unlocks the data and makes it available to all threads. 
-		 *
-		 * @note	Internal method.
-		 */
-		void _unlock() const;
-
-	protected:
-		/**
-		 * @brief	Returns the size of the internal buffer in bytes. This is calculated based
-		 *			on parameters provided upon construction and specific implementation details.
-		 */
-		virtual UINT32 getInternalBufferSize() const = 0;
-
-	private:
-		UINT8* mData;
-		bool mOwnsData;
-		mutable bool mLocked;
-
-		/************************************************************************/
-		/* 								SERIALIZATION                      		*/
-		/************************************************************************/
-	public:
-		friend class GpuResourceDataRTTI;
-		static RTTITypeBase* getRTTIStatic();
-		virtual RTTITypeBase* getRTTI() const override;
-	};
+#pragma once
+
+#include "BsCorePrerequisites.h"
+
+namespace BansheeEngine
+{
+	/** @addtogroup Implementation
+	 *  @{
+	 */
+
+	/**
+	 * You can use this class as a storage for reading and writing from/to various GPU resources. It is meant to be created
+	 * on sim thread and used on the core thread. This class is abstract and specific resource types need to implement their
+	 * own type of GpuResourceData.
+	 * 			
+	 * @note	
+	 * Normal use of this class involves requesting an instance of GpuResourceData from a Resource, then scheduling a read
+	 * or write on that resource using the provided instance. Instance will be locked while it is used by the core thread 
+	 * and sim thread will be allowed to access it when the operation ends. Caller can track AsyncOp%s regarding the 
+	 * read/write operation to be notified when it is complete.
+	 * @note
+	 * If you allocate an internal buffer to store the resource data, the ownership of the buffer will always remain with 
+	 * the initial instance of the class. If that initial instance is deleted, any potential copies will point to garbage 
+	 * data.
+	 */
+	class BS_CORE_EXPORT GpuResourceData : public IReflectable
+	{
+	public:
+		GpuResourceData();
+		GpuResourceData(const GpuResourceData& copy);
+		virtual ~GpuResourceData();
+
+		GpuResourceData& operator=(const GpuResourceData& rhs);
+
+		/** Returns pointer to the internal buffer. */
+		UINT8* getData() const;
+
+		/**
+		 * Allocates an internal buffer of a certain size. If there is another buffer already allocated, it will be freed 
+		 * and new one will be allocated. Buffer size is determined based on parameters used for initializing the class.
+		 */
+		void allocateInternalBuffer();
+
+		/**
+		 * Allocates an internal buffer of a certain size. If there is another buffer already allocated, it will be freed
+		 * and new one will be allocated.
+		 *
+		 * @param[in]	size	The size of the buffer in bytes.
+		 */
+		void allocateInternalBuffer(UINT32 size);
+
+		/**
+		 * Frees the internal buffer that was allocated using allocateInternalBuffer(). Called automatically when the 
+		 * instance of the class is destroyed.
+		 */
+		void freeInternalBuffer();
+
+		/**
+		 * Makes the internal data pointer point to some external data. No copying is done, so you must ensure that external
+		 * data exists as long as this class uses it. You are also responsible for deleting the data when you are done 
+		 * with it.
+		 *
+		 * @note	If any internal data is allocated, it is freed.
+		 */
+		void setExternalBuffer(UINT8* data);
+
+		/** Checks if the internal buffer is locked due to some other thread using it. */
+		bool isLocked() const { return mLocked; }
+
+		/** Locks the data and makes it available only to the core thread. */
+		void _lock() const;
+
+		/**	Unlocks the data and makes it available to all threads.  */
+		void _unlock() const;
+
+	protected:
+		/**
+		 * Returns the size of the internal buffer in bytes. This is calculated based on parameters provided upon 
+		 * construction and specific implementation details.
+		 */
+		virtual UINT32 getInternalBufferSize() const = 0;
+
+	private:
+		UINT8* mData;
+		bool mOwnsData;
+		mutable bool mLocked;
+
+		/************************************************************************/
+		/* 								SERIALIZATION                      		*/
+		/************************************************************************/
+	public:
+		friend class GpuResourceDataRTTI;
+		static RTTITypeBase* getRTTIStatic();
+		virtual RTTITypeBase* getRTTI() const override;
+	};
+
+	/** @} */
 }
 }

+ 133 - 149
BansheeCore/Include/BsHardwareBufferManager.h

@@ -1,149 +1,133 @@
-#pragma once
-
-#include "BsCorePrerequisites.h"
-#include "BsModule.h"
-#include "BsVertexBuffer.h"
-#include "BsIndexBuffer.h"
-#include "BsVertexDeclaration.h"
-
-namespace BansheeEngine 
-{
-	/**
-	 * @brief	Handles creation of various hardware buffers.
-	 *
-	 * @note	Sim thread only.
-	 */
-	class BS_CORE_EXPORT HardwareBufferManager : public Module<HardwareBufferManager>
-	{
-    public:
-        HardwareBufferManager();
-        virtual ~HardwareBufferManager();
-
-		/**
-		 * @brief	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	vertexSize	Size of a single vertex in the buffer, in bytes.
-		 * @param	numVerts	Number of vertices the buffer can hold.
-		 * @param	usage		Usage that tells the hardware how will be buffer be used. 
-		 * @param	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);
-
-		/**
-		 * @brief	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	itype		Index type, determines size of an index.
-		 * @param	numIndexes	Number of indexes can buffer can hold.
-		 * @param	usage		Usage that tells the hardware how will be buffer be used. 
-		 */
-		virtual IndexBufferPtr createIndexBuffer(IndexType itype, UINT32 numIndexes, GpuBufferUsage usage);
-
-		/**
-		 * @brief	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	size	Size of the parameter buffer in bytes.
-		 * @param	usage	Usage that tells the hardware how will be buffer be used. 
-		 */
-		virtual GpuParamBlockBufferPtr createGpuParamBlockBuffer(UINT32 size, GpuParamBlockUsage usage = GPBU_DYNAMIC);
-
-		/**
-		 * @brief	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	elementCount  	Number of elements in the buffer. 
-		 * @param	elementSize   	Size of each individual element in the buffer, in bytes.
-		 * @param	type		  	Type of the buffer.
-		 * @param	usage		  	Usage that tells the hardware how will be buffer be used. 
-		 * @param	randomGpuWrite	(optional) Allows the GPU to write to the resource.
-		 * @param	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);
-
-		/**
-		 * @brief	Creates a new vertex declaration from a list of vertex elements.
-		 */
-		virtual VertexDeclarationPtr createVertexDeclaration(const List<VertexElement>& elements);
-	};
-
-	/**
-	 * @brief	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);
-	};
-}
-
+#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 */
+}
+

+ 38 - 42
BansheeCore/Include/BsIResourceListener.h

@@ -1,43 +1,39 @@
-#pragma once
-
-#include "BsCorePrerequisites.h"
-
-namespace BansheeEngine
-{
-	/**
-	 * @brief	Interface that allows the implementing class to be notified
-	 *			when the resources it is referencing change.
-	 */
-	class BS_CORE_EXPORT IResourceListener
-	{
-	public:
-		IResourceListener();
-		virtual ~IResourceListener();
-
-	protected:
-		friend class ResourceListenerManager;
-
-		/**
-		 * @brief	Retrieves all the resources that the class depends on.
-		 *
-		 * @note	You must add the resources to the provided "resources" array.
-		 */
-		virtual void getListenerResources(Vector<HResource>& resources) = 0;
-
-		/**
-		 * @brief	Marks the resource dependencies list as dirty and schedules it for rebuild.
-		 */
-		virtual void markListenerResourcesDirty();
-
-		/**
-		 * @brief	Called when a resource has been fully loaded.
-		 */
-		virtual void notifyResourceLoaded(const HResource& resource) { }
-
-		/**
-		 * @brief	Called when the internal resource the resource handle 
-		 *			is pointing to changes.
-		 */
-		virtual void notifyResourceChanged(const HResource& resource) { }
-	};
+#pragma once
+
+#include "BsCorePrerequisites.h"
+
+namespace BansheeEngine
+{
+	/** @addtogroup Implementation
+	 *  @{
+	 */
+
+	/** Interface that allows the implementing class to be notified when the resources it is referencing change. */
+	class BS_CORE_EXPORT IResourceListener
+	{
+	public:
+		IResourceListener();
+		virtual ~IResourceListener();
+
+	protected:
+		friend class ResourceListenerManager;
+
+		/**
+		 * Retrieves all the resources that the class depends on.
+		 *
+		 * @note	Derived implementations must add the resources to the provided @p resources array.
+		 */
+		virtual void getListenerResources(Vector<HResource>& resources) = 0;
+
+		/**	Marks the resource dependencies list as dirty and schedules it for rebuild. */
+		virtual void markListenerResourcesDirty();
+
+		/**	Called when a resource has been fully loaded. */
+		virtual void notifyResourceLoaded(const HResource& resource) { }
+
+		/**	Called when the internal resource the resource handle is pointing to changes. */
+		virtual void notifyResourceChanged(const HResource& resource) { }
+	};
+
+	/** @} */
 }
 }

+ 91 - 108
BansheeCore/Include/BsIndexBuffer.h

@@ -1,109 +1,92 @@
-#pragma once
-
-#include "BsCorePrerequisites.h"
-#include "BsHardwareBuffer.h"
-#include "BsCoreObject.h"
-
-namespace BansheeEngine 
-{
-	/**
-	 * @brief	Type of the indices used, used for determining size.
-	 */
-	enum IndexType 
-	{
-		IT_16BIT,
-		IT_32BIT
-	};
-
-	/**
-	 * @brief	Contains information about an index buffer.
-	 */
-	class BS_CORE_EXPORT IndexBufferProperties
-	{
-	public:
-		IndexBufferProperties(IndexType idxType, UINT32 numIndexes);
-
-		/**
-		 * @brief	Returns the type of indices stored.
-		 */
-		IndexType getType() const { return mIndexType; }
-
-		/**
-		 * @brief	Returns the number of indices this buffer can hold.
-		 */
-		UINT32 getNumIndices() const { return mNumIndexes; }
-
-		/**
-		 * @brief	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;
-	};
-
-	/**
-	 * @brief	Core thread specific implementation of an index buffer.
-	 *
-	 * @see		IndexBuffer
-	 */
-	class BS_CORE_EXPORT IndexBufferCore : public CoreObjectCore, public HardwareBuffer
-	{
-	public:
-		IndexBufferCore(IndexType idxType, UINT32 numIndexes, GpuBufferUsage usage);
-		virtual ~IndexBufferCore() { }
-
-		/**
-		 * @brief	Returns information about the index buffer.
-		 */
-		const IndexBufferProperties& getProperties() const { return mProperties; }
-
-	protected:
-		IndexBufferProperties mProperties;
-	};
-
-	/**
-	 * @brief	Hardware buffer that hold indices that reference vertices in a vertex buffer.
-	 */
-    class BS_CORE_EXPORT IndexBuffer : public CoreObject
-    {
-	public:
-		virtual ~IndexBuffer() { }
-
-		/**
-		 * @brief	Returns information about the index buffer.
-		 */
-		const IndexBufferProperties& getProperties() const { return mProperties; }
-
-		/**
-		 * @brief	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;
-    };
+#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;
+    };
 }
 }

+ 358 - 372
BansheeCore/Include/BsMesh.h

@@ -1,373 +1,359 @@
-#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
-{
-	/**
-	 * @brief	Core thread portion of a Mesh.
-	 *
-	 * @see		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();
-
-		/**
-		 * @brief	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;
-
-		/**
-		 * @brief	Updates a part of the current mesh with the provided data.
-		 *
-		 * @param	subresourceIdx		Index of the subresource to update, if the mesh has more than one.
-		 * @param	data				Data to update the mesh with.
-		 * @param	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	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);
-
-		/**
-		 * @brief	Reads a part of the current resource into the provided "data" parameter.
-		 * 			Data buffer needs to be pre-allocated.
-		 *
-		 * @param	subresourceIdx		Index of the subresource to update, if the mesh has more than one.
-		 * @param	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);
-
-		/**
-		 * @brief	Creates a new empty mesh. Created mesh will have no sub-meshes.
-		 *
-		 * @param	numVertices		Number of vertices in the mesh.
-		 * @param	numIndices		Number of indices in the mesh. 
-		 * @param	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	usage			Optimizes performance depending on planned usage of the mesh.
-		 * @param	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	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);
-
-		/**
-		 * @brief	Creates a new empty mesh. Created mesh will have specified sub-meshes you may render independently.
-		 *
-		 * @param	numVertices		Number of vertices in the mesh.
-		 * @param	numIndices		Number of indices in the mesh. 
-		 * @param	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	subMeshes		Defines how are indices separated into sub-meshes, and how are those sub-meshes rendered.
-		 *							Sub-meshes may be rendered independently.
-		 * @param	usage			Optimizes performance depending on planned usage of the mesh.
-		 * @param	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);
-
-		/**
-		 * @brief	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	initialMeshData	Vertex and index data to initialize the mesh with.
-		 * @param	usage			Optimizes performance depending on planned usage of the mesh.
-		 * @param	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);
-
-		/**
-		 * @brief	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	initialMeshData	Vertex and index data used for initializing the mesh. 
-		 * @param	subMeshes		Defines how are indices separated into sub-meshes, and how are those sub-meshes rendered.
-		 *							Sub-meshes may be rendered independently.
-		 * @param	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;
-
-		/**
-		 * @brief	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;
-	};
-
-	/**
-	 * @brief	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;
-
-		/**
-		 * @brief	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	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);
-
-		/**
-		 * @brief	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	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);
-
-		/**
-		 * @brief	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	subresourceIdx	Only 0 is supported. You can only update entire mesh at once.
-		 *
-		 * @note	Thread safe.
-		 */
-		MeshDataPtr allocateSubresourceBuffer(UINT32 subresourceIdx) const;
-
-		/**
-		 * @brief	Reads data from the cached system memory mesh buffer into the provided buffer. 
-		 * 		  
-		 * @param	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.
-		 *
-		 *			The mesh must have been created with MU_CPUCACHED usage otherwise this method
-		 *			will not return any data.
-		 */
-		void readData(MeshData& dest);
-
-		/**
-		 * @brief	Retrieves a core implementation of a mesh usable only from the
-		 *			core thread.
-		 */
-		SPtr<MeshCore> getCore() const;
-
-		/**
-		 * @brief	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);
-
-		/**
-		 * @brief	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;
-
-		/**
-		 * @brief	Creates buffers used for caching of CPU mesh data.
-		 *
-		 * @note	Make sure to initialize all mesh properties before calling this.
-		 */
-		void createCPUBuffer();
-
-		/**
-		 * @brief	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:
-		/**
-		 * @brief	Creates a new empty mesh. Created mesh will have no sub-meshes.
-		 *
-		 * @param	numVertices		Number of vertices in the mesh.
-		 * @param	numIndices		Number of indices in the mesh. 
-		 * @param	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	usage			Optimizes performance depending on planned usage of the mesh.
-		 * @param	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	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);
-
-		/**
-		 * @brief	Creates a new empty mesh. Created mesh will have specified sub-meshes you may render independently.
-		 *
-		 * @param	numVertices		Number of vertices in the mesh.
-		 * @param	numIndices		Number of indices in the mesh. 
-		 * @param	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	subMeshes		Defines how are indices separated into sub-meshes, and how are those sub-meshes rendered.
-		 *							Sub-meshes may be rendered independently.
-		 * @param	usage			Optimizes performance depending on planned usage of the mesh.
-		 * @param	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);
-
-		/**
-		 * @brief	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	initialMeshData	Vertex and index data to initialize the mesh with.
-		 * @param	usage			Optimizes performance depending on planned usage of the mesh.
-		 * @param	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);
-
-		/**
-		 * @brief	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	initialMeshData	Vertex and index data used for initializing the mesh. 
-		 * @param	subMeshes		Defines how are indices separated into sub-meshes, and how are those sub-meshes rendered.
-		 *							Sub-meshes may be rendered independently.
-		 * @param	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);
-	};
+#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 Renderer
+	 *  @{
+	 */
+
+	/** @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[in]	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);
+	};
+
+	/** @} */
 }
 }

+ 187 - 206
BansheeCore/Include/BsMeshBase.h

@@ -1,207 +1,188 @@
-#pragma once
-
-#include "BsCorePrerequisites.h"
-#include "BsResource.h"
-#include "BsBounds.h"
-#include "BsDrawOps.h"
-#include "BsSubMesh.h"
-
-namespace BansheeEngine
-{
-	/**
-	 * @brief	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. */
-	};
-
-	/**
-	 * @brief	Contains various properties describing 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);
-
-		/**
-		 * @brief	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;
-
-		/**
-		 * @brief	Retrieves a total number of sub-meshes in this mesh.
-		 */
-		UINT32 getNumSubMeshes() const;
-
-		/**
-		 * @brief	Returns maximum number of vertices the mesh may store.
-		 */
-		UINT32 getNumVertices() const { return mNumVertices; }
-
-		/**
-		 * @brief	Returns maximum number of indices the mesh may store.
-		 */
-		UINT32 getNumIndices() const { return mNumIndices; }
-
-		/**
-		 * @brief	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;
-	};
-
-	/**
-	 * @brief	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() { }
-
-		/**
-		 * @brief	Get vertex data used for rendering.
-		 */
-		virtual SPtr<VertexData> getVertexData() const = 0;
-
-		/**
-		 * @brief	Get index data used for rendering.
-		 */
-		virtual SPtr<IndexBufferCore> getIndexBuffer() const = 0;
-
-		/**
-		 * @brief	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; }
-
-		/**
-		 * @brief	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; }
-
-		/**
-		 * @brief	Returns a structure that describes how are the vertices stored in the mesh's vertex buffer.
-		 */
-		virtual SPtr<VertexDataDesc> getVertexDesc() const = 0;
-
-		/**
-		 * @brief	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.
-		 * 			
-		 *			Internal method.
-		 */
-		virtual void _notifyUsedOnGPU() { }
-
-		/**
-		 * @brief	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;
-	};
-
-	/**
-	 * @brief	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:
-		/**
-		 * @brief	Constructs a new mesh with no sub-meshes.
-		 *
-		 * @param	numVertices		Number of vertices in the mesh.
-		 * @param	numIndices		Number of indices in the mesh. 
-		 * @param	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);
-
-		/**
-		 * @brief	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	numVertices		Number of vertices in the mesh.
-		 * @param	numIndices		Number of indices in the mesh.
-		 * @param	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();
-
-		/**
-		 * @brief	Returns properties that contain information about the mesh.
-		 */
-		const MeshProperties& getProperties() const { return mProperties; }
-
-		/**
-		 * @brief	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;
-	};
+#pragma once
+
+#include "BsCorePrerequisites.h"
+#include "BsResource.h"
+#include "BsBounds.h"
+#include "BsDrawOps.h"
+#include "BsSubMesh.h"
+
+namespace BansheeEngine
+{
+	/** @addtogroup Renderer
+	 *  @{
+	 */
+
+	/**
+	 * 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. */
+	};
+
+	/** Contains various properties describing 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;
+	};
+
+	/** @} */
 }
 }

+ 295 - 336
BansheeCore/Include/BsMeshData.h

@@ -1,337 +1,296 @@
-#pragma once
-
-#include "BsCorePrerequisites.h"
-#include "BsGpuResourceData.h"
-#include "BsVertexBuffer.h"
-#include "BsIndexBuffer.h"
-#include "BsVertexDeclaration.h"
-#include "BsDrawOps.h"
-#include "BsSubMesh.h"
-#include "BsBounds.h"
-
-namespace BansheeEngine
-{
-	/**
-	 * @brief	Iterator that allows you to easily populate or read vertex elements
-	 *			in MeshData.
-	 */
-	template<class T>
-	class VertexElemIter
-	{
-	public:
-		VertexElemIter()
-			:mData(nullptr), mEnd(nullptr), mByteStride(0), mNumElements(0)
-		{
-
-		}
-
-		VertexElemIter(UINT8* data, UINT32 byteStride, UINT32 numElements)
-			:mData(data), mByteStride(byteStride), mNumElements(numElements)
-		{
-			mEnd = mData + byteStride * numElements;
-		}
-
-		/**
-		 * @brief	Adds a new value to the iterators current position and
-		 *			advances the iterator.
-		 */
-		void addValue(const T& value)
-		{
-			setValue(value);
-			moveNext();
-		}
-
-		/**
-		 * @brief	Sets a new value at the iterators current position.
-		 */
-		void setValue(const T& value)
-		{
-			memcpy(mData, &value, sizeof(T));
-		}
-
-		/**
-		 * @brief	Returns the value at the iterators current position.
-		 */
-		T& getValue()
-		{
-			return *((T*)mData);
-		}
-
-		/**
-		 * @brief	Moves the iterator to the next position. Returns true
-		 *			if there are more elements.
-		 */
-		bool moveNext()
-		{
-#ifdef BS_DEBUG_MODE
-			if(mData >= mEnd)
-			{
-				BS_EXCEPT(InternalErrorException, "Vertex element iterator out of buffer bounds.");
-			}
-#endif
-
-			mData += mByteStride;
-
-			return mData < mEnd;
-		}
-
-		/**
-		 * @brief	Returns the number of elements this iterator can iterate over.
-		 */
-		UINT32 getNumElements() const { return mNumElements; }
-
-	private:
-		UINT8* mData;
-		UINT8* mEnd;
-		UINT32 mByteStride;
-		UINT32 mNumElements;
-	};
-
-	/**
-	 * @brief	Contains per-vertex bone weights and indexes used 
-	 *			for skinning, for up to four bones.
-	 */
-	struct BoneWeight
-	{
-		int index0;
-		int index1;
-		int index2;
-		int index3;
-
-		float weight0;
-		float weight1;
-		float weight2;
-		float weight3;
-	};
-
-	/**
-	 * @brief	Contains mesh vertex and index data used for initializing, updating and reading mesh data from Mesh.
-	 */
-	class BS_CORE_EXPORT MeshData : public GpuResourceData
-	{
-	public:
-		/**
-		 * @brief	Constructs a new object that can hold number of vertices described by the provided vertex data description. As well
-		 *			as a number of indices of the provided type.
-		 */
-		MeshData(UINT32 numVertices, UINT32 numIndexes, const VertexDataDescPtr& vertexData, IndexType indexType = IT_32BIT);
-		~MeshData();
-
-		/**
-		 * @brief	Copies data from "data" parameter into the internal buffer for the specified semantic.
-		 *
-		 * @param	semantic   		Semantic that allows the engine to connect the data to a shader input slot.
-		 * @param	data			Vertex data, containing at least "size" bytes.
-		 * @param	size			The size of the data. Must be the size of the vertex element type * number of vertices.
-		 * @param	semanticIdx 	(optional) If there are multiple semantics with the same name, use different index to differentiate between them.
-		 * @param	streamIdx   	(optional) Zero-based index of the stream. Each stream will internally be represented as a single vertex buffer.
-		 */
-		void setVertexData(VertexElementSemantic semantic, UINT8* data, UINT32 size, UINT32 semanticIdx = 0, UINT32 streamIdx = 0);
-
-		/**
-		 * @brief	Copies data from the internal buffer to the pre-allocated buffer for the specified semantic.
-		 *
-		 * @param	semantic   		Semantic that allows the engine to connect the data to a shader input slot.
-		 * @param	data			Buffer that will receive vertex data, of at least "size" bytes.
-		 * @param	size			The size of the data. Must be the size of the vertex element type * number of vertices.
-		 * @param	semanticIdx 	(optional) If there are multiple semantics with the same name, use different index to differentiate between them.
-		 * @param	streamIdx   	(optional) Zero-based index of the stream. Each stream will internally be represented as a single vertex buffer.
-		 */
-		void getVertexData(VertexElementSemantic semantic, UINT8* data, UINT32 size, UINT32 semanticIdx = 0, UINT32 streamIdx = 0);
-
-		/**
-		 * @brief	Returns an iterator you can use for easily retrieving or setting Vector2 vertex elements. This is the preferred
-		 * 			method of assigning or reading vertex data. 
-		 * 			
-		 * @note	If vertex data of this type/semantic/index/stream doesn't exist and exception will be thrown.
-		 */
-		VertexElemIter<Vector2> getVec2DataIter(VertexElementSemantic semantic, UINT32 semanticIdx = 0, UINT32 streamIdx = 0);
-
-		/**
-		 * @brief	Returns an iterator you can use for easily retrieving or setting Vector3 vertex elements. This is the preferred
-		 * 			method of assigning or reading vertex data. 
-		 * 			
-		 * @note	If vertex data of this type/semantic/index/stream doesn't exist and exception will be thrown.
-		 */
-		VertexElemIter<Vector3> getVec3DataIter(VertexElementSemantic semantic, UINT32 semanticIdx = 0, UINT32 streamIdx = 0);
-
-		/**
-		 * @brief	Returns an iterator you can use for easily retrieving or setting Vector4 vertex elements. This is the preferred
-		 * 			method of assigning or reading vertex data. 
-		 * 			
-		 * @note	If vertex data of this type/semantic/index/stream doesn't exist and exception will be thrown.
-		 */
-		VertexElemIter<Vector4> getVec4DataIter(VertexElementSemantic semantic, UINT32 semanticIdx = 0, UINT32 streamIdx = 0);
-
-		/**
-		 * @brief	Returns an iterator you can use for easily retrieving or setting DWORD vertex elements. This is the preferred
-		 * 			method of assigning or reading vertex data. 
-		 * 			
-		 * @note	If vertex data of this type/semantic/index/stream doesn't exist and exception will be thrown.
-		 */
-		VertexElemIter<UINT32> getDWORDDataIter(VertexElementSemantic semantic, UINT32 semanticIdx = 0, UINT32 streamIdx = 0);
-
-		/**
-		 * @brief	Returns the total number of vertices this object can hold.
-		 */
-		UINT32 getNumVertices() const { return mNumVertices; }
-
-		/**
-		 * @brief	Returns the total number of indices this object can hold.
-		 */
-		UINT32 getNumIndices() const;
-
-		/**
-		 * @brief	Returns a 16-bit pointer to the start of the internal index buffer.
-		 */
-		UINT16* getIndices16() const;
-
-		/**
-		 * @brief	Returns a 32-bit pointer to the start of the internal index buffer.
-		 */
-		UINT32* getIndices32() const;
-
-		/**
-		 * @brief	Returns the size of an index element in bytes.
-		 */
-		UINT32 getIndexElementSize() const;
-
-		/**
-		 * @brief	Returns the type of an index element.
-		 */
-		IndexType getIndexType() const { return mIndexType; }
-
-		/**
-		 * @brief	Returns the pointer to the first element of the specified type. If you want to
-		 * 			iterate over all elements you need to call getVertexStride() to get the number
-		 * 			of bytes you need to advance between each element.
-		 *
-		 * @param	semantic   		Semantic that allows the engine to connect the data to a shader input slot.
-		 * @param	semanticIdx 	(optional) If there are multiple semantics with the same name, use different index to differentiate between them.
-		 * @param	streamIdx   	(optional) Zero-based index of the stream. Each stream will internally be represented as a single vertex buffer.
-		 *
-		 * @return	null if it fails, else the element data.
-		 */
-		UINT8* getElementData(VertexElementSemantic semantic, UINT32 semanticIdx = 0, UINT32 streamIdx = 0) const;
-
-		/**
-		 * @brief	Returns an offset into the internal buffer where this element with the provided semantic starts. 
-		 *			Offset is provided in number of bytes.
-		 * 
-		 * @param	semantic   		Semantic that allows the engine to connect the data to a shader input slot.
-		 * @param	semanticIdx 	(optional) If there are multiple semantics with the same name, use different index to differentiate between them.
-		 * @param	streamIdx   	(optional) Zero-based index of the stream. Each stream will internally be represented as a single vertex buffer.
-		 */
-		UINT32 getElementOffset(VertexElementSemantic semantic, UINT32 semanticIdx = 0, UINT32 streamIdx = 0) const;
-
-		/**
-		 * @brief	Returns an object that describes data contained in a single vertex.
-		 */
-		const VertexDataDescPtr& getVertexDesc() const { return mVertexData; }
-
-		/**
-		 * @brief	Return the size (in bytes) of the entire buffer.
-		 */
-		UINT32 getSize() const { return getInternalBufferSize(); }
-
-		/**
-		 * @brief	Calculates the bounds of all vertices stored in the internal buffer.
-		 */
-		Bounds calculateBounds() const;
-
-		/**
-		 * @brief	Combines a number of submeshes and their mesh data into one large mesh data buffer.
-		 *
-		 * @param	elements	Data containing vertices and indices referenced by the submeshes. Number of elements
-		 *						must be the same as number of submeshes.
-		 * @param	subMeshes	Submeshes representing vertex and index range to take from mesh data and combine. Number of
-		 *						submeshes must match the number of provided MeshData elements.
-		 * @param	[out] subMeshes		Outputs all combined sub-meshes with their new index and vertex offsets referencing
-		 *								the newly created MeshData.
-		 *
-		 * @returns	Combined mesh data containing all vertices and indexes references by the provided sub-meshes.
-		 */
-		static MeshDataPtr combine(const Vector<MeshDataPtr>& elements, const Vector<Vector<SubMesh>>& allSubMeshes,
-			Vector<SubMesh>& subMeshes);
-
-	protected:
-		/**
-		 * @brief	Returns the size of the internal buffer in bytes.
-		 */
-		UINT32 getInternalBufferSize() const override;
-
-	private:
-		/**
-		 * @brief	Returns a pointer to the start of the index buffer.
-		 */
-		UINT8* getIndexData() const { return getData(); }
-
-		/**
-		 * @brief	Returns a pointer to the start of the specified vertex stream.
-		 */
-		UINT8* getStreamData(UINT32 streamIdx) const;
-
-		/**
-		 * @brief	Returns an offset in bytes to the start of the index buffer from the start of the
-		 *			internal buffer.
-		 */
-		UINT32 getIndexBufferOffset() const;
-
-		/**
-		 * @brief	Returns an offset in bytes to the start of the stream from the start of the
-		 *			internal buffer.
-		 */
-		UINT32 getStreamOffset(UINT32 streamIdx = 0) const;
-
-		/**
-		 * @brief	Returns the size of the index buffer in bytes.
-		 */
-		UINT32 getIndexBufferSize() const;
-
-		/**
-		 * @brief	Returns the size of the specified stream in bytes.
-		 */
-		UINT32 getStreamSize(UINT32 streamIdx) const;
-
-		/**
-		 * @brief	Returns the size of all the streams in bytes.
-		 */
-		UINT32 getStreamSize() const;
-
-		/**
-		 * @brief	Returns the data needed for iterating over the requested vertex element.
-		 *
-		 * @param	semantic   		Semantic of the element we are looking for.
-		 * @param	semanticIdx 	If there are multiple semantics with the same name, use different index to differentiate between them.
-		 * @param	streamIdx   	Zero-based index of the stream the element resides in.
-		 * @param [out] data		Pointer to the start of this elements data.
-		 * @param [out] stride		Number of bytes between vertex elements of this type.
-		 */
-		void getDataForIterator(VertexElementSemantic semantic, UINT32 semanticIdx, UINT32 streamIdx, UINT8*& data, UINT32& stride) const;
-
-	private:
-		friend class Mesh;
-		friend class MeshCore;
-		friend class MeshHeap;
-		friend class MeshHeapCore;
-
-		UINT32 mDescBuilding;
-
-		UINT32 mNumVertices;
-		UINT32 mNumIndices;
-		IndexType mIndexType;
-
-		VertexDataDescPtr mVertexData;
-
-		/************************************************************************/
-		/* 								SERIALIZATION                      		*/
-		/************************************************************************/
-	private:
-		MeshData(); // Serialization only
-
-	public:
-		friend class MeshDataRTTI;
-		static RTTITypeBase* getRTTIStatic();
-		virtual RTTITypeBase* getRTTI() const override;
-	};
+#pragma once
+
+#include "BsCorePrerequisites.h"
+#include "BsGpuResourceData.h"
+#include "BsVertexBuffer.h"
+#include "BsIndexBuffer.h"
+#include "BsVertexDeclaration.h"
+#include "BsDrawOps.h"
+#include "BsSubMesh.h"
+#include "BsBounds.h"
+
+namespace BansheeEngine
+{
+	/** @addtogroup Renderer
+	 *  @{
+	 */
+
+	/** Iterator that allows you to easily populate or read vertex elements in MeshData. */
+	template<class T>
+	class VertexElemIter
+	{
+	public:
+		VertexElemIter()
+			:mData(nullptr), mEnd(nullptr), mByteStride(0), mNumElements(0)
+		{
+
+		}
+
+		VertexElemIter(UINT8* data, UINT32 byteStride, UINT32 numElements)
+			:mData(data), mByteStride(byteStride), mNumElements(numElements)
+		{
+			mEnd = mData + byteStride * numElements;
+		}
+
+		/**	Adds a new value to the iterators current position and advances the iterator. */
+		void addValue(const T& value)
+		{
+			setValue(value);
+			moveNext();
+		}
+
+		/**	Sets a new value at the iterators current position. */
+		void setValue(const T& value)
+		{
+			memcpy(mData, &value, sizeof(T));
+		}
+
+		/**	Returns the value at the iterators current position. */
+		T& getValue()
+		{
+			return *((T*)mData);
+		}
+
+		/**	Moves the iterator to the next position. Returns true if there are more elements. */
+		bool moveNext()
+		{
+#ifdef BS_DEBUG_MODE
+			if(mData >= mEnd)
+			{
+				BS_EXCEPT(InternalErrorException, "Vertex element iterator out of buffer bounds.");
+			}
+#endif
+
+			mData += mByteStride;
+
+			return mData < mEnd;
+		}
+
+		/**	Returns the number of elements this iterator can iterate over. */
+		UINT32 getNumElements() const { return mNumElements; }
+
+	private:
+		UINT8* mData;
+		UINT8* mEnd;
+		UINT32 mByteStride;
+		UINT32 mNumElements;
+	};
+
+	/** Contains per-vertex bone weights and indexes used for skinning, for up to four bones. */
+	struct BoneWeight
+	{
+		int index0;
+		int index1;
+		int index2;
+		int index3;
+
+		float weight0;
+		float weight1;
+		float weight2;
+		float weight3;
+	};
+
+	/** Contains mesh vertex and index data used for initializing, updating and reading mesh data from Mesh. */
+	class BS_CORE_EXPORT MeshData : public GpuResourceData
+	{
+	public:
+		/**
+		 * Constructs a new object that can hold number of vertices described by the provided vertex data description. As 
+		 * well as a number of indices of the provided type.
+		 */
+		MeshData(UINT32 numVertices, UINT32 numIndexes, const VertexDataDescPtr& vertexData, IndexType indexType = IT_32BIT);
+		~MeshData();
+
+		/**
+		 * Copies data from @p data parameter into the internal buffer for the specified semantic.
+		 *
+		 * @param[in]	semantic   		Semantic that allows the engine to connect the data to a shader input slot.
+		 * @param[in]	data			Vertex data, containing at least @p size bytes.
+		 * @param[in]	size			The size of the data. Must be the size of the vertex element type * number of 
+		 *								vertices.
+		 * @param[in]	semanticIdx 	(optional) If there are multiple semantics with the same name, use different index
+		 *								to differentiate between them.
+		 * @param[in]	streamIdx   	(optional) Zero-based index of the stream. Each stream will internally be 
+		 *								represented as a single vertex buffer.
+		 */
+		void setVertexData(VertexElementSemantic semantic, UINT8* data, UINT32 size, UINT32 semanticIdx = 0, UINT32 streamIdx = 0);
+
+		/**
+		 * Copies data from the internal buffer to the pre-allocated buffer for the specified semantic.
+		 *
+		 * @param[in]	semantic   		Semantic that allows the engine to connect the data to a shader input slot.
+		 * @param[in]	data			Buffer that will receive vertex data, of at least @p size bytes.
+		 * @param[in]	size			The size of the data. Must be the size of the vertex element type * number of 
+		 *								vertices.
+		 * @param[in]	semanticIdx 	(optional) If there are multiple semantics with the same name, use different index
+		 *								to differentiate between them.
+		 * @param[in]	streamIdx   	(optional) Zero-based index of the stream. Each stream will internally be 
+		 *								represented as a single vertex buffer.
+		 */
+		void getVertexData(VertexElementSemantic semantic, UINT8* data, UINT32 size, UINT32 semanticIdx = 0, UINT32 streamIdx = 0);
+
+		/**
+		 * Returns an iterator you can use for easily retrieving or setting Vector2 vertex elements. This is the preferred
+		 * method of assigning or reading vertex data. 
+		 * 			
+		 * @note	If vertex data of this type/semantic/index/stream doesn't exist and exception will be thrown.
+		 */
+		VertexElemIter<Vector2> getVec2DataIter(VertexElementSemantic semantic, UINT32 semanticIdx = 0, UINT32 streamIdx = 0);
+
+		/**
+		 * Returns an iterator you can use for easily retrieving or setting Vector3 vertex elements. This is the preferred
+		 * method of assigning or reading vertex data. 
+		 * 			
+		 * @note	If vertex data of this type/semantic/index/stream doesn't exist and exception will be thrown.
+		 */
+		VertexElemIter<Vector3> getVec3DataIter(VertexElementSemantic semantic, UINT32 semanticIdx = 0, UINT32 streamIdx = 0);
+
+		/**
+		 * Returns an iterator you can use for easily retrieving or setting Vector4 vertex elements. This is the preferred
+		 * method of assigning or reading vertex data. 
+		 * 			
+		 * @note	If vertex data of this type/semantic/index/stream doesn't exist and exception will be thrown.
+		 */
+		VertexElemIter<Vector4> getVec4DataIter(VertexElementSemantic semantic, UINT32 semanticIdx = 0, UINT32 streamIdx = 0);
+
+		/**
+		 * Returns an iterator you can use for easily retrieving or setting DWORD vertex elements. This is the preferred
+		 * method of assigning or reading vertex data. 
+		 * 			
+		 * @note	If vertex data of this type/semantic/index/stream doesn't exist and exception will be thrown.
+		 */
+		VertexElemIter<UINT32> getDWORDDataIter(VertexElementSemantic semantic, UINT32 semanticIdx = 0, UINT32 streamIdx = 0);
+
+		/** Returns the total number of vertices this object can hold. */
+		UINT32 getNumVertices() const { return mNumVertices; }
+
+		/** Returns the total number of indices this object can hold. */
+		UINT32 getNumIndices() const;
+
+		/**	Returns a 16-bit pointer to the start of the internal index buffer. */
+		UINT16* getIndices16() const;
+
+		/**	Returns a 32-bit pointer to the start of the internal index buffer. */
+		UINT32* getIndices32() const;
+
+		/**	Returns the size of an index element in bytes. */
+		UINT32 getIndexElementSize() const;
+
+		/**	Returns the type of an index element. */
+		IndexType getIndexType() const { return mIndexType; }
+
+		/**
+		 * Returns the pointer to the first element of the specified type. If you want to iterate over all elements you 
+		 * need to call getVertexStride() to get the number	of bytes you need to advance between each element.
+		 *
+		 * @param[in]	semantic   		Semantic that allows the engine to connect the data to a shader input slot.
+		 * @param[in]	semanticIdx 	(optional) If there are multiple semantics with the same name, use different index 
+		 *								to differentiate between them.
+		 * @param[in]	streamIdx   	(optional) Zero-based index of the stream. Each stream will internally be 
+		 *								represented as a single vertex buffer.
+		 * @return						null if it fails, else the element data.
+		 */
+		UINT8* getElementData(VertexElementSemantic semantic, UINT32 semanticIdx = 0, UINT32 streamIdx = 0) const;
+
+		/**
+		 * Returns an offset into the internal buffer where this element with the provided semantic starts. Offset is 
+		 * provided in number of bytes.
+		 * 
+		 * @param[in]	semantic   		Semantic that allows the engine to connect the data to a shader input slot.
+		 * @param[in]	semanticIdx 	(optional) If there are multiple semantics with the same name, use different index 
+		 *								to differentiate between them.
+		 * @param[in]	streamIdx   	(optional) Zero-based index of the stream. Each stream will internally be 
+		 *								represented as a single vertex buffer.
+		 */
+		UINT32 getElementOffset(VertexElementSemantic semantic, UINT32 semanticIdx = 0, UINT32 streamIdx = 0) const;
+
+		/** Returns an object that describes data contained in a single vertex. */
+		const VertexDataDescPtr& getVertexDesc() const { return mVertexData; }
+
+		/**	Return the size (in bytes) of the entire buffer. */
+		UINT32 getSize() const { return getInternalBufferSize(); }
+
+		/**	Calculates the bounds of all vertices stored in the internal buffer. */
+		Bounds calculateBounds() const;
+
+		/**
+		 * Combines a number of submeshes and their mesh data into one large mesh data buffer.
+		 *
+		 * @param[in]	elements	Data containing vertices and indices referenced by the submeshes. Number of elements
+		 *							must be the same as number of submeshes.
+		 * @param[in]	subMeshes	Submeshes representing vertex and index range to take from mesh data and combine. 
+		 *							Number of submeshes must match the number of provided MeshData elements.
+		 * @param[out]	subMeshes	Outputs all combined sub-meshes with their new index and vertex offsets referencing
+		 *							the newly created MeshData.
+		 * @return					Combined mesh data containing all vertices and indexes references by the provided 
+		 *							sub-meshes.
+		 */
+		static MeshDataPtr combine(const Vector<MeshDataPtr>& elements, const Vector<Vector<SubMesh>>& allSubMeshes,
+			Vector<SubMesh>& subMeshes);
+
+	protected:
+		/**	Returns the size of the internal buffer in bytes. */
+		UINT32 getInternalBufferSize() const override;
+
+	private:
+		/**	Returns a pointer to the start of the index buffer. */
+		UINT8* getIndexData() const { return getData(); }
+
+		/**	Returns a pointer to the start of the specified vertex stream. */
+		UINT8* getStreamData(UINT32 streamIdx) const;
+
+		/**	Returns an offset in bytes to the start of the index buffer from the start of the internal buffer. */
+		UINT32 getIndexBufferOffset() const;
+
+		/**	Returns an offset in bytes to the start of the stream from the start of the internal buffer. */
+		UINT32 getStreamOffset(UINT32 streamIdx = 0) const;
+
+		/**	Returns the size of the index buffer in bytes. */
+		UINT32 getIndexBufferSize() const;
+
+		/**	Returns the size of the specified stream in bytes. */
+		UINT32 getStreamSize(UINT32 streamIdx) const;
+
+		/**	Returns the size of all the streams in bytes. */
+		UINT32 getStreamSize() const;
+
+		/**
+		 * Returns the data needed for iterating over the requested vertex element.
+		 *
+		 * @param[in]	semantic   		Semantic of the element we are looking for.
+		 * @param[in]	semanticIdx 	If there are multiple semantics with the same name, use different index to 
+		 *								differentiate between them.
+		 * @param[in]	streamIdx   	Zero-based index of the stream the element resides in.
+		 * @param[out] data				Pointer to the start of this elements data.
+		 * @param[out] stride			Number of bytes between vertex elements of this type.
+		 */
+		void getDataForIterator(VertexElementSemantic semantic, UINT32 semanticIdx, UINT32 streamIdx, UINT8*& data, UINT32& stride) const;
+
+	private:
+		friend class Mesh;
+		friend class MeshCore;
+		friend class MeshHeap;
+		friend class MeshHeapCore;
+
+		UINT32 mDescBuilding;
+
+		UINT32 mNumVertices;
+		UINT32 mNumIndices;
+		IndexType mIndexType;
+
+		VertexDataDescPtr mVertexData;
+
+		/************************************************************************/
+		/* 								SERIALIZATION                      		*/
+		/************************************************************************/
+	private:
+		MeshData(); // Serialization only
+
+	public:
+		friend class MeshDataRTTI;
+		static RTTITypeBase* getRTTIStatic();
+		virtual RTTITypeBase* getRTTI() const override;
+	};
+
+	/** @} */
 }
 }

+ 58 - 66
BansheeCore/Include/BsMeshManager.h

@@ -1,67 +1,59 @@
-#pragma once
-
-#include "BsCorePrerequisites.h"
-#include "BsModule.h"
-#include "BsMesh.h"
-
-namespace BansheeEngine
-{
-	/**
-	 * @brief	Manager that handles creation of Meshes.
-	 */
-	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);
-
-		/**
-		 * @brief	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();
-
-		/**
-		 * @brief	Returns some dummy mesh data with one triangle you may use for initializing a mesh.
-		 */
-		MeshDataPtr getDummyMeshData() const { return mDummyMeshData; }
-
-		/**
-		 * @brief	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;
-	};
+#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 */
 }
 }

+ 30 - 45
BansheeCore/Include/BsMultiRenderTexture.h

@@ -5,10 +5,13 @@
 
 
 namespace BansheeEngine
 namespace BansheeEngine
 {
 {
+	/** @addtogroup RenderAPI
+	 *  @{
+	 */
+
 	/**
 	/**
-	 * @brief	Descriptor class used for initializing a MultiRenderTexture.
-	 *			Contains descriptors for each individual color render surface and 
-	 *			their common depth/stencil surface.
+	 * 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
 	struct BS_CORE_EXPORT MULTI_RENDER_TEXTURE_DESC
 	{
 	{
@@ -27,9 +30,7 @@ namespace BansheeEngine
 		RENDER_SURFACE_CORE_DESC depthStencilSurface;
 		RENDER_SURFACE_CORE_DESC depthStencilSurface;
 	};
 	};
 
 
-	/**
-	 * @brief	Contains various properties that describe a render texture.
-	 */
+	/** Contains various properties that describe a render texture. */
 	class BS_CORE_EXPORT MultiRenderTextureProperties : public RenderTargetProperties
 	class BS_CORE_EXPORT MultiRenderTextureProperties : public RenderTargetProperties
 	{
 	{
 	public:
 	public:
@@ -44,9 +45,11 @@ namespace BansheeEngine
 		void construct(const TextureProperties* props);
 		void construct(const TextureProperties* props);
 	};
 	};
 
 
+	/** @cond INTERNAL */
+
 	/**
 	/**
-	 * @brief	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.
+	 * 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.
 	 * @note	Core thread only.
 	 */
 	 */
@@ -55,29 +58,20 @@ namespace BansheeEngine
 	public:
 	public:
 		virtual ~MultiRenderTextureCore();
 		virtual ~MultiRenderTextureCore();
 
 
-		/**
-		 * @copydoc	CoreObjectCore::initialize
-		 */
+		/** @copydoc CoreObjectCore::initialize */
 		virtual void initialize() override;
 		virtual void initialize() override;
 
 
-		/**
-		 * @brief	Returns properties that describe the render texture.
-		 */
+		/** Returns properties that describe the render texture. */
 		const MultiRenderTextureProperties& getProperties() const;
 		const MultiRenderTextureProperties& getProperties() const;
 
 
 	protected:
 	protected:
 		MultiRenderTextureCore(const MULTI_RENDER_TEXTURE_CORE_DESC& desc);
 		MultiRenderTextureCore(const MULTI_RENDER_TEXTURE_CORE_DESC& desc);
 
 
-		/**
-		 * @copydoc	CoreObjectCore::syncToCore
-		 */
+		/** @copydoc CoreObjectCore::syncToCore */
 		virtual void syncToCore(const CoreSyncData& data) override;
 		virtual void syncToCore(const CoreSyncData& data) override;
 
 
 	private:
 	private:
-		/**
-		 * @brief	Checks that all render surfaces and depth/stencil surface match. If they do not match
-		 *			an exception is thrown.
-		 */
+		/** Checks that all render surfaces and depth/stencil surface match. If they do not match an exception is thrown. */
 		void throwIfBuffersDontMatch() const;
 		void throwIfBuffersDontMatch() const;
 
 
 		// TODO - Not implemented
 		// TODO - Not implemented
@@ -90,9 +84,11 @@ namespace BansheeEngine
 		MULTI_RENDER_TEXTURE_CORE_DESC mDesc;
 		MULTI_RENDER_TEXTURE_CORE_DESC mDesc;
 	};
 	};
 
 
+	/** @endcond */
+
 	/**
 	/**
-	 * @brief	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.
+	 * 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.
 	 * @note	Sim thread only.
 	 */
 	 */
@@ -102,55 +98,44 @@ namespace BansheeEngine
 		virtual ~MultiRenderTexture() { }
 		virtual ~MultiRenderTexture() { }
 
 
 		/**
 		/**
-		 * @brief	Returns a color surface texture you may bind as an input to an GPU program.
+		 * 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.
 		 * @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]; }
 		const HTexture& getBindableColorTexture(UINT32 idx) const { return mBindableColorTex[idx]; }
 
 
 		/**
 		/**
-		 * @brief	Returns a depth/stencil surface texture you may bind as an input to an GPU program.
+		 * 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.
+		 * @note	Be aware that you cannot bind a render texture for reading and writing at the same time.
 		 */
 		 */
 		const HTexture& getBindableDepthStencilTexture() const { return mBindableDepthStencilTex; }
 		const HTexture& getBindableDepthStencilTexture() const { return mBindableDepthStencilTex; }
 
 
-		/**
-		 * @brief	Retrieves a core implementation of a render texture usable only from the
-		 *			core thread.
-		 */
+		/** Retrieves a core implementation of a render texture usable only from the core thread. */
 		SPtr<MultiRenderTextureCore> getCore() const;
 		SPtr<MultiRenderTextureCore> getCore() const;
 
 
-		/**
-		 * @copydoc	TextureManager::createMultiRenderTexture
-		 */
+		/** @copydoc TextureManager::createMultiRenderTexture */
 		static MultiRenderTexturePtr create(const MULTI_RENDER_TEXTURE_DESC& desc);
 		static MultiRenderTexturePtr create(const MULTI_RENDER_TEXTURE_DESC& desc);
 
 
-		/**
-		 * @brief	Returns properties that describe the render texture.
-		 */
+		/**	Returns properties that describe the render texture. */
 		const MultiRenderTextureProperties& getProperties() const;
 		const MultiRenderTextureProperties& getProperties() const;
 
 
-		/**
-		 * @brief	Returns the number of color surfaces used by the render texture.
-		 */
+		/**	Returns the number of color surfaces used by the render texture. */
 		UINT32 getColorSurfaceCount() const;
 		UINT32 getColorSurfaceCount() const;
 
 
 	protected:
 	protected:
 		MultiRenderTexture(const MULTI_RENDER_TEXTURE_DESC& desc);
 		MultiRenderTexture(const MULTI_RENDER_TEXTURE_DESC& desc);
 
 
-		/**
-		 * @copydoc	RenderTarget::createCore
-		 */
+		/** @copydoc RenderTarget::createCore */
 		SPtr<CoreObjectCore> createCore() const override;
 		SPtr<CoreObjectCore> createCore() const override;
 
 
-		/**
-		 * @copydoc	CoreObjectCore::syncToCore
-		 */
+		/** @copydoc CoreObjectCore::syncToCore */
 		virtual CoreSyncData syncToCore(FrameAlloc* allocator) override;
 		virtual CoreSyncData syncToCore(FrameAlloc* allocator) override;
 
 
 		MULTI_RENDER_TEXTURE_DESC mDesc;
 		MULTI_RENDER_TEXTURE_DESC mDesc;
 		Vector<HTexture> mBindableColorTex;
 		Vector<HTexture> mBindableColorTex;
 		HTexture mBindableDepthStencilTex;
 		HTexture mBindableDepthStencilTex;
 	};
 	};
+
+	/** @} */
 }
 }

+ 73 - 75
BansheeCore/Include/BsOcclusionQuery.h

@@ -1,76 +1,74 @@
-#pragma once
-
-#include "BsCorePrerequisites.h"
-
-namespace BansheeEngine
-{
-	/**
-	* @brief	Represents a query that counts number of samples rendered by the GPU
-	*			while the query is active.
-	*
-	* @note		Core thread only.
-	*/
-	class BS_CORE_EXPORT OcclusionQuery
-	{
-	public:
-		OcclusionQuery(bool binary);
-		virtual ~OcclusionQuery() {}
-
-		/**
-		* @brief	Starts the query. Any draw calls after this call will have any rendered samples
-		*			counted in the query.
-		*
-		* @note		Place any commands you want to measure after this call. Call "end" when done.
-		*/
-		virtual void begin() = 0;
-
-		/**
-		* @brief	Stops the query. 
-		*
-		* @note		Be aware that queries are executed on the GPU and the results will not be immediately available.
-		*/
-		virtual void end() = 0;
-
-		/**
-		* @brief	Check if GPU has processed the query.
-		*/
-		virtual bool isReady() const = 0;
-
-		/**
-		 * @brief	Returns the number of samples that passed the depth and stencil test between
-		 *			query start and end.
-		 *
-		 * @note	If the query is binary, this will return 0 or 1. 1 meaning one or more samples were rendered,
-		 *			but will not give you the exact count.
-		 */
-		virtual UINT32 getNumSamples() = 0;
-
-		/**
-		 * @brief	Triggered when the query has completed. Argument provided
-		 *			is the number of samples counted by the query.
-		 */
-		Event<void(UINT32)> onComplete;
-
-		/**
-		 * @brief	Creates a new occlusion query. 
-		 *
-		 * @param binary	If query is binary it will not give you an exact count of samples rendered, but will instead
-		 *					just return 0 (no samples were rendered) or 1 (one or more samples were rendered). Binary
-		 *					queries can return sooner as they potentially do not need to wait until all of the geometry is rendered.
-		 */
-		static OcclusionQueryPtr create(bool binary);
-
-	protected:
-		friend class QueryManager;
-
-		/**
-		* @brief	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;
-		bool mBinary;
-	};
+#pragma once
+
+#include "BsCorePrerequisites.h"
+
+namespace BansheeEngine
+{
+	/** @addtogroup RenderAPI
+	 *  @{
+	 */
+
+	/**
+	 * Represents a query that counts number of samples rendered by the GPU while the query is active.
+	 *
+	 * @note		Core thread only.
+	 */
+	class BS_CORE_EXPORT OcclusionQuery
+	{
+	public:
+		OcclusionQuery(bool binary);
+		virtual ~OcclusionQuery() {}
+
+		/**
+		 * Starts the query. Any draw calls after this call will have any rendered samples counted in the query.
+		 *
+		 * @note	Place any commands you want to measure after this call. Call end() when done.
+		 */
+		virtual void begin() = 0;
+
+		/**
+		 * Stops the query. 
+		 *
+		 * @note	Be aware that queries are executed on the GPU and the results will not be immediately available.
+		 */
+		virtual void end() = 0;
+
+		/** Check if GPU has processed the query. */
+		virtual bool isReady() const = 0;
+
+		/**
+		 * Returns the number of samples that passed the depth and stencil test between query start and end.
+		 *
+		 * @note	
+		 * If the query is binary, this will return 0 or 1. 1 meaning one or more samples were rendered, but will not give
+		 * you the exact count.
+		 */
+		virtual UINT32 getNumSamples() = 0;
+
+		/** Triggered when the query has completed. Argument provided is the number of samples counted by the query. */
+		Event<void(UINT32)> onComplete;
+
+		/**
+		 * Creates a new occlusion query. 
+		 *
+		 * @param[in] binary	If query is binary it will not give you an exact count of samples rendered, but will instead
+		 *						just return 0 (no samples were rendered) or 1 (one or more samples were rendered). Binary
+		 *						queries can return sooner as they potentially do not need to wait until all of the geometry
+		 *						is rendered.
+		 */
+		static OcclusionQueryPtr create(bool binary);
+
+	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;
+		bool mBinary;
+	};
+
+	/** @} */
 }
 }

+ 109 - 94
BansheeCore/Include/BsParamBlocks.h

@@ -1,95 +1,110 @@
-#pragma once
-
-#include "BsCorePrerequisites.h"
-#include "BsGpuParamDesc.h"
-#include "BsGpuParams.h"
-#include "BsRenderAPI.h"
-#include "BsGpuParamBlockBuffer.h"
-
-namespace BansheeEngine
-{
-	/**
-	 * Macros used for manually constructing parameter block buffers used by GPU programs.
-	 */
-
-#define BS_PARAM_BLOCK_BEGIN(Name)																							\
-	struct Name																												\
-	{																														\
-		Name()																												\
-		{																													\
-			Vector<GpuParamDataDesc> params = getEntries();																	\
-			RenderAPICore& rapi = RenderAPICore::instance();																\
-																															\
-			mBlockDesc = rapi.generateParamBlockDesc(#Name, params);														\
-																															\
-			SPtr<GpuParamDesc> paramsDesc = bs_shared_ptr_new<GpuParamDesc>();												\
-			paramsDesc->paramBlocks[#Name] = mBlockDesc;																	\
-			for (auto& param : params)																						\
-				paramsDesc->params[param.name] = param;																		\
-																															\
-			mParams = GpuParamsCore::create(paramsDesc, rapi.getGpuProgramHasColumnMajorMatrices());						\
-																															\
-			mBuffer = GpuParamBlockBufferCore::create(mBlockDesc.blockSize * sizeof(UINT32));								\
-			mParams->setParamBlockBuffer(#Name, mBuffer);																	\
-			initEntries();																									\
-		}																													\
-																															\
-		const SPtr<GpuParamBlockBufferCore>& getBuffer() const { return mBuffer; }											\
-		const GpuParamBlockDesc& getDesc() const { return mBlockDesc; }														\
-																															\
-	private:																												\
-		struct META_FirstEntry {};																							\
-		static void META_GetPrevEntries(Vector<GpuParamDataDesc>& params, META_FirstEntry id) { }							\
-		void META_InitPrevEntry(const SPtr<GpuParamsCore>& params, META_FirstEntry id) { }									\
-																															\
-		typedef META_FirstEntry 
-
-#define BS_PARAM_BLOCK_ENTRY_ARRAY(Type, Name, NumElements)																	\
-		META_Entry_##Name;																									\
-																															\
-		struct META_NextEntry_##Name {};																					\
-		static void META_GetPrevEntries(Vector<GpuParamDataDesc>& params, META_NextEntry_##Name id)							\
-		{																													\
-			META_GetPrevEntries(params, META_Entry_##Name##());																\
-																															\
-			params.push_back(GpuParamDataDesc());																			\
-			GpuParamDataDesc& newEntry = params.back();																		\
-			newEntry.name = #Name;																							\
-			newEntry.type = (GpuParamDataType)TGpuDataParamInfo<Type>::TypeId;												\
-			newEntry.arraySize = NumElements;																				\
-		}																													\
-																															\
-		void META_InitPrevEntry(const SPtr<GpuParamsCore>& params, META_NextEntry_##Name id)								\
-		{																													\
-			META_InitPrevEntry(params, META_Entry_##Name##());																\
-			params->getParam(#Name, Name);																					\
-		}																													\
-																															\
-	public:																													\
-		TGpuDataParam<Type, true> Name;																						\
-																															\
-	private:																												\
-		typedef META_NextEntry_##Name
-
-#define BS_PARAM_BLOCK_ENTRY(Type, Name) BS_PARAM_BLOCK_ENTRY_ARRAY(Type, Name, 1)
-
-#define BS_PARAM_BLOCK_END																									\
-		META_LastEntry;																										\
-																															\
-		static Vector<GpuParamDataDesc> getEntries()																		\
-		{																													\
-			Vector<GpuParamDataDesc> entries;																				\
-			META_GetPrevEntries(entries, META_LastEntry());																	\
-			return entries;																									\
-		}																													\
-																															\
-		void initEntries()																									\
-		{																													\
-			META_InitPrevEntry(mParams, META_LastEntry());																	\
-		}																													\
-																															\
-		SPtr<GpuParamsCore> mParams;																						\
-		SPtr<GpuParamBlockBufferCore> mBuffer;																				\
-		GpuParamBlockDesc mBlockDesc;																						\
-	};
+#pragma once
+
+#include "BsCorePrerequisites.h"
+#include "BsGpuParamDesc.h"
+#include "BsGpuParams.h"
+#include "BsRenderAPI.h"
+#include "BsGpuParamBlockBuffer.h"
+
+namespace BansheeEngine
+{
+	/** @cond INTERNAL */
+	/** @addtogroup Renderer
+	 *  @{
+	 */
+
+/** 
+ * Starts a new custom parameter block. Custom parameter blocks allow you to create C++ structures that map directly
+ * to GPU program buffers (e.g. uniform buffer in OpenGL or constant buffer in DX). Must be followed by BS_PARAM_BLOCK_END.
+ */
+#define BS_PARAM_BLOCK_BEGIN(Name)																							\
+	struct Name																												\
+	{																														\
+		Name()																												\
+		{																													\
+			Vector<GpuParamDataDesc> params = getEntries();																	\
+			RenderAPICore& rapi = RenderAPICore::instance();																\
+																															\
+			mBlockDesc = rapi.generateParamBlockDesc(#Name, params);														\
+																															\
+			SPtr<GpuParamDesc> paramsDesc = bs_shared_ptr_new<GpuParamDesc>();												\
+			paramsDesc->paramBlocks[#Name] = mBlockDesc;																	\
+			for (auto& param : params)																						\
+				paramsDesc->params[param.name] = param;																		\
+																															\
+			mParams = GpuParamsCore::create(paramsDesc, rapi.getGpuProgramHasColumnMajorMatrices());						\
+																															\
+			mBuffer = GpuParamBlockBufferCore::create(mBlockDesc.blockSize * sizeof(UINT32));								\
+			mParams->setParamBlockBuffer(#Name, mBuffer);																	\
+			initEntries();																									\
+		}																													\
+																															\
+		const SPtr<GpuParamBlockBufferCore>& getBuffer() const { return mBuffer; }											\
+		const GpuParamBlockDesc& getDesc() const { return mBlockDesc; }														\
+																															\
+	private:																												\
+		struct META_FirstEntry {};																							\
+		static void META_GetPrevEntries(Vector<GpuParamDataDesc>& params, META_FirstEntry id) { }							\
+		void META_InitPrevEntry(const SPtr<GpuParamsCore>& params, META_FirstEntry id) { }									\
+																															\
+		typedef META_FirstEntry 
+
+/**
+ * Registers a new entry in a parameter block. Must be called in between BS_PARAM_BLOCK_BEGIN and BS_PARAM_BLOCK_END calls.
+ */
+#define BS_PARAM_BLOCK_ENTRY_ARRAY(Type, Name, NumElements)																	\
+		META_Entry_##Name;																									\
+																															\
+		struct META_NextEntry_##Name {};																					\
+		static void META_GetPrevEntries(Vector<GpuParamDataDesc>& params, META_NextEntry_##Name id)							\
+		{																													\
+			META_GetPrevEntries(params, META_Entry_##Name##());																\
+																															\
+			params.push_back(GpuParamDataDesc());																			\
+			GpuParamDataDesc& newEntry = params.back();																		\
+			newEntry.name = #Name;																							\
+			newEntry.type = (GpuParamDataType)TGpuDataParamInfo<Type>::TypeId;												\
+			newEntry.arraySize = NumElements;																				\
+		}																													\
+																															\
+		void META_InitPrevEntry(const SPtr<GpuParamsCore>& params, META_NextEntry_##Name id)								\
+		{																													\
+			META_InitPrevEntry(params, META_Entry_##Name##());																\
+			params->getParam(#Name, Name);																					\
+		}																													\
+																															\
+	public:																													\
+		TGpuDataParam<Type, true> Name;																						\
+																															\
+	private:																												\
+		typedef META_NextEntry_##Name
+
+/** 
+ * Registers a new entry in a parameter block. Must be called in between BS_PARAM_BLOCK_BEGIN and BS_PARAM_BLOCK_END calls. 
+ */
+#define BS_PARAM_BLOCK_ENTRY(Type, Name) BS_PARAM_BLOCK_ENTRY_ARRAY(Type, Name, 1)
+
+/** Ends parameter block definition. See BS_PARAM_BLOCK_BEGIN. */
+#define BS_PARAM_BLOCK_END																									\
+		META_LastEntry;																										\
+																															\
+		static Vector<GpuParamDataDesc> getEntries()																		\
+		{																													\
+			Vector<GpuParamDataDesc> entries;																				\
+			META_GetPrevEntries(entries, META_LastEntry());																	\
+			return entries;																									\
+		}																													\
+																															\
+		void initEntries()																									\
+		{																													\
+			META_InitPrevEntry(mParams, META_LastEntry());																	\
+		}																													\
+																															\
+		SPtr<GpuParamsCore> mParams;																						\
+		SPtr<GpuParamBlockBufferCore> mBuffer;																				\
+		GpuParamBlockDesc mBlockDesc;																						\
+	};
+
+	/** @} */
+	/** @endcond */
 }
 }

+ 90 - 102
BansheeCore/Include/BsPixelBuffer.h

@@ -1,103 +1,91 @@
-#pragma once
-
-#include "BsCorePrerequisites.h"
-#include "BsHardwareBuffer.h"
-#include "BsPixelUtil.h"
-
-namespace BansheeEngine 
-{
-	/**
-	 * @brief	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:
-		/**
-		 * @brief	Constructs a new pixel buffer with the provided settings.
-		 *
-		 * @param	width			Width of the pixel buffer in pixels.
-		 * @param	height			Height of the pixel buffer in pixels.
-		 * @param	depth			Depth of the pixel buffer in pixels (number of 2D slices).
-		 * @param	format			Format of each pixel in the buffer.
-		 * @param	usage			Usage signaling the render system how we plan on using the buffer.
-		 * @param	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;	
-
-		/**
-		 * @brief	Locks a certain region of the pixel buffer for reading and returns a pointer
-		 *			to the locked region.
-		 *
-		 * @param	lockBox		Region of the surface to lock.
-		 * @param	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);
-
-		/**
-		 * @brief	Returns width of the surface in pixels.
-		 */
-        UINT32 getWidth() const { return mWidth; }
-
-		/**
-		 * @brief	Returns height of the surface in pixels.
-		 */
-        UINT32 getHeight() const { return mHeight; }
-
-		/**
-		 * @brief	Returns depth of the surface in pixels.
-		 */
-        UINT32 getDepth() const { return mDepth; }
-
-		/**
-		 * @brief	Returns format of the pixels in the surface.
-		 */
-        PixelFormat getFormat() const { return mFormat; }
-
-	protected:
-		friend class RenderTexture;
-
-		/**
-		 * @brief	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;
-    };
+#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 */
 }
 }

+ 84 - 83
BansheeCore/Include/BsQueryManager.h

@@ -1,84 +1,85 @@
-#pragma once
-
-#include "BsCorePrerequisites.h"
-#include "BsEventQuery.h"
-#include "BsModule.h"
-
-namespace BansheeEngine
-{
-	/**
-	 * @brief	Handles creation and destruction of GPU queries.
-	 * 			
-	 * @note	Core thread only.
-	 */
-	class BS_CORE_EXPORT QueryManager : public Module<QueryManager>
-	{
-	public:
-		QueryManager();
-		~QueryManager();
-
-		/**
-		 * @brief	Creates a new event query that allows you to get notified
-		 *			when GPU starts executing the query.
-		 */
-		virtual EventQueryPtr createEventQuery() const = 0;
-
-		/**
-		* @brief	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;
-
-		/**
-		* @brief	Creates a new occlusion query that allows you to know
-		*			how many fragments were rendered between query start and end.
-		*
-		* @param 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;
-
-		/**
-		 * @note	Internal method, called every frame.
-		 */
-		void _update();
-
-	protected:
-		friend class EventQuery;
-		friend class TimerQuery;
-		friend class OcclusionQuery;
-
-		/**
-		 * @brief	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);
-
-		/**
-		* @brief	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);
-
-		/**
-		* @brief	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);
-
-		/**
-		 * @brief	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;
-	};
+#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 */
 }
 }

+ 55 - 81
BansheeCore/Include/BsRasterizerState.h

@@ -6,12 +6,11 @@
 
 
 namespace BansheeEngine
 namespace BansheeEngine
 {
 {
-	/**
-	 * @brief	Structure that describes pipeline rasterizer state. Used for initializing
-	 *			a RasterizerState.
-	 *
-	 * @see		RasterizerState
+	/** @addtogroup RenderAPI
+	 *  @{
 	 */
 	 */
+
+	/** Structure that describes pipeline rasterizer state. Used for initializing a RasterizerState. */
 	struct BS_CORE_EXPORT RASTERIZER_STATE_DESC
 	struct BS_CORE_EXPORT RASTERIZER_STATE_DESC
 	{
 	{
 		RASTERIZER_STATE_DESC()
 		RASTERIZER_STATE_DESC()
@@ -41,85 +40,71 @@ namespace BansheeEngine
 		bool antialiasedLineEnable;
 		bool antialiasedLineEnable;
 	};
 	};
 
 
-	/**
-	 * @brief	Properties of RasterizerState. Shared between sim and core thread versions of RasterizerState.
-	 */
+	/** Properties of RasterizerState. Shared between sim and core thread versions of RasterizerState. */
 	class BS_CORE_EXPORT RasterizerProperties
 	class BS_CORE_EXPORT RasterizerProperties
 	{
 	{
 	public:
 	public:
 		RasterizerProperties(const RASTERIZER_STATE_DESC& desc);
 		RasterizerProperties(const RASTERIZER_STATE_DESC& desc);
 
 
-		/**
-		 * @brief	Polygon mode allows you to draw polygons as solid objects or as wireframe by
-		 *			just drawing their edges.
-		 */
+		/** Polygon mode allows you to draw polygons as solid objects or as wireframe by just drawing their edges. */
 		PolygonMode getPolygonMode() const { return mData.polygonMode; }
 		PolygonMode getPolygonMode() const { return mData.polygonMode; }
 
 
 		/**
 		/**
-		 * @brief	Sets vertex winding order. Faces that contain vertices with this order will 
-		 *			be culled and not rasterized. Used primarily for saving cycles by not rendering
-		 *			backfacing faces.
+		 * Sets vertex winding order. Faces that contain vertices with this order will be culled and not rasterized. Used 
+		 * primarily for saving cycles by not rendering backfacing faces.
 		 */
 		 */
 		CullingMode getCullMode() const { return mData.cullMode; }
 		CullingMode getCullMode() const { return mData.cullMode; }
 
 
 		/**
 		/**
-		* @brief	Represents a constant depth bias that will offset the depth values of new pixels 
-		*			by the specified amount.
-		*
-		* @note		This is useful if you want to avoid z fighting for objects at the same or similar depth.
-		*/
+		 * Represents a constant depth bias that will offset the depth values of new pixels by the specified amount.
+		 *
+		 * @note		This is useful if you want to avoid z fighting for objects at the same or similar depth.
+		 */
 		float getDepthBias() const { return mData.depthBias; }
 		float getDepthBias() const { return mData.depthBias; }
 
 
-		/**
-		 * @brief	Maximum depth bias value.
-		 */
+		/**	Maximum depth bias value. */
 		float getDepthBiasClamp() const { return mData.depthBiasClamp; }
 		float getDepthBiasClamp() const { return mData.depthBiasClamp; }
 
 
 		/**
 		/**
-		 * @brief	Represents a dynamic depth bias that increases as the slope of the rendered polygons 
-		 *			surface increases. Resulting value offsets depth values of new pixels. This offset will 
-		 *			be added on top of the constant depth bias.
+		 * Represents a dynamic depth bias that increases as the slope of the rendered polygons surface increases. 
+		 * Resulting value offsets depth values of new pixels. This offset will be added on top of the constant depth bias.
 		 *
 		 *
 		 * @note	This is useful if you want to avoid z fighting for objects at the same or similar depth.
 		 * @note	This is useful if you want to avoid z fighting for objects at the same or similar depth.
 		 */
 		 */
 		float getSlopeScaledDepthBias() const { return mData.slopeScaledDepthBias; }
 		float getSlopeScaledDepthBias() const { return mData.slopeScaledDepthBias; }
 
 
 		/**
 		/**
-		 * @brief	If true, clipping of polygons past the far Z plane is enabled. This ensures proper
-		 *			Z ordering for polygons outside of valid depth range (otherwise they all have the same
-		 *			depth). It can be useful to disable if you are performing stencil operations that count on
-		 *			objects having a front and a back (like stencil shadow) and don't want to clip the back.
+		 * If true, clipping of polygons past the far Z plane is enabled. This ensures proper Z ordering for polygons 
+		 * outside of valid depth range (otherwise they all have the same depth). It can be useful to disable if you are 
+		 * performing stencil operations that count on objects having a front and a back (like stencil shadow) and don't 
+		 * want to clip the back.
 		 */
 		 */
 		bool getDepthClipEnable() const { return mData.depthClipEnable; }
 		bool getDepthClipEnable() const { return mData.depthClipEnable; }
 
 
 		/**
 		/**
-		 * @brief	Scissor rectangle allows you to cull all pixels outside of the scissor rectangle.
+		 * Scissor rectangle allows you to cull all pixels outside of the scissor rectangle.
 		 *			
 		 *			
 		 * @see		RenderAPICore::setScissorRect
 		 * @see		RenderAPICore::setScissorRect
 		 */
 		 */
 		bool getScissorEnable() const { return mData.scissorEnable; }
 		bool getScissorEnable() const { return mData.scissorEnable; }
 
 
 		/**
 		/**
-		 * @brief	Determines how are samples in multi-sample render targets handled.
-		 *			If disabled all samples in the render target will be written the same value, 
-		 *			and if enabled each sample will be generated separately.
+		 * Determines how are samples in multi-sample render targets handled. If disabled all samples in the render target 
+		 * will be written the same value, and if enabled each sample will be generated separately.
 		 *			
 		 *			
-		 * @note	In order to get an antialiased image you need to both enable this option and use
-		 *			a MSAA render target.
+		 * @note	In order to get an antialiased image you need to both enable this option and use a MSAA render target.
 		 */
 		 */
 		bool getMultisampleEnable() const { return mData.multisampleEnable; }
 		bool getMultisampleEnable() const { return mData.multisampleEnable; }
 
 
 		/**
 		/**
-		 * @brief	Determines should the lines be antialiased. This is separate from multi-sample
-		 *			antialiasing setting as lines can be antialiased without multi-sampling.
+		 * Determines should the lines be antialiased. This is separate from multi-sample antialiasing setting as lines can
+		 * be antialiased without multi-sampling.
 		 *
 		 *
 		 * @note	This setting is usually ignored if MSAA is used, as that provides sufficient antialiasing.
 		 * @note	This setting is usually ignored if MSAA is used, as that provides sufficient antialiasing.
 		 */
 		 */
 		bool getAntialiasedLineEnable() const { return mData.antialiasedLineEnable; }
 		bool getAntialiasedLineEnable() const { return mData.antialiasedLineEnable; }
 
 
-		/**
-		 * @brief	Returns the hash value generated from the rasterizer state properties.
-		 */
+		/** Returns the hash value generated from the rasterizer state properties. */
 		UINT64 getHash() const { return mHash; }
 		UINT64 getHash() const { return mHash; }
 
 
 	protected:
 	protected:
@@ -131,8 +116,10 @@ namespace BansheeEngine
 		UINT64 mHash;
 		UINT64 mHash;
 	};
 	};
 
 
+	/** @cond INTERNAL */
+
 	/**
 	/**
-	 * @brief	Core thread version of RasterizerState.
+	 * Core thread version of RasterizerState.
 	 *
 	 *
 	 * @note	Core thread.
 	 * @note	Core thread.
 	 */
 	 */
@@ -141,19 +128,13 @@ namespace BansheeEngine
 	public:
 	public:
 		virtual ~RasterizerStateCore();
 		virtual ~RasterizerStateCore();
 
 
-		/**
-		 * @brief	Returns information about the rasterizer state.
-		 */
+		/** Returns information about the rasterizer state. */
 		const RasterizerProperties& getProperties() const;
 		const RasterizerProperties& getProperties() const;
 
 
-		/**
-		 * @brief	Returns a unique state ID. Only the lowest 10 bits are used.
-		 */
+		/**	Returns a unique state ID. Only the lowest 10 bits are used. */
 		UINT32 getId() const { return mId; }
 		UINT32 getId() const { return mId; }
 
 
-		/**
-		 * @brief	Returns the default rasterizer state.
-		 */
+		/** Returns the default rasterizer state. */
 		static const SPtr<RasterizerStateCore>& getDefault();
 		static const SPtr<RasterizerStateCore>& getDefault();
 
 
 	protected:
 	protected:
@@ -161,23 +142,21 @@ namespace BansheeEngine
 
 
 		RasterizerStateCore(const RASTERIZER_STATE_DESC& desc, UINT32 id);
 		RasterizerStateCore(const RASTERIZER_STATE_DESC& desc, UINT32 id);
 
 
-		/**
-		 * @copydoc	CoreObjectCore::initialize
-		 */
+		/** @copydoc CoreObjectCore::initialize */
 		void initialize() override;
 		void initialize() override;
 
 
-		/**
-		 * @brief	Creates any API-specific state objects.
-		 */
+		/**	Creates any API-specific state objects. */
 		virtual void createInternal() { }
 		virtual void createInternal() { }
 
 
 		RasterizerProperties mProperties;
 		RasterizerProperties mProperties;
 		UINT32 mId;
 		UINT32 mId;
 	};
 	};
 
 
+	/** @endcond */
+
 	/**
 	/**
-	 * @brief	Render system pipeline state that allows you to modify how an object is rasterized.
-	 *			i.e. how are polygons converted to pixels.
+	 * Render system pipeline state that allows you to modify how an object is rasterized. i.e. how are polygons converted
+	 * to pixels.
 	 *
 	 *
 	 * @note	Rasterizer states are immutable. Sim thread only.
 	 * @note	Rasterizer states are immutable. Sim thread only.
 	 */
 	 */
@@ -186,30 +165,19 @@ namespace BansheeEngine
 	public:
 	public:
 		virtual ~RasterizerState();
 		virtual ~RasterizerState();
 
 
-		/**
-		 * @brief	Returns information about the rasterizer state.
-		 */
+		/**	Returns information about the rasterizer state. */
 		const RasterizerProperties& getProperties() const;
 		const RasterizerProperties& getProperties() const;
 
 
-		/**
-		 * @brief	Retrieves a core implementation of the rasterizer state usable only from the
-		 *			core thread.
-		 */
+		/** Retrieves a core implementation of the rasterizer state usable only from the core thread. */
 		SPtr<RasterizerStateCore> getCore() const;
 		SPtr<RasterizerStateCore> getCore() const;
 
 
-		/**
-		 * @brief	Creates a new rasterizer state using the specified rasterizer state descriptor structure.
-		 */
+		/** Creates a new rasterizer state using the specified rasterizer state descriptor structure. */
 		static RasterizerStatePtr create(const RASTERIZER_STATE_DESC& desc);
 		static RasterizerStatePtr create(const RASTERIZER_STATE_DESC& desc);
 
 
-		/**
-		 * @brief	Returns the default rasterizer state.
-		 */
+		/**	Returns the default rasterizer state. */
 		static const RasterizerStatePtr& getDefault();
 		static const RasterizerStatePtr& getDefault();
 
 
-		/**
-		 * @brief	Generates a hash value from a rasterizer state descriptor.
-		 */
+		/**	Generates a hash value from a rasterizer state descriptor. */
 		static UINT64 generateHash(const RASTERIZER_STATE_DESC& desc);
 		static UINT64 generateHash(const RASTERIZER_STATE_DESC& desc);
 
 
 	protected:
 	protected:
@@ -217,9 +185,7 @@ namespace BansheeEngine
 
 
 		RasterizerState(const RASTERIZER_STATE_DESC& desc);
 		RasterizerState(const RASTERIZER_STATE_DESC& desc);
 		
 		
-		/**
-		 * @copydoc	CoreObjectCore::createCore
-		 */
+		/** @copydoc CoreObjectCore::createCore */
 		SPtr<CoreObjectCore> createCore() const override;
 		SPtr<CoreObjectCore> createCore() const override;
 
 
 		RasterizerProperties mProperties;
 		RasterizerProperties mProperties;
@@ -234,11 +200,16 @@ namespace BansheeEngine
 		static RTTITypeBase* getRTTIStatic();
 		static RTTITypeBase* getRTTIStatic();
 		virtual RTTITypeBase* getRTTI() const override;	
 		virtual RTTITypeBase* getRTTI() const override;	
 	};
 	};
+
+	/** @} */
 }
 }
 
 
-/**
- * @brief	Hash value generator for RASTERIZER_STATE_DESC.
+/** @cond STDLIB */
+/** @addtogroup RenderAPI
+ *  @{
  */
  */
+
+/**	Hash value generator for RASTERIZER_STATE_DESC. */
 template<>
 template<>
 struct std::hash<BansheeEngine::RASTERIZER_STATE_DESC>
 struct std::hash<BansheeEngine::RASTERIZER_STATE_DESC>
 {
 {
@@ -246,4 +217,7 @@ struct std::hash<BansheeEngine::RASTERIZER_STATE_DESC>
 	{
 	{
 		return (size_t)BansheeEngine::RasterizerState::generateHash(value);
 		return (size_t)BansheeEngine::RasterizerState::generateHash(value);
 	}
 	}
-};
+};
+
+/** @} */
+/** @endcond */

+ 99 - 142
BansheeCore/Include/BsRenderAPI.h

@@ -1,8 +1,5 @@
 #pragma once
 #pragma once
 #include "BsCorePrerequisites.h"
 #include "BsCorePrerequisites.h"
-
-#include <memory>
-
 #include "BsSamplerState.h"
 #include "BsSamplerState.h"
 #include "BsCommandQueue.h"
 #include "BsCommandQueue.h"
 #include "BsDrawOps.h"
 #include "BsDrawOps.h"
@@ -18,10 +15,13 @@
 
 
 namespace BansheeEngine
 namespace BansheeEngine
 {
 {
+	/** @addtogroup RenderAPI
+	 *  @{
+	 */
+
 	/**
 	/**
-	 * @brief	Version of the render API interface usable from the sim thread. All the commands
-	 *			get queued on the accessor provided to each method and will be executed on
-	 *			the core thread later.
+	 * Version of the render API interface usable from the sim thread. All the commands	get queued on the accessor provided
+	 * to each method and will be executed on the core thread later.
 	 *
 	 *
 	 * @see		RenderAPICore
 	 * @see		RenderAPICore
 	 *
 	 *
@@ -140,10 +140,11 @@ namespace BansheeEngine
 		static bool getVertexColorFlipRequired();
 		static bool getVertexColorFlipRequired();
 	};
 	};
 
 
+	/** @cond INTERNAL */
+
 	/**
 	/**
-	 * @brief	Render system provides base functionality for a rendering API like
-	 *			DirectX or OpenGL. Most of the class is abstract and specific
-	 *			subclass for each rendering API needs to be implemented.
+	 * Render system provides base functionality for a rendering API like DirectX or OpenGL. Most of the class is abstract
+	 * and specific subclass for each rendering API needs to be implemented.
 	 *
 	 *
 	 * @note	Core thread only unless specifically noted otherwise on per-method basis.
 	 * @note	Core thread only unless specifically noted otherwise on per-method basis.
 	 */
 	 */
@@ -154,226 +155,190 @@ namespace BansheeEngine
 		virtual ~RenderAPICore();
 		virtual ~RenderAPICore();
 
 
 		/**
 		/**
-		 * @brief	Returns the name of the rendering system. 
+		 * Returns the name of the rendering system. 
 		 *
 		 *
 		 * @note	Thread safe.
 		 * @note	Thread safe.
 		 */
 		 */
 		virtual const StringID& getName() const = 0;
 		virtual const StringID& getName() const = 0;
 
 
 		/**
 		/**
-		 * @brief	Gets the name of the primary shading language
-		 *			used by the rendering system.
+		 * Gets the name of the primary shading language used by the rendering system.
 		 *
 		 *
 		 * @note	Thread safe.
 		 * @note	Thread safe.
 		 */
 		 */
 		virtual const String& getShadingLanguageName() const = 0;
 		virtual const String& getShadingLanguageName() const = 0;
 
 
 		/**
 		/**
-		 * @brief	Sets a sampler state for the specified texture unit.
+		 * Sets a sampler state for the specified texture unit.
 		 *
 		 *
 		 * @see		SamplerState
 		 * @see		SamplerState
 		 */
 		 */
 		virtual void setSamplerState(GpuProgramType gptype, UINT16 texUnit, const SPtr<SamplerStateCore>& samplerState) = 0;
 		virtual void setSamplerState(GpuProgramType gptype, UINT16 texUnit, const SPtr<SamplerStateCore>& samplerState) = 0;
 
 
 		/**
 		/**
-		 * @brief	Sets a blend state used for all active render targets.
+		 * Sets a blend state used for all active render targets.
 		 *
 		 *
 		 * @see		BlendState
 		 * @see		BlendState
 		 */
 		 */
 		virtual void setBlendState(const SPtr<BlendStateCore>& blendState) = 0;
 		virtual void setBlendState(const SPtr<BlendStateCore>& blendState) = 0;
 
 
 		/**
 		/**
-		 * @brief	Sets a state that controls various rasterizer options. 
+		 * Sets a state that controls various rasterizer options. 
 		 *
 		 *
 		 * @see		RasterizerState
 		 * @see		RasterizerState
 		 */
 		 */
 		virtual void setRasterizerState(const SPtr<RasterizerStateCore>& rasterizerState) = 0;
 		virtual void setRasterizerState(const SPtr<RasterizerStateCore>& rasterizerState) = 0;
 
 
 		/**
 		/**
-		 * @brief	Sets a state that controls depth & stencil buffer options.
+		 * Sets a state that controls depth & stencil buffer options.
 		 *
 		 *
 		 * @see		DepthStencilState
 		 * @see		DepthStencilState
 		 */
 		 */
 		virtual void setDepthStencilState(const SPtr<DepthStencilStateCore>& depthStencilState, UINT32 stencilRefValue) = 0;
 		virtual void setDepthStencilState(const SPtr<DepthStencilStateCore>& depthStencilState, UINT32 stencilRefValue) = 0;
 
 
 		/**
 		/**
-		 * @brief	Binds a texture to the pipeline for the specified GPU program type at the specified slot.
-		 *			If the slot matches the one configured in the GPU program the program will be able to access
-		 *			this texture on the GPU.
+		 * Binds a texture to the pipeline for the specified GPU program type at the specified slot. If the slot matches 
+		 * the one configured in the GPU program the program will be able to access this texture on the GPU.
 		 */
 		 */
 		virtual void setTexture(GpuProgramType gptype, UINT16 unit, bool enabled, const SPtr<TextureCore>& texPtr) = 0;
 		virtual void setTexture(GpuProgramType gptype, UINT16 unit, bool enabled, const SPtr<TextureCore>& texPtr) = 0;
 
 
-		/**
-		* @brief	Turns off a texture unit.
-		*/
+		/**	Turns off a texture unit. */
 		virtual void disableTextureUnit(GpuProgramType gptype, UINT16 texUnit);
 		virtual void disableTextureUnit(GpuProgramType gptype, UINT16 texUnit);
 
 
-		/**
-		 * @brief	Binds a texture that can be used for random load/store operations from a GPU program.
-		 */
+		/**	Binds a texture that can be used for random load/store operations from a GPU program. */
 		virtual void setLoadStoreTexture(GpuProgramType gptype, UINT16 unit, bool enabled, 
 		virtual void setLoadStoreTexture(GpuProgramType gptype, UINT16 unit, bool enabled, 
 			const SPtr<TextureCore>& texPtr, const TextureSurface& surface) = 0;
 			const SPtr<TextureCore>& texPtr, const TextureSurface& surface) = 0;
 
 
 		/**
 		/**
-		 * @brief	Signals that rendering for a specific viewport has started. Any draw calls
-		 *			need to be called between beginFrame and endFrame. You may not switch render targets
-		 *			until you call endFrame.
+		 * Signals that rendering for a specific viewport has started. Any draw calls need to be called between beginFrame()
+		 * and endFrame(). 
 		 */
 		 */
 		virtual void beginFrame() = 0;
 		virtual void beginFrame() = 0;
 		
 		
-		/**
-		 * @brief	Ends that rendering to a specific viewport has ended.
-		 */
+		/** Ends that rendering to a specific viewport has ended. */
 		virtual void endFrame() = 0;
 		virtual void endFrame() = 0;
 
 
 		/**
 		/**
-		 * @brief	Sets the active viewport that will be used for all render operations.
+		 * Sets the active viewport that will be used for all render operations.
 		 *
 		 *
-		 * @param	area	Area of the viewport, in normalized ([0,1] range) coordinates.
+		 * @param[in]	area	Area of the viewport, in normalized ([0,1] range) coordinates.
 		 */
 		 */
 		virtual void setViewport(const Rect2& area) = 0;
 		virtual void setViewport(const Rect2& area) = 0;
 
 
 		/**
 		/**
-		 * @brief	Sets the provided vertex buffers starting at the specified source index.
-		 *			Set buffer to nullptr to clear the buffer at the specified index.
+		 * Sets the provided vertex buffers starting at the specified source index.	Set buffer to nullptr to clear the 
+		 * buffer at the specified index.
 		 */
 		 */
 		virtual void setVertexBuffers(UINT32 index, SPtr<VertexBufferCore>* buffers, UINT32 numBuffers) = 0;
 		virtual void setVertexBuffers(UINT32 index, SPtr<VertexBufferCore>* buffers, UINT32 numBuffers) = 0;
 
 
 		/**
 		/**
-		 * @brief	Sets an index buffer to use when drawing. Indices in an index buffer
-		 * 			reference vertices in the vertex buffer, which increases cache coherency
-		 * 			and reduces the size of vertex buffers by eliminating duplicate data.
+		 * Sets an index buffer to use when drawing. Indices in an index buffer reference vertices in the vertex buffer, 
+		 * which increases cache coherency and reduces the size of vertex buffers by eliminating duplicate data.
 		 */
 		 */
 		virtual void setIndexBuffer(const SPtr<IndexBufferCore>& buffer) = 0;
 		virtual void setIndexBuffer(const SPtr<IndexBufferCore>& buffer) = 0;
 
 
 		/**
 		/**
-		 * @brief	Sets the vertex declaration to use when drawing. Vertex declaration
-		 * 			is used to decode contents of a single vertex in a vertex buffer.
+		 * Sets the vertex declaration to use when drawing. Vertex declaration is used to decode contents of a single 
+		 * vertex in a vertex buffer.
 		 */
 		 */
 		virtual void setVertexDeclaration(const SPtr<VertexDeclarationCore>& vertexDeclaration) = 0;
 		virtual void setVertexDeclaration(const SPtr<VertexDeclarationCore>& vertexDeclaration) = 0;
 
 
-		/**
-		 * @brief	Sets the draw operation that determines how to interpret the elements
-		 * 			of the index or vertex buffers.
-		 */
+		/** Sets the draw operation that determines how to interpret the elements of the index or vertex buffers. */
 		virtual void setDrawOperation(DrawOperationType op) = 0;
 		virtual void setDrawOperation(DrawOperationType op) = 0;
 
 
 		/**
 		/**
-		 * @brief	Draw an object based on currently bound GPU programs, vertex declaration and vertex buffers.
-		 * 			
-		 *			Draws directly from the vertex buffer without using indices.
+		 * Draw an object based on currently bound GPU programs, vertex declaration and vertex buffers. Draws directly from
+		 * the vertex buffer without using indices.
 		 */
 		 */
 		virtual void draw(UINT32 vertexOffset, UINT32 vertexCount) = 0;
 		virtual void draw(UINT32 vertexOffset, UINT32 vertexCount) = 0;
 
 
-		/**
-		 * @brief	Draw an object based on currently bound GPU programs, vertex declaration, vertex 
-		 * 			and index buffers.
-		 */
+		/** Draw an object based on currently bound GPU programs, vertex declaration, vertex and index buffers. */
 		virtual void drawIndexed(UINT32 startIndex, UINT32 indexCount, UINT32 vertexOffset, UINT32 vertexCount) = 0;
 		virtual void drawIndexed(UINT32 startIndex, UINT32 indexCount, UINT32 vertexOffset, UINT32 vertexCount) = 0;
 
 
-		/**
-		 * @brief	Swap the front and back buffer of the specified render target.
-		 */
+		/** Swap the front and back buffer of the specified render target. */
 		virtual void swapBuffers(const SPtr<RenderTargetCore>& target);
 		virtual void swapBuffers(const SPtr<RenderTargetCore>& target);
 
 
 		/**
 		/**
-		 * @brief	Gets the capabilities of the render system.
+		 * Gets the capabilities of the render system.
 		 *
 		 *
 		 * @note	Thread safe.
 		 * @note	Thread safe.
 		 */
 		 */
 		const RenderAPICapabilities* getCapabilities() const;
 		const RenderAPICapabilities* getCapabilities() const;
 
 
-		/**
-		 * @brief	Returns information about the driver version.
-		 */
+		/** Returns information about the driver version. */
 		virtual const DriverVersion& getDriverVersion() const;
 		virtual const DriverVersion& getDriverVersion() const;
 
 
 		/**
 		/**
-		 * @brief	Binds the provided GPU program to the pipeline. Any following
-		 *			draw operations will use this program. 
+		 * Binds the provided GPU program to the pipeline. Any following draw operations will use this program. 
 		 *
 		 *
 		 * @note	You need to bind at least a vertex and a fragment program in order to draw something.
 		 * @note	You need to bind at least a vertex and a fragment program in order to draw something.
 		 */
 		 */
 		virtual void bindGpuProgram(const SPtr<GpuProgramCore>& prg);
 		virtual void bindGpuProgram(const SPtr<GpuProgramCore>& prg);
 
 
 		/**
 		/**
-		 * @brief	Binds constant(uniform) GPU program parameters. Caller must ensure these match the previously
-		 *			bound GPU program.
+		 * Binds constant(uniform) GPU program parameters. Caller must ensure these match the previously bound GPU program.
 		 */
 		 */
 		virtual void setConstantBuffers(GpuProgramType gptype, const SPtr<GpuParamsCore>& params) = 0;
 		virtual void setConstantBuffers(GpuProgramType gptype, const SPtr<GpuParamsCore>& params) = 0;
 
 
-		/**
-		 * @brief	Binds all specified GPU program parameters. Caller must ensure these match the previously
-		 *			bound GPU program.
-		 */
+		/** Binds all specified GPU program parameters. Caller must ensure these match the previously bound GPU program. */
 		virtual void setGpuParams(GpuProgramType gptype, const SPtr<GpuParamsCore>& params);
 		virtual void setGpuParams(GpuProgramType gptype, const SPtr<GpuParamsCore>& params);
 
 
-		/**
-		 * @brief	Unbinds a program of a given type. 
-		 */
+		/**	Unbinds a program of a given type. */
 		virtual void unbindGpuProgram(GpuProgramType gptype);
 		virtual void unbindGpuProgram(GpuProgramType gptype);
 
 
-		/**
-		 * @brief	Query if a GPU program of a given type is currently bound.
-		 */
+		/**	Query if a GPU program of a given type is currently bound. */
 		virtual bool isGpuProgramBound(GpuProgramType gptype);
 		virtual bool isGpuProgramBound(GpuProgramType gptype);
 
 
-		/**
-		 * @brief	Sets up clip planes that will clip drawn geometry on the negative side of the planes.
-		 */
+		/**	Sets up clip planes that will clip drawn geometry on the negative side of the planes. */
 		virtual void setClipPlanes(const PlaneList& clipPlanes);
 		virtual void setClipPlanes(const PlaneList& clipPlanes);
 
 
-		/**
-		 * @brief	Adds a new clip plane. All drawn geometry will be clipped to this plane.
-		 */
+		/**	Adds a new clip plane. All drawn geometry will be clipped to this plane. */
 		virtual void addClipPlane(const Plane& p);
 		virtual void addClipPlane(const Plane& p);
 
 
-		/**
-		 * @brief	Clears all clip planes.
-		 */
+		/**	Clears all clip planes. */
 		virtual void resetClipPlanes();
 		virtual void resetClipPlanes();
 
 
 		/**
 		/**
-		 * @brief	Allows you to set up a region in which rendering can take place. Coordinates are in pixels.
-		 *			No rendering will be done to render target pixels outside of the provided region.
+		 * Allows you to set up a region in which rendering can take place. Coordinates are in pixels. No rendering will be
+		 * done to render target pixels outside of the provided region.
 		 */
 		 */
 		virtual void setScissorRect(UINT32 left, UINT32 top, UINT32 right, UINT32 bottom) = 0;
 		virtual void setScissorRect(UINT32 left, UINT32 top, UINT32 right, UINT32 bottom) = 0;
 
 
 		/**
 		/**
-		 * @brief	Clears the currently active render target.
+		 * Clears the currently active render target.
 		 *
 		 *
-		 * @param	buffers			Combination of one or more elements of FrameBufferType
-		 *							denoting which buffers are to be cleared.
-		 * @param	color			(optional) The color to clear the color buffer with, if enabled.
-		 * @param	depth			(optional) The value to initialize the depth buffer with, if enabled.
-		 * @param	stencil			(optional) The value to initialize the stencil buffer with, if enabled.
+		 * @param[in]	buffers		Combination of one or more elements of FrameBufferType denoting which buffers are 
+		 *							to be cleared.
+		 * @param[in]	color		(optional) The color to clear the color buffer with, if enabled.
+		 * @param[in]	depth		(optional) The value to initialize the depth buffer with, if enabled.
+		 * @param[in]	stencil		(optional) The value to initialize the stencil buffer with, if enabled.
 		 */
 		 */
 		virtual void clearRenderTarget(UINT32 buffers, const Color& color = Color::Black, float depth = 1.0f, UINT16 stencil = 0) = 0;
 		virtual void clearRenderTarget(UINT32 buffers, const Color& color = Color::Black, float depth = 1.0f, UINT16 stencil = 0) = 0;
 
 
 		/**
 		/**
-		 * @brief	Clears the currently active viewport (i.e. it clears just a sub-area of a render-target that is covered by the viewport,
-		 * 			as opposed to clearRenderTarget which always clears the entire render target).
+		 * Clears the currently active viewport (i.e. it clears just a sub-area of a render-target that is covered by the 
+		 * viewport, as opposed to clearRenderTarget() which always clears the entire render target).
 		 *
 		 *
-		 * @param	buffers			Combination of one or more elements of FrameBufferType
-		 *							denoting which buffers are to be cleared.
-		 * @param	color			(optional) The color to clear the color buffer with, if enabled.
-		 * @param	depth			(optional) The value to initialize the depth buffer with, if enabled.
-		 * @param	stencil			(optional) The value to initialize the stencil buffer with, if enabled.
+		 * @param[in]	buffers		Combination of one or more elements of FrameBufferType denoting which buffers are to be
+		 *							cleared.
+		 * @param[in]	color		(optional) The color to clear the color buffer with, if enabled.
+		 * @param[in]	depth		(optional) The value to initialize the depth buffer with, if enabled.
+		 * @param[in]	stencil		(optional) The value to initialize the stencil buffer with, if enabled.
 		 */
 		 */
 		virtual void clearViewport(UINT32 buffers, const Color& color = Color::Black, float depth = 1.0f, UINT16 stencil = 0) = 0;
 		virtual void clearViewport(UINT32 buffers, const Color& color = Color::Black, float depth = 1.0f, UINT16 stencil = 0) = 0;
 
 
 		/**
 		/**
-		 * @brief	Change the render target into which we want to draw.
+		 * Change the render target into which we want to draw.
 		 *
 		 *
-		 * @param	target					Render target to draw to.
-		 * @param	readOnlyDepthStencil	If true the caller guarantees he won't write to the depth/stencil buffer (if 
-		 *									any was provided). This allows the depth buffer to be bound for depth testing, 
-		 *									as well as reading in a shader, at the same time.
+		 * @param[in]	target					Render target to draw to.
+		 * @param[in]	readOnlyDepthStencil	If true the caller guarantees he won't write to the depth/stencil buffer 
+		 *										(if any was provided). This allows the depth buffer to be bound for depth 
+		 *										testing, as well as reading in a shader, at the same time.
 		 */
 		 */
         virtual void setRenderTarget(const SPtr<RenderTargetCore>& target, bool readOnlyDepthStencil = false) = 0;
         virtual void setRenderTarget(const SPtr<RenderTargetCore>& target, bool readOnlyDepthStencil = false) = 0;
 
 
 		/**
 		/**
-		 * @brief	Returns information about available output devices and their video modes.
+		 * Returns information about available output devices and their video modes.
 		 *
 		 *
 		 * @note	Thread safe.
 		 * @note	Thread safe.
 		 */
 		 */
@@ -384,75 +349,67 @@ namespace BansheeEngine
 		/************************************************************************/
 		/************************************************************************/
 
 
 		/**
 		/**
-		 * @brief	Gets the native type used for vertex colors.
+		 * Gets the native type used for vertex colors.
 		 *
 		 *
 		 * @note	Thread safe.
 		 * @note	Thread safe.
 		 */
 		 */
 		virtual VertexElementType getColorVertexElementType() const = 0;
 		virtual VertexElementType getColorVertexElementType() const = 0;
 
 
 		/**
 		/**
-		 * @brief	Contains a default matrix into a matrix suitable for use
-		 *			by this specific render system.
+		 * Contains a default matrix into a matrix suitable for use by this specific render system.
 		 *
 		 *
 		 * @note	Thread safe.
 		 * @note	Thread safe.
 		 */
 		 */
 		virtual void convertProjectionMatrix(const Matrix4& matrix, Matrix4& dest) = 0;
 		virtual void convertProjectionMatrix(const Matrix4& matrix, Matrix4& dest) = 0;
 
 
 		/**
 		/**
-		 * @brief	Gets horizontal texel offset used for mapping texels to pixels
-		 *			in this render system.
+		 * Gets horizontal texel offset used for mapping texels to pixels in this render system.
 		 *
 		 *
 		 * @note	Thread safe.
 		 * @note	Thread safe.
 		 */
 		 */
 		virtual float getHorizontalTexelOffset() = 0;
 		virtual float getHorizontalTexelOffset() = 0;
 
 
 		/**
 		/**
-		 * @brief	Gets vertical texel offset used for mapping texels to pixels
-		 *			in this render system.
+		 * Gets vertical texel offset used for mapping texels to pixels in this render system.
 		 *
 		 *
 		 * @note		Thread safe.
 		 * @note		Thread safe.
 		 */
 		 */
 		virtual float getVerticalTexelOffset() = 0;
 		virtual float getVerticalTexelOffset() = 0;
 
 
 		/**
 		/**
-		 * @brief	Gets the minimum (closest) depth value used by this
-		 *			render system.
+		 * Gets the minimum (closest) depth value used by this render system.
 		 *
 		 *
 		 * @note	Thread safe.
 		 * @note	Thread safe.
 		 */
 		 */
 		virtual float getMinimumDepthInputValue() = 0;
 		virtual float getMinimumDepthInputValue() = 0;
 
 
 		/**
 		/**
-		 * @brief	Gets the maximum (farthest) depth value used by this
-		 *			render system.
+		 * Gets the maximum (farthest) depth value used by this render system.
 		 *
 		 *
 		 * @note	Thread safe.
 		 * @note	Thread safe.
 		 */
 		 */
 		virtual float getMaximumDepthInputValue() = 0;
 		virtual float getMaximumDepthInputValue() = 0;
 
 
 		/**
 		/**
-		 * @brief	Checks if vertex color needs to be flipped before sent to the shader.
+		 * Checks if vertex color needs to be flipped before sent to the shader.
 		 *
 		 *
 		 * @note	Thread safe.
 		 * @note	Thread safe.
 		 */
 		 */
 		virtual bool getVertexColorFlipRequired() const { return false; }
 		virtual bool getVertexColorFlipRequired() const { return false; }
 
 
-		/**
-		 * @brief	Checks whether GPU programs expect matrices in column major format.
-		 */
+		/** Checks whether GPU programs expect matrices in column major format. */
 		virtual bool getGpuProgramHasColumnMajorMatrices() const { return false; }
 		virtual bool getGpuProgramHasColumnMajorMatrices() const { return false; }
 
 
 		/**
 		/**
-		 * @brief	Generates a parameter block description and calculates per-parameter offsets for the provided gpu
-		 * 			data parameters. The offsets are render API specific and correspond to std140 layout for OpenGL, and
-		 * 			the default layout in DirectX.
+		 * Generates a parameter block description and calculates per-parameter offsets for the provided gpu data 
+		 * parameters. The offsets are render API specific and correspond to std140 layout for OpenGL, and the default 
+		 * layout in DirectX.
 		 * 			
 		 * 			
-		 * @param	name	Name to assign the parameter block.
-		 * @param	params	List of parameters in the parameter block. Only name, type and array size fields need to be
-		 * 					populated, the rest will be populated when the method returns.
-		 * 					
-		 * @returns	Descriptor for the parameter block holding the provided parameters as laid out by the default render
-		 * 			API layout.
+		 * @param[in]	name	Name to assign the parameter block.
+		 * @param[in]	params	List of parameters in the parameter block. Only name, type and array size fields need to be
+		 * 						populated, the rest will be populated when the method returns.		
+		 * @return				Descriptor for the parameter block holding the provided parameters as laid out by the 
+		 *						default render API layout.
 		 */
 		 */
 		virtual GpuParamBlockDesc generateParamBlockDesc(const String& name, Vector<GpuParamDataDesc>& params) = 0;
 		virtual GpuParamBlockDesc generateParamBlockDesc(const String& name, Vector<GpuParamDataDesc>& params) = 0;
 
 
@@ -461,42 +418,39 @@ namespace BansheeEngine
 		/************************************************************************/
 		/************************************************************************/
 	protected:
 	protected:
 		/**
 		/**
-		 * @brief	Initializes the render API system and creates a primary render window.
+		 * Initializes the render API system and creates a primary render window.
 		 *
 		 *
-		 * @note	Although I'd like otherwise, due to the nature of some render API implementations,
-		 * 			you cannot initialize the render system without a window.
-		 *
-		 *			Sim thread.
+		 * @note	
+		 * Although I'd like otherwise, due to the nature of some render API implementations, you cannot initialize the 
+		 * render system without a window.
+		 * @note
+		 * Sim thread.
 		 */
 		 */
 		RenderWindowPtr initialize(const RENDER_WINDOW_DESC& primaryWindowDesc);
 		RenderWindowPtr initialize(const RENDER_WINDOW_DESC& primaryWindowDesc);
 
 
 		/**
 		/**
-		 * @brief	Prepares the initialization of the render API system on the core thread. After
-		 *			the system is prepared a render window can be created and initialization finalized.
+		 * Prepares the initialization of the render API system on the core thread. After the system is prepared a render 
+		 * window can be created and initialization finalized.
 		 */
 		 */
 		virtual void initializePrepare();
 		virtual void initializePrepare();
 
 
 		/**
 		/**
-		 * @brief	Finalizes the initialization of the render API system on the core thread. 
-		 *			Should be called after the primary render window is created.
+		 * Finalizes the initialization of the render API system on the core thread. Should be called after the primary 
+		 * render window is created.
 		 */
 		 */
 		virtual void initializeFinalize(const SPtr<RenderWindowCore>& primaryWindow);
 		virtual void initializeFinalize(const SPtr<RenderWindowCore>& primaryWindow);
 
 
 		/**
 		/**
-		 * @brief	Shuts down the render API system and cleans up all resources.
+		 * Shuts down the render API system and cleans up all resources.
 		 *
 		 *
 		 * @note	Sim thread.
 		 * @note	Sim thread.
 		 */
 		 */
 		void destroy();
 		void destroy();
 
 
-		/**
-		 * @brief	Performs render API system shutdown on the core thread.
-		 */
+		/** Performs render API system shutdown on the core thread. */
 		virtual void destroyCore();
 		virtual void destroyCore();
 
 
-		/**
-		 * @copydoc	setClipPlanes.
-		 */
+		/** @copydoc setClipPlanes */
 		virtual void setClipPlanesImpl(const PlaneList& clipPlanes) = 0;
 		virtual void setClipPlanesImpl(const PlaneList& clipPlanes) = 0;
 
 
 		/************************************************************************/
 		/************************************************************************/
@@ -524,4 +478,7 @@ namespace BansheeEngine
 		RenderAPICapabilities* mCurrentCapabilities;
 		RenderAPICapabilities* mCurrentCapabilities;
 		VideoModeInfoPtr mVideoModeInfo;
 		VideoModeInfoPtr mVideoModeInfo;
 	};
 	};
+
+	/** @endcond */
+	/** @} */
 }
 }

+ 73 - 192
BansheeCore/Include/BsRenderAPICapabilities.h

@@ -12,7 +12,12 @@
 
 
 namespace BansheeEngine 
 namespace BansheeEngine 
 {
 {
-	/// Enumerates the categories of capabilities
+	/** @cond INTERNAL */
+	/** @addtogroup RenderAPI
+	 *  @{
+	 */
+
+	/** Categories of render API capabilities. */
 	enum CapabilitiesCategory : UINT64
 	enum CapabilitiesCategory : UINT64
 	{
 	{
 		CAPS_CATEGORY_COMMON = 0,
 		CAPS_CATEGORY_COMMON = 0,
@@ -22,9 +27,7 @@ namespace BansheeEngine
 		CAPS_CATEGORY_COUNT = 32 /**< Maximum number of categories. */
 		CAPS_CATEGORY_COUNT = 32 /**< Maximum number of categories. */
 	};
 	};
 
 
-	/**
-	 * @brief	Enum describing the different hardware capabilities we can check for.
-	 */
+	/** Enum describing the different hardware capabilities we can check for. */
 	enum Capabilities : UINT64
 	enum Capabilities : UINT64
 	{
 	{
 		RSC_AUTOMIPMAP				= BS_CAPS_VALUE(CAPS_CATEGORY_COMMON, 0), /**< Supports generating mipmaps in hardware. */
 		RSC_AUTOMIPMAP				= BS_CAPS_VALUE(CAPS_CATEGORY_COMMON, 0), /**< Supports generating mipmaps in hardware. */
@@ -68,9 +71,7 @@ namespace BansheeEngine
 		RSC_PBUFFER			 = BS_CAPS_VALUE(CAPS_CATEGORY_GL, 1), /**< Support for PBuffers. */
 		RSC_PBUFFER			 = BS_CAPS_VALUE(CAPS_CATEGORY_GL, 1), /**< Support for PBuffers. */
 	};
 	};
 
 
-	/**
-	 * @brief	Holds data about render system driver version.
-	 */
+	/** Holds data about render system driver version. */
 	struct BS_CORE_EXPORT DriverVersion 
 	struct BS_CORE_EXPORT DriverVersion 
 	{
 	{
 		int major;
 		int major;
@@ -83,9 +84,7 @@ namespace BansheeEngine
 			major = minor = release = build = 0;
 			major = minor = release = build = 0;
 		}
 		}
 
 
-		/**
-		 * @brief	Returns the driver version as a single string.
-		 */
+		/**	Returns the driver version as a single string. */
 		String toString() const 
 		String toString() const 
 		{
 		{
 			StringStream str;
 			StringStream str;
@@ -93,10 +92,7 @@ namespace BansheeEngine
 			return str.str();
 			return str.str();
 		}
 		}
 
 
-		/**
-		 * @brief	Parses a string in the major.minor.release.build format
-		 *			and stores the version numbers.
-		 */
+		/** Parses a string in the major.minor.release.build format and stores the version numbers. */
 		void fromString(const String& versionString)
 		void fromString(const String& versionString)
 		{
 		{
 			Vector<BansheeEngine::String> tokens = StringUtil::split(versionString, ".");
 			Vector<BansheeEngine::String> tokens = StringUtil::split(versionString, ".");
@@ -114,22 +110,19 @@ namespace BansheeEngine
 		}
 		}
 	};
 	};
 
 
-	/**
-	 * @brief	Types of GPU vendors
-	 */
+	/** Types of GPU vendors. */
 	enum GPUVendor
 	enum GPUVendor
 	{
 	{
 		GPU_UNKNOWN = 0,
 		GPU_UNKNOWN = 0,
 		GPU_NVIDIA = 1,
 		GPU_NVIDIA = 1,
 		GPU_AMD = 2, 
 		GPU_AMD = 2, 
 		GPU_INTEL = 3,
 		GPU_INTEL = 3,
-
 		GPU_VENDOR_COUNT = 4
 		GPU_VENDOR_COUNT = 4
 	};
 	};
 
 
 	/**
 	/**
-	 * @brief	Holds information about render hardware and driver capabilities
-	 *			and allows you to easily set and query those capabilities.
+	 * Holds information about render hardware and driver capabilities and allows you to easily set and query those 
+	 * capabilities.
 	 */
 	 */
 	class BS_CORE_EXPORT RenderAPICapabilities
 	class BS_CORE_EXPORT RenderAPICapabilities
 	{
 	{
@@ -137,108 +130,79 @@ namespace BansheeEngine
 		RenderAPICapabilities ();
 		RenderAPICapabilities ();
 		virtual ~RenderAPICapabilities ();
 		virtual ~RenderAPICapabilities ();
 
 
-		/**
-		 * @brief	Sets the current driver version.
-		 */
+		/** Sets the current driver version. */
 		void setDriverVersion(const DriverVersion& version)
 		void setDriverVersion(const DriverVersion& version)
 		{
 		{
 			mDriverVersion = version;
 			mDriverVersion = version;
 		}
 		}
 		
 		
-		/**
-		 * @brief	Returns current driver version.
-		 */
+		/**	Returns current driver version. */
 		DriverVersion getDriverVersion() const
 		DriverVersion getDriverVersion() const
 		{
 		{
 			return mDriverVersion;
 			return mDriverVersion;
 		}
 		}
 
 
-		/**
-		 * @brief	Returns vendor of the currently used GPU.
-		 */
+		/**	Returns vendor of the currently used GPU. */
 		GPUVendor getVendor() const
 		GPUVendor getVendor() const
 		{
 		{
 			return mVendor;
 			return mVendor;
 		}
 		}
 
 
-		/**
-		 * @brief	Sets the GPU vendor.
-		 */
+		/**	Sets the GPU vendor. */
 		void setVendor(GPUVendor v)
 		void setVendor(GPUVendor v)
 		{
 		{
 			mVendor = v;
 			mVendor = v;
 		}
 		}
 
 
-		/**
-		 * @brief	Parses a vendor string and returns an enum with the vendor
-		 *			if parsed succesfully.
-		 */
+		/** Parses a vendor string and returns an enum with the vendor if parsed succesfully. */
 		static GPUVendor vendorFromString(const String& vendorString);
 		static GPUVendor vendorFromString(const String& vendorString);
 
 
-		/**
-		 * @brief	Converts a vendor enum to a string.
-		 */
+		/** Converts a vendor enum to a string. */
 		static String vendorToString(GPUVendor v);
 		static String vendorToString(GPUVendor v);
 
 
-		/**
-		 * @brief	Sets the maximum number of texture units per pipeline stage.
-		 */
+		/**	Sets the maximum number of texture units per pipeline stage. */
 		void setNumTextureUnits(GpuProgramType type, UINT16 num)
 		void setNumTextureUnits(GpuProgramType type, UINT16 num)
 		{
 		{
 			mNumTextureUnitsPerStage[type] = num;
 			mNumTextureUnitsPerStage[type] = num;
 		}
 		}
 
 
-		/**
-		 * @brief	Sets the maximum number of texture units in all pipeline stages.
-		 */
+		/** Sets the maximum number of texture units in all pipeline stages. */
 		void setNumCombinedTextureUnits(UINT16 num)
 		void setNumCombinedTextureUnits(UINT16 num)
 		{
 		{
 			mNumCombinedTextureUnits = num;
 			mNumCombinedTextureUnits = num;
 		}
 		}
 
 
-		/**
-		 * @brief	Sets the maximum number of GPU param block buffers per pipeline stage.
-		 */
+		/**	Sets the maximum number of GPU param block buffers per pipeline stage. */
 		void setNumGpuParamBlockBuffers(GpuProgramType type, UINT16 num)
 		void setNumGpuParamBlockBuffers(GpuProgramType type, UINT16 num)
 		{
 		{
 			mNumGpuParamBlocksPerStage[type] = num;
 			mNumGpuParamBlocksPerStage[type] = num;
 		}
 		}
 
 
-		/**
-		 * @brief	Sets the maximum number of GPU param block buffers in all pipeline stages.
-		 */
+		/**	Sets the maximum number of GPU param block buffers in all pipeline stages. */
 		void setNumCombinedGpuParamBlockBuffers(UINT16 num)
 		void setNumCombinedGpuParamBlockBuffers(UINT16 num)
 		{
 		{
 			mNumCombinedUniformBlocks = num;
 			mNumCombinedUniformBlocks = num;
 		}
 		}
 
 
-		/**
-		 * @brief	Sets maximum stencil buffer depth in bits.
-		 */
+		/**	Sets maximum stencil buffer depth in bits. */
 		void setStencilBufferBitDepth(UINT16 num)
 		void setStencilBufferBitDepth(UINT16 num)
 		{
 		{
 			mStencilBufferBitDepth = num;
 			mStencilBufferBitDepth = num;
 		}
 		}
 
 
-		/**
-		 * @brief	Sets maximum number of bound vertex buffers.
-		 */
+		/**	Sets maximum number of bound vertex buffers. */
 		void setMaxBoundVertexBuffers(UINT32 num)
 		void setMaxBoundVertexBuffers(UINT32 num)
 		{
 		{
 			mMaxBoundVertexBuffers = num;
 			mMaxBoundVertexBuffers = num;
 		}
 		}
 
 
-		/**
-		 * @brief	Sets maximum number of simultaneously set render targets.
-		 */
+		/**	Sets maximum number of simultaneously set render targets. */
 		void setNumMultiRenderTargets(UINT16 num)
 		void setNumMultiRenderTargets(UINT16 num)
 		{
 		{
 			mNumMultiRenderTargets = num;
 			mNumMultiRenderTargets = num;
 		}
 		}
 
 
-		/**
-		 * @brief	Returns the number of texture units supported per pipeline stage.
-		 */
+		/**	Returns the number of texture units supported per pipeline stage. */
 		UINT16 getNumTextureUnits(GpuProgramType type) const
 		UINT16 getNumTextureUnits(GpuProgramType type) const
 		{
 		{
 			auto iterFind = mNumTextureUnitsPerStage.find(type);
 			auto iterFind = mNumTextureUnitsPerStage.find(type);
@@ -248,18 +212,13 @@ namespace BansheeEngine
 				return 0;
 				return 0;
 		}
 		}
 
 
-		/**
-		* @brief	Returns the number of texture units supported in all pipeline stages.
-		*/
+		/**	Returns the number of texture units supported in all pipeline stages. */
 		UINT16 getNumCombinedTextureUnits() const
 		UINT16 getNumCombinedTextureUnits() const
 		{
 		{
 			return mNumCombinedTextureUnits;
 			return mNumCombinedTextureUnits;
 		}
 		}
 
 
-		/**
-		 * @brief	Returns the maximum number of bound GPU program param block 
-		 *			buffers per pipeline stage.
-		 */
+		/**	Returns the maximum number of bound GPU program param block buffers per pipeline stage. */
 		UINT16 getNumGpuParamBlockBuffers(GpuProgramType type) const
 		UINT16 getNumGpuParamBlockBuffers(GpuProgramType type) const
 		{
 		{
 			auto iterFind = mNumGpuParamBlocksPerStage.find(type);
 			auto iterFind = mNumGpuParamBlocksPerStage.find(type);
@@ -269,64 +228,45 @@ namespace BansheeEngine
 				return 0;
 				return 0;
 		}
 		}
 
 
-		/**
-		* @brief	Returns the maximum number of bound GPU program param block
-		*			buffers in all pipeline stages.
-		*/
+		/** Returns the maximum number of bound GPU program param block buffers in all pipeline stages. */
 		UINT16 getNumCombinedGpuParamBlockBuffers() const
 		UINT16 getNumCombinedGpuParamBlockBuffers() const
 		{
 		{
 			return mNumCombinedUniformBlocks;
 			return mNumCombinedUniformBlocks;
 		}
 		}
 
 
-		/**
-		 * @brief	Returns the maximum number of bits available for
-		 *			the stencil buffer.
-		 */
+		/** Returns the maximum number of bits available for the stencil buffer. */
 		UINT16 getStencilBufferBitDepth() const
 		UINT16 getStencilBufferBitDepth() const
 		{
 		{
 			return mStencilBufferBitDepth;
 			return mStencilBufferBitDepth;
 		}
 		}
 
 
-		/**
-		 * @brief	Returns the maximum number of vertex buffers that can be bound
-		 *			at once.
-		 */
+		/** Returns the maximum number of vertex buffers that can be bound at once. */
 		UINT32 getMaxBoundVertexBuffers() const
 		UINT32 getMaxBoundVertexBuffers() const
 		{
 		{
 			return mMaxBoundVertexBuffers;
 			return mMaxBoundVertexBuffers;
 		}
 		}
 
 
-		/**
-		 * @brief	Returns the maximum number of render targets we can render to
-		 *			simultaneously.
-		 */
+		/**	Returns the maximum number of render targets we can render to simultaneously. */
 		UINT16 getNumMultiRenderTargets() const
 		UINT16 getNumMultiRenderTargets() const
 		{
 		{
 			return mNumMultiRenderTargets;
 			return mNumMultiRenderTargets;
 		}
 		}
 
 
-		/**
-		 * @brief	Sets a capability flag indicating this capability is supported.
-		 */
+		/**	Sets a capability flag indicating this capability is supported. */
 		void setCapability(const Capabilities c) 
 		void setCapability(const Capabilities c) 
 		{ 
 		{ 
 			UINT64 index = (CAPS_CATEGORY_MASK & c) >> BS_CAPS_BITSHIFT;
 			UINT64 index = (CAPS_CATEGORY_MASK & c) >> BS_CAPS_BITSHIFT;
 			mCapabilities[index] |= (c & ~CAPS_CATEGORY_MASK);
 			mCapabilities[index] |= (c & ~CAPS_CATEGORY_MASK);
 		}
 		}
 
 
-		/**
-		 * @brief	Remove a capability flag indicating this capability is 
-		 *			not supported (default).
-		 */
+		/**	Remove a capability flag indicating this capability is not supported (default). */
 		void unsetCapability(const Capabilities c) 
 		void unsetCapability(const Capabilities c) 
 		{ 
 		{ 
 			UINT64 index = (CAPS_CATEGORY_MASK & c) >> BS_CAPS_BITSHIFT;
 			UINT64 index = (CAPS_CATEGORY_MASK & c) >> BS_CAPS_BITSHIFT;
 			mCapabilities[index] &= (~c | CAPS_CATEGORY_MASK);
 			mCapabilities[index] &= (~c | CAPS_CATEGORY_MASK);
 		}
 		}
 
 
-		/**
-		 * @brief	Checks is the specified capability supported.
-		 */
+		/**	Checks is the specified capability supported. */
 		bool hasCapability(const Capabilities c) const
 		bool hasCapability(const Capabilities c) const
 		{
 		{
 			UINT64 index = (CAPS_CATEGORY_MASK & c) >> BS_CAPS_BITSHIFT;
 			UINT64 index = (CAPS_CATEGORY_MASK & c) >> BS_CAPS_BITSHIFT;
@@ -334,41 +274,33 @@ namespace BansheeEngine
 			return (mCapabilities[index] & (c & ~CAPS_CATEGORY_MASK)) != 0;
 			return (mCapabilities[index] & (c & ~CAPS_CATEGORY_MASK)) != 0;
 		}
 		}
 
 
-		/**
-		 * @brief	Adds a shader profile to the list of render-system specific supported profiles.
-		 */
+		/**	Adds a shader profile to the list of render-system specific supported profiles. */
 		void addShaderProfile(const String& profile)
 		void addShaderProfile(const String& profile)
 		{
 		{
 			mSupportedShaderProfiles.insert(profile);
 			mSupportedShaderProfiles.insert(profile);
 		}
 		}
 
 
-		/**
-		 * @brief	Adds a mapping between GPU program profile enum and render-system specific profile name.
-		 */
+		/**	Adds a mapping between GPU program profile enum and render-system specific profile name. */
 		void addGpuProgramProfile(GpuProgramProfile gpuProgProfile, const String& rsSpecificProfile)
 		void addGpuProgramProfile(GpuProgramProfile gpuProgProfile, const String& rsSpecificProfile)
 		{
 		{
 			mGenericToSpecificShaderProfileMap[gpuProgProfile] = rsSpecificProfile;
 			mGenericToSpecificShaderProfileMap[gpuProgProfile] = rsSpecificProfile;
 		}
 		}
 
 
-		/**
-		 * @brief	Returns true if the provided profile is supported.
-		 */
+		/**	Returns true if the provided profile is supported. */
 		bool isShaderProfileSupported(const String& profile) const
 		bool isShaderProfileSupported(const String& profile) const
 		{
 		{
 			return (mSupportedShaderProfiles.end() != mSupportedShaderProfiles.find(profile));
 			return (mSupportedShaderProfiles.end() != mSupportedShaderProfiles.find(profile));
 		}
 		}
 
 
-		/**
-		 * @brief	Returns a set of all supported shader profiles.
-		 */
+		/**	Returns a set of all supported shader profiles. */
 		const Set<String>& getSupportedShaderProfiles() const
 		const Set<String>& getSupportedShaderProfiles() const
 		{
 		{
 			return mSupportedShaderProfiles;
 			return mSupportedShaderProfiles;
 		}
 		}
 
 
 		/**
 		/**
-		 * @brief	Converts a generic GpuProgramProfile identifier into a render-system specific one.  
-		 *			Returns an empty string if conversion cannot be done.
+		 * 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
 		String gpuProgProfileToRSSpecificProfile(GpuProgramProfile gpuProgProfile) const
 		{
 		{
@@ -381,222 +313,168 @@ namespace BansheeEngine
 			return "";
 			return "";
 		}
 		}
 
 
-		/**
-		 * @brief	Gets the number of floating-point constants vertex programs support.
-		 */
+		/** Gets the number of floating-point constants vertex programs support. */
 		UINT16 getVertexProgramConstantFloatCount() const
 		UINT16 getVertexProgramConstantFloatCount() const
 		{
 		{
 			return mVertexProgramConstantFloatCount;           
 			return mVertexProgramConstantFloatCount;           
 		}
 		}
 
 
-		/**
-		 * @brief	Gets the number of integer constants vertex programs support.
-		 */
+		/**	Gets the number of integer constants vertex programs support. */
 		UINT16 getVertexProgramConstantIntCount() const
 		UINT16 getVertexProgramConstantIntCount() const
 		{
 		{
 			return mVertexProgramConstantIntCount;           
 			return mVertexProgramConstantIntCount;           
 		}
 		}
 
 
-		/**
-		 * @brief	Gets the number of boolean constants vertex programs support.
-		 */
+		/**	Gets the number of boolean constants vertex programs support. */
 		UINT16 getVertexProgramConstantBoolCount() const
 		UINT16 getVertexProgramConstantBoolCount() const
 		{
 		{
 			return mVertexProgramConstantBoolCount;           
 			return mVertexProgramConstantBoolCount;           
 		}
 		}
 
 
-		/**
-		 * @brief	Gets the number of floating-point constants geometry programs support.
-		 */
+		/**	Gets the number of floating-point constants geometry programs support. */
 		UINT16 getGeometryProgramConstantFloatCount() const
 		UINT16 getGeometryProgramConstantFloatCount() const
 		{
 		{
 			return mGeometryProgramConstantFloatCount;           
 			return mGeometryProgramConstantFloatCount;           
 		}
 		}
 
 
-		/**
-		 * @brief	 Gets the number of integer constants geometry programs support.
-		 */
+		/**	 Gets the number of integer constants geometry programs support. */
 		UINT16 getGeometryProgramConstantIntCount() const
 		UINT16 getGeometryProgramConstantIntCount() const
 		{
 		{
 			return mGeometryProgramConstantIntCount;           
 			return mGeometryProgramConstantIntCount;           
 		}
 		}
 
 
-		/**
-		 * @brief	 Gets the number of boolean constants geometry programs support.
-		 */
+		/**	 Gets the number of boolean constants geometry programs support. */
 		UINT16 getGeometryProgramConstantBoolCount() const
 		UINT16 getGeometryProgramConstantBoolCount() const
 		{
 		{
 			return mGeometryProgramConstantBoolCount;           
 			return mGeometryProgramConstantBoolCount;           
 		}
 		}
 
 
-		/**
-		 * @brief	Gets the number of floating-point constants fragment programs support.
-		 */
+		/**	Gets the number of floating-point constants fragment programs support. */
 		UINT16 getFragmentProgramConstantFloatCount() const
 		UINT16 getFragmentProgramConstantFloatCount() const
 		{
 		{
 			return mFragmentProgramConstantFloatCount;           
 			return mFragmentProgramConstantFloatCount;           
 		}
 		}
 
 
-		/**
-		 * @brief	Gets the number of integer constants fragment programs support.
-		 */
+		/**	Gets the number of integer constants fragment programs support. */
 		UINT16 getFragmentProgramConstantIntCount() const
 		UINT16 getFragmentProgramConstantIntCount() const
 		{
 		{
 			return mFragmentProgramConstantIntCount;           
 			return mFragmentProgramConstantIntCount;           
 		}
 		}
 		
 		
-		/**
-		 * @brief	 Gets the number of boolean constants fragment programs support.
-		 */
+		/** Gets the number of boolean constants fragment programs support. */
 		UINT16 getFragmentProgramConstantBoolCount() const
 		UINT16 getFragmentProgramConstantBoolCount() const
 		{
 		{
 			return mFragmentProgramConstantBoolCount;           
 			return mFragmentProgramConstantBoolCount;           
 		}
 		}
 
 
-		/**
-		 * @brief	Sets the current GPU device name.
-		 */
+		/**	Sets the current GPU device name. */
 		void setDeviceName(const String& name)
 		void setDeviceName(const String& name)
 		{
 		{
 			mDeviceName = name;
 			mDeviceName = name;
 		}
 		}
 
 
-		/**
-		 * @brief	Gets the current GPU device name.
-		 */
+		/**	Gets the current GPU device name. */
 		String getDeviceName() const
 		String getDeviceName() const
 		{
 		{
 			return mDeviceName;
 			return mDeviceName;
 		}
 		}
 
 
-		/**
-		 * @brief	Sets the number of floating-point constants vertex programs support.
-		 */
+		/**	Sets the number of floating-point constants vertex programs support. */
 		void setVertexProgramConstantFloatCount(UINT16 c)
 		void setVertexProgramConstantFloatCount(UINT16 c)
 		{
 		{
 			mVertexProgramConstantFloatCount = c;           
 			mVertexProgramConstantFloatCount = c;           
 		}
 		}
 
 
-		/**
-		 * @brief	Sets the number of integer constants vertex programs support.
-		 */
+		/**	Sets the number of integer constants vertex programs support. */
 		void setVertexProgramConstantIntCount(UINT16 c)
 		void setVertexProgramConstantIntCount(UINT16 c)
 		{
 		{
 			mVertexProgramConstantIntCount = c;           
 			mVertexProgramConstantIntCount = c;           
 		}
 		}
 
 
-		/**
-		 * @brief	Sets the number of boolean constants vertex programs support.
-		 */
+		/**	Sets the number of boolean constants vertex programs support. */
 		void setVertexProgramConstantBoolCount(UINT16 c)
 		void setVertexProgramConstantBoolCount(UINT16 c)
 		{
 		{
 			mVertexProgramConstantBoolCount = c;           
 			mVertexProgramConstantBoolCount = c;           
 		}
 		}
 
 
-		/**
-		 * @brief	Sets the number of floating-point constants geometry programs support.
-		 */
+		/**	Sets the number of floating-point constants geometry programs support. */
 		void setGeometryProgramConstantFloatCount(UINT16 c)
 		void setGeometryProgramConstantFloatCount(UINT16 c)
 		{
 		{
 			mGeometryProgramConstantFloatCount = c;           
 			mGeometryProgramConstantFloatCount = c;           
 		}
 		}
 
 
-		/**
-		 * @brief	Sets the number of integer constants geometry programs support.
-		 */
+		/**	Sets the number of integer constants geometry programs support. */
 		void setGeometryProgramConstantIntCount(UINT16 c)
 		void setGeometryProgramConstantIntCount(UINT16 c)
 		{
 		{
 			mGeometryProgramConstantIntCount = c;           
 			mGeometryProgramConstantIntCount = c;           
 		}
 		}
 
 
-		/**
-		 * @brief	Sets the number of boolean constants geometry programs support.
-		 */
+		/**	Sets the number of boolean constants geometry programs support. */
 		void setGeometryProgramConstantBoolCount(UINT16 c)
 		void setGeometryProgramConstantBoolCount(UINT16 c)
 		{
 		{
 			mGeometryProgramConstantBoolCount = c;           
 			mGeometryProgramConstantBoolCount = c;           
 		}
 		}
 
 
-		/**
-		 * @brief	Sets the number of floating-point constants fragment programs support.
-		 */
+		/**	Sets the number of floating-point constants fragment programs support. */
 		void setFragmentProgramConstantFloatCount(UINT16 c)
 		void setFragmentProgramConstantFloatCount(UINT16 c)
 		{
 		{
 			mFragmentProgramConstantFloatCount = c;           
 			mFragmentProgramConstantFloatCount = c;           
 		}
 		}
 
 
-		/**
-		 * @brief	Sets the number of integer constants fragment programs support.
-		 */
+		/**	Sets the number of integer constants fragment programs support. */
 		void setFragmentProgramConstantIntCount(UINT16 c)
 		void setFragmentProgramConstantIntCount(UINT16 c)
 		{
 		{
 			mFragmentProgramConstantIntCount = c;           
 			mFragmentProgramConstantIntCount = c;           
 		}
 		}
 
 
-		/**
-		 * @brief	Sets the number of boolean constants fragment programs support.
-		 */
+		/**	Sets the number of boolean constants fragment programs support. */
 		void setFragmentProgramConstantBoolCount(UINT16 c)
 		void setFragmentProgramConstantBoolCount(UINT16 c)
 		{
 		{
 			mFragmentProgramConstantBoolCount = c;           
 			mFragmentProgramConstantBoolCount = c;           
 		}
 		}
 
 
-		/**
-		 * @brief	Sets the maximum point screen size in pixels.
-		 */
+		/**	Sets the maximum point screen size in pixels. */
 		void setMaxPointSize(float s)
 		void setMaxPointSize(float s)
 		{
 		{
 			mMaxPointSize = s;
 			mMaxPointSize = s;
 		}
 		}
 
 
-		/**
-		 * @brief	Gets the maximum point screen size in pixels.
-		 */
+		/**	Gets the maximum point screen size in pixels. */
 		float getMaxPointSize(void) const
 		float getMaxPointSize(void) const
 		{
 		{
 			return mMaxPointSize;
 			return mMaxPointSize;
 		}
 		}
 
 
-		/**
-		 * @brief	Sets the number of vertices a single geometry program run can emit.
-		 */
+		/**	Sets the number of vertices a single geometry program run can emit. */
 		void setGeometryProgramNumOutputVertices(int numOutputVertices)
 		void setGeometryProgramNumOutputVertices(int numOutputVertices)
 		{
 		{
 			mGeometryProgramNumOutputVertices = numOutputVertices;
 			mGeometryProgramNumOutputVertices = numOutputVertices;
 		}
 		}
 
 
-		/**
-		 * @brief	Gets the number of vertices a single geometry program run can emit.
-		 */
+		/**	Gets the number of vertices a single geometry program run can emit. */
 		int getGeometryProgramNumOutputVertices(void) const
 		int getGeometryProgramNumOutputVertices(void) const
 		{
 		{
 			return mGeometryProgramNumOutputVertices;
 			return mGeometryProgramNumOutputVertices;
 		}
 		}
 
 
-		/**
-		 * @brief	Get the identifier of the render system from which these capabilities were generated.
-		 */
+		/**	Get the identifier of the render system from which these capabilities were generated. */
 		StringID getRenderAPIName() const
 		StringID getRenderAPIName() const
 		{
 		{
 			return mRenderAPIName;
 			return mRenderAPIName;
 		}
 		}
 
 
-		/**
-		 * @brief	Set the identifier of the render system from which these capabilities were generated.
-		 */
+		/**	Set the identifier of the render system from which these capabilities were generated. */
 		void setRenderAPIName(const StringID& rs)
 		void setRenderAPIName(const StringID& rs)
 		{
 		{
 			mRenderAPIName = rs;
 			mRenderAPIName = rs;
 		}
 		}
 
 
 	private:
 	private:
-		/**
-		 * @brief	Initializes vendor enum -> vendor name mappings.
-		 */
+		/**	Initializes vendor enum -> vendor name mappings. */
 		static void initVendorStrings();
 		static void initVendorStrings();
 
 
 	private:
 	private:
-		static Vector<BansheeEngine::String> msGPUVendorStrings;
+		static Vector<String> msGPUVendorStrings;
 
 
 		DriverVersion mDriverVersion;
 		DriverVersion mDriverVersion;
 		GPUVendor mVendor = GPU_UNKNOWN;
 		GPUVendor mVendor = GPU_UNKNOWN;
@@ -651,4 +529,7 @@ namespace BansheeEngine
 		// Allows us to convert a generic shader profile to a render-system specific one
 		// Allows us to convert a generic shader profile to a render-system specific one
 		UnorderedMap<GpuProgramProfile, String> mGenericToSpecificShaderProfileMap;
 		UnorderedMap<GpuProgramProfile, String> mGenericToSpecificShaderProfileMap;
 	};
 	};
+
+	/** @} */
+	/** @endcond */
 }
 }

+ 24 - 23
BansheeCore/Include/BsRenderAPIFactory.h

@@ -1,24 +1,25 @@
-#pragma once
-
-#include "BsCorePrerequisites.h"
-
-namespace BansheeEngine
-{
-	/**
-	 * @brief	Factory class that you may specialize in order to start up
-	 *			a specific render system.
-	 */
-	class RenderAPIFactory
-	{
-	public:
-		/**
-		 * @brief	Creates and starts up the render system managed by this factory. 
-		 */
-		virtual void create() = 0;
-
-		/**
-		 * @brief	Returns the name of the render system this factory creates.
-		 */
-		virtual const String& name() const = 0;
-	};
+#pragma once
+
+#include "BsCorePrerequisites.h"
+
+namespace BansheeEngine
+{
+	/** @cond INTERNAL */
+	/** @addtogroup RenderAPI
+	 *  @{
+	 */
+
+	/** Factory class that you may specialize in order to start up a specific render system. */
+	class RenderAPIFactory
+	{
+	public:
+		/**	Creates and starts up the render system managed by this factory.  */
+		virtual void create() = 0;
+
+		/**	Returns the name of the render system this factory creates. */
+		virtual const String& name() const = 0;
+	};
+
+	/** @} */
+	/** @endcond */
 }
 }

+ 41 - 40
BansheeCore/Include/BsRenderAPIManager.h

@@ -1,40 +1,41 @@
-#pragma once
-
-#include "BsCorePrerequisites.h"
-#include "BsModule.h"
-#include "BsRenderAPIFactory.h"
-
-namespace BansheeEngine
-{
-	typedef std::shared_ptr<RenderAPIFactory> RenderAPIFactoryPtr;
-
-	/**
-	 * @brief	Manager that handles render system start up.
-	 */
-	class BS_CORE_EXPORT RenderAPIManager : public Module<RenderAPIManager>
-	{
-	public:
-		RenderAPIManager();
-		~RenderAPIManager();
-
-		/**
-		 * @brief	Starts the render API with the provided name and creates the primary render window.
-		 *
-		 * @param	name				Name of the render system to start. Factory for this render system must be previously
-		 *								registered.
-		 * @param	primaryWindowDesc	Contains options used for creating the primary window.
-		 *
-		 * @returns	Created render window if initialization is successful, null otherwise.
-		 */
-		RenderWindowPtr initialize(const String& name, RENDER_WINDOW_DESC& primaryWindowDesc);
-
-		/**
-		 * @brief	Registers a new render API factory responsible for creating a specific render system type.
-		 */
-		void registerFactory(RenderAPIFactoryPtr factory);
-	private:
-		Vector<RenderAPIFactoryPtr> mAvailableFactories;
-		bool mRenderAPIInitialized;
-	};
-}
-
+#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 */
+}
+

+ 258 - 335
BansheeCore/Include/BsRenderStateManager.h

@@ -1,336 +1,259 @@
-#pragma once
-
-#include "BsCorePrerequisites.h"
-#include "BsModule.h"
-#include "BsBlendState.h"
-#include "BsRasterizerState.h"
-#include "BsDepthStencilState.h"
-#include "BsSamplerState.h"
-
-namespace BansheeEngine
-{
-	/**
-	 * @brief	Handles creation of various render states.
-	 */
-	class BS_CORE_EXPORT RenderStateManager : public Module <RenderStateManager>
-	{
-	public:
-		/**
-		 * @brief	Creates and initializes a new SamplerState.
-		 */
-		SamplerStatePtr createSamplerState(const SAMPLER_STATE_DESC& desc) const;
-
-		/**
-		 * @brief	Creates and initializes a new DepthStencilState.
-		 */
-		DepthStencilStatePtr createDepthStencilState(const DEPTH_STENCIL_STATE_DESC& desc) const;
-
-		/**
-		 * @brief	Creates and initializes a new RasterizerState.
-		 */
-		RasterizerStatePtr createRasterizerState(const RASTERIZER_STATE_DESC& desc) const;
-
-		/**
-		 * @brief	Creates and initializes a new BlendState.
-		 */
-		BlendStatePtr createBlendState(const BLEND_STATE_DESC& desc) const;
-
-		/**
-		 * @brief	Creates an uninitialized sampler state. Requires manual initialization
-		 *			after creation.
-		 *
-		 * @note	Internal method.
-		 */
-		SamplerStatePtr _createSamplerStatePtr(const SAMPLER_STATE_DESC& desc) const;
-
-		/**
-		 * @brief	Creates an uninitialized depth-stencil state. Requires manual initialization
-		 *			after creation.
-		 *
-		 * @note	Internal method.
-		 */
-		DepthStencilStatePtr _createDepthStencilStatePtr(const DEPTH_STENCIL_STATE_DESC& desc) const;
-
-		/**
-		 * @brief	Creates an uninitialized rasterizer state. Requires manual initialization
-		 *			after creation.
-		 *
-		 * @note	Internal method.
-		 */
-		RasterizerStatePtr _createRasterizerStatePtr(const RASTERIZER_STATE_DESC& desc) const;
-
-		/**
-		 * @brief	Creates an uninitialized blend state. Requires manual initialization
-		 *			after creation.
-		 *
-		 * @note	Internal method.
-		 */
-		BlendStatePtr _createBlendStatePtr(const BLEND_STATE_DESC& desc) const;
-
-		/**
-		 * @brief	Gets a sampler state initialized with default options.
-		 */
-		const SamplerStatePtr& getDefaultSamplerState() const;
-
-		/**
-		 * @brief	Gets a blend state initialized with default options.
-		 */
-		const BlendStatePtr& getDefaultBlendState() const;
-
-		/**
-		 * @brief	Gets a rasterizer state initialized with default options.
-		 */
-		const RasterizerStatePtr& getDefaultRasterizerState() const;
-
-		/**
-		 * @brief	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;
-	};
-
-	/**
-	 * @brief	Handles creation of various render states.
-	 */
-	class BS_CORE_EXPORT RenderStateCoreManager : public Module<RenderStateCoreManager>
-	{
-	private:
-		/**
-		 * @brief	Contains data about a cached blend state
-		 */
-		struct CachedBlendState
-		{
-			CachedBlendState()
-				:id(0)
-			{ }
-
-			CachedBlendState(UINT32 id)
-				:id(id)
-			{ }
-
-			std::weak_ptr<BlendStateCore> state;
-			UINT32 id;
-		};
-
-		/**
-		 * @brief	Contains data about a cached blend state
-		 */
-		struct CachedRasterizerState
-		{
-			CachedRasterizerState()
-				:id(0)
-			{ }
-
-			CachedRasterizerState(UINT32 id)
-				:id(id)
-			{ }
-
-			std::weak_ptr<RasterizerStateCore> state;
-			UINT32 id;
-		};
-
-		/**
-		 * @brief	Contains data about a cached blend 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;
-
-		/**
-		 * @brief	Creates an uninitialized sampler state. Requires manual initialization
-		 *			after creation.
-		 *
-		 * @note	Internal method.
-		 */
-		SPtr<SamplerStateCore> _createSamplerState(const SAMPLER_STATE_DESC& desc) const;
-
-		/**
-		 * @brief	Creates an uninitialized depth-stencil state. Requires manual initialization
-		 *			after creation.
-		 *
-		 * @note	Internal method.
-		 */
-		SPtr<DepthStencilStateCore> _createDepthStencilState(const DEPTH_STENCIL_STATE_DESC& desc) const;
-
-		/**
-		 * @brief	Creates an uninitialized rasterizer state. Requires manual initialization
-		 *			after creation.
-		 *
-		 * @note	Internal method.
-		 */
-		SPtr<RasterizerStateCore> _createRasterizerState(const RASTERIZER_STATE_DESC& desc) const;
-
-		/**
-		 * @brief	Creates an uninitialized blend state. Requires manual initialization
-		 *			after creation.
-		 *
-		 * @note	Internal method.
-		 */
-		SPtr<BlendStateCore> _createBlendState(const BLEND_STATE_DESC& desc) const;
-
-		/**
-		 * @brief	Gets a sampler state initialized with default options.
-		 */
-		const SPtr<SamplerStateCore>& getDefaultSamplerState() const;
-
-		/**
-		 * @brief	Gets a blend state initialized with default options.
-		 */
-		const SPtr<BlendStateCore>& getDefaultBlendState() const;
-
-		/**
-		 * @brief	Gets a rasterizer state initialized with default options.
-		 */
-		const SPtr<RasterizerStateCore>& getDefaultRasterizerState() const;
-
-		/**
-		 * @brief	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:
-		/**
-		 * @brief	Triggered when a new sampler state is created. 
-		 */
-		void notifySamplerStateCreated(const SAMPLER_STATE_DESC& desc, const SPtr<SamplerStateCore>& state) const;
-
-		/**
-		 * @brief	Triggered when a new sampler state is created. 
-		 */
-		void notifyBlendStateCreated(const BLEND_STATE_DESC& desc, const CachedBlendState& state) const;
-
-		/**
-		 * @brief	Triggered when a new sampler state is created. 
-		 */
-		void notifyRasterizerStateCreated(const RASTERIZER_STATE_DESC& desc, const CachedRasterizerState& state) const;
-
-		/**
-		 * @brief	Triggered when a new sampler state is created. 
-		 */
-		void notifyDepthStencilStateCreated(const DEPTH_STENCIL_STATE_DESC& desc, const CachedDepthStencilState& state) const;
-
-		/**
-		 * @brief	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;
-
-		/**
-		 * @brief	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;
-
-				/**
-		 * @brief	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;
-
-				/**
-		 * @brief	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;
-
-		/**
-		 * @brief	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);
-	};
+#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 */
 }
 }

+ 205 - 232
BansheeCore/Include/BsRenderTarget.h

@@ -1,232 +1,205 @@
-#pragma once
-
-#include "BsCorePrerequisites.h"
-#include "BsPixelUtil.h"
-#include "BsViewport.h"
-#include "BsCoreObject.h"
-#include "BsEvent.h"
-
-namespace BansheeEngine 
-{
-	/**
-	 * @brief	Structure that contains information about
-	 *			what part of the texture represents the render surface.
-	 */
-	struct BS_CORE_EXPORT RENDER_SURFACE_DESC
-	{
-		HTexture texture;
-		UINT32 face;
-		UINT32 mipLevel;
-	};
-
-	/**
-	 * @see		RENDER_SURFACE_DESC
-	 *
-	 * @note	References core textures instead of texture handles.
-	 */
-	struct BS_CORE_EXPORT RENDER_SURFACE_CORE_DESC
-	{
-		SPtr<TextureCore> texture;
-		UINT32 face;
-		UINT32 mipLevel;
-	};
-
-	/**
-	 * @brief	Contains various properties that describe a render target.
-	 */
-	class BS_CORE_EXPORT RenderTargetProperties
-	{
-	public:
-		virtual ~RenderTargetProperties() { }
-
-		/**
-		 * @brief	Returns width of the render target, in pixels.
-		 * 
-		 * @note	Sim thread only.
-		 */
-        UINT32 getWidth() const { return mWidth; }
-
-		/**
-		 * @brief	Returns height of the render target, in pixels.
-		 *
-		 * @note	Sim thread only.
-		 */
-        UINT32 getHeight() const { return mHeight; }
-
-		/**
-		 * @brief	Gets the number of samples used for multisampling.
-		 *			(0 or 1 if multisampling is not used).
-		 */
-		UINT32 getMultisampleCount() const { return mMultisampleCount; }
-
-		/**
-		 * @brief	Returns true if the render target will wait for vertical sync 
-		 *			before swapping buffers. This will eliminate tearing but may increase
-		 *			input latency.
-		 */
-		bool getVSync() const { return mVSync; }
-
-		/**
-		 * @brief	Returns how often should the frame be presented in respect to
-		 *			display device refresh rate. Normal value is 1 where it will
-		 *			match the refresh rate. Higher values will decrease the frame
-		 *			rate (e.g. present interval of 2 on 60Hz refresh rate will display
-		 *			at most 30 frames per second).
-		 */
-		UINT32 getVSyncInterval() const { return mVSyncInterval; }
-
-		/**
-		 * @brief	Returns true if pixels written to the render target will be gamma corrected.
-		 */
-		bool isHwGammaEnabled() const { return mHwGamma; }
-
-		/**
-		 * @brief	Returns true if the render target can be used for rendering.
-		 *
-		 * @note	Core thread only.
-		 */
-		bool isActive() const { return mActive; }
-
-		/**
-		 * @brief	Controls in what order is the render target rendered to compared to other render targets.
-		 *			Targets with higher priority will be rendered before ones with lower priority.
-		 */
-		INT32 getPriority() const { return mPriority; }
-
-		/**
-		 * @brief	Returns true if the render target is a render window.
-		 */
-		bool isWindow() const { return mIsWindow; }
-
-		/**
-		 * @brief	Does the texture need to be vertically flipped because of different screen space coordinate systems.
-		 *			(i.e. is origin top left or bottom left. Engine default is top left.)
-		 */
-		bool requiresTextureFlipping() const { return mRequiresTextureFlipping; }
-
-	protected:
-		friend class RenderTargetCore;
-		friend class RenderTarget;
-
-		UINT32 mWidth = 0;
-		UINT32 mHeight = 0;
-		UINT32 mColorDepth = 32;
-
-		INT32 mPriority = 0;
-		UINT32 mVSyncInterval = 1;
-
-		bool mActive = true;
-		bool mHwGamma = false;
-		bool mVSync = false;
-		bool mRequiresTextureFlipping = false;
-		bool mIsWindow = false;
-
-		UINT32 mMultisampleCount = 0;
-	};
-
-	/**
-	 * @brief	Provides access to internal render target implementation usable only from the core thread.
-	 *
-	 * @note	Core thread only.
-	 */
-	class BS_CORE_EXPORT RenderTargetCore : public CoreObjectCore
-	{
-	public:
-		/**
-		 * @brief	Frame buffer type when double-buffering is used.
-		 */
-		enum FrameBuffer
-		{
-			FB_FRONT,
-			FB_BACK,
-			FB_AUTO
-		};
-
-		RenderTargetCore();
-		virtual ~RenderTargetCore() { }
-
-		/**
-		 * @brief	Sets a priority that determines in which orders the render targets the processed.
-		 * 			
-		 * @param	priority	The priority. Higher value means the target will be rendered sooner.
-		 */
-		void setPriority(INT32 priority);
-
-		/**
-		 * @brief	Swaps the frame buffers to display the next frame.
-		 */
-		virtual void swapBuffers() {};
-
-		/**
-		 * @brief	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;
-
-		/**
-		 * @brief	Returns properties that describe the render target.
-		 */
-		const RenderTargetProperties& getProperties() const;
-
-	protected:
-		friend class RenderTarget;
-
-		/**
-		 * @brief	Returns properties that describe the render target.
-		 */
-		virtual const RenderTargetProperties& getPropertiesInternal() const = 0;
-	};
-
-	/**
-	 * @brief	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() { }
-
-		/**
-		 * @brief	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);
-
-		/**
-		 * @brief	Returns properties that describe the render target.
-		 *
-		 * @note	Sim thread only.
-		 */
-		const RenderTargetProperties& getProperties() const;
-
-		/**
-		 * @brief	Retrieves a core implementation of a render target usable only from the
-		 *			core thread.
-		 */
-		SPtr<RenderTargetCore> getCore() const;
-
-		/**
-		 * @brief	Event that gets triggered whenever the render target is resized.
-		 *
-		 * @note	Sim thread only.
-		 */
-		mutable Event<void()> onResized;
-
-    protected:
-		friend class RenderTargetCore;
-
-		/**
-		 * @brief	Returns properties that describe the render target.
-		 */
-		virtual const RenderTargetProperties& getPropertiesInternal() const = 0;
-    };
-}
+#pragma once
+
+#include "BsCorePrerequisites.h"
+#include "BsPixelUtil.h"
+#include "BsViewport.h"
+#include "BsCoreObject.h"
+#include "BsEvent.h"
+
+namespace BansheeEngine 
+{
+	/** @addtogroup RenderAPI
+	 *  @{
+	 */
+
+	/** Structure that contains information about what part of the texture represents the render surface. */
+	struct BS_CORE_EXPORT RENDER_SURFACE_DESC
+	{
+		HTexture texture;
+		UINT32 face;
+		UINT32 mipLevel;
+	};
+
+	/**
+	 * @see		RENDER_SURFACE_DESC
+	 *
+	 * @note	References core textures instead of texture handles.
+	 */
+	struct BS_CORE_EXPORT RENDER_SURFACE_CORE_DESC
+	{
+		SPtr<TextureCore> texture;
+		UINT32 face;
+		UINT32 mipLevel;
+	};
+
+	/** Contains various properties that describe a render target. */
+	class BS_CORE_EXPORT RenderTargetProperties
+	{
+	public:
+		virtual ~RenderTargetProperties() { }
+
+		/**
+		 * Returns width of the render target, in pixels.
+		 * 
+		 * @note	Sim thread only.
+		 */
+        UINT32 getWidth() const { return mWidth; }
+
+		/**
+		 * Returns height of the render target, in pixels.
+		 *
+		 * @note	Sim thread only.
+		 */
+        UINT32 getHeight() const { return mHeight; }
+
+		/** Gets the number of samples used for multisampling. (0 or 1 if multisampling is not used). */
+		UINT32 getMultisampleCount() const { return mMultisampleCount; }
+
+		/**
+		 * Returns true if the render target will wait for vertical sync before swapping buffers. This will eliminate 
+		 * tearing but may increase input latency.
+		 */
+		bool getVSync() const { return mVSync; }
+
+		/**
+		 * Returns how often should the frame be presented in respect to display device refresh rate. Normal value is 1 
+		 * where it will match the refresh rate. Higher values will decrease the frame rate (e.g. present interval of 2 on
+		 * 60Hz refresh rate will display at most 30 frames per second).
+		 */
+		UINT32 getVSyncInterval() const { return mVSyncInterval; }
+
+		/** Returns true if pixels written to the render target will be gamma corrected. */
+		bool isHwGammaEnabled() const { return mHwGamma; }
+
+		/**
+		 * Returns true if the render target can be used for rendering.
+		 *
+		 * @note	Core thread only.
+		 */
+		bool isActive() const { return mActive; }
+
+		/**
+		 * Controls in what order is the render target rendered to compared to other render targets. Targets with higher 
+		 * priority will be rendered before ones with lower priority.
+		 */
+		INT32 getPriority() const { return mPriority; }
+
+		/** Returns true if the render target is a render window. */
+		bool isWindow() const { return mIsWindow; }
+
+		/**
+		 * Does the texture need to be vertically flipped because of different screen space coordinate systems.	(i.e. is 
+		 * origin top left or bottom left. Engine default is top left.)
+		 */
+		bool requiresTextureFlipping() const { return mRequiresTextureFlipping; }
+
+	protected:
+		friend class RenderTargetCore;
+		friend class RenderTarget;
+
+		UINT32 mWidth = 0;
+		UINT32 mHeight = 0;
+		UINT32 mColorDepth = 32;
+
+		INT32 mPriority = 0;
+		UINT32 mVSyncInterval = 1;
+
+		bool mActive = true;
+		bool mHwGamma = false;
+		bool mVSync = false;
+		bool mRequiresTextureFlipping = false;
+		bool mIsWindow = false;
+
+		UINT32 mMultisampleCount = 0;
+	};
+
+	/** @cond INTERNAL */
+
+	/**
+	 * Provides access to internal render target implementation usable only from the core thread.
+	 *
+	 * @note	Core thread only.
+	 */
+	class BS_CORE_EXPORT RenderTargetCore : public CoreObjectCore
+	{
+	public:
+		/** Frame buffer type when double-buffering is used. */
+		enum FrameBuffer
+		{
+			FB_FRONT,
+			FB_BACK,
+			FB_AUTO
+		};
+
+		RenderTargetCore();
+		virtual ~RenderTargetCore() { }
+
+		/**
+		 * Sets a priority that determines in which orders the render targets the processed.
+		 * 			
+		 * @param[in]	priority	The priority. Higher value means the target will be rendered sooner.
+		 */
+		void setPriority(INT32 priority);
+
+		/** Swaps the frame buffers to display the next frame. */
+		virtual void swapBuffers() {};
+
+		/** 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;
+
+		/**	Returns properties that describe the render target. */
+		const RenderTargetProperties& getProperties() const;
+
+	protected:
+		friend class RenderTarget;
+
+		/**	Returns properties that describe the render target. */
+		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;
+    };
+
+	/** @} */
+}

+ 49 - 61
BansheeCore/Include/BsRenderTexture.h

@@ -6,29 +6,20 @@
 
 
 namespace BansheeEngine
 namespace BansheeEngine
 {    
 {    
-	/**
-	 * @brief	Structure that describes a render texture color and depth/stencil surfaces.
+	/** @addtogroup RenderAPI
+	 *  @{
 	 */
 	 */
+
+	/**	Structure that describes a render texture color and depth/stencil surfaces. */
 	struct BS_CORE_EXPORT RENDER_TEXTURE_DESC
 	struct BS_CORE_EXPORT RENDER_TEXTURE_DESC
 	{
 	{
 		RENDER_SURFACE_DESC colorSurface;
 		RENDER_SURFACE_DESC colorSurface;
 		RENDER_SURFACE_DESC depthStencilSurface;
 		RENDER_SURFACE_DESC depthStencilSurface;
 	};
 	};
 
 
-	/**
-	 * @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;
-	};
+	struct RENDER_TEXTURE_CORE_DESC;
 
 
-	/**
-	 * @brief	Contains various properties that describe a render texture.
-	 */
+	/**	Contains various properties that describe a render texture. */
 	class BS_CORE_EXPORT RenderTextureProperties : public RenderTargetProperties
 	class BS_CORE_EXPORT RenderTextureProperties : public RenderTargetProperties
 	{
 	{
 	public:
 	public:
@@ -43,8 +34,21 @@ namespace BansheeEngine
 		friend class RenderTexture;
 		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;
+	};
+
 	/**
 	/**
-	 * @brief	Provides access to internal render texture implementation usable only from the core thread.
+	 * Provides access to internal render texture implementation usable only from the core thread.
 	 *
 	 *
 	 * @note	Core thread only.
 	 * @note	Core thread only.
 	 */
 	 */
@@ -54,41 +58,32 @@ namespace BansheeEngine
 		RenderTextureCore(const RENDER_TEXTURE_CORE_DESC& desc);
 		RenderTextureCore(const RENDER_TEXTURE_CORE_DESC& desc);
 		virtual ~RenderTextureCore();
 		virtual ~RenderTextureCore();
 
 
-		/**
-		 * @copydoc	CoreObjectCore::initialize
-		 */
+		/** @copydoc CoreObjectCore::initialize */
 		virtual void initialize();
 		virtual void initialize();
 
 
 		/**
 		/**
-		 * @brief	Returns a color surface texture you may bind as an input to an GPU program.
+		 * 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.
 		 * @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; }
 		SPtr<TextureCore> getBindableColorTexture() const { return mDesc.colorSurface.texture; }
 
 
 		/**
 		/**
-		 * @brief	Returns a depth/stencil surface texture you may bind as an input to an GPU program.
+		 * 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.
 		 * @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; }
 		SPtr<TextureCore> getBindableDepthStencilTexture() const { return mDesc.depthStencilSurface.texture; }
 
 
-
-		/**
-		 * @brief	Returns properties that describe the render texture.
-		 */
+		/**	Returns properties that describe the render texture. */
 		const RenderTextureProperties& getProperties() const;
 		const RenderTextureProperties& getProperties() const;
 
 
 	protected:
 	protected:
-		/**
-		 * @copydoc	CoreObjectCore::syncToCore
-		 */
+		/** @copydoc CoreObjectCore::syncToCore */
 		virtual void syncToCore(const CoreSyncData& data) override;
 		virtual void syncToCore(const CoreSyncData& data) override;
 
 
 	private:
 	private:
-		/**
-		 * @brief	Throws an exception of the color and depth/stencil buffers aren't compatible.
-		 */
+		/**	Throws an exception of the color and depth/stencil buffers aren't compatible. */
 		void throwIfBuffersDontMatch() const;
 		void throwIfBuffersDontMatch() const;
 
 
 	protected:
 	protected:
@@ -100,12 +95,12 @@ namespace BansheeEngine
 		RENDER_TEXTURE_CORE_DESC mDesc;
 		RENDER_TEXTURE_CORE_DESC mDesc;
 	};
 	};
 
 
+	/** @endcond */
+
 	/**
 	/**
-	 * @brief	Render target specialization that allows you to render into a texture you may
-	 *			later bind in further render operations.
+	 * 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.
+	 * @note	Sim thread only. Retrieve core implementation from getCore() for core thread only functionality.
 	 */
 	 */
     class BS_CORE_EXPORT RenderTexture : public RenderTarget
     class BS_CORE_EXPORT RenderTexture : public RenderTarget
     {
     {
@@ -113,51 +108,46 @@ namespace BansheeEngine
 		virtual ~RenderTexture() { }
 		virtual ~RenderTexture() { }
 
 
 		/**
 		/**
-		 * @brief	Creates a new render texture with color and optionally depth/stencil surfaces.
+		 * Creates a new render texture with color and optionally depth/stencil surfaces.
 		 *
 		 *
-		 * @param	textureType			Type of texture to render to.
-		 * @param	width				Width of the render texture, in pixels.
-		 * @param	height				Height of the render texture, in pixels.
-		 * @param	format				Pixel format used by the texture color surface.
-		 * @param	hwGamma				Should the written pixels be gamma corrected.
-		 * @param	multisampleCount	If higher than 1, texture containing multiple samples per pixel is created.
-		 * @param	createDepth			Should a depth/stencil surface be created along with the color surface.
-		 * @param	depthStencilFormat	Format used by the depth stencil surface, if one is created.
+		 * @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, 
 		static RenderTexturePtr create(TextureType textureType, UINT32 width, UINT32 height, 
 			PixelFormat format = PF_R8G8B8A8, bool hwGamma = false, UINT32 multisampleCount = 0, 
 			PixelFormat format = PF_R8G8B8A8, bool hwGamma = false, UINT32 multisampleCount = 0, 
 			bool createDepth = true, PixelFormat depthStencilFormat = PF_D24S8);
 			bool createDepth = true, PixelFormat depthStencilFormat = PF_D24S8);
 
 
-		/**
-		 * @copydoc	TextureManager::createRenderTexture(const RENDER_TEXTURE_DESC&)
-		 */
+		/** @copydoc TextureManager::createRenderTexture(const RENDER_TEXTURE_DESC&) */
 		static RenderTexturePtr create(const RENDER_TEXTURE_DESC& desc);
 		static RenderTexturePtr create(const RENDER_TEXTURE_DESC& desc);
 
 
 		/**
 		/**
-		 * @brief	Returns a color surface texture you may bind as an input to an GPU program.
+		 * 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.
 		 * @note	Be aware that you cannot bind a render texture for reading and writing at the same time.
 		 */
 		 */
 		const HTexture& getBindableColorTexture() const { return mBindableColorTex; }
 		const HTexture& getBindableColorTexture() const { return mBindableColorTex; }
 
 
 		/**
 		/**
-		 * @brief	Returns a depth/stencil surface texture you may bind as an input to an GPU program.
+		 * 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.
+		 * @note	Be aware that you cannot bind a render texture for reading and writing at the same time.
 		 */
 		 */
 		const HTexture& getBindableDepthStencilTexture() const { return mBindableDepthStencilTex; }
 		const HTexture& getBindableDepthStencilTexture() const { return mBindableDepthStencilTex; }
 
 
 		/**
 		/**
-		 * @brief	Retrieves a core implementation of a render texture usable only from the
-		 *			core thread.
+		 * Retrieves a core implementation of a render texture usable only from the core thread.
 		 *
 		 *
 		 * @note	Core thread only.
 		 * @note	Core thread only.
 		 */
 		 */
 		SPtr<RenderTextureCore> getCore() const;
 		SPtr<RenderTextureCore> getCore() const;
 
 
-		/**
-		 * @brief	Returns properties that describe the render texture.
-		 */
+		/**	Returns properties that describe the render texture. */
 		const RenderTextureProperties& getProperties() const;
 		const RenderTextureProperties& getProperties() const;
 
 
 	protected:
 	protected:
@@ -165,14 +155,10 @@ namespace BansheeEngine
 
 
 		RenderTexture(const RENDER_TEXTURE_DESC& desc);
 		RenderTexture(const RENDER_TEXTURE_DESC& desc);
 
 
-		/**
-		 * @copydoc	RenderTexture::createCore
-		 */
+		/** @copydoc RenderTexture::createCore */
 		virtual SPtr<CoreObjectCore> createCore() const override;
 		virtual SPtr<CoreObjectCore> createCore() const override;
 
 
-		/**
-		 * @copydoc	CoreObjectCore::syncToCore
-		 */
+		/** @copydoc CoreObjectCore::syncToCore */
 		virtual CoreSyncData syncToCore(FrameAlloc* allocator) override;
 		virtual CoreSyncData syncToCore(FrameAlloc* allocator) override;
 
 
 	protected:
 	protected:
@@ -181,4 +167,6 @@ namespace BansheeEngine
 
 
 		RENDER_TEXTURE_DESC mDesc;
 		RENDER_TEXTURE_DESC mDesc;
 	};
 	};
+
+	/** @} */
 }
 }

+ 70 - 139
BansheeCore/Include/BsRenderWindow.h

@@ -1,16 +1,17 @@
 #pragma once
 #pragma once
 
 
 #include "BsCorePrerequisites.h"
 #include "BsCorePrerequisites.h"
-
 #include "BsRenderTarget.h"
 #include "BsRenderTarget.h"
 #include "BsVideoModeInfo.h"
 #include "BsVideoModeInfo.h"
 #include "BsVector2I.h"
 #include "BsVector2I.h"
 
 
 namespace BansheeEngine
 namespace BansheeEngine
 {
 {
-	/**
-	 * @brief	Structure that is used for initializing a render window.
+	/** @addtogroup RenderAPI
+	 *  @{
 	 */
 	 */
+
+	/** Structure that is used for initializing a render window. */
 	struct BS_CORE_EXPORT RENDER_WINDOW_DESC
 	struct BS_CORE_EXPORT RENDER_WINDOW_DESC
 	{
 	{
 		RENDER_WINDOW_DESC()
 		RENDER_WINDOW_DESC()
@@ -42,49 +43,32 @@ namespace BansheeEngine
 		NameValuePairList platformSpecific; /**< Platform-specific creation options. */
 		NameValuePairList platformSpecific; /**< Platform-specific creation options. */
 	};
 	};
 
 
-	/**
-	 * @brief	Contains various properties that describe a render window.
-	 */
+	/**	Contains various properties that describe a render window. */
 	class BS_CORE_EXPORT RenderWindowProperties : public RenderTargetProperties
 	class BS_CORE_EXPORT RenderWindowProperties : public RenderTargetProperties
 	{
 	{
 	public:
 	public:
 		RenderWindowProperties(const RENDER_WINDOW_DESC& desc);
 		RenderWindowProperties(const RENDER_WINDOW_DESC& desc);
 		virtual ~RenderWindowProperties() { }
 		virtual ~RenderWindowProperties() { }
 
 
-		/**
-		 * @brief	Gets the horizontal origin of the window in pixels.
-		 */
+		/**	Gets the horizontal origin of the window in pixels. */
 		INT32 getLeft() const { return mLeft; }
 		INT32 getLeft() const { return mLeft; }
 
 
-		/**
-		 * @brief	Gets the vertical origin of the window in pixels.
-		 */
+		/**	Gets the vertical origin of the window in pixels. */
 		INT32 getTop() const { return mTop; }
 		INT32 getTop() const { return mTop; }
 
 
-		/**
-		 * @brief	Indicates whether the window currently has keyboard focus.
-		 */
+		/**	Indicates whether the window currently has keyboard focus. */
 		bool hasFocus() const { return mHasFocus; }
 		bool hasFocus() const { return mHasFocus; }
 
 
-		/**
-		 * @brief	Returns true if window is running in fullscreen mode.
-		 */
+		/**	Returns true if window is running in fullscreen mode. */
 		bool isFullScreen() const { return mIsFullScreen; }
 		bool isFullScreen() const { return mIsFullScreen; }
 
 
-		/**
-		 * @brief	Returns true if the window is modal (blocks interaction with
-		 *			any non-modal window until closed).
-		 */
+		/**	Returns true if the window is modal (blocks interaction with any non-modal window until closed). */
 		bool isModal() const { return mIsModal; }
 		bool isModal() const { return mIsModal; }
 
 
-		/**
-		 * @brief	Returns true if the window is hidden.
-		 */
+		/**	Returns true if the window is hidden. */
 		bool isHidden() const { return mHidden; }
 		bool isHidden() const { return mHidden; }
 
 
-		/**
-		 * @brief	Returns true if the window is maximized.
-		 */
+		/**	Returns true if the window is maximized. */
 		bool isMaximized() const { return mIsMaximized; }
 		bool isMaximized() const { return mIsMaximized; }
 
 
 	protected:
 	protected:
@@ -100,8 +84,10 @@ namespace BansheeEngine
 		bool mIsMaximized = false;
 		bool mIsMaximized = false;
 	};
 	};
 
 
+	/** @cond INTERNAL */
+
 	/**
 	/**
-	 * @brief	Provides access to internal render window implementation usable only from the core thread.
+	 * Provides access to internal render window implementation usable only from the core thread.
 	 *
 	 *
 	 * @note	Core thread only.
 	 * @note	Core thread only.
 	 */
 	 */
@@ -112,111 +98,93 @@ namespace BansheeEngine
 		virtual ~RenderWindowCore();
 		virtual ~RenderWindowCore();
 
 
 		/** 
 		/** 
-		 * @brief	Switches the window to fullscreen mode. Child windows cannot go into fullscreen mode.
+		 * Switches the window to fullscreen mode. Child windows cannot go into fullscreen mode.
 		 *
 		 *
-		 * @param	width		Width of the window frame buffer in pixels.
-		 * @param	height		Height of the window frame buffer in pixels.
-		 * @param	refreshRate	Refresh rate of the window in Hertz.
-		 * @param	monitorIdx	Index of the monitor to go fullscreen on.
+		 * @param[in]	width		Width of the window frame buffer in pixels.
+		 * @param[in]	height		Height of the window frame buffer in pixels.
+		 * @param[in]	refreshRate	Refresh rate of the window in Hertz.
+		 * @param[in]	monitorIdx	Index of the monitor to go fullscreen on.
 		 *
 		 *
 		 * @note	If the exact provided mode isn't available, closest one is used instead.
 		 * @note	If the exact provided mode isn't available, closest one is used instead.
 		 */
 		 */
 		virtual void setFullscreen(UINT32 width, UINT32 height, float refreshRate = 60.0f, UINT32 monitorIdx = 0) { }
 		virtual void setFullscreen(UINT32 width, UINT32 height, float refreshRate = 60.0f, UINT32 monitorIdx = 0) { }
 
 
 		/**
 		/**
-		* @brief	Switches the window to fullscreen mode. Child windows cannot go into fullscreen mode.
-		*
-		* @param	videoMode	Mode retrieved from VideoModeInfo in RenderAPI.
-		*/
+		 * Switches the window to fullscreen mode. Child windows cannot go into fullscreen mode.
+		 *
+		 * @param[in]	videoMode	Mode retrieved from VideoModeInfo in RenderAPI.
+		 */
 		virtual void setFullscreen(const VideoMode& mode) { }
 		virtual void setFullscreen(const VideoMode& mode) { }
 
 
 		/**
 		/**
-		 * @brief	Switches the window to windowed mode.
+		 * Switches the window to windowed mode.
 		 *
 		 *
-		 * @param	Window width in pixels.
-		 * @param	Window height in pixels.
+		 * @param[in]	Window width in pixels.
+		 * @param[in]	Window height in pixels.
 		 */
 		 */
 		virtual void setWindowed(UINT32 width, UINT32 height) { }
 		virtual void setWindowed(UINT32 width, UINT32 height) { }
 
 
-        /**
-         * @brief	Hide or show the window.
-         */
+        /**	Hide or show the window. */
         virtual void setHidden(bool hidden);
         virtual void setHidden(bool hidden);
 
 
-		/**
-		 * @brief	Makes the render target active or inactive. (e.g. for a window, it will hide or restore the window).
-		 */
+		/**	Makes the render target active or inactive. (e.g. for a window, it will hide or restore the window). */
 		virtual void setActive(bool state);
 		virtual void setActive(bool state);
 
 
-		/**
-		 * @brief	Minimizes the window to the taskbar.
-		 */
+		/**	Minimizes the window to the taskbar. */
 		virtual void minimize() { }
 		virtual void minimize() { }
 
 
-		/**
-		 * @brief	Maximizes the window over the entire current screen.
-		 */
+		/**	Maximizes the window over the entire current screen. */
 		virtual void maximize() { }
 		virtual void maximize() { }
 
 
-		/**
-		 * @brief	Restores the window to original position and size if it is
-		 *			minimized or maximized.
-		 */
+		/**	Restores the window to original position and size if it is minimized or maximized. */
 		virtual void restore() { }
 		virtual void restore() { }
 
 
-        /**
-         * @brief	Change the size of the window.
-         */
+        /**	Change the size of the window. */
         virtual void resize(UINT32 width, UINT32 height) = 0;
         virtual void resize(UINT32 width, UINT32 height) = 0;
 
 
-        /**
-         * @brief	Reposition the window.
-         */
+        /**	Reposition the window. */
         virtual void move(INT32 left, INT32 top) = 0;
         virtual void move(INT32 left, INT32 top) = 0;
 
 
-		/**
-		 * @brief	Returns properties that describe the render window.
-		 */
+		/**	Returns properties that describe the render window. */
 		const RenderWindowProperties& getProperties() const;
 		const RenderWindowProperties& getProperties() const;
 
 
 		/**
 		/**
-		 * @brief	Called when window is moved or resized.
+		 * Called when window is moved or resized.
 		 *
 		 *
-		 * @note	Core thread. Internal method.
+		 * @note	Core thread.
 		 */
 		 */
 		virtual void _windowMovedOrResized();
 		virtual void _windowMovedOrResized();
 
 
 		/**
 		/**
-		 * @brief	Called when window has received focus.
+		 * Called when window has received focus.
 		 *
 		 *
 		 * @note	Core thread.
 		 * @note	Core thread.
 		 */
 		 */
 		virtual void _windowFocusReceived();
 		virtual void _windowFocusReceived();
 
 
 		/**
 		/**
-		 * @brief	Called when window has lost focus.
+		 * Called when window has lost focus.
 		 *
 		 *
 		 * @note	Core thread.
 		 * @note	Core thread.
 		 */
 		 */
 		virtual void _windowFocusLost();
 		virtual void _windowFocusLost();
 
 
 		/**
 		/**
-		 * @brief	Called when window has been maximized.
+		 * Called when window has been maximized.
 		 *
 		 *
 		 * @note	Core thread.
 		 * @note	Core thread.
 		 */
 		 */
 		virtual void _notifyMaximized();
 		virtual void _notifyMaximized();
 
 
 		/**
 		/**
-		 * @brief	Called when window has been minimized.
+		 * Called when window has been minimized.
 		 *
 		 *
 		 * @note	Core thread.
 		 * @note	Core thread.
 		 */
 		 */
 		virtual void _notifyMinimized();
 		virtual void _notifyMinimized();
 
 
 		/**
 		/**
-		 * @brief	Called when window has been restored 
-		 *			from minimized or maximized state.
+		 * Called when window has been restored from minimized or maximized state.
 		 *
 		 *
 		 * @note	Core thread.
 		 * @note	Core thread.
 		 */
 		 */
@@ -228,15 +196,13 @@ namespace BansheeEngine
 		friend class RenderWindowCoreManager;
 		friend class RenderWindowCoreManager;
 
 
 		/**
 		/**
-		 * @brief	Returns window properties that are always kept in sync between core and sim threads.
+		 * Returns window properties that are always kept in sync between core and sim threads.
 		 *
 		 *
 		 * @note	Used for keeping up what are the most up to date settings.
 		 * @note	Used for keeping up what are the most up to date settings.
 		 */
 		 */
 		virtual RenderWindowProperties& getSyncedProperties() = 0;
 		virtual RenderWindowProperties& getSyncedProperties() = 0;
 
 
-		/**
-		 * @brief	Updates window properties from the synced property data.
-		 */
+		/** Updates window properties from the synced property data. */
 		virtual void syncProperties() = 0;
 		virtual void syncProperties() = 0;
 
 
 		RENDER_WINDOW_DESC mDesc;
 		RENDER_WINDOW_DESC mDesc;
@@ -244,97 +210,66 @@ namespace BansheeEngine
 		UINT32 mWindowId;
 		UINT32 mWindowId;
 	};
 	};
 
 
+	/** @endcond */
+
 	/**
 	/**
-	 * @brief	Render target specialization that allows you to render into window
-	 *			frame buffer(s).
+	 * 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.
+	 * @note	Sim thread only. Retrieve core implementation from getCore() for core thread only functionality.
 	 */
 	 */
     class BS_CORE_EXPORT RenderWindow : public RenderTarget
     class BS_CORE_EXPORT RenderWindow : public RenderTarget
     {
     {
     public:
     public:
 		virtual ~RenderWindow() { }
 		virtual ~RenderWindow() { }
 
 
-		/**
-		 * @copydoc	RenderTarget::destroy
-		 */
+		/** @copydoc RenderTarget::destroy */
 		virtual void destroy() override;	
 		virtual void destroy() override;	
 
 
-		/**
-		 * @brief	Converts screen position into window local position.
-		 */
+		/**	Converts screen position into window local position. */
 		virtual Vector2I screenToWindowPos(const Vector2I& screenPos) const = 0;
 		virtual Vector2I screenToWindowPos(const Vector2I& screenPos) const = 0;
 
 
-		/**
-		 * @brief	Converts window local position to screen position.
-		 */
+		/**	Converts window local position to screen position. */
 		virtual Vector2I windowToScreenPos(const Vector2I& windowPos) const = 0;
 		virtual Vector2I windowToScreenPos(const Vector2I& windowPos) const = 0;
 
 
-		/**
-		 * @brief	Resize the window to specified width and height in pixels.
-		 */
+		/**	Resize the window to specified width and height in pixels. */
 		void resize(CoreAccessor& accessor, UINT32 width, UINT32 height);
 		void resize(CoreAccessor& accessor, UINT32 width, UINT32 height);
 
 
-		/**
-		 * @brief	Move the window to specified screen coordinates.
-		 */
+		/**	Move the window to specified screen coordinates. */
 		void move(CoreAccessor& accessor, INT32 left, INT32 top);
 		void move(CoreAccessor& accessor, INT32 left, INT32 top);
 
 
-		/**
-		 * @brief	Hide the window. (Does not destroy it, just hides it).
-		 */
+		/**	Hide the window. (Does not destroy it, just hides it). */
 		void hide(CoreAccessor& accessor);
 		void hide(CoreAccessor& accessor);
 
 
-		/**
-		 * @brief	Shows a previously hidden window.
-		 */
+		/**	Shows a previously hidden window. */
 		void show(CoreAccessor& accessor);
 		void show(CoreAccessor& accessor);
 
 
-		/**
-		 * @copydoc	RenderWindowCore::minimize
-		 */
+		/** @copydoc RenderWindowCore::minimize */
 		void minimize(CoreAccessor& accessor);
 		void minimize(CoreAccessor& accessor);
 
 
-		/**
-		 * @copydoc	RenderWindowCore::maximize
-		 */
+		/** @copydoc RenderWindowCore::maximize */
 		void maximize(CoreAccessor& accessor);
 		void maximize(CoreAccessor& accessor);
 
 
-		/**
-		 * @copydoc	RenderWindowCore::restore
-		 */
+		/** @copydoc RenderWindowCore::restore */
 		void restore(CoreAccessor& accessor);
 		void restore(CoreAccessor& accessor);
 
 
-		/**
-		 * @copydoc RenderWindowCore::setFullscreen(UINT32, UINT32, float, UINT32)
-		 */
+		/** @copydoc RenderWindowCore::setFullscreen(UINT32, UINT32, float, UINT32) */
 		void setFullscreen(CoreAccessor& accessor, UINT32 width, UINT32 height, float refreshRate = 60.0f, UINT32 monitorIdx = 0);
 		void setFullscreen(CoreAccessor& accessor, UINT32 width, UINT32 height, float refreshRate = 60.0f, UINT32 monitorIdx = 0);
 
 
-		/**
-		 * @copydoc RenderWindowCore::setFullscreen(const VideoMode&)
-		 */
+		/** @copydoc RenderWindowCore::setFullscreen(const VideoMode&) */
 		void setFullscreen(CoreAccessor& accessor, const VideoMode& mode);
 		void setFullscreen(CoreAccessor& accessor, const VideoMode& mode);
 
 
-		/**
-		 * @copydoc RenderWindowCore::setWindowed
-		 */
+		/** @copydoc RenderWindowCore::setWindowed */
 		void setWindowed(CoreAccessor& accessor, UINT32 width, UINT32 height);
 		void setWindowed(CoreAccessor& accessor, UINT32 width, UINT32 height);
 
 
-		/**
-		 * @brief	Retrieves a core implementation of a render window usable only from the
-		 *			core thread.
-		 */
+		/**	Retrieves a core implementation of a render window usable only from the core thread. */
 		SPtr<RenderWindowCore> getCore() const;
 		SPtr<RenderWindowCore> getCore() const;
 
 
-		/**
-		 * @brief	Returns properties that describe the render window.
-		 */
+		/**	Returns properties that describe the render window. */
 		const RenderWindowProperties& getProperties() const;
 		const RenderWindowProperties& getProperties() const;
 
 
 		/**
 		/**
-		 * @brief	Creates a new render window using the specified options. Optionally
-		 *			makes the created window a child of another window.
+		 * 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);
 		static RenderWindowPtr create(RENDER_WINDOW_DESC& desc, RenderWindowPtr parentWindow = nullptr);
 
 
@@ -343,23 +278,19 @@ namespace BansheeEngine
 
 
 		RenderWindow(const RENDER_WINDOW_DESC& desc, UINT32 windowId);
 		RenderWindow(const RENDER_WINDOW_DESC& desc, UINT32 windowId);
 
 
-		/**
-		 * @brief	Returns render window properties that may be edited.
-		 */
+		/** Returns render window properties that may be edited. */
 		RenderWindowProperties& getMutableProperties();
 		RenderWindowProperties& getMutableProperties();
 
 
-		/**
-		 * @copydoc	RenderTarget::createCore
-		 */
+		/** @copydoc RenderTarget::createCore */
 		SPtr<CoreObjectCore> createCore() const override;
 		SPtr<CoreObjectCore> createCore() const override;
 
 
-		/**
-		 * @brief	Updates window properties from the synced property data.
-		 */
+		/**	Updates window properties from the synced property data. */
 		virtual void syncProperties() = 0;
 		virtual void syncProperties() = 0;
 
 
 	protected:
 	protected:
 		RENDER_WINDOW_DESC mDesc;
 		RENDER_WINDOW_DESC mDesc;
 		UINT32 mWindowId;
 		UINT32 mWindowId;
     };
     };
+
+	/** @} */
 }
 }

+ 131 - 173
BansheeCore/Include/BsRenderWindowManager.h

@@ -1,174 +1,132 @@
-#pragma once
-
-#include "BsCorePrerequisites.h"
-#include "BsModule.h"
-#include "BsRenderWindow.h"
-#include "BsEvent.h"
-
-namespace BansheeEngine
-{
-	/**
-	 * @brief	Handles creation and internal updates relating to render windows.
-	 *
-	 * @note	Internal class.
-	 */
-	class BS_CORE_EXPORT RenderWindowManager : public Module<RenderWindowManager>
-	{
-		/**
-		 * @brief	Holds information about a window that was moved or resized.
-		 */
-		struct MoveOrResizeData
-		{
-			INT32 x, y;
-			UINT32 width, height;
-			RenderWindow* window;
-		};
-
-	public:
-		RenderWindowManager();
-		~RenderWindowManager();
-
-		/**
-		 * @brief	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);
-
-		/**
-		 * @brief	Called once per frame. Dispatches events.
-		 * 
-		 * @note	Internal method.
-		 */
-		void _update();
-
-		/**
-		 * @brief	Called by the core thread when window is destroyed.
-		 */
-		void notifyWindowDestroyed(RenderWindow* window);
-
-		/**
-		 * @brief	Called by the core thread when window receives focus.
-		 */
-		void notifyFocusReceived(RenderWindowCore* window);
-
-		/**
-		 * @brief	Called by the core thread when window loses focus.
-		 */
-		void notifyFocusLost(RenderWindowCore* window);
-
-		/**
-		 * @brief	Called by the core thread when window is moved or resized.
-		 */
-		void notifyMovedOrResized(RenderWindowCore* window);
-
-		/**
-		 * @brief	Called by the sim thread when window properties change.
-		 */
-		void notifySyncDataDirty(RenderWindowCore* coreWindow);
-
-		/**
-		 * @brief	Returns a list of all open render windows.
-		 */
-		Vector<RenderWindow*> getRenderWindows() const;
-
-		/**
-		 * @brief	Event that is triggered when a window gains focus.
-		 */
-		Event<void(RenderWindow&)> onFocusGained;
-
-		/**
-		 * @brief	Event that is triggered when a window loses focus.
-		 */
-		Event<void(RenderWindow&)> onFocusLost;
-
-		/**
-		 * @brief	Event that is triggered when mouse leaves a window.
-		 */
-		Event<void(RenderWindow&)> onMouseLeftWindow;
-	protected:
-		friend class RenderWindow;
-
-		/**
-		 * @brief	Called by the core thread when mouse leaves a window.
-		 */
-		void windowMouseLeft(RenderWindowCore* window);
-
-		/**
-		 * @brief	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;
-	};
-
-	/**
-	 * @brief	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);
-
-		/**
-		 * @brief	Called once per frame. Dispatches events.
-		 * 
-		 * @note	Internal method.
-		 */
-		void _update();
-
-		/**
-		 * @brief	Called by the core thread when window properties change.
-		 */
-		void notifySyncDataDirty(RenderWindowCore* window);
-
-		/**
-		 * @brief	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;
-
-		/**
-		 * @brief	Called whenever a window is created.
-		 */
-		void windowCreated(RenderWindowCore* window);
-
-		/**
-		 * @brief	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;
-	};
+#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 */
 }
 }

+ 31 - 30
BansheeCore/Include/BsRendererFactory.h

@@ -1,31 +1,32 @@
-#pragma once
-
-#include "BsCorePrerequisites.h"
-
-namespace BansheeEngine
-{
-	/**
-	 * @brief	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
-	 * 			
-	 * @note	Internal class.
-	 */
-	class BS_CORE_EXPORT RendererFactory
-	{
-	public:
-		virtual ~RendererFactory() { }
-
-		/**
-		 * @brief	Creates a new instance of the renderer.
-		 */
-		virtual CoreRendererPtr create() = 0;
-
-		/**
-		 * @brief	Returns the name of the renderer this factory creates.
-		 */
-		virtual const String& name() const = 0;
-	};
+#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 */
 }
 }

+ 51 - 50
BansheeCore/Include/BsRendererManager.h

@@ -1,50 +1,51 @@
-#pragma once
-
-#include "BsCorePrerequisites.h"
-#include "BsRendererFactory.h"
-#include "BsModule.h"
-
-namespace BansheeEngine
-{
-	/**
-	 * @brief	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();
-
-		/**
-		 * @brief	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);
-
-		/**
-		 * @brief	Initializes the currently active renderer, making it ready to render.
-		 */
-		void initialize();
-
-		/**
-		 * @brief	Returns the currently active renderer. Null if no renderer is active.
-		 */
-		CoreRendererPtr getActive() { return mActiveRenderer; }
-
-		/**
-		 * @brief	Registers a new renderer factory. Any renderer you try to make active with
-		 * 			"setActive" you will need to have previously registered here.
-		 *
-		 * @note	Internal method.
-		 */
-		void _registerFactory(RendererFactoryPtr factory);
-	private:
-		Vector<RendererFactoryPtr> mAvailableFactories;
-
-		CoreRendererPtr mActiveRenderer;
-	};
-}
-
+#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 */
+}
+

+ 229 - 249
BansheeCore/Include/BsRendererMeshData.h

@@ -1,250 +1,230 @@
-#pragma once
-
-#include "BsCorePrerequisites.h"
-#include "BsMeshData.h"
-
-namespace BansheeEngine
-{
-	/**
-	 * @brief	Available vertex layouts (Combinations other than those provided are allowed).
-	 */
-	enum class VertexLayout
-	{
-		Position = 0x01,
-		Color = 0x02,
-		Normal = 0x04,
-		Tangent = 0x08,
-		BoneWeights = 0x10,
-		UV0 = 0x20,
-		UV1 = 0x40,
-		PC = Position | Color,
-		PU = Position | UV0,
-		PCU = Position | Color | UV0,
-		PCN = Position | Color | Normal,
-		PCNU = Position | Color | Normal | UV0,
-		PCNT = Position | Color | Normal | Tangent,
-		PCNTU = Position | Color | Normal | Tangent | UV0,
-		PN = Position | Normal,
-		PNU = Position | Normal | UV0,
-		PNT = Position | Normal | Tangent,
-		PNTU = Position | Normal | Tangent | UV0,
-	};
-
-	/**
-	 * @brief	Wrapper around MeshData that constructs the default mesh data structure 
-	 *			expected by the renderer and other engine systems. Data will be compressed and
-	 *			uncompressed when written to and read to as needed to comply with wanted format.
-	 *			
-	 * @note	This is the default implementation while the Renderer plugins can override it by overriding
-	 *			createMeshData method in their Renderer implementation.
-	 */
-	class BS_CORE_EXPORT RendererMeshData
-	{
-	public:
-		/**
-		 * @brief	Reads the vertex positions into the provided output buffer.
-		 *			Data will be copied and potentially uncompressed to fit the output
-		 *			format as needed.
-		 *			
-		 * @param	buffer	Pre-allocated buffer to output the position data to.
-		 * @param	size	Size of the pre-allocated buffer. Must be big enough to fit
-		 *					all contents (numVertices * sizeof(Vector3)).
-		 */
-		void getPositions(Vector3* buffer, UINT32 size);
-
-		/**
-		 * @brief	Writes the vertex positions from the provided output buffer.
-		 *			Data will be copied and potentially compressed to fit the internal 
-		 *			mesh data format as needed.
-		 *			
-		 * @param	buffer	Pre-allocated buffer to read the position data from.
-		 * @param	size	Size of the input buffer. Must be (numVertices * sizeof(Vector3)).
-		 */
-		void setPositions(Vector3* buffer, UINT32 size);
-
-		/**
-		 * @brief	Reads the vertex normals into the provided output buffer.
-		 *			Data will be copied and potentially uncompressed to fit the output
-		 *			format as needed.
-		 *			
-		 * @param	buffer	Pre-allocated buffer to output the normal data to.
-		 * @param	size	Size of the pre-allocated buffer. Must be big enough to fit
-		 *					all contents (numVertices * sizeof(Vector3)).
-		 */
-		void getNormals(Vector3* buffer, UINT32 size);
-
-		/**
-		 * @brief	Writes the vertex normals from the provided output buffer.
-		 *			Data will be copied and potentially compressed to fit the internal 
-		 *			mesh data format as needed.
-		 *			
-		 * @param	buffer	Pre-allocated buffer to read the normal data from.
-		 * @param	size	Size of the input buffer. Must be (numVertices * sizeof(Vector3)).
-		 */
-		void setNormals(Vector3* buffer, UINT32 size);
-
-		/**
-		 * @brief	Reads the vertex tangents into the provided output buffer.
-		 *			Data will be copied and potentially uncompressed to fit the output
-		 *			format as needed.
-		 *			
-		 * @param	buffer	Pre-allocated buffer to output the tangent data to.
-		 * @param	size	Size of the pre-allocated buffer. Must be big enough to fit
-		 *					all contents (numVertices * sizeof(Vector4)).
-		 */
-		void getTangents(Vector4* buffer, UINT32 size);
-
-		/**
-		 * @brief	Writes the vertex tangents from the provided output buffer.
-		 *			Data will be copied and potentially compressed to fit the internal 
-		 *			mesh data format as needed.
-		 *			
-		 * @param	buffer	Pre-allocated buffer to read the tangent data from.
-		 * @param	size	Size of the input buffer. Must be (numVertices * sizeof(Vector4)).
-		 */
-		void setTangents(Vector4* buffer, UINT32 size);
-
-		/**
-		 * @brief	Reads the vertex colors into the provided output buffer.
-		 *			Data will be copied and potentially uncompressed to fit the output
-		 *			format as needed.
-		 *			
-		 * @param	buffer	Pre-allocated buffer to output the color data to.
-		 * @param	size	Size of the pre-allocated buffer. Must be big enough to fit
-		 *					all contents (numVertices * sizeof(Color)).
-		 */
-		void getColors(Color* buffer, UINT32 size);
-
-		/**
-		 * @brief	Writes the vertex colors from the provided output buffer.
-		 *			Data will be copied and potentially compressed to fit the internal 
-		 *			mesh data format as needed.
-		 *			
-		 * @param	buffer	Pre-allocated buffer to read the color data from.
-		 * @param	size	Size of the input buffer. Must be (numVertices * sizeof(Color)).
-		 */
-		void setColors(Color* buffer, UINT32 size);
-
-		/**
-		 * @brief	Writes the vertex colors from the provided output buffer.
-		 *			Data will be copied and potentially compressed to fit the internal 
-		 *			mesh data format as needed.
-		 *			
-		 * @param	buffer	Pre-allocated buffer to read the color data from. Colors should be in RGBA format.
-		 * @param	size	Size of the input buffer. Must be (numVertices * sizeof(UINT32)).
-		 */
-		void setColors(UINT32* buffer, UINT32 size);
-
-		/**
-		 * @brief	Reads the first UV channel coordinates into the provided output buffer.
-		 *			Data will be copied and potentially uncompressed to fit the output
-		 *			format as needed.
-		 *			
-		 * @param	buffer	Pre-allocated buffer to output the coordinate data to.
-		 * @param	size	Size of the pre-allocated buffer. Must be big enough to fit
-		 *					all contents (numVertices * sizeof(Vector2)).
-		 */
-		void getUV0(Vector2* buffer, UINT32 size);
-
-		/**
-		 * @brief	Writes the first UV channel coordinates from the provided output buffer.
-		 *			Data will be copied and potentially compressed to fit the internal 
-		 *			mesh data format as needed.
-		 *			
-		 * @param	buffer	Pre-allocated buffer to read the coordinate data from.
-		 * @param	size	Size of the input buffer. Must be (numVertices * sizeof(Vector2)).
-		 */
-		void setUV0(Vector2* buffer, UINT32 size);
-
-		/**
-		 * @brief	Reads the second UV channel coordinates into the provided output buffer.
-		 *			Data will be copied and potentially uncompressed to fit the output
-		 *			format as needed.
-		 *			
-		 * @param	buffer	Pre-allocated buffer to output the coordinate data to.
-		 * @param	size	Size of the pre-allocated buffer. Must be big enough to fit
-		 *					all contents (numVertices * sizeof(Vector2)).
-		 */
-		void getUV1(Vector2* buffer, UINT32 size);
-
-		/**
-		 * @brief	Writes the second UV channel coordinates from the provided output buffer.
-		 *			Data will be copied and potentially compressed to fit the internal 
-		 *			mesh data format as needed.
-		 *			
-		 * @param	buffer	Pre-allocated buffer to read the coordinate data from.
-		 * @param	size	Size of the input buffer. Must be (numVertices * sizeof(Vector2)).
-		 */
-		void setUV1(Vector2* buffer, UINT32 size);
-
-		/**
-		 * @brief	Reads the bone weights and indices into the provided output buffer.
-		 *			Data will be copied and potentially uncompressed to fit the output
-		 *			format as needed.
-		 *			
-		 * @param	buffer	Pre-allocated buffer to output the bone weight data to.
-		 * @param	size	Size of the pre-allocated buffer. Must be big enough to fit
-		 *					all contents (numVertices * sizeof(BoneWeight)).
-		 */
-		void getBoneWeights(BoneWeight* buffer, UINT32 size);
-
-		/**
-		 * @brief	Writes the bone weights and indices from the provided output buffer.
-		 *			Data will be copied and potentially compressed to fit the internal 
-		 *			mesh data format as needed.
-		 *			
-		 * @param	buffer	Pre-allocated buffer to read the bone weight data from.
-		 * @param	size	Size of the input buffer. Must be (numVertices * sizeof(BoneWeight)).
-		 */
-		void setBoneWeights(BoneWeight* buffer, UINT32 size);
-
-		/**
-		 * @brief	Reads the indices into the provided output buffer.
-		 *			Data will be copied and potentially uncompressed to fit the output
-		 *			format as needed.
-		 *			
-		 * @param	buffer	Pre-allocated buffer to output the index data to.
-		 * @param	size	Size of the pre-allocated buffer. Must be big enough to fit
-		 *					all contents (numVertices * sizeof(INT32)).
-		 */
-		void getIndices(UINT32* buffer, UINT32 size);
-
-		/**
-		 * @brief	Writes the indices from the provided output buffer.
-		 *			Data will be copied and potentially compressed to fit the internal 
-		 *			mesh data format as needed.
-		 *			
-		 * @param	buffer	Pre-allocated buffer to read the index data from.
-		 * @param	size	Size of the input buffer. Must be (numVertices * sizeof(INT32)).
-		 */
-		void setIndices(UINT32* buffer, UINT32 size);
-
-		/**
-		 * @brief	Returns the underlying MeshData structure.
-		 */
-		MeshDataPtr getData() const { return mMeshData; }
-
-		/**
-		 * @brief	Creates a new empty mesh data structure.
-		 */
-		static RendererMeshDataPtr create(UINT32 numVertices, UINT32 numIndices, VertexLayout layout, IndexType indexType = IT_32BIT);
-
-		/**
-		 * @brief	Creates a new mesh data structure using an existing mesh data buffer.
-		 */
-		static RendererMeshDataPtr create(const MeshDataPtr& meshData);
-
-		/**
-		 * @brief	Creates a vertex descriptor from a vertex layout enum.
-		 */
-		static VertexDataDescPtr vertexLayoutVertexDesc(VertexLayout type);
-
-	private:
-		friend class CoreRenderer;
-
-		RendererMeshData(UINT32 numVertices, UINT32 numIndices, VertexLayout layout, IndexType indexType = IT_32BIT);
-		RendererMeshData(const MeshDataPtr& meshData);
-
-		MeshDataPtr mMeshData;
-	};
+#pragma once
+
+#include "BsCorePrerequisites.h"
+#include "BsMeshData.h"
+
+namespace BansheeEngine
+{
+	/** cond INTERNAL */
+	/** @addtogroup Renderer
+	 *  @{
+	 */
+
+	/**	Available vertex layouts (Combinations other than those provided are allowed). */
+	enum class VertexLayout
+	{
+		Position = 0x01,
+		Color = 0x02,
+		Normal = 0x04,
+		Tangent = 0x08,
+		BoneWeights = 0x10,
+		UV0 = 0x20,
+		UV1 = 0x40,
+		PC = Position | Color,
+		PU = Position | UV0,
+		PCU = Position | Color | UV0,
+		PCN = Position | Color | Normal,
+		PCNU = Position | Color | Normal | UV0,
+		PCNT = Position | Color | Normal | Tangent,
+		PCNTU = Position | Color | Normal | Tangent | UV0,
+		PN = Position | Normal,
+		PNU = Position | Normal | UV0,
+		PNT = Position | Normal | Tangent,
+		PNTU = Position | Normal | Tangent | UV0,
+	};
+
+	/**
+	 * Wrapper around MeshData that constructs the default mesh data structure expected by the renderer and other engine 
+	 * systems. Data will be compressed and uncompressed when written to and read to as needed to comply with wanted format.
+	 *			
+	 * @note	This is the default implementation while the Renderer plugins can override it by overriding
+	 *			createMeshData() method in their Renderer implementation.
+	 */
+	class BS_CORE_EXPORT RendererMeshData
+	{
+	public:
+		/**
+		 * Reads the vertex positions into the provided output buffer. Data will be copied and potentially uncompressed to
+		 * fit the output format as needed.
+		 *			
+		 * @param[in]	buffer	Pre-allocated buffer to output the position data to.
+		 * @param[in]	size	Size of the pre-allocated buffer. Must be big enough to fit all contents (numVertices * 
+		 *						sizeof(Vector3)).
+		 */
+		void getPositions(Vector3* buffer, UINT32 size);
+
+		/**
+		 * Writes the vertex positions from the provided output buffer. Data will be copied and potentially compressed to
+		 * fit the internal mesh data format as needed.
+		 *			
+		 * @param[in]	buffer	Pre-allocated buffer to read the position data from.
+		 * @param[in]	size	Size of the input buffer. Must be (numVertices * sizeof(Vector3)).
+		 */
+		void setPositions(Vector3* buffer, UINT32 size);
+
+		/**
+		 * Reads the vertex normals into the provided output buffer. Data will be copied and potentially uncompressed to 
+		 * fit the output format as needed.
+		 *			
+		 * @param[in]	buffer	Pre-allocated buffer to output the normal data to.
+		 * @param[in]	size	Size of the pre-allocated buffer. Must be big enough to fit all contents (numVertices * 
+		 *						sizeof(Vector3)).
+		 */
+		void getNormals(Vector3* buffer, UINT32 size);
+
+		/**
+		 * Writes the vertex normals from the provided output buffer. Data will be copied and potentially compressed to 
+		 * fit the internal mesh data format as needed.
+		 *			
+		 * @param[in]	buffer	Pre-allocated buffer to read the normal data from.
+		 * @param[in]	size	Size of the input buffer. Must be (numVertices * sizeof(Vector3)).
+		 */
+		void setNormals(Vector3* buffer, UINT32 size);
+
+		/**
+		 * Reads the vertex tangents into the provided output buffer. Data will be copied and potentially uncompressed to 
+		 * fit the output format as needed.
+		 *			
+		 * @param[in]	buffer	Pre-allocated buffer to output the tangent data to.
+		 * @param[in]	size	Size of the pre-allocated buffer. Must be big enough to fit all contents (numVertices * 
+		 *						sizeof(Vector4)).
+		 */
+		void getTangents(Vector4* buffer, UINT32 size);
+
+		/**
+		 * Writes the vertex tangents from the provided output buffer. Data will be copied and potentially compressed to 
+		 * fit the internal mesh data format as needed.
+		 *			
+		 * @param[in]	buffer	Pre-allocated buffer to read the tangent data from.
+		 * @param[in]	size	Size of the input buffer. Must be (numVertices * sizeof(Vector4)).
+		 */
+		void setTangents(Vector4* buffer, UINT32 size);
+
+		/**
+		 * Reads the vertex colors into the provided output buffer. Data will be copied and potentially uncompressed to 
+		 * fit the output format as needed.
+		 *			
+		 * @param[in]	buffer	Pre-allocated buffer to output the color data to.
+		 * @param[in]	size	Size of the pre-allocated buffer. Must be big enough to fit all contents (numVertices * 
+		 *						sizeof(Color)).
+		 */
+		void getColors(Color* buffer, UINT32 size);
+
+		/**
+		 * Writes the vertex colors from the provided output buffer. Data will be copied and potentially compressed to 
+		 * fit the internal mesh data format as needed.
+		 *			
+		 * @param[in]	buffer	Pre-allocated buffer to read the color data from.
+		 * @param[in]	size	Size of the input buffer. Must be (numVertices * sizeof(Color)).
+		 */
+		void setColors(Color* buffer, UINT32 size);
+
+		/**
+		 * Writes the vertex colors from the provided output buffer. Data will be copied and potentially compressed to 
+		 * fit the internal mesh data format as needed.
+		 *			
+		 * @param[in]	buffer	Pre-allocated buffer to read the color data from. Colors should be in RGBA format.
+		 * @param[in]	size	Size of the input buffer. Must be (numVertices * sizeof(UINT32)).
+		 */
+		void setColors(UINT32* buffer, UINT32 size);
+
+		/**
+		 * Reads the first UV channel coordinates into the provided output buffer. Data will be copied and potentially 
+		 * uncompressed to fit the output format as needed.
+		 *			
+		 * @param[in]	buffer	Pre-allocated buffer to output the coordinate data to.
+		 * @param[in]	size	Size of the pre-allocated buffer. Must be big enough to fit all contents (numVertices * 
+		 *						sizeof(Vector2)).
+		 */
+		void getUV0(Vector2* buffer, UINT32 size);
+
+		/**
+		 * Writes the first UV channel coordinates from the provided output buffer. Data will be copied and potentially 
+		 * compressed to fit the internal mesh data format as needed.
+		 *			
+		 * @param[in]	buffer	Pre-allocated buffer to read the coordinate data from.
+		 * @param[in]	size	Size of the input buffer. Must be (numVertices * sizeof(Vector2)).
+		 */
+		void setUV0(Vector2* buffer, UINT32 size);
+
+		/**
+		 * Reads the second UV channel coordinates into the provided output buffer. Data will be copied and potentially 
+		 * uncompressed to fit the output format as needed.
+		 *			
+		 * @param[in]	buffer	Pre-allocated buffer to output the coordinate data to.
+		 * @param[in]	size	Size of the pre-allocated buffer. Must be big enough to fit all contents (numVertices * 
+		 *						sizeof(Vector2)).
+		 */
+		void getUV1(Vector2* buffer, UINT32 size);
+
+		/**
+		 * Writes the second UV channel coordinates from the provided output buffer. Data will be copied and potentially 
+		 * compressed to fit the internal mesh data format as needed.
+		 *			
+		 * @param[in]	buffer	Pre-allocated buffer to read the coordinate data from.
+		 * @param[in]	size	Size of the input buffer. Must be (numVertices * sizeof(Vector2)).
+		 */
+		void setUV1(Vector2* buffer, UINT32 size);
+
+		/**
+		 * Reads the bone weights and indices into the provided output buffer. Data will be copied and potentially 
+		 * uncompressed to fit the output format as needed.
+		 *			
+		 * @param[in]	buffer	Pre-allocated buffer to output the bone weight data to.
+		 * @param[in]	size	Size of the pre-allocated buffer. Must be big enough to fit all contents (numVertices * 
+		 *						sizeof(BoneWeight)).
+		 */
+		void getBoneWeights(BoneWeight* buffer, UINT32 size);
+
+		/**
+		 * Writes the bone weights and indices from the provided output buffer. Data will be copied and potentially 
+		 * compressed to fit the internal mesh data format as needed.
+		 *			
+		 * @param[in]	buffer	Pre-allocated buffer to read the bone weight data from.
+		 * @param[in]	size	Size of the input buffer. Must be (numVertices * sizeof(BoneWeight)).
+		 */
+		void setBoneWeights(BoneWeight* buffer, UINT32 size);
+
+		/**
+		 * Reads the indices into the provided output buffer. Data will be copied and potentially uncompressed to fit the 
+		 * output format as needed.
+		 *			
+		 * @param[in]	buffer	Pre-allocated buffer to output the index data to.
+		 * @param[in]	size	Size of the pre-allocated buffer. Must be big enough to fit all contents (numVertices * 
+		 *						sizeof(INT32)).
+		 */
+		void getIndices(UINT32* buffer, UINT32 size);
+
+		/**
+		 * Writes the indices from the provided output buffer. Data will be copied and potentially compressed to fit the 
+		 * internal mesh data format as needed.
+		 *			
+		 * @param[in]	buffer	Pre-allocated buffer to read the index data from.
+		 * @param[in]	size	Size of the input buffer. Must be (numVertices * sizeof(INT32)).
+		 */
+		void setIndices(UINT32* buffer, UINT32 size);
+
+		/**	Returns the underlying MeshData structure. */
+		MeshDataPtr getData() const { return mMeshData; }
+
+		/**	Creates a new empty mesh data structure. */
+		static RendererMeshDataPtr create(UINT32 numVertices, UINT32 numIndices, VertexLayout layout, IndexType indexType = IT_32BIT);
+
+		/**	Creates a new mesh data structure using an existing mesh data buffer. */
+		static RendererMeshDataPtr create(const MeshDataPtr& meshData);
+
+		/**	Creates a vertex descriptor from a vertex layout enum. */
+		static VertexDataDescPtr vertexLayoutVertexDesc(VertexLayout type);
+
+	private:
+		friend class CoreRenderer;
+
+		RendererMeshData(UINT32 numVertices, UINT32 numIndices, VertexLayout layout, IndexType indexType = IT_32BIT);
+		RendererMeshData(const MeshDataPtr& meshData);
+
+		MeshDataPtr mMeshData;
+	};
+
+	/** @} */
+	/** @endcond */
 }
 }

+ 24 - 16
BansheeCore/Include/BsRendererUtility.h

@@ -7,8 +7,13 @@
 
 
 namespace BansheeEngine
 namespace BansheeEngine
 {
 {
+	/** @cond INTERNAL */
+	/** @addtogroup Renderer
+	 *  @{
+	 */
+
 	/**
 	/**
-	 * @brief	Contains various utility methods that make various common operations in the renderer easier.
+	 * Contains various utility methods that make various common operations in the renderer easier.
 	 * 			
 	 * 			
 	 * @note	Core thread only.
 	 * @note	Core thread only.
 	 */
 	 */
@@ -19,41 +24,41 @@ namespace BansheeEngine
 		~RendererUtility();
 		~RendererUtility();
 
 
 		/**
 		/**
-		 * @brief	Activates the specified material pass for rendering. Any further draw calls will be executed using 
-		 * 			this pass.
+		 * Activates the specified material pass for rendering. Any further draw calls will be executed using this pass.
 		 *
 		 *
-		 * @param	material	Material containing the pass.
-		 * @param	passIdx		Index of the pass in the material.
+		 * @param[in]	material	Material containing the pass.
+		 * @param[in]	passIdx		Index of the pass in the material.
 		 *
 		 *
 		 * @note	Core thread.
 		 * @note	Core thread.
 		 */
 		 */
 		void setPass(const SPtr<MaterialCore>& material, UINT32 passIdx);
 		void setPass(const SPtr<MaterialCore>& material, UINT32 passIdx);
 
 
 		/**
 		/**
-		 * @brief	Sets parameters (textures, samplers, buffers) for the currently active pass.
+		 * Sets parameters (textures, samplers, buffers) for the currently active pass.
 		 *
 		 *
-		 * @param	material	Material whose pass' parameters to bind.
-		 * @param	passIdx		Index of the pass in the material.
+		 * @param[in]	material	Material whose pass' parameters to bind.
+		 * @param[in]	passIdx		Index of the pass in the material.
 		 *					
 		 *					
 		 * @note	Core thread.
 		 * @note	Core thread.
 		 */
 		 */
 		static void setPassParams(const SPtr<MaterialCore>& material, UINT32 passIdx = 0);
 		static void setPassParams(const SPtr<MaterialCore>& material, UINT32 passIdx = 0);
 
 
 		/**
 		/**
-		 * @brief	Draws the specified mesh.
+		 * Draws the specified mesh.
 		 *
 		 *
 		 * @note	Core thread.
 		 * @note	Core thread.
 		 */
 		 */
 		void draw(const SPtr<MeshCoreBase>& mesh, const SubMesh& subMesh);
 		void draw(const SPtr<MeshCoreBase>& mesh, const SubMesh& subMesh);
 
 
 		/**
 		/**
-		 * @brief	Draws a quad over the entire viewport in normalized device coordinates.
+		 * Draws a quad over the entire viewport in normalized device coordinates.
 		 * 			
 		 * 			
-		 * @param	viewport	Destination viewport to draw the quad in.
-		 * @param	uv			UV coordinates to assign to the corners of the quad.
-		 * @param	textureSize	Size of the texture the UV coordinates are specified for. If the UV coordinates are already
-		 * 						in normalized (0, 1) range then keep this value as is. If the UV coordinates are in texels
-		 * 						then set this value to the texture size so they can be normalized internally.
+		 * @param[in]	viewport	Destination viewport to draw the quad in.
+		 * @param[in]	uv			UV coordinates to assign to the corners of the quad.
+		 * @param[in]	textureSize	Size of the texture the UV coordinates are specified for. If the UV coordinates are 
+		 *							already in normalized (0, 1) range then keep this value as is. If the UV coordinates 
+		 *							are in texels then set this value to the texture size so they can be normalized 
+		 *							internally.
 		 * 			
 		 * 			
 		 * @note	Core thread.
 		 * @note	Core thread.
 		 */
 		 */
@@ -65,9 +70,12 @@ namespace BansheeEngine
 	};
 	};
 
 
 	/**
 	/**
-	 * @brief	Provides easy access to RendererUtility.
+	 * Provides easy access to RendererUtility.
 	 * 			
 	 * 			
 	 * @note	Core thread only.
 	 * @note	Core thread only.
 	 */
 	 */
 	BS_CORE_EXPORT RendererUtility& gRendererUtility();
 	BS_CORE_EXPORT RendererUtility& gRendererUtility();
+
+	/** @} */
+	/** @endcond */
 }
 }

+ 54 - 75
BansheeCore/Include/BsSamplerState.h

@@ -1,17 +1,18 @@
 #pragma once
 #pragma once
 
 
 #include "BsCorePrerequisites.h"
 #include "BsCorePrerequisites.h"
-#include "BsMatrix4.h"
-#include "BsPixelUtil.h"
-#include "BsTexture.h"
 #include "BsColor.h"
 #include "BsColor.h"
 #include "BsIReflectable.h"
 #include "BsIReflectable.h"
 #include "BsCoreObject.h"
 #include "BsCoreObject.h"
 
 
 namespace BansheeEngine 
 namespace BansheeEngine 
 {
 {
+	/** @addtogroup RenderAPI
+	 *  @{
+	 */
+
 	/**
 	/**
-	 * @brief	Structure used for initializing a SamplerState.
+	 * Structure used for initializing a SamplerState.
 	 *
 	 *
 	 * @see		SamplerState
 	 * @see		SamplerState
 	 */
 	 */
@@ -37,67 +38,53 @@ namespace BansheeEngine
 		CompareFunction comparisonFunc;
 		CompareFunction comparisonFunc;
 	};
 	};
 
 
-	/**
-	 * @brief	Properties of SamplerState. Shared between sim and core thread versions of SamplerState.
-	 */
+	/** Properties of SamplerState. Shared between sim and core thread versions of SamplerState. */
 	class BS_CORE_EXPORT SamplerProperties
 	class BS_CORE_EXPORT SamplerProperties
 	{
 	{
 	public:
 	public:
 		SamplerProperties(const SAMPLER_STATE_DESC& desc);
 		SamplerProperties(const SAMPLER_STATE_DESC& desc);
 
 
 		/**
 		/**
-		 * @brief	Returns texture addressing mode for each possible texture coordinate. Addressing
-		 *			modes determine how are texture coordinates outside of [0, 1] range handled.
+		 * 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; }
 		const UVWAddressingMode& getTextureAddressingMode() const { return mData.addressMode; }
 
 
-		/**
-		 * @brief	Gets the filtering used when sampling from a texture.
-		 */
+		/** Gets the filtering used when sampling from a texture. */
         FilterOptions getTextureFiltering(FilterType ftpye) const;
         FilterOptions getTextureFiltering(FilterType ftpye) const;
 
 
 		/**
 		/**
-		 * @brief	Gets the anisotropy level. Higher anisotropy means better filtering
-		 *			for textures displayed on an angled slope relative to the viewer.
+		 * 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; }
 		unsigned int getTextureAnisotropy() const { return mData.maxAniso; }
 
 
-		/**
-		 * @brief	Gets a function that compares sampled data with existing sampled data.
-		 */
+		/** Gets a function that compares sampled data with existing sampled data. */
 		CompareFunction getComparisonFunction() const { return mData.comparisonFunc; }
 		CompareFunction getComparisonFunction() const { return mData.comparisonFunc; }
 
 
 		/**
 		/**
-		* @brief	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.
-		*/
+		 * 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; }
 		float getTextureMipmapBias() const { return mData.mipmapBias; }
 
 
-		/**
-		 * @brief	Returns the minimum mip map level.
-		 */
+		/** Returns the minimum mip map level. */
 		float getMinimumMip() const { return mData.mipMin; }
 		float getMinimumMip() const { return mData.mipMin; }
 
 
-		/**
-		 * @brief	Returns the maximum mip map level.
-		 */
+		/** Returns the maximum mip map level. */
 		float getMaximumMip() const { return mData.mipMax; }
 		float getMaximumMip() const { return mData.mipMax; }
 
 
 		/**
 		/**
-		 * @brief	Gets the border color that will be used when border texture addressing is used
-		 *			and texture address is outside of the valid range.
+		 * 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;
 		const Color& getBorderColor() const;
 
 
-		/**
-		 * @brief	Returns the hash value generated from the sampler state properties.
-		 */
+		/**	Returns the hash value generated from the sampler state properties. */
 		UINT64 getHash() const { return mHash; }
 		UINT64 getHash() const { return mHash; }
 
 
-		/**
-		 * @brief	Returns the descriptor originally used for creating the sampler state.
-		 */
+		/**	Returns the descriptor originally used for creating the sampler state. */
 		SAMPLER_STATE_DESC getDesc() const { return mData; }
 		SAMPLER_STATE_DESC getDesc() const { return mData; }
 
 
 	protected:
 	protected:
@@ -109,8 +96,10 @@ namespace BansheeEngine
 		UINT64 mHash;
 		UINT64 mHash;
 	};
 	};
 
 
+	/** @cond INTERNAL */
+
 	/**
 	/**
-	 * @brief	Core thread version of SamplerState.
+	 * Core thread version of SamplerState.
 	 *
 	 *
 	 * @note	Core thread.
 	 * @note	Core thread.
 	 */
 	 */
@@ -119,14 +108,10 @@ namespace BansheeEngine
 	public:
 	public:
 		virtual ~SamplerStateCore();
 		virtual ~SamplerStateCore();
 
 
-		/**
-		 * @brief	Returns information about the sampler state.
-		 */
+		/**	Returns information about the sampler state. */
 		const SamplerProperties& getProperties() const;
 		const SamplerProperties& getProperties() const;
 
 
-		/**
-		 * @brief	Returns the default sampler state.
-		 */
+		/**	Returns the default sampler state. */
 		static const SPtr<SamplerStateCore>& getDefault();
 		static const SPtr<SamplerStateCore>& getDefault();
 
 
 	protected:
 	protected:
@@ -134,64 +119,50 @@ namespace BansheeEngine
 
 
 		SamplerStateCore(const SAMPLER_STATE_DESC& desc);
 		SamplerStateCore(const SAMPLER_STATE_DESC& desc);
 
 
-		/**
-		 * @copydoc	CoreObjectCore::initialize
-		 */
+		/** @copydoc CoreObjectCore::initialize */
 		void initialize() override;
 		void initialize() override;
 
 
-		/**
-		 * @brief	Creates any API-specific state objects.
-		 */
+		/**	Creates any API-specific state objects. */
 		virtual void createInternal() { }
 		virtual void createInternal() { }
 
 
 		SamplerProperties mProperties;
 		SamplerProperties mProperties;
 	};
 	};
 
 
+	/** @endcond */
+
 	/**
 	/**
-	 * @brief	Class representing the state of a texture sampler.
+	 * 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.
-	 *
-	 *			Sim thread.
+	 * @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
 	class BS_CORE_EXPORT SamplerState : public IReflectable, public CoreObject
     {
     {
     public:
     public:
 		virtual ~SamplerState();
 		virtual ~SamplerState();
 
 
-		/**
-		 * @brief	Returns information about the sampler state.
-		 */
+		/**	Returns information about the sampler state. */
 		const SamplerProperties& getProperties() const;
 		const SamplerProperties& getProperties() const;
 
 
-		/**
-		 * @brief	Retrieves a core implementation of the sampler state usable only from the
-		 *			core thread.
-		 */
+		/**	Retrieves a core implementation of the sampler state usable only from the core thread. */
 		SPtr<SamplerStateCore> getCore() const;
 		SPtr<SamplerStateCore> getCore() const;
 
 
-		/**
-		 * @brief	Creates a new sampler state using the provided descriptor structure.
-		 */
+		/**	Creates a new sampler state using the provided descriptor structure. */
 		static SamplerStatePtr create(const SAMPLER_STATE_DESC& desc);
 		static SamplerStatePtr create(const SAMPLER_STATE_DESC& desc);
 
 
-		/**
-		 * @brief	Returns the default sampler state.
-		 */
+		/**	Returns the default sampler state. */
 		static const SamplerStatePtr& getDefault();
 		static const SamplerStatePtr& getDefault();
 
 
-		/**
-		 * @brief	Generates a hash value from a sampler state descriptor.
-		 */
+		/**	Generates a hash value from a sampler state descriptor. */
 		static UINT64 generateHash(const SAMPLER_STATE_DESC& desc);
 		static UINT64 generateHash(const SAMPLER_STATE_DESC& desc);
 
 
 	protected:
 	protected:
 		SamplerState(const SAMPLER_STATE_DESC& desc);
 		SamplerState(const SAMPLER_STATE_DESC& desc);
 
 
-		/**
-		 * @copydoc	CoreObjectCore::createCore
-		 */
+		/** @copydoc CoreObjectCore::createCore */
 		SPtr<CoreObjectCore> createCore() const override;
 		SPtr<CoreObjectCore> createCore() const override;
 
 
 		SamplerProperties mProperties;
 		SamplerProperties mProperties;
@@ -207,11 +178,16 @@ namespace BansheeEngine
 		static RTTITypeBase* getRTTIStatic();
 		static RTTITypeBase* getRTTIStatic();
 		virtual RTTITypeBase* getRTTI() const override;
 		virtual RTTITypeBase* getRTTI() const override;
     };
     };
+
+	/** @} */
 }
 }
 
 
-/**
- * @brief	Hash value generator for SAMPLER_STATE_DESC.
+/** @cond STDLIB */
+/** @addtogroup RenderAPI
+ *  @{
  */
  */
+
+/**	Hash value generator for SAMPLER_STATE_DESC. */
 template<>
 template<>
 struct std::hash<BansheeEngine::SAMPLER_STATE_DESC>
 struct std::hash<BansheeEngine::SAMPLER_STATE_DESC>
 {
 {
@@ -219,4 +195,7 @@ struct std::hash<BansheeEngine::SAMPLER_STATE_DESC>
 	{
 	{
 		return (size_t)BansheeEngine::SamplerState::generateHash(value);
 		return (size_t)BansheeEngine::SamplerState::generateHash(value);
 	}
 	}
-};
+};
+
+/** @} */
+/** @endcond */

+ 28 - 24
BansheeCore/Include/BsSubMesh.h

@@ -1,25 +1,29 @@
-#pragma once
-
-#include "BsCorePrerequisites.h"
-#include "BsDrawOps.h"
-
-namespace BansheeEngine
-{
-	/**
-	 * @brief	Data about a sub-mesh range and the type of primitives contained in the range.
-	 */
-	struct BS_CORE_EXPORT SubMesh
-	{
-		SubMesh()
-			: indexOffset(0), indexCount(0), drawOp(DOT_TRIANGLE_LIST)
-		{ }
-
-		SubMesh(UINT32 indexOffset, UINT32 indexCount, DrawOperationType drawOp):
-			indexOffset(indexOffset), indexCount(indexCount), drawOp(drawOp)
-		{ }
-
-		UINT32 indexOffset;
-		UINT32 indexCount;
-		DrawOperationType drawOp;
-	};
+#pragma once
+
+#include "BsCorePrerequisites.h"
+#include "BsDrawOps.h"
+
+namespace BansheeEngine
+{
+	/** @addtogroup RenderAPI
+	 *  @{
+	 */
+
+	/**	Data about a sub-mesh range and the type of primitives contained in the range. */
+	struct BS_CORE_EXPORT SubMesh
+	{
+		SubMesh()
+			: indexOffset(0), indexCount(0), drawOp(DOT_TRIANGLE_LIST)
+		{ }
+
+		SubMesh(UINT32 indexOffset, UINT32 indexCount, DrawOperationType drawOp):
+			indexOffset(indexOffset), indexCount(indexCount), drawOp(drawOp)
+		{ }
+
+		UINT32 indexOffset;
+		UINT32 indexCount;
+		DrawOperationType drawOp;
+	};
+
+	/** @} */
 }
 }

+ 97 - 114
BansheeCore/Include/BsTextureView.h

@@ -1,115 +1,98 @@
-#pragma once
-
-#include "BsCorePrerequisites.h"
-#include "BsCoreObject.h"
-
-namespace BansheeEngine
-{
-	/**
-	 * @brief	Data describing a texture view.
-	 */
-	struct BS_CORE_EXPORT TEXTURE_VIEW_DESC
-	{
-		/**
-		 * First mip level of the parent texture the view binds (0 - base level). 
-		 * This applied to all array slices specified below.
-		 */
-		UINT32 mostDetailMip;
-
-		/**
-		 * Number of mip levels to bind to the view. 
-		 * This applied to all array slices specified below.
-		 */
-		UINT32 numMips;
-
-		/**
-		 * First array slice the view binds to. This will be array index for 
-		 * 1D and 2D array textures, texture slice index for 3D textures, and 
-		 * face index for cube textures(cube index * 6).
- 		 */
-		UINT32 firstArraySlice;
-
-		/**
-		 * Number of array slices to bind tot he view. This will be number of
-		 * array elements for 1D and 2D array textures, number of slices for 3D textures,
-		 * and number of cubes for cube textures.
-		 */
-		UINT32 numArraySlices;
-
-		/**
-		 *	Type of texture view.
-		 */
-		GpuViewUsage usage;
-	};
-
-	/**
-	 * @brief	Texture views allow you to reference only a party of a texture.
-	 *			They may reference one or multiple mip-levels on one or multiple texture
-	 *			array slices. Selected mip level will apply to all slices.
-	 *
-	 *			They also allow you to re-purpose a texture. (e.g. make a render target 
-	 *			a bindable texture).
-	 */
-	class BS_CORE_EXPORT TextureView
-	{
-	public:
-		class HashFunction
-		{
-		public:
-			size_t operator()(const TEXTURE_VIEW_DESC &key) const;
-		};
-
-		class EqualFunction
-		{
-		public:
-			bool operator()(const TEXTURE_VIEW_DESC &a, const TEXTURE_VIEW_DESC &b) const;
-		};
-
-		virtual ~TextureView();
-
-		/**
-		 * @brief	Returns the most detailed mip level visible by the view.
-		 */
-		UINT32 getMostDetailedMip() const { return mDesc.mostDetailMip; }
-
-		/**
-		 * @brief	Returns the number of mip levels in a single slice visible by the view.
-		 */
-		UINT32 getNumMips() const { return mDesc.numMips; }
-
-		/**
-		 * @brief	Returns the first array slice index visible by this view.
-		 */
-		UINT32 getFirstArraySlice() const { return mDesc.firstArraySlice; }
-
-		/**
-		 * @brief	Returns the number of array slices visible by this view.
-		 */
-		UINT32 getNumArraySlices() const { return mDesc.numArraySlices; }
-
-		/**
-		 * @brief	Returns texture view usage. This determines where on the pipeline can be
-		 *			bind the view.
-		 */
-		GpuViewUsage getUsage() const { return mDesc.usage; }
-
-		/**
-		 * @brief	Returns the descriptor structure used for initializing the view.
-		 */
-		const TEXTURE_VIEW_DESC& getDesc() const { return mDesc; }
-
-		/**
-		 * @brief	Gets the owner texture the view is referencing.
-		 */
-		SPtr<TextureCore> getTexture() const { return mOwnerTexture; }
-
-	protected:
-		TextureView(const SPtr<TextureCore>& texture, const TEXTURE_VIEW_DESC& _desc);
-
-	protected:
-		friend class TextureCore;
-
-		TEXTURE_VIEW_DESC mDesc;
-		SPtr<TextureCore> mOwnerTexture;
-	};
+#pragma once
+
+#include "BsCorePrerequisites.h"
+
+namespace BansheeEngine
+{
+	/** @cond INTERNAL */
+	/** @addtogroup RenderAPI
+	 *  @{
+	 */
+
+	/** Data describing a texture view. */
+	struct BS_CORE_EXPORT TEXTURE_VIEW_DESC
+	{
+		/**
+		 * First mip level of the parent texture the view binds (0 - base level). This applied to all array slices 
+		 * specified below.
+		 */
+		UINT32 mostDetailMip;
+
+		/** Number of mip levels to bind to the view. This applied to all array slices specified below. */
+		UINT32 numMips;
+
+		/**
+		 * First array slice the view binds to. This will be array index for 1D and 2D array textures, texture slice index 
+		 * for 3D textures, and face index for cube textures(cube index * 6).
+ 		 */
+		UINT32 firstArraySlice;
+
+		/**
+		 * Number of array slices to bind tot he view. This will be number of array elements for 1D and 2D array textures, 
+		 * number of slices for 3D textures, and number of cubes for cube textures.
+		 */
+		UINT32 numArraySlices;
+
+		/** Type of texture view. */
+		GpuViewUsage usage;
+	};
+
+	/**
+	 * Texture views allow you to reference only a party of a texture. They may reference one or multiple mip-levels on one
+	 * or multiple texture array slices. Selected mip level will apply to all slices.
+	 *
+	 * They also allow you to re-purpose a texture. (e.g. make a render target  a bindable texture).
+	 *
+	 * @note	Core thread.
+	 */
+	class BS_CORE_EXPORT TextureView
+	{
+	public:
+		class HashFunction
+		{
+		public:
+			size_t operator()(const TEXTURE_VIEW_DESC &key) const;
+		};
+
+		class EqualFunction
+		{
+		public:
+			bool operator()(const TEXTURE_VIEW_DESC &a, const TEXTURE_VIEW_DESC &b) const;
+		};
+
+		virtual ~TextureView();
+
+		/**	Returns the most detailed mip level visible by the view. */
+		UINT32 getMostDetailedMip() const { return mDesc.mostDetailMip; }
+
+		/**	Returns the number of mip levels in a single slice visible by the view. */
+		UINT32 getNumMips() const { return mDesc.numMips; }
+
+		/**	Returns the first array slice index visible by this view. */
+		UINT32 getFirstArraySlice() const { return mDesc.firstArraySlice; }
+
+		/**	Returns the number of array slices visible by this view. */
+		UINT32 getNumArraySlices() const { return mDesc.numArraySlices; }
+
+		/**	Returns texture view usage. This determines where on the pipeline can be bind the view. */
+		GpuViewUsage getUsage() const { return mDesc.usage; }
+
+		/**	Returns the descriptor structure used for initializing the view. */
+		const TEXTURE_VIEW_DESC& getDesc() const { return mDesc; }
+
+		/**	Gets the owner texture the view is referencing. */
+		SPtr<TextureCore> getTexture() const { return mOwnerTexture; }
+
+	protected:
+		TextureView(const SPtr<TextureCore>& texture, const TEXTURE_VIEW_DESC& _desc);
+
+	protected:
+		friend class TextureCore;
+
+		TEXTURE_VIEW_DESC mDesc;
+		SPtr<TextureCore> mOwnerTexture;
+	};
+
+	/** @} */
+	/** @endcond */
 }
 }

+ 63 - 66
BansheeCore/Include/BsTimerQuery.h

@@ -1,67 +1,64 @@
-#pragma once
-
-#include "BsCorePrerequisites.h"
-
-namespace BansheeEngine
-{
-	/**
-	 * @brief	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() {}
-
-		/**
-		 * @brief	Starts the counter. 
-		 * 			
-		 * @note	Place any commands you want to measure after this call. Call "end" when done.
-		 */
-		virtual void begin() = 0;
-
-		/**
-		 * @brief	Stops the counter.
-		 */
-		virtual void end() = 0;
-
-		/**
-		 * @brief	Check if GPU has processed the query.
-		 */
-		virtual bool isReady() const = 0;
-
-		/**
-		 * @brief	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;
-
-		/**
-		* @brief	Triggered when GPU processes the query. As a parameter
-		*			it provides query duration in milliseconds.
-		*/
-		Event<void(float)> onTriggered;
-
-		/**
-		 * @brief	Creates a new query, but does not schedule it on GPU.
-		 */
-		static TimerQueryPtr create();
-
-	protected:
-		friend class QueryManager;
-
-		/**
-		* @brief	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;
-	};
+#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 */
 }
 }

+ 82 - 92
BansheeCore/Include/BsVertexBuffer.h

@@ -1,93 +1,83 @@
-#pragma once
-
-#include "BsCorePrerequisites.h"
-#include "BsHardwareBuffer.h"
-#include "BsCoreObject.h"
-#include "BsColor.h"
-
-namespace BansheeEngine 
-{
-	/**
-	 * @brief	Contains information about a vertex buffer buffer.
-	 */
-	class BS_CORE_EXPORT VertexBufferProperties
-	{
-	public:
-		VertexBufferProperties(UINT32 numVertices, UINT32 vertexSize);
-
-		/**
-		 * @brief	Gets the size in bytes of a single vertex in this buffer.
-		 */
-        UINT32 getVertexSize() const { return mVertexSize; }
-
-		/**
-		 * @brief	Get the number of vertices in this buffer.
-		 */
-        UINT32 getNumVertices() const { return mNumVertices; }
-
-	protected:
-		friend class VertexBuffer;
-		friend class VertexBufferCore;
-
-		UINT32 mNumVertices;
-		UINT32 mVertexSize;
-	};
-
-	/**
-	 * @brief	Core thread specific implementation of a vertex buffer.
-	 *
-	 * @see		VertexBuffer
-	 */
-	class BS_CORE_EXPORT VertexBufferCore : public CoreObjectCore, public HardwareBuffer
-	{
-	public:
-		VertexBufferCore(UINT32 vertexSize, UINT32 numVertices, GpuBufferUsage usage, bool streamOut);
-		virtual ~VertexBufferCore() { }
-
-		/**
-		 * @brief	Returns information about the vertex buffer.
-		 */
-		const VertexBufferProperties& getProperties() const { return mProperties; }
-
-	protected:
-		VertexBufferProperties mProperties;
-	};
-
-	/**
-	 * @brief	Specialization of a hardware buffer used for holding vertex data.
-	 */
-    class BS_CORE_EXPORT VertexBuffer : public CoreObject
-    {
-	public:
-		virtual ~VertexBuffer() { }
-
-		/**
-		 * @brief	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;
-    };
+#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;
+    };
+
+	/** @} */
 }
 }

+ 55 - 68
BansheeCore/Include/BsVertexData.h

@@ -1,69 +1,56 @@
-#pragma once
-
-#include "BsCorePrerequisites.h"
-#include "BsVertexDeclaration.h"
-#include "BsVertexBuffer.h"
-
-namespace BansheeEngine 
-{
-	/**
-	 * @brief	Container class consisting of a set of vertex buffers and their
-	 *			declaration.
-	 *
-	 * @note	Used just for more easily passing around vertex information.
-	 */
-	class BS_CORE_EXPORT VertexData
-	{
-    public:
-        VertexData();
-        ~VertexData();
-
-		/**
-		 * @brief	Declaration used for the contained vertex buffers.
-		 */
-		SPtr<VertexDeclarationCore> vertexDeclaration;
-
-		/**
-		 * @brief	Number of vertices to use.
-		 */
-		UINT32 vertexCount;
-
-		/**
-		 * @brief	Assigns a new vertex buffer to the specified index.
-		 */
-		void setBuffer(UINT32 index, SPtr<VertexBufferCore> buffer);
-
-		/**
-		 * @brief	Retrieves a vertex buffer from the specified index.
-		 */
-		SPtr<VertexBufferCore> getBuffer(UINT32 index) const;
-
-		/**
-		 * @brief	Returns a list of all bound vertex buffers.
-		 */
-		const UnorderedMap<UINT32, SPtr<VertexBufferCore>>& getBuffers() const { return mVertexBuffers; }
-
-		/**
-		 * @brief	Checks if there is a buffer at the specified index.
-		 */
-		bool isBufferBound(UINT32 index) const;
-
-		/**
-		 * @brief	Gets total number of bound buffers.
-		 */
-		UINT32 getBufferCount() const { return (UINT32)mVertexBuffers.size(); }
-
-		/**
-		 * @brief	Returns the maximum index of all bound buffers.
-		 */
-		UINT32 getMaxBufferIndex() const { return mMaxBufferIdx; }
-
-	private:
-		void recalculateMaxIndex();
-
-    private:
-		UnorderedMap<UINT32, SPtr<VertexBufferCore>> mVertexBuffers;
-
-		UINT32 mMaxBufferIdx = 0;
-	};
+#pragma once
+
+#include "BsCorePrerequisites.h"
+#include "BsVertexDeclaration.h"
+#include "BsVertexBuffer.h"
+
+namespace BansheeEngine 
+{
+	/** @addtogroup RenderAPI
+	 *  @{
+	 */
+
+	/**
+	 * Container class consisting of a set of vertex buffers and their declaration.
+	 *
+	 * @note	Used just for more easily passing around vertex information.
+	 */
+	class BS_CORE_EXPORT VertexData
+	{
+    public:
+        VertexData();
+        ~VertexData();
+
+		/**	Assigns a new vertex buffer to the specified index. */
+		void setBuffer(UINT32 index, SPtr<VertexBufferCore> buffer);
+
+		/**	Retrieves a vertex buffer from the specified index. */
+		SPtr<VertexBufferCore> getBuffer(UINT32 index) const;
+
+		/**	Returns a list of all bound vertex buffers. */
+		const UnorderedMap<UINT32, SPtr<VertexBufferCore>>& getBuffers() const { return mVertexBuffers; }
+
+		/**	Checks if there is a buffer at the specified index. */
+		bool isBufferBound(UINT32 index) const;
+
+		/**	Gets total number of bound buffers. */
+		UINT32 getBufferCount() const { return (UINT32)mVertexBuffers.size(); }
+
+		/**	Returns the maximum index of all bound buffers. */
+		UINT32 getMaxBufferIndex() const { return mMaxBufferIdx; }
+
+		/**	Declaration used for the contained vertex buffers. */
+		SPtr<VertexDeclarationCore> vertexDeclaration;
+
+		/**	Number of vertices to use. */
+		UINT32 vertexCount;
+
+	private:
+		void recalculateMaxIndex();
+
+		UnorderedMap<UINT32, SPtr<VertexBufferCore>> mVertexBuffers;
+		UINT32 mMaxBufferIdx = 0;
+	};
+
+	/** @} */
 }
 }

+ 228 - 276
BansheeCore/Include/BsVertexDeclaration.h

@@ -1,277 +1,229 @@
-#pragma once
-
-#include "BsCorePrerequisites.h"
-#include "BsColor.h"
-#include "BsCoreObject.h"
-
-namespace BansheeEngine
-{
-	/**
-	 * @brief	Semantics that are used for identifying the meaning of
-	 *			vertex buffer elements.
-	 */
-	enum VertexElementSemantic 
-	{
-		VES_POSITION = 1,
-		VES_BLEND_WEIGHTS = 2,
-        VES_BLEND_INDICES = 3,
-		VES_NORMAL = 4,
-		VES_COLOR = 5,
-		VES_TEXCOORD = 6,
-        VES_BITANGENT = 7,
-        VES_TANGENT = 8,
-		VES_POSITIONT = 9,
-		VES_PSIZE = 10
-	};
-
-	/**
-	 * @brief	Types used to identify base types of vertex element contents
-	 */
-    enum VertexElementType
-    {
-        VET_FLOAT1 = 0,
-        VET_FLOAT2 = 1,
-        VET_FLOAT3 = 2,
-        VET_FLOAT4 = 3,
-		VET_COLOR = 4,
-		VET_SHORT1 = 5,
-		VET_SHORT2 = 6,
-		VET_SHORT3 = 7,
-		VET_SHORT4 = 8,
-        VET_UBYTE4 = 9,
-        VET_COLOR_ARGB = 10,
-        VET_COLOR_ABGR = 11,
-		VET_UINT4 = 12,
-		VET_SINT4 = 13
-    };
-
-	/**
-	 * @brief	Describes a single vertex element in a vertex declaration.
-	 */
-	class BS_CORE_EXPORT VertexElement
-    {
-    public:
-		VertexElement() {}
-        VertexElement(UINT16 source, UINT32 offset, VertexElementType theType,
-			VertexElementSemantic semantic, UINT16 index = 0);
-
-		bool operator== (const VertexElement& rhs) const;
-		bool operator!= (const VertexElement& rhs) const;
-
-		/**
-		 * @brief	Returns index of the vertex buffer from which this element is stored.
-		 */
-		UINT16 getStreamIdx() const { return mSource; }
-
-		/**
-		 * @brief	Returns an offset into the buffer where this vertex is stored. This value
-		 *			might be in bytes but doesn't have to be, it's likely to be render API specific.
-		 */
-        UINT32 getOffset() const { return mOffset; }
-
-		/**
-		 * @brief	Gets the base data type of tis element.
-		 */
-        VertexElementType getType() const { return mType; }
-
-		/**
-		 * @brief	Gets a semantic that describes what this element contains.
-		 */
-        VertexElementSemantic getSemantic() const { return mSemantic; }
-
-		/**
-		 * @brief	Gets an index of this element. Only relevant when you have
-		 *			multiple elements with the same semantic, e.g. uv0, uv1.
-		 */
-		UINT16 getSemanticIdx() const { return mIndex; }
-
-		/**
-		 * @brief	Returns the size of this element in bytes.
-		 */
-		UINT32 getSize() const;
-
-		/**
-		 * @brief	Returns the size of a base element type.
-		 */
-		static UINT32 getTypeSize(VertexElementType etype);
-
-		/**
-		 * @brief	Returns the number of values in the provided base element type.
-		 *			e.g. float4 has four values.
-		 */
-		static UINT16 getTypeCount(VertexElementType etype);
-
-		/**
-		 * @brief	Gets packed color vertex element type used by the active render system.
-		 */
-		static VertexElementType getBestColorVertexElementType();
-
-	protected:
-		UINT16 mSource;
-		UINT32 mOffset;
-		VertexElementType mType;
-		VertexElementSemantic mSemantic;
-		UINT16 mIndex;
-    };
-
-	BS_ALLOW_MEMCPY_SERIALIZATION(VertexElement);
-
-	/**
-	 * @brief	Contains information about a vertex declaration.
-	 */
-	class BS_CORE_EXPORT VertexDeclarationProperties
-	{
-	public:
-		VertexDeclarationProperties(const List<VertexElement>& elements);
-
-		bool operator== (const VertexDeclarationProperties& rhs) const;
-		bool operator!= (const VertexDeclarationProperties& rhs) const;
-
-		/**
-		 * @brief	Get the number of elements in the declaration.
-		 */
-        UINT32 getElementCount() const { return (UINT32)mElementList.size(); }
-        
-		/**
-		 * @brief	Returns a list of vertex elements in the declaration.
-		 */
-		const List<VertexElement>& getElements() const { return mElementList; }
-
-		/**
-		 * @brief	Returns a single vertex element at the specified index.
-		 */
-		const VertexElement* getElement(UINT16 index) const;
-
-		/**
-		 * @brief	Attempts to find an element by the given semantic and semantic index. If no element
-		 *			can be found null is returned.
-		 */
-		virtual const VertexElement* findElementBySemantic(VertexElementSemantic sem, UINT16 index = 0) const;
-
-		/**
-		 * @brief	Returns a list of all elements that use the provided source index.
-		 */
-		virtual List<VertexElement> findElementsBySource(UINT16 source) const;
-
-		/**
-		 * @brief	Returns the total size of all vertex elements using the provided source index.
-		 */
-		virtual UINT32 getVertexSize(UINT16 source) const;
-
-	protected:
-		friend class VertexDeclaration;
-		friend class VertexDeclarationRTTI;
-
-		List<VertexElement> mElementList;
-	};
-
-	/**
-	 * @brief	Core thread portion of a VertexDeclaration.
-	 *
-	 * @see		VertexDeclaration.
-	 *
-	 * @note	Core thread.
-	 */
-	class BS_CORE_EXPORT VertexDeclarationCore : public CoreObjectCore
-    {
-	public:
-		virtual ~VertexDeclarationCore() { }
-
-		/**
-		 * @copydoc	CoreObjectCore::initialize
-		 */
-		void initialize() override;
-
-		/**
-		 * @brief	Returns properties describing the vertex declaration.
-		 */
-		const VertexDeclarationProperties& getProperties() const { return mProperties; }
-
-		/**
-		 * @brief	Returns an ID unique to this declaration.
-		 */
-		UINT32 getId() const { return mId; }
-
-		/**
-		 * @brief	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);
-
-		/**
-		 * @brief	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);
-
-	protected:
-		VertexDeclarationProperties mProperties;
-		UINT32 mId;
-
-		static UINT32 NextFreeId;
-    };
-
-	/**
-	 * @brief	Describes a set of vertex elements, used for describing contents of
-	 *			a vertex buffer or inputs to a vertex GPU program.
-	 *
-	 * @note	Sim thread.
-	 */
-	class BS_CORE_EXPORT VertexDeclaration : public IReflectable, public CoreObject
-    {
-	public:
-		virtual ~VertexDeclaration() { }
-
-		/**
-		 * @brief	Returns properties describing the vertex declaration.
-		 */
-		const VertexDeclarationProperties& getProperties() const { return mProperties; }
-
-		/**
-		 * @brief	Retrieves a core implementation of a vertex declaration usable only from the
-		 *			core thread.
-		 */
-		SPtr<VertexDeclarationCore> getCore() const;
-
-		/**
-		 * @copydoc		HardwareBufferManager::createVertexDeclaration
-		 */
-		static VertexDeclarationPtr createVertexDeclaration(const List<VertexElement>& elements);
-
-    protected:
-		friend class HardwareBufferManager;
-
-		VertexDeclaration(const List<VertexElement>& elements);
-
-		/**
-		 * @copydoc	CoreObject::createCore
-		 */
-		SPtr<CoreObjectCore> createCore() const override;
-
-	protected:
-		VertexDeclarationProperties mProperties;
-
-		/************************************************************************/
-		/* 								SERIALIZATION                      		*/
-		/************************************************************************/
-	public:
-		friend class VertexDeclarationRTTI;
-		static RTTITypeBase* getRTTIStatic();
-		virtual RTTITypeBase* getRTTI() const override;
-    };
-
-	/**
-	 * @brief	Converts a vertex semantic enum to a readable name.
-	 */
-	BS_CORE_EXPORT String toString(const VertexElementSemantic& val);
-
-	/**
-	 * @brief	Converts a vertex semantic enum to a readable name.
-	 */
-	BS_CORE_EXPORT WString toWString(const VertexElementSemantic& val);
+#pragma once
+
+#include "BsCorePrerequisites.h"
+#include "BsColor.h"
+#include "BsCoreObject.h"
+
+namespace BansheeEngine
+{
+	/** @addtogroup RenderAPI
+	 *  @{
+	 */
+
+	/** Semantics that are used for identifying the meaning of vertex buffer elements. */
+	enum VertexElementSemantic 
+	{
+		VES_POSITION = 1,
+		VES_BLEND_WEIGHTS = 2,
+        VES_BLEND_INDICES = 3,
+		VES_NORMAL = 4,
+		VES_COLOR = 5,
+		VES_TEXCOORD = 6,
+        VES_BITANGENT = 7,
+        VES_TANGENT = 8,
+		VES_POSITIONT = 9,
+		VES_PSIZE = 10
+	};
+
+	/**	Types used to identify base types of vertex element contents. */
+    enum VertexElementType
+    {
+        VET_FLOAT1 = 0,
+        VET_FLOAT2 = 1,
+        VET_FLOAT3 = 2,
+        VET_FLOAT4 = 3,
+		VET_COLOR = 4,
+		VET_SHORT1 = 5,
+		VET_SHORT2 = 6,
+		VET_SHORT3 = 7,
+		VET_SHORT4 = 8,
+        VET_UBYTE4 = 9,
+        VET_COLOR_ARGB = 10,
+        VET_COLOR_ABGR = 11,
+		VET_UINT4 = 12,
+		VET_SINT4 = 13
+    };
+
+	/**	Describes a single vertex element in a vertex declaration. */
+	class BS_CORE_EXPORT VertexElement
+    {
+    public:
+		VertexElement() {}
+        VertexElement(UINT16 source, UINT32 offset, VertexElementType theType,
+			VertexElementSemantic semantic, UINT16 index = 0);
+
+		bool operator== (const VertexElement& rhs) const;
+		bool operator!= (const VertexElement& rhs) const;
+
+		/**	Returns index of the vertex buffer from which this element is stored. */
+		UINT16 getStreamIdx() const { return mSource; }
+
+		/**
+		 * Returns an offset into the buffer where this vertex is stored. This value might be in bytes but doesn't have to
+		 * be, it's likely to be render API specific.
+		 */
+        UINT32 getOffset() const { return mOffset; }
+
+		/** Gets the base data type of tis element. */
+        VertexElementType getType() const { return mType; }
+
+		/**	Gets a semantic that describes what this element contains. */
+        VertexElementSemantic getSemantic() const { return mSemantic; }
+
+		/**
+		 * Gets an index of this element. Only relevant when you have multiple elements with the same semantic, 
+		 * e.g. uv0, uv1.
+		 */
+		UINT16 getSemanticIdx() const { return mIndex; }
+
+		/** Returns the size of this element in bytes. */
+		UINT32 getSize() const;
+
+		/**	Returns the size of a base element type. */
+		static UINT32 getTypeSize(VertexElementType etype);
+
+		/** Returns the number of values in the provided base element type. e.g. float4 has four values. */
+		static UINT16 getTypeCount(VertexElementType etype);
+
+		/**	Gets packed color vertex element type used by the active render system. */
+		static VertexElementType getBestColorVertexElementType();
+
+	protected:
+		UINT16 mSource;
+		UINT32 mOffset;
+		VertexElementType mType;
+		VertexElementSemantic mSemantic;
+		UINT16 mIndex;
+    };
+
+	BS_ALLOW_MEMCPY_SERIALIZATION(VertexElement);
+
+	/**	Contains information about a vertex declaration. */
+	class BS_CORE_EXPORT VertexDeclarationProperties
+	{
+	public:
+		VertexDeclarationProperties(const List<VertexElement>& elements);
+
+		bool operator== (const VertexDeclarationProperties& rhs) const;
+		bool operator!= (const VertexDeclarationProperties& rhs) const;
+
+		/**	Get the number of elements in the declaration. */
+        UINT32 getElementCount() const { return (UINT32)mElementList.size(); }
+        
+		/**	Returns a list of vertex elements in the declaration. */
+		const List<VertexElement>& getElements() const { return mElementList; }
+
+		/**	Returns a single vertex element at the specified index. */
+		const VertexElement* getElement(UINT16 index) const;
+
+		/**
+		 * Attempts to find an element by the given semantic and semantic index. If no element can be found null is returned.
+		 */
+		virtual const VertexElement* findElementBySemantic(VertexElementSemantic sem, UINT16 index = 0) const;
+
+		/**	Returns a list of all elements that use the provided source index. */
+		virtual List<VertexElement> findElementsBySource(UINT16 source) const;
+
+		/**	Returns the total size of all vertex elements using the provided source index. */
+		virtual UINT32 getVertexSize(UINT16 source) const;
+
+	protected:
+		friend class VertexDeclaration;
+		friend class VertexDeclarationRTTI;
+
+		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.
+	 *
+	 * @note	Sim thread.
+	 */
+	class BS_CORE_EXPORT VertexDeclaration : public IReflectable, public CoreObject
+    {
+	public:
+		virtual ~VertexDeclaration() { }
+
+		/** Returns properties describing the vertex declaration. */
+		const VertexDeclarationProperties& getProperties() const { return mProperties; }
+
+		/**	Retrieves a core implementation of a vertex declaration usable only from the core thread. */
+		SPtr<VertexDeclarationCore> getCore() const;
+
+		/** @copydoc HardwareBufferManager::createVertexDeclaration */
+		static VertexDeclarationPtr createVertexDeclaration(const List<VertexElement>& elements);
+
+    protected:
+		friend class HardwareBufferManager;
+
+		VertexDeclaration(const List<VertexElement>& elements);
+
+		/** @copydoc CoreObject::createCore */
+		SPtr<CoreObjectCore> createCore() const override;
+
+	protected:
+		VertexDeclarationProperties mProperties;
+
+		/************************************************************************/
+		/* 								SERIALIZATION                      		*/
+		/************************************************************************/
+	public:
+		friend class VertexDeclarationRTTI;
+		static RTTITypeBase* getRTTIStatic();
+		virtual RTTITypeBase* getRTTI() const override;
+    };
+
+	/**	Converts a vertex semantic enum to a readable name. */
+	BS_CORE_EXPORT String toString(const VertexElementSemantic& val);
+
+	/**	Converts a vertex semantic enum to a readable name. */
+	BS_CORE_EXPORT WString toWString(const VertexElementSemantic& val);
+
+	/** @} */
 }
 }

+ 110 - 130
BansheeCore/Include/BsVideoModeInfo.h

@@ -1,131 +1,111 @@
-#pragma once
-
-#include "BsCorePrerequisites.h"
-
-namespace BansheeEngine
-{
-	/**
-	 * @brief	Video mode contains information about how a render window
-	 *			presents its information to an output device like a monitor.
-	 */
-	class BS_CORE_EXPORT VideoMode
-	{
-	public:
-		VideoMode() {}
-
-		/**
-		 * @brief	Creates a new video mode.
-		 *
-		 * @param	width		Width of the frame buffer in pixels.
-		 * @param	height		Height of the frame buffer in pixels.
-		 * @param	refreshRate	How often should the output device refresh the output image in Hertz.
-		 * @param	outputIdx	Output index of the output device. Normally this means
-		 *						output monitor. 0th index always represents the primary device
-		 *						while order of others is undefined.
-		 */
-		VideoMode(UINT32 width, UINT32 height, float refreshRate = 60.0f, UINT32 outputIdx = 0);
-		virtual ~VideoMode();
-
-		bool operator== (const VideoMode& other) const;
-
-		/**
-		 * @brief	Width of the front/back buffer in pixels.
-		 */
-		UINT32 getWidth() const { return mWidth; }
-
-		/**
-		 * @brief	Height of the front/back buffer in pixels.
-		 */
-		UINT32 getHeight() const { return mHeight; }
-
-		/**
-		 * @brief	Returns a refresh rate in Hertz.
-		 */
-		virtual float getRefreshRate() const { return mRefreshRate; }
-
-		/**
-		 * @brief	Returns information about the parent output.
-		 */
-		UINT32 getOutputIdx() const { return mOutputIdx; }
-
-		/**
-		 * @brief	Determines was video mode user created or provided by the API/OS.
-		 *			API/OS created video modes can contain additional information that allows
-		 *			the video mode to be used more accurately and you should use them when possible.
-		 */
-		bool isCustom() const { return mIsCustom;  }
-	protected:
-		UINT32 mWidth = 1280;
-		UINT32 mHeight = 720;
-		float mRefreshRate = 60.0f;
-		UINT32 mOutputIdx = 0;
-		bool mIsCustom = true;
-	};
-
-	/**
-	 * @brief	Contains information about a video output device, including
-	 *			a list of all available video modes.
-	 */
-	class BS_CORE_EXPORT VideoOutputInfo
-	{
-	public:
-		VideoOutputInfo() { }
-		virtual ~VideoOutputInfo();
-
-		VideoOutputInfo(const VideoOutputInfo&) = delete; // Make non-copyable
-		VideoOutputInfo& operator=(const VideoOutputInfo&) = delete; // Make non-copyable
-
-		/**
-		 * @brief	Name of the output device.
-		 */
-		const String& getName() const { return mName; }
-
-		/**
-		 * @brief	Number of available video modes for this output.
-		 */
-		UINT32 getNumVideoModes() const { return (UINT32)mVideoModes.size(); }
-
-		/**
-		 * @brief	Returns video mode at the specified index.
-		 */
-		const VideoMode& getVideoMode(UINT32 idx) const { return *mVideoModes.at(idx); }
-
-		/**
-		 * @brief	Returns the video mode currently used by the desktop.
-		 */
-		const VideoMode& getDesktopVideoMode() const { return *mDesktopVideoMode; }
-
-	protected:
-		String mName;
-		Vector<VideoMode*> mVideoModes;
-		VideoMode* mDesktopVideoMode = nullptr;
-	};
-
-	/**
-	 * @brief	Contains information about available output devices (e.g. monitor) 
-	 *			and their video modes.
-	 */
-	class BS_CORE_EXPORT VideoModeInfo
-	{
-	public:
-		VideoModeInfo() { }
-		virtual ~VideoModeInfo();
-
-		VideoModeInfo(const VideoModeInfo&) = delete; // Make non-copyable
-		VideoModeInfo& operator=(const VideoModeInfo&) = delete; // Make non-copyable
-
-		/**
-		 * @brief	Returns the number of available output devices.
-		 */
-		UINT32 getNumOutputs() const { return (UINT32)mOutputs.size(); }
-
-		/**
-		 * @brief	Returns video mode information about a specific output device. 0th index always 
-		 * 			represents the primary device while order of others is undefined.
-		 */
-		const VideoOutputInfo& getOutputInfo(UINT32 idx) const { return *mOutputs[idx]; }
-
-	protected:
-		Vector<VideoOutputInfo*> mOutputs;
-	};
+#pragma once
+
+#include "BsCorePrerequisites.h"
+
+namespace BansheeEngine
+{
+	/** @addtogroup RenderAPI
+	 *  @{
+	 */
+
+	/**
+	 * Video mode contains information about how a render window presents its information to an output device like a 
+	 * monitor.
+	 */
+	class BS_CORE_EXPORT VideoMode
+	{
+	public:
+		VideoMode() {}
+
+		/**
+		 * Creates a new video mode.
+		 *
+		 * @param[in]	width		Width of the frame buffer in pixels.
+		 * @param[in]	height		Height of the frame buffer in pixels.
+		 * @param[in]	refreshRate	How often should the output device refresh the output image in hertz.
+		 * @param[in]	outputIdx	Output index of the output device. Normally this means output monitor. 0th index always
+		 *							represents the primary device while order of others is undefined.
+		 */
+		VideoMode(UINT32 width, UINT32 height, float refreshRate = 60.0f, UINT32 outputIdx = 0);
+		virtual ~VideoMode();
+
+		bool operator== (const VideoMode& other) const;
+
+		/**	Width of the front/back buffer in pixels. */
+		UINT32 getWidth() const { return mWidth; }
+
+		/**	Height of the front/back buffer in pixels. */
+		UINT32 getHeight() const { return mHeight; }
+
+		/**	Returns a refresh rate in hertz. */
+		virtual float getRefreshRate() const { return mRefreshRate; }
+
+		/**	Returns information about the parent output. */
+		UINT32 getOutputIdx() const { return mOutputIdx; }
+
+		/**
+		 * Determines was video mode user created or provided by the API/OS. API/OS created video modes can contain 
+		 * additional information that allows the video mode to be used more accurately and you should use them when possible.
+		 */
+		bool isCustom() const { return mIsCustom;  }
+	protected:
+		UINT32 mWidth = 1280;
+		UINT32 mHeight = 720;
+		float mRefreshRate = 60.0f;
+		UINT32 mOutputIdx = 0;
+		bool mIsCustom = true;
+	};
+
+	/** Contains information about a video output device, including a list of all available video modes. */
+	class BS_CORE_EXPORT VideoOutputInfo
+	{
+	public:
+		VideoOutputInfo() { }
+		virtual ~VideoOutputInfo();
+
+		VideoOutputInfo(const VideoOutputInfo&) = delete; // Make non-copyable
+		VideoOutputInfo& operator=(const VideoOutputInfo&) = delete; // Make non-copyable
+
+		/**	Name of the output device. */
+		const String& getName() const { return mName; }
+
+		/**	Number of available video modes for this output. */
+		UINT32 getNumVideoModes() const { return (UINT32)mVideoModes.size(); }
+
+		/**	Returns video mode at the specified index. */
+		const VideoMode& getVideoMode(UINT32 idx) const { return *mVideoModes.at(idx); }
+
+		/**	Returns the video mode currently used by the desktop. */
+		const VideoMode& getDesktopVideoMode() const { return *mDesktopVideoMode; }
+
+	protected:
+		String mName;
+		Vector<VideoMode*> mVideoModes;
+		VideoMode* mDesktopVideoMode = nullptr;
+	};
+
+	/** Contains information about available output devices (e.g. monitor) and their video modes. */
+	class BS_CORE_EXPORT VideoModeInfo
+	{
+	public:
+		VideoModeInfo() { }
+		virtual ~VideoModeInfo();
+
+		VideoModeInfo(const VideoModeInfo&) = delete; // Make non-copyable
+		VideoModeInfo& operator=(const VideoModeInfo&) = delete; // Make non-copyable
+
+		/**	Returns the number of available output devices. */
+		UINT32 getNumOutputs() const { return (UINT32)mOutputs.size(); }
+
+		/**
+		 * Returns video mode information about a specific output device. 0th index always represents the primary device 
+		 * while order of others is undefined.
+		 */
+		const VideoOutputInfo& getOutputInfo(UINT32 idx) const { return *mOutputs[idx]; }
+
+	protected:
+		Vector<VideoOutputInfo*> mOutputs;
+	};
+
+	/** @} */
 }
 }

+ 220 - 285
BansheeCore/Include/BsViewport.h

@@ -1,286 +1,221 @@
-#pragma once
-
-#include "BsCorePrerequisites.h"
-#include "BsIReflectable.h"
-#include "BsCoreObject.h"
-#include "BsColor.h"
-#include "BsRect2I.h"
-#include "BsRect2.h"
-#include "BsEvent.h"
-
-namespace BansheeEngine 
-{
-	/**
-	 * @brief	Viewport provides you with a way to render to only a part of a 
-	 * 			RenderTarget. It also allows you to set up color/depth/stencil
-	 * 			clear values for that specific region.
-	 */
-	class BS_CORE_EXPORT ViewportBase
-    {
-    public:       
-		virtual ~ViewportBase() { }
-
-        /**
-         * @brief	Gets the normalized x coordinate of the viewport, in [0, 1] range.
-         */
-        float getNormalizedX() const { return mNormArea.x; }
-
-        /**
-         * @brief	Gets the normalized y coordinate of the viewport, in [0, 1] range.
-         */
-        float getNormalizedY() const { return mNormArea.y; }
-
-        /**
-         * @brief	Gets the normalized width of the viewport, in [0, 1] range.
-         */
-        float getNormalizedWidth() const { return mNormArea.width; }
-
-		/**
-         * @brief	Gets the normalized height of the viewport, in [0, 1] range.
-         */
-        float getNormalizedHeight() const { return mNormArea.height; }
-
-        /**
-         * @brief	Gets the actual x coordinate of the viewport in pixels, in [0, RenderTargetWidth] range.
-         */
-		INT32 getX() const;
-
-        /**
-         * @brief	Gets the actual y coordinate of the viewport in pixels, in [0, RenderTargetHeight] range.
-         */
-		INT32 getY() const;
-
-		/**
-         * @brief	Gets the actual width coordinate of the viewport in pixels, in [0, RenderTargetWidth] range.
-         */
-		INT32 getWidth() const;
-
-		/**
-         * @brief	Gets the actual height coordinate of the viewport in pixels, in [0, RenderTargetHeight] range.
-         */
-		INT32 getHeight() const;
-               
-        /**
-         * @brief	Changes the area that the viewport covers.
-         *
-         * @note	Viewport coordinates are normalized in [0, 1] range.
-         */
-        void setArea(float x, float y, float width, float height);
-
-		/**
-		 * @brief	Returns actual area of the viewport, in pixels.
-		 */
-		Rect2I getArea() const;
-
-		/**
-		 * @brief	Returns the normalized area of the viewport.
-		 *
-		 * @note	Viewport coordinates are normalized in [0, 1] range.
-		 */
-		Rect2 getNormArea() const { return mNormArea; }
-
-		/**
-		 * @brief	Activates or deactivates clears for color, depth or stencil buffers.
-		 *			Buffers will be cleared before rendering to this viewport is performed.
-		 */
-		void setRequiresClear(bool colorClear, bool depthClear, bool stencilClear);
-
-		/**
-		 * @brief	Sets values to clear color, depth and stencil buffers to.
-		 */
-		void setClearValues(const Color& clearColor, float clearDepth = 0.0f, UINT16 clearStencil = 0);
-
-		/**
-		 * @brief	Returns the color to clear the viewport color buffers to.
-		 */
-		const Color& getClearColor() const { return mClearColor; }
-
-		/**
-		 * @brief	Returns the value to clear the viewport depth buffers to.
-		 */
-		float getClearDepthValue() const { return mDepthClearValue; }
-
-		/**
-		 * @brief	Returns the value to clear the viewport stencil buffer to.
-		 */
-		UINT16 getClearStencilValue() const { return mStencilClearValue; }
-
-		/**
-		 * @brief	Returns true if viewport requires color clear before rendering.
-		 */
-		bool getRequiresColorClear() const { return mRequiresColorClear; }
-
-		/**
-		 * @brief	Returns true if viewport requires depth clear before rendering.
-		 */
-		bool getRequiresDepthClear() const { return mRequiresDepthClear; }
-
-		/**
-		 * @brief	Returns true if viewport requires stencil clear before rendering.
-		 */
-		bool getRequiresStencilClear() const { return mRequiresStencilClear; }
-
-    protected:
-        /**
-         * @brief	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
-		 */
-		virtual void _markCoreDirty() { }
-
-		/**
-		 * @brief	Gets the render target width.
-		 */
-		virtual UINT32 getTargetWidth() const = 0;
-
-		/**
-		 * @brief	Gets the render target width.
-		 */
-		virtual UINT32 getTargetHeight() const = 0;
-
-		Rect2 mNormArea;
-
-		bool mRequiresColorClear;
-		bool mRequiresDepthClear;
-		bool mRequiresStencilClear;
-
-		Color mClearColor;
-		float mDepthClearValue;
-		UINT16 mStencilClearValue;
-
-		static const Color DEFAULT_CLEAR_COLOR;
-    };
-
-	/**
-	 * @copydoc	ViewportBase
-	 */
-	class BS_CORE_EXPORT ViewportCore : public CoreObjectCore, public ViewportBase
-    {
-    public:       
-        /**
-         * @brief	Returns the render target the viewport is associated with.
-         */
-		SPtr<RenderTargetCore> getTarget() const { return mTarget; }
-
-		/**
-		 * @brief	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;
-    };
-
-	/**
-	 * @copydoc	ViewportBase
-	 */
-	class BS_CORE_EXPORT Viewport : public IReflectable, public CoreObject, public ViewportBase
-    {
-    public:       
-        /**
-         * @brief	Returns the render target the viewport is associated with.
-         */
-        RenderTargetPtr getTarget() const { return mTarget; }
-
-		/**
-		 * @brief	Sets the render target the viewport will be associated with.
-		 */
-		void setTarget(const RenderTargetPtr& target);
-
-		/**
-		 * @brief	Retrieves a core implementation of a viewport usable only from the
-		 *			core thread.
-		 */
-		SPtr<ViewportCore> getCore() const;
-
-		/**
-		 * @copydoc	ViewportBase::ViewportBase
-		 */
-		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
-		 */
-		void _markCoreDirty() override;
-
-		/**
-		 * @copydoc	CoreObject::getTargetWidth
-		 */
-		UINT32 getTargetWidth() const override;
-
-		/**
-		 * @copydoc	CoreObject::getTargetHeight
-		 */
-		UINT32 getTargetHeight() const override;
-
-		/**
-		 * @copydoc	CoreObject::syncToCore
-		 */
-		CoreSyncData syncToCore(FrameAlloc* allocator) override;
-
-		/**
-		 * @copydoc	CoreObject::getCoreDependencies
-		 */
-		void getCoreDependencies(Vector<CoreObject*>& dependencies) override;
-
-		/**
-		 * @copydoc	CoreObject::createCore
-		 */
-		SPtr<CoreObjectCore> createCore() const override;
-
-        RenderTargetPtr mTarget;
-
-		/************************************************************************/
-		/* 								RTTI		                     		*/
-		/************************************************************************/
-		Viewport();
-
-		/**
-		 * @brief	Creates an empty viewport for serialization purposes.
-		 */
-		static ViewportPtr createEmpty();
-	public:
-		friend class ViewportRTTI;
-		static RTTITypeBase* getRTTIStatic();
-		virtual RTTITypeBase* getRTTI() const override;
-    };
+#pragma once
+
+#include "BsCorePrerequisites.h"
+#include "BsIReflectable.h"
+#include "BsCoreObject.h"
+#include "BsColor.h"
+#include "BsRect2I.h"
+#include "BsRect2.h"
+#include "BsEvent.h"
+
+namespace BansheeEngine 
+{
+	/** @addtogroup Implementation
+	 *  @{
+	 */
+
+	/**
+	 * Viewport provides you with a way to render to only a part of a RenderTarget. It also allows you to set up 
+	 * color/depth/stencil clear values for that specific region.
+	 */
+	class BS_CORE_EXPORT ViewportBase
+    {
+    public:       
+		virtual ~ViewportBase() { }
+
+        /**	Gets the normalized x coordinate of the viewport, in [0, 1] range. */
+        float getNormalizedX() const { return mNormArea.x; }
+
+        /**	Gets the normalized y coordinate of the viewport, in [0, 1] range. */
+        float getNormalizedY() const { return mNormArea.y; }
+
+        /**	Gets the normalized width of the viewport, in [0, 1] range. */
+        float getNormalizedWidth() const { return mNormArea.width; }
+
+		/**	Gets the normalized height of the viewport, in [0, 1] range.  */
+        float getNormalizedHeight() const { return mNormArea.height; }
+
+        /**	Gets the actual x coordinate of the viewport in pixels, in [0, RenderTargetWidth] range. */
+		INT32 getX() const;
+
+        /**	Gets the actual y coordinate of the viewport in pixels, in [0, RenderTargetHeight] range. */
+		INT32 getY() const;
+
+		/**	Gets the actual width coordinate of the viewport in pixels, in [0, RenderTargetWidth] range. */
+		INT32 getWidth() const;
+
+		/**	Gets the actual height coordinate of the viewport in pixels, in [0, RenderTargetHeight] range. */
+		INT32 getHeight() const;
+               
+        /**
+         * Changes the area that the viewport covers.
+         *
+         * @note	Viewport coordinates are normalized in [0, 1] range.
+         */
+        void setArea(float x, float y, float width, float height);
+
+		/**	Returns actual area of the viewport, in pixels. */
+		Rect2I getArea() const;
+
+		/**
+		 * Returns the normalized area of the viewport.
+		 *
+		 * @note	Viewport coordinates are normalized in [0, 1] range.
+		 */
+		Rect2 getNormArea() const { return mNormArea; }
+
+		/**
+		 * Activates or deactivates clears for color, depth or stencil buffers. Buffers will be cleared before rendering 
+		 * to this viewport is performed.
+		 */
+		void setRequiresClear(bool colorClear, bool depthClear, bool stencilClear);
+
+		/**	Sets values to clear color, depth and stencil buffers to. */
+		void setClearValues(const Color& clearColor, float clearDepth = 0.0f, UINT16 clearStencil = 0);
+
+		/** Returns the color to clear the viewport color buffers to. */
+		const Color& getClearColor() const { return mClearColor; }
+
+		/**	Returns the value to clear the viewport depth buffers to. */
+		float getClearDepthValue() const { return mDepthClearValue; }
+
+		/**	Returns the value to clear the viewport stencil buffer to. */
+		UINT16 getClearStencilValue() const { return mStencilClearValue; }
+
+		/**	Returns true if viewport requires color clear before rendering. */
+		bool getRequiresColorClear() const { return mRequiresColorClear; }
+
+		/**	Returns true if viewport requires depth clear before rendering. */
+		bool getRequiresDepthClear() const { return mRequiresDepthClear; }
+
+		/**	Returns true if viewport requires stencil clear before rendering. */
+		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 */
+		virtual void _markCoreDirty() { }
+
+		/** Gets the render target width. */
+		virtual UINT32 getTargetWidth() const = 0;
+
+		/**	Gets the render target width. */
+		virtual UINT32 getTargetHeight() const = 0;
+
+		Rect2 mNormArea;
+
+		bool mRequiresColorClear;
+		bool mRequiresDepthClear;
+		bool mRequiresStencilClear;
+
+		Color mClearColor;
+		float mDepthClearValue;
+		UINT16 mStencilClearValue;
+
+		static const Color DEFAULT_CLEAR_COLOR;
+    };
+
+	/** @} */
+
+	/** @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
+    {
+    public:       
+        /**	Returns the render target the viewport is associated with. */
+        RenderTargetPtr getTarget() const { return mTarget; }
+
+		/**	Sets the render target the viewport will be associated with. */
+		void setTarget(const RenderTargetPtr& target);
+
+		/**	Retrieves a core implementation of a viewport usable only from the core thread. */
+		SPtr<ViewportCore> getCore() const;
+
+		/** @copydoc ViewportBase::ViewportBase */
+		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 */
+		void _markCoreDirty() override;
+
+		/** @copydoc CoreObject::getTargetWidth */
+		UINT32 getTargetWidth() const override;
+
+		/** @copydoc CoreObject::getTargetHeight */
+		UINT32 getTargetHeight() const override;
+
+		/** @copydoc CoreObject::syncToCore */
+		CoreSyncData syncToCore(FrameAlloc* allocator) override;
+
+		/** @copydoc CoreObject::getCoreDependencies */
+		void getCoreDependencies(Vector<CoreObject*>& dependencies) override;
+
+		/** @copydoc CoreObject::createCore */
+		SPtr<CoreObjectCore> createCore() const override;
+
+        RenderTargetPtr mTarget;
+
+		/************************************************************************/
+		/* 								RTTI		                     		*/
+		/************************************************************************/
+		Viewport();
+
+		/** Creates an empty viewport for serialization purposes. */
+		static ViewportPtr createEmpty();
+	public:
+		friend class ViewportRTTI;
+		static RTTITypeBase* getRTTIStatic();
+		virtual RTTITypeBase* getRTTI() const override;
+    };
+
+	/** @} */
 }
 }

+ 1 - 1
BansheeCore/Source/BsInput.cpp

@@ -70,7 +70,7 @@ namespace BansheeEngine
 					deviceData.keyStates[i] = ButtonState::On;
 					deviceData.keyStates[i] = ButtonState::On;
 			}
 			}
 
 
-			UINT32 numAxes = deviceData.axes.size();
+			UINT32 numAxes = (UINT32)deviceData.axes.size();
 			for (UINT32 i = 0; i < numAxes; i++)
 			for (UINT32 i = 0; i < numAxes; i++)
 			{
 			{
 				deviceData.axes[i].rel = 0.0f;
 				deviceData.axes[i].rel = 0.0f;

+ 49 - 48
BansheeCore/Source/BsRendererManager.cpp

@@ -1,49 +1,50 @@
-#include "BsRendererManager.h"
-#include "BsCoreRenderer.h"
-#include "BsException.h"
-
-namespace BansheeEngine
-{
-	RendererManager::~RendererManager()
-	{
-		if (mActiveRenderer != nullptr)
-			mActiveRenderer->destroy();
-	}
-
-	void RendererManager::setActive(const String& name)
-	{
-		for(auto iter = mAvailableFactories.begin(); iter != mAvailableFactories.end(); ++iter)
-		{
-			if((*iter)->name() == name)
-			{
-				CoreRendererPtr newRenderer = (*iter)->create();
-				if(newRenderer != nullptr)
-				{
-					if (mActiveRenderer != nullptr)
-						mActiveRenderer->destroy();
-
-					mActiveRenderer = newRenderer;
-				}				
-			}
-		}
-
-		if(mActiveRenderer == nullptr)
-		{
-			BS_EXCEPT(InternalErrorException, 
-				"Cannot initialize renderer. Renderer with the name '" + name + "' cannot be found.")
-		}
-	}
-
-	void RendererManager::initialize()
-	{
-		if (mActiveRenderer != nullptr)
-			mActiveRenderer->initialize();
-	}
-
-	void RendererManager::_registerFactory(RendererFactoryPtr factory)
-	{
-		assert(factory != nullptr);
-
-		mAvailableFactories.push_back(factory);
-	}
+#include "BsRendererManager.h"
+#include "BsCoreRenderer.h"
+#include "BsException.h"
+#include "BsRendererFactory.h"
+
+namespace BansheeEngine
+{
+	RendererManager::~RendererManager()
+	{
+		if (mActiveRenderer != nullptr)
+			mActiveRenderer->destroy();
+	}
+
+	void RendererManager::setActive(const String& name)
+	{
+		for(auto iter = mAvailableFactories.begin(); iter != mAvailableFactories.end(); ++iter)
+		{
+			if((*iter)->name() == name)
+			{
+				CoreRendererPtr newRenderer = (*iter)->create();
+				if(newRenderer != nullptr)
+				{
+					if (mActiveRenderer != nullptr)
+						mActiveRenderer->destroy();
+
+					mActiveRenderer = newRenderer;
+				}				
+			}
+		}
+
+		if(mActiveRenderer == nullptr)
+		{
+			BS_EXCEPT(InternalErrorException, 
+				"Cannot initialize renderer. Renderer with the name '" + name + "' cannot be found.")
+		}
+	}
+
+	void RendererManager::initialize()
+	{
+		if (mActiveRenderer != nullptr)
+			mActiveRenderer->initialize();
+	}
+
+	void RendererManager::_registerFactory(RendererFactoryPtr factory)
+	{
+		assert(factory != nullptr);
+
+		mAvailableFactories.push_back(factory);
+	}
 }
 }

+ 145 - 148
BansheeCore/Source/BsSamplerState.cpp

@@ -1,148 +1,145 @@
-#include "BsSamplerState.h"
-#include "BsSamplerStateRTTI.h"
-#include "BsRenderStateManager.h"
-#include "BsRenderAPI.h"
-#include "BsException.h"
-#include "BsResources.h"
-
-namespace BansheeEngine 
-{
-	bool SAMPLER_STATE_DESC::operator == (const SAMPLER_STATE_DESC& rhs) const
-	{
-		return addressMode == rhs.addressMode && 
-			minFilter == rhs.minFilter && 
-			magFilter == rhs.magFilter && 
-			mipFilter == rhs.mipFilter &&
-			maxAniso == rhs.maxAniso && 
-			mipmapBias == rhs.mipmapBias && 
-			mipMin == rhs.mipMin && 
-			mipMax == rhs.mipMax && 
-			borderColor == rhs.borderColor && 
-			comparisonFunc == rhs.comparisonFunc;
-	}
-
-	SamplerProperties::SamplerProperties(const SAMPLER_STATE_DESC& desc)
-		:mData(desc), mHash(SamplerState::generateHash(desc))
-	{ }
-
-	FilterOptions SamplerProperties::getTextureFiltering(FilterType ft) const
-	{
-		switch (ft)
-		{
-		case FT_MIN:
-			return mData.minFilter;
-		case FT_MAG:
-			return mData.magFilter;
-		case FT_MIP:
-			return mData.mipFilter;
-		}
-
-		return mData.minFilter;
-	}
-
-	const Color& SamplerProperties::getBorderColor() const
-	{
-		return mData.borderColor;
-	}
-
-	SamplerStateCore::SamplerStateCore(const SAMPLER_STATE_DESC& desc)
-		:mProperties(desc)
-	{
-		
-	}
-
-	SamplerStateCore::~SamplerStateCore()
-	{
-		RenderStateCoreManager::instance().notifySamplerStateDestroyed(mProperties.mData);
-	}
-
-	void SamplerStateCore::initialize()
-	{
-		// Since we cache states it's possible this object was already initialized
-		// (i.e. multiple sim-states can share a single core-state)
-		if (isInitialized())
-			return;
-
-		createInternal();
-		CoreObjectCore::initialize();
-	}
-
-	const SamplerProperties& SamplerStateCore::getProperties() const
-	{
-		return mProperties;
-	}
-
-	const SPtr<SamplerStateCore>& SamplerStateCore::getDefault()
-	{
-		return RenderStateCoreManager::instance().getDefaultSamplerState();
-	}
-
-	SamplerState::SamplerState(const SAMPLER_STATE_DESC& desc)
-		:mProperties(desc)
-	{
-
-	}
-
-	SamplerState::~SamplerState()
-	{
-
-	}
-
-	SPtr<SamplerStateCore> SamplerState::getCore() const
-	{
-		return std::static_pointer_cast<SamplerStateCore>(mCoreSpecific);
-	}
-
-	SPtr<CoreObjectCore> SamplerState::createCore() const
-	{
-		return RenderStateCoreManager::instance()._createSamplerState(mProperties.mData);
-	}
-
-	SamplerStatePtr SamplerState::create(const SAMPLER_STATE_DESC& desc)
-	{
-		return RenderStateManager::instance().createSamplerState(desc);
-	}
-
-	const SamplerStatePtr& SamplerState::getDefault()
-	{
-		return RenderStateManager::instance().getDefaultSamplerState();
-	}
-
-	UINT64 SamplerState::generateHash(const SAMPLER_STATE_DESC& desc)
-	{
-		size_t hash = 0;
-		hash_combine(hash, (UINT32)desc.addressMode.u);
-		hash_combine(hash, (UINT32)desc.addressMode.v);
-		hash_combine(hash, (UINT32)desc.addressMode.w);
-		hash_combine(hash, (UINT32)desc.minFilter);
-		hash_combine(hash, (UINT32)desc.magFilter);
-		hash_combine(hash, (UINT32)desc.mipFilter);
-		hash_combine(hash, desc.maxAniso);
-		hash_combine(hash, desc.mipmapBias);
-		hash_combine(hash, desc.mipMin);
-		hash_combine(hash, desc.mipMax);
-		hash_combine(hash, desc.borderColor);
-		hash_combine(hash, (UINT32)desc.comparisonFunc);
-
-		return (UINT64)hash;
-	}
-
-	const SamplerProperties& SamplerState::getProperties() const
-	{
-		return mProperties;
-	}
-
-	/************************************************************************/
-	/* 								RTTI		                     		*/
-	/************************************************************************/
-
-	RTTITypeBase* SamplerState::getRTTIStatic()
-	{
-		return SamplerStateRTTI::instance();
-	}
-
-	RTTITypeBase* SamplerState::getRTTI() const
-	{
-		return SamplerState::getRTTIStatic();
-	}
-}
+#include "BsSamplerState.h"
+#include "BsSamplerStateRTTI.h"
+#include "BsRenderStateManager.h"
+
+namespace BansheeEngine 
+{
+	bool SAMPLER_STATE_DESC::operator == (const SAMPLER_STATE_DESC& rhs) const
+	{
+		return addressMode == rhs.addressMode && 
+			minFilter == rhs.minFilter && 
+			magFilter == rhs.magFilter && 
+			mipFilter == rhs.mipFilter &&
+			maxAniso == rhs.maxAniso && 
+			mipmapBias == rhs.mipmapBias && 
+			mipMin == rhs.mipMin && 
+			mipMax == rhs.mipMax && 
+			borderColor == rhs.borderColor && 
+			comparisonFunc == rhs.comparisonFunc;
+	}
+
+	SamplerProperties::SamplerProperties(const SAMPLER_STATE_DESC& desc)
+		:mData(desc), mHash(SamplerState::generateHash(desc))
+	{ }
+
+	FilterOptions SamplerProperties::getTextureFiltering(FilterType ft) const
+	{
+		switch (ft)
+		{
+		case FT_MIN:
+			return mData.minFilter;
+		case FT_MAG:
+			return mData.magFilter;
+		case FT_MIP:
+			return mData.mipFilter;
+		}
+
+		return mData.minFilter;
+	}
+
+	const Color& SamplerProperties::getBorderColor() const
+	{
+		return mData.borderColor;
+	}
+
+	SamplerStateCore::SamplerStateCore(const SAMPLER_STATE_DESC& desc)
+		:mProperties(desc)
+	{
+		
+	}
+
+	SamplerStateCore::~SamplerStateCore()
+	{
+		RenderStateCoreManager::instance().notifySamplerStateDestroyed(mProperties.mData);
+	}
+
+	void SamplerStateCore::initialize()
+	{
+		// Since we cache states it's possible this object was already initialized
+		// (i.e. multiple sim-states can share a single core-state)
+		if (isInitialized())
+			return;
+
+		createInternal();
+		CoreObjectCore::initialize();
+	}
+
+	const SamplerProperties& SamplerStateCore::getProperties() const
+	{
+		return mProperties;
+	}
+
+	const SPtr<SamplerStateCore>& SamplerStateCore::getDefault()
+	{
+		return RenderStateCoreManager::instance().getDefaultSamplerState();
+	}
+
+	SamplerState::SamplerState(const SAMPLER_STATE_DESC& desc)
+		:mProperties(desc)
+	{
+
+	}
+
+	SamplerState::~SamplerState()
+	{
+
+	}
+
+	SPtr<SamplerStateCore> SamplerState::getCore() const
+	{
+		return std::static_pointer_cast<SamplerStateCore>(mCoreSpecific);
+	}
+
+	SPtr<CoreObjectCore> SamplerState::createCore() const
+	{
+		return RenderStateCoreManager::instance()._createSamplerState(mProperties.mData);
+	}
+
+	SamplerStatePtr SamplerState::create(const SAMPLER_STATE_DESC& desc)
+	{
+		return RenderStateManager::instance().createSamplerState(desc);
+	}
+
+	const SamplerStatePtr& SamplerState::getDefault()
+	{
+		return RenderStateManager::instance().getDefaultSamplerState();
+	}
+
+	UINT64 SamplerState::generateHash(const SAMPLER_STATE_DESC& desc)
+	{
+		size_t hash = 0;
+		hash_combine(hash, (UINT32)desc.addressMode.u);
+		hash_combine(hash, (UINT32)desc.addressMode.v);
+		hash_combine(hash, (UINT32)desc.addressMode.w);
+		hash_combine(hash, (UINT32)desc.minFilter);
+		hash_combine(hash, (UINT32)desc.magFilter);
+		hash_combine(hash, (UINT32)desc.mipFilter);
+		hash_combine(hash, desc.maxAniso);
+		hash_combine(hash, desc.mipmapBias);
+		hash_combine(hash, desc.mipMin);
+		hash_combine(hash, desc.mipMax);
+		hash_combine(hash, desc.borderColor);
+		hash_combine(hash, (UINT32)desc.comparisonFunc);
+
+		return (UINT64)hash;
+	}
+
+	const SamplerProperties& SamplerState::getProperties() const
+	{
+		return mProperties;
+	}
+
+	/************************************************************************/
+	/* 								RTTI		                     		*/
+	/************************************************************************/
+
+	RTTITypeBase* SamplerState::getRTTIStatic()
+	{
+		return SamplerStateRTTI::instance();
+	}
+
+	RTTITypeBase* SamplerState::getRTTI() const
+	{
+		return SamplerState::getRTTIStatic();
+	}
+}

+ 589 - 589
BansheeD3D9RenderAPI/Source/BsD3D9Mappings.cpp

@@ -1,589 +1,589 @@
-#include "BsD3D9Mappings.h"
-#include "BsException.h"
-#include "BsDebug.h"
-
-namespace BansheeEngine 
-{
-	D3DTEXTUREADDRESS D3D9Mappings::get(TextureAddressingMode tam, const D3DCAPS9& devCaps)
-	{
-		switch(tam)
-		{
-		case TAM_WRAP:
-			return D3DTADDRESS_WRAP;
-		case TAM_MIRROR:
-			return D3DTADDRESS_MIRROR;
-		case TAM_CLAMP:
-			return D3DTADDRESS_CLAMP;
-        case TAM_BORDER:
-            if (devCaps.TextureAddressCaps & D3DPTADDRESSCAPS_BORDER)
-                return D3DTADDRESS_BORDER;
-            else
-                return D3DTADDRESS_CLAMP;
-		}
-
-		return D3DTADDRESS_FORCE_DWORD;
-	}
-
-	D3DBLEND D3D9Mappings::get(BlendFactor sbf)
-	{
-		switch(sbf)
-		{
-		case BF_ONE:
-			return D3DBLEND_ONE;
-		case BF_ZERO:
-			return D3DBLEND_ZERO;
-		case BF_DEST_COLOR:
-			return D3DBLEND_DESTCOLOR;
-		case BF_SOURCE_COLOR:
-			return D3DBLEND_SRCCOLOR;
-		case BF_INV_DEST_COLOR:
-			return D3DBLEND_INVDESTCOLOR;
-		case BF_INV_SOURCE_COLOR:
-			return D3DBLEND_INVSRCCOLOR;
-		case BF_DEST_ALPHA:
-			return D3DBLEND_DESTALPHA;
-		case BF_SOURCE_ALPHA:
-			return D3DBLEND_SRCALPHA;
-		case BF_INV_DEST_ALPHA:
-			return D3DBLEND_INVDESTALPHA;
-		case BF_INV_SOURCE_ALPHA:
-			return D3DBLEND_INVSRCALPHA;
-		}
-
-		return D3DBLEND_FORCE_DWORD;
-	}
-
-	D3DBLENDOP D3D9Mappings::get(BlendOperation sbo)
-	{
-		switch(sbo)
-		{
-		case BO_ADD:
-			return D3DBLENDOP_ADD;
-		case BO_SUBTRACT:
-			return D3DBLENDOP_SUBTRACT;
-		case BO_REVERSE_SUBTRACT:
-			return D3DBLENDOP_REVSUBTRACT;
-		case BO_MIN:
-			return D3DBLENDOP_MIN;
-		case BO_MAX:
-			return D3DBLENDOP_MAX;
-		}
-
-		return D3DBLENDOP_FORCE_DWORD;
-	}
-
-	DWORD D3D9Mappings::get(CompareFunction cf)
-	{
-		switch(cf)
-		{
-		case CMPF_ALWAYS_FAIL:
-			return D3DCMP_NEVER;
-		case CMPF_ALWAYS_PASS:
-			return D3DCMP_ALWAYS;
-		case CMPF_LESS:
-			return D3DCMP_LESS;
-		case CMPF_LESS_EQUAL:
-			return D3DCMP_LESSEQUAL;
-		case CMPF_EQUAL:
-			return D3DCMP_EQUAL;
-		case CMPF_NOT_EQUAL:
-			return D3DCMP_NOTEQUAL;
-		case CMPF_GREATER_EQUAL:
-			return D3DCMP_GREATEREQUAL;
-		case CMPF_GREATER:
-			return D3DCMP_GREATER;
-		};
-
-		return 0;
-	}
-
-	DWORD D3D9Mappings::get(CullingMode cm, bool flip)
-	{
-		switch(cm)
-		{
-		case CULL_NONE:
-			return D3DCULL_NONE;
-		case CULL_CLOCKWISE:
-			if(flip)
-				return D3DCULL_CCW;
-			else
-				return D3DCULL_CW;
-		case CULL_COUNTERCLOCKWISE:
-			if(flip)
-				return D3DCULL_CW;
-			else
-				return D3DCULL_CCW;
-		}
-
-		return 0;
-	}
-
-	D3DFILLMODE D3D9Mappings::get(PolygonMode level)
-	{
-		switch(level)
-		{
-		case PM_WIREFRAME:
-			return D3DFILL_WIREFRAME;
-		case PM_SOLID:
-			return D3DFILL_SOLID;
-		}
-
-		return D3DFILL_FORCE_DWORD;
-	}
-
-	DWORD D3D9Mappings::get(StencilOperation op, bool invert)
-	{
-		switch(op)
-		{
-		case SOP_KEEP:
-			return D3DSTENCILOP_KEEP;
-		case SOP_ZERO:
-			return D3DSTENCILOP_ZERO;
-		case SOP_REPLACE:
-			return D3DSTENCILOP_REPLACE;
-		case SOP_INCREMENT:
-            return invert ? D3DSTENCILOP_DECRSAT : D3DSTENCILOP_INCRSAT;
-		case SOP_DECREMENT:
-            return invert ? D3DSTENCILOP_INCRSAT : D3DSTENCILOP_DECRSAT;
-		case SOP_INCREMENT_WRAP:
-            return invert ? D3DSTENCILOP_DECR : D3DSTENCILOP_INCR;
-		case SOP_DECREMENT_WRAP:
-            return invert ? D3DSTENCILOP_INCR : D3DSTENCILOP_DECR;
-		case SOP_INVERT:
-			return D3DSTENCILOP_INVERT;
-		}
-
-		return 0;
-	}
-
-	D3DSAMPLERSTATETYPE D3D9Mappings::get(FilterType ft)
-    {
-        switch (ft)
-        {
-        case FT_MIN:
-            return D3DSAMP_MINFILTER;
-            break;
-        case FT_MAG:
-            return D3DSAMP_MAGFILTER;
-            break;
-        case FT_MIP:
-            return D3DSAMP_MIPFILTER;
-            break;
-        }
-
-        return D3DSAMP_MINFILTER;
-    }
-
-	DWORD D3D9Mappings::get(FilterType ft, FilterOptions fo, const D3DCAPS9& devCaps, D3DTexType texType)
-	{
-		// Assume normal
-		DWORD capsType = devCaps.TextureFilterCaps;
-
-		switch( texType )
-		{
-		case D3D_TEX_TYPE_NORMAL:
-			capsType = devCaps.TextureFilterCaps;
-			break;
-		case D3D_TEX_TYPE_CUBE:
-			capsType = devCaps.CubeTextureFilterCaps;
-			break;
-		case D3D_TEX_TYPE_VOLUME:
-			capsType = devCaps.VolumeTextureFilterCaps;
-			break;
-		}
-
-        switch (ft)
-        {
-        case FT_MIN:
-            switch(fo)
-            {
-                // NOTE: Fall through if device doesn't support requested type
-            case FO_ANISOTROPIC:
-                if(capsType & D3DPTFILTERCAPS_MINFANISOTROPIC)
-                {
-                    return D3DTEXF_ANISOTROPIC;
-                    break;
-                }
-            case FO_LINEAR:
-                if(capsType & D3DPTFILTERCAPS_MINFLINEAR)
-                {
-                    return D3DTEXF_LINEAR;
-                    break;
-                }
-            case FO_POINT:
-            case FO_NONE:
-                return D3DTEXF_POINT;
-                break;
-            }
-            break;
-        case FT_MAG:
-            switch( fo )
-            {
-            // NOTE: Fall through if device doesn't support requested type
-            case FO_ANISOTROPIC:
-                if(capsType & D3DPTFILTERCAPS_MAGFANISOTROPIC)
-                {
-                    return D3DTEXF_ANISOTROPIC;
-                    break;
-                }
-            case FO_LINEAR:
-                if(capsType & D3DPTFILTERCAPS_MAGFLINEAR)
-                {
-                    return D3DTEXF_LINEAR;
-                    break;
-                }
-            case FO_POINT:
-            case FO_NONE:
-                return D3DTEXF_POINT;
-                break;
-            }
-            break;
-        case FT_MIP:
-            switch( fo )
-            {
-            case FO_ANISOTROPIC:
-            case FO_LINEAR:
-                if(capsType & D3DPTFILTERCAPS_MIPFLINEAR)
-                {
-                    return D3DTEXF_LINEAR;
-                    break;
-                }
-            case FO_POINT:
-                if(capsType & D3DPTFILTERCAPS_MIPFPOINT)
-                {
-                    return D3DTEXF_POINT;
-                    break;
-                }
-            case FO_NONE:
-                return D3DTEXF_NONE;
-                break;
-            }
-            break;
-        }
-
-        return 0;
-	}
-
-	D3D9Mappings::D3DTexType D3D9Mappings::get(TextureType texType)
-	{
-		switch( texType )
-		{
-		case TEX_TYPE_1D :
-		case TEX_TYPE_2D :
-			return D3D9Mappings::D3D_TEX_TYPE_NORMAL;
-		case TEX_TYPE_CUBE_MAP :
-			return D3D9Mappings::D3D_TEX_TYPE_CUBE;
-		case TEX_TYPE_3D :
-            return D3D9Mappings::D3D_TEX_TYPE_VOLUME;
-		}
-		return D3D9Mappings::D3D_TEX_TYPE_NONE;
-	}
-
-    DWORD D3D9Mappings::get(GpuBufferUsage usage)
-    {
-        DWORD ret = 0;
-        if (usage & GBU_DYNAMIC)
-        {
-            ret |= D3DUSAGE_DYNAMIC;
-        }
-
-        return ret;
-    }
-
-    DWORD D3D9Mappings::get(GpuLockOptions options, GpuBufferUsage usage)
-    {
-        DWORD ret = 0;
-        if (options == GBL_WRITE_ONLY_DISCARD)
-        {
-            // D3D doesn't like discard or no_overwrite on non-dynamic buffers
-            if (usage & GBU_DYNAMIC)
-                ret |= D3DLOCK_DISCARD;
-        }
-        
-		if (options == GBL_READ_ONLY)
-        {
-			ret |= D3DLOCK_READONLY;
-        }
-
-        if (options == GBL_WRITE_ONLY_NO_OVERWRITE)
-        {
-            // D3D doesn't like discard or no_overwrite on non-dynamic buffers
-            if (usage & GBU_DYNAMIC)
-                ret |= D3DLOCK_NOOVERWRITE;
-        }
-
-        return ret;
-    }
-
-    D3DFORMAT D3D9Mappings::get(IndexType itype)
-    {
-        if (itype == IT_32BIT)
-        {
-            return D3DFMT_INDEX32;
-        }
-        else
-        {
-            return D3DFMT_INDEX16;
-        }
-    }
-
-	D3DDECLTYPE D3D9Mappings::get(VertexElementType vType)
-	{
-		switch (vType)
-		{
-		case VET_COLOR:
-		case VET_COLOR_ABGR:
-		case VET_COLOR_ARGB:
-			return D3DDECLTYPE_D3DCOLOR;
-			break;
-		case VET_FLOAT1:
-			return D3DDECLTYPE_FLOAT1;
-			break;
-		case VET_FLOAT2:
-			return D3DDECLTYPE_FLOAT2;
-			break;
-		case VET_FLOAT3:
-			return D3DDECLTYPE_FLOAT3;
-			break;
-		case VET_FLOAT4:
-			return D3DDECLTYPE_FLOAT4;
-			break;
-        case VET_SHORT2:
-			return D3DDECLTYPE_SHORT2;
-			break;
-        case VET_SHORT4:
-			return D3DDECLTYPE_SHORT4;
-			break;
-        case VET_UBYTE4:
-            return D3DDECLTYPE_UBYTE4;
-            break;
-		}
-
-		return D3DDECLTYPE_FLOAT3;
-	}
-
-	D3DDECLUSAGE D3D9Mappings::get(VertexElementSemantic sem)
-	{
-		switch (sem)
-		{
-		case VES_BLEND_INDICES:
-			return D3DDECLUSAGE_BLENDINDICES;
-		case VES_BLEND_WEIGHTS:
-			return D3DDECLUSAGE_BLENDWEIGHT;
-		case VES_COLOR:
-			return D3DDECLUSAGE_COLOR;
-		case VES_NORMAL:
-			return D3DDECLUSAGE_NORMAL;
-		case VES_POSITION:
-			return D3DDECLUSAGE_POSITION;
-		case VES_TEXCOORD:
-			return D3DDECLUSAGE_TEXCOORD;
-		case VES_BITANGENT:
-			return D3DDECLUSAGE_BINORMAL;
-		case VES_TANGENT:
-			return D3DDECLUSAGE_TANGENT;
-		default:
-			BS_EXCEPT(RenderingAPIException, "Invalid semantic for D3D9 render system: " + toString(sem));
-		}
-
-		return D3DDECLUSAGE_POSITION;
-	}
-
-	VertexElementSemantic D3D9Mappings::get(D3DDECLUSAGE sem)
-	{
-		switch (sem)
-		{
-		case D3DDECLUSAGE_BLENDINDICES:
-			return VES_BLEND_INDICES;
-		case D3DDECLUSAGE_BLENDWEIGHT:
-			return VES_BLEND_WEIGHTS;
-		case D3DDECLUSAGE_COLOR:
-			return VES_COLOR;
-		case D3DDECLUSAGE_NORMAL:
-			return VES_NORMAL;
-		case D3DDECLUSAGE_POSITION:
-			return VES_POSITION;
-		case D3DDECLUSAGE_TEXCOORD:
-			return VES_TEXCOORD;
-		case D3DDECLUSAGE_BINORMAL:
-			return VES_BITANGENT;
-		case D3DDECLUSAGE_TANGENT:
-			return VES_TANGENT;
-		default:
-			BS_EXCEPT(RenderingAPIException, "Invalid semantic for D3D9 render system: " + toString(sem));
-		}
-
-		return VES_POSITION;
-	}
-
-	D3DXMATRIX D3D9Mappings::makeD3DXMatrix(const Matrix4& mat)
-	{
-		// Transpose matrix
-		// D3D9 uses row vectors i.e. V*M
-		return D3DXMATRIX(
-            mat[0][0], mat[1][0], mat[2][0], mat[3][0],
-            mat[0][1], mat[1][1], mat[2][1], mat[3][1],
-            mat[0][2], mat[1][2], mat[2][2], mat[3][2],
-            mat[0][3], mat[1][3], mat[2][3], mat[3][3]);
-	}
-
-	Matrix4 D3D9Mappings::convertD3DXMatrix(const D3DXMATRIX& mat)
-	{
-		return Matrix4(
-            mat.m[0][0], mat.m[1][0], mat.m[2][0], mat.m[3][0],
-            mat.m[0][1], mat.m[1][1], mat.m[2][1], mat.m[3][1],
-            mat.m[0][2], mat.m[1][2], mat.m[2][2], mat.m[3][2],
-            mat.m[0][3], mat.m[1][3], mat.m[2][3], mat.m[3][3]);
-	}
-
-	PixelFormat D3D9Mappings::_getPF(D3DFORMAT d3dPF)
-	{
-		switch(d3dPF)
-		{
-		case D3DFMT_R8G8B8:
-			return PF_B8G8R8;
-		case D3DFMT_A8R8G8B8:
-			return PF_B8G8R8A8;
-		case D3DFMT_A8B8G8R8:
-			return PF_R8G8B8A8;
-		case D3DFMT_X8B8G8R8:
-			return PF_R8G8B8X8;
-		case D3DFMT_X8R8G8B8:
-			return PF_B8G8R8X8;
-		case D3DFMT_R16F:
-			return PF_FLOAT16_R;
-		case D3DFMT_A16B16G16R16F:
-			return PF_FLOAT16_RGBA;
-		case D3DFMT_R32F:
-			return PF_FLOAT32_R;
-		case D3DFMT_G32R32F: // TODO - For some reason G and R are flipped in DX9 which might not be compatible with other render systems directly
-			return PF_FLOAT32_RG;
-		case D3DFMT_A32B32G32R32F:
-			return PF_FLOAT32_RGBA;
-		case D3DFMT_G16R16F: // TODO - For some reason G and R are flipped in DX9 which might not be compatible with other render systems directly
-			return PF_FLOAT16_RG;
-		case D3DFMT_DXT1:
-			return PF_BC1;
-		case D3DFMT_DXT3:
-			return PF_BC2;
-		case D3DFMT_DXT5:
-			return PF_BC3;
-		case D3DFMT_D24S8:
-			return PF_D24S8;
-		case D3DFMT_D32F_LOCKABLE:
-			return PF_D32;
-		case D3DFMT_D16:
-			return PF_D16;
-		case D3DFMT_A2B10G10R10:
-			return PF_UNORM_R10G10B10A2;
-		default:
-			return PF_UNKNOWN;
-		}
-	}
-
-	D3DFORMAT D3D9Mappings::_getPF(PixelFormat pf)
-	{
-		// DX9 uses different format semantics than most render systems, where most significant bit is signified by the
-		// first channel letter. For example in RGBA8 format, R is most-significant byte. Which is why most formats map to their
-		// reverse version in-engine as seen below.
-		// (This is not the case for floating point formats, EXCEPT for green-red one)
-		switch(pf)
-		{
-		case PF_B8G8R8A8:
-			return D3DFMT_A8R8G8B8;
-		case PF_R8G8B8X8:
-			return D3DFMT_X8B8G8R8;
-		case PF_B8G8R8X8:
-			return D3DFMT_X8R8G8B8;
-		case PF_FLOAT16_R:
-			return D3DFMT_R16F;
-		case PF_FLOAT16_RG:
-			return D3DFMT_G16R16F;
-		case PF_FLOAT16_RGBA:
-			return D3DFMT_A16B16G16R16F;
-		case PF_FLOAT32_R:
-			return D3DFMT_R32F;
-		case PF_FLOAT32_RG:
-			return D3DFMT_G32R32F;
-		case PF_FLOAT32_RGBA:
-			return D3DFMT_A32B32G32R32F;
-		case PF_BC1:
-		case PF_BC1a:
-			return D3DFMT_DXT1;
-		case PF_BC2:
-			return D3DFMT_DXT3;
-		case PF_BC3:
-			return D3DFMT_DXT5;
-		case PF_D24S8:
-			return D3DFMT_D24S8;
-		case PF_D32:
-			return D3DFMT_D32F_LOCKABLE;
-		case PF_D16:
-			return D3DFMT_D16;
-		case PF_UNORM_R10G10B10A2:
-			return D3DFMT_A2B10G10R10;
-		case PF_UNKNOWN:
-		default:
-			return D3DFMT_UNKNOWN;
-		}
-	}
-
-	PixelFormat D3D9Mappings::_getClosestSupportedPF(PixelFormat enginePF)
-	{
-		if (_getPF(enginePF) != D3DFMT_UNKNOWN)
-			return enginePF;
-
-		switch(enginePF)
-		{
-		case PF_R8:
-			return PF_B8G8R8X8;
-		case PF_R8G8:
-			return PF_B8G8R8X8;
-		case PF_B8G8R8:
-			return PF_B8G8R8X8;
-		case PF_A8R8G8B8:
-			return PF_B8G8R8A8;
-		case PF_A8B8G8R8:
-			return PF_R8G8B8A8;
-		case PF_R8G8B8:
-			return PF_B8G8R8;
-		case PF_FLOAT16_RGB:
-			return PF_FLOAT16_RGBA;
-		case PF_FLOAT32_RGB:
-			return PF_FLOAT32_RGBA;
-		case PF_D32_S8X24:
-			return PF_D24S8;
-		case PF_UNKNOWN:
-		default:
-			return PF_B8G8R8A8;
-		}
-	}
-
-	PixelFormat D3D9Mappings::_getClosestSupportedRenderTargetPF(PixelFormat enginePF)
-	{
-		switch(enginePF)
-		{
-		case PF_B8G8R8A8:
-			return PF_B8G8R8A8;
-		case PF_B8G8R8X8:
-			return PF_B8G8R8X8;
-		default:
-			return PF_B8G8R8A8;
-		}
-	}
-
-	PixelFormat D3D9Mappings::_getClosestSupportedDepthStencilPF(PixelFormat enginePF)
-	{
-		switch(enginePF)
-		{
-		case PF_D24S8:
-			return PF_D24S8;
-		case PF_D32:
-			return PF_D32;
-		case PF_D16:
-			return PF_D16;
-		default:
-			return PF_D24S8;
-		}
-	}
-}
+#include "BsD3D9Mappings.h"
+#include "BsException.h"
+#include "BsMatrix4.h"
+
+namespace BansheeEngine 
+{
+	D3DTEXTUREADDRESS D3D9Mappings::get(TextureAddressingMode tam, const D3DCAPS9& devCaps)
+	{
+		switch(tam)
+		{
+		case TAM_WRAP:
+			return D3DTADDRESS_WRAP;
+		case TAM_MIRROR:
+			return D3DTADDRESS_MIRROR;
+		case TAM_CLAMP:
+			return D3DTADDRESS_CLAMP;
+        case TAM_BORDER:
+            if (devCaps.TextureAddressCaps & D3DPTADDRESSCAPS_BORDER)
+                return D3DTADDRESS_BORDER;
+            else
+                return D3DTADDRESS_CLAMP;
+		}
+
+		return D3DTADDRESS_FORCE_DWORD;
+	}
+
+	D3DBLEND D3D9Mappings::get(BlendFactor sbf)
+	{
+		switch(sbf)
+		{
+		case BF_ONE:
+			return D3DBLEND_ONE;
+		case BF_ZERO:
+			return D3DBLEND_ZERO;
+		case BF_DEST_COLOR:
+			return D3DBLEND_DESTCOLOR;
+		case BF_SOURCE_COLOR:
+			return D3DBLEND_SRCCOLOR;
+		case BF_INV_DEST_COLOR:
+			return D3DBLEND_INVDESTCOLOR;
+		case BF_INV_SOURCE_COLOR:
+			return D3DBLEND_INVSRCCOLOR;
+		case BF_DEST_ALPHA:
+			return D3DBLEND_DESTALPHA;
+		case BF_SOURCE_ALPHA:
+			return D3DBLEND_SRCALPHA;
+		case BF_INV_DEST_ALPHA:
+			return D3DBLEND_INVDESTALPHA;
+		case BF_INV_SOURCE_ALPHA:
+			return D3DBLEND_INVSRCALPHA;
+		}
+
+		return D3DBLEND_FORCE_DWORD;
+	}
+
+	D3DBLENDOP D3D9Mappings::get(BlendOperation sbo)
+	{
+		switch(sbo)
+		{
+		case BO_ADD:
+			return D3DBLENDOP_ADD;
+		case BO_SUBTRACT:
+			return D3DBLENDOP_SUBTRACT;
+		case BO_REVERSE_SUBTRACT:
+			return D3DBLENDOP_REVSUBTRACT;
+		case BO_MIN:
+			return D3DBLENDOP_MIN;
+		case BO_MAX:
+			return D3DBLENDOP_MAX;
+		}
+
+		return D3DBLENDOP_FORCE_DWORD;
+	}
+
+	DWORD D3D9Mappings::get(CompareFunction cf)
+	{
+		switch(cf)
+		{
+		case CMPF_ALWAYS_FAIL:
+			return D3DCMP_NEVER;
+		case CMPF_ALWAYS_PASS:
+			return D3DCMP_ALWAYS;
+		case CMPF_LESS:
+			return D3DCMP_LESS;
+		case CMPF_LESS_EQUAL:
+			return D3DCMP_LESSEQUAL;
+		case CMPF_EQUAL:
+			return D3DCMP_EQUAL;
+		case CMPF_NOT_EQUAL:
+			return D3DCMP_NOTEQUAL;
+		case CMPF_GREATER_EQUAL:
+			return D3DCMP_GREATEREQUAL;
+		case CMPF_GREATER:
+			return D3DCMP_GREATER;
+		};
+
+		return 0;
+	}
+
+	DWORD D3D9Mappings::get(CullingMode cm, bool flip)
+	{
+		switch(cm)
+		{
+		case CULL_NONE:
+			return D3DCULL_NONE;
+		case CULL_CLOCKWISE:
+			if(flip)
+				return D3DCULL_CCW;
+			else
+				return D3DCULL_CW;
+		case CULL_COUNTERCLOCKWISE:
+			if(flip)
+				return D3DCULL_CW;
+			else
+				return D3DCULL_CCW;
+		}
+
+		return 0;
+	}
+
+	D3DFILLMODE D3D9Mappings::get(PolygonMode level)
+	{
+		switch(level)
+		{
+		case PM_WIREFRAME:
+			return D3DFILL_WIREFRAME;
+		case PM_SOLID:
+			return D3DFILL_SOLID;
+		}
+
+		return D3DFILL_FORCE_DWORD;
+	}
+
+	DWORD D3D9Mappings::get(StencilOperation op, bool invert)
+	{
+		switch(op)
+		{
+		case SOP_KEEP:
+			return D3DSTENCILOP_KEEP;
+		case SOP_ZERO:
+			return D3DSTENCILOP_ZERO;
+		case SOP_REPLACE:
+			return D3DSTENCILOP_REPLACE;
+		case SOP_INCREMENT:
+            return invert ? D3DSTENCILOP_DECRSAT : D3DSTENCILOP_INCRSAT;
+		case SOP_DECREMENT:
+            return invert ? D3DSTENCILOP_INCRSAT : D3DSTENCILOP_DECRSAT;
+		case SOP_INCREMENT_WRAP:
+            return invert ? D3DSTENCILOP_DECR : D3DSTENCILOP_INCR;
+		case SOP_DECREMENT_WRAP:
+            return invert ? D3DSTENCILOP_INCR : D3DSTENCILOP_DECR;
+		case SOP_INVERT:
+			return D3DSTENCILOP_INVERT;
+		}
+
+		return 0;
+	}
+
+	D3DSAMPLERSTATETYPE D3D9Mappings::get(FilterType ft)
+    {
+        switch (ft)
+        {
+        case FT_MIN:
+            return D3DSAMP_MINFILTER;
+            break;
+        case FT_MAG:
+            return D3DSAMP_MAGFILTER;
+            break;
+        case FT_MIP:
+            return D3DSAMP_MIPFILTER;
+            break;
+        }
+
+        return D3DSAMP_MINFILTER;
+    }
+
+	DWORD D3D9Mappings::get(FilterType ft, FilterOptions fo, const D3DCAPS9& devCaps, D3DTexType texType)
+	{
+		// Assume normal
+		DWORD capsType = devCaps.TextureFilterCaps;
+
+		switch( texType )
+		{
+		case D3D_TEX_TYPE_NORMAL:
+			capsType = devCaps.TextureFilterCaps;
+			break;
+		case D3D_TEX_TYPE_CUBE:
+			capsType = devCaps.CubeTextureFilterCaps;
+			break;
+		case D3D_TEX_TYPE_VOLUME:
+			capsType = devCaps.VolumeTextureFilterCaps;
+			break;
+		}
+
+        switch (ft)
+        {
+        case FT_MIN:
+            switch(fo)
+            {
+                // NOTE: Fall through if device doesn't support requested type
+            case FO_ANISOTROPIC:
+                if(capsType & D3DPTFILTERCAPS_MINFANISOTROPIC)
+                {
+                    return D3DTEXF_ANISOTROPIC;
+                    break;
+                }
+            case FO_LINEAR:
+                if(capsType & D3DPTFILTERCAPS_MINFLINEAR)
+                {
+                    return D3DTEXF_LINEAR;
+                    break;
+                }
+            case FO_POINT:
+            case FO_NONE:
+                return D3DTEXF_POINT;
+                break;
+            }
+            break;
+        case FT_MAG:
+            switch( fo )
+            {
+            // NOTE: Fall through if device doesn't support requested type
+            case FO_ANISOTROPIC:
+                if(capsType & D3DPTFILTERCAPS_MAGFANISOTROPIC)
+                {
+                    return D3DTEXF_ANISOTROPIC;
+                    break;
+                }
+            case FO_LINEAR:
+                if(capsType & D3DPTFILTERCAPS_MAGFLINEAR)
+                {
+                    return D3DTEXF_LINEAR;
+                    break;
+                }
+            case FO_POINT:
+            case FO_NONE:
+                return D3DTEXF_POINT;
+                break;
+            }
+            break;
+        case FT_MIP:
+            switch( fo )
+            {
+            case FO_ANISOTROPIC:
+            case FO_LINEAR:
+                if(capsType & D3DPTFILTERCAPS_MIPFLINEAR)
+                {
+                    return D3DTEXF_LINEAR;
+                    break;
+                }
+            case FO_POINT:
+                if(capsType & D3DPTFILTERCAPS_MIPFPOINT)
+                {
+                    return D3DTEXF_POINT;
+                    break;
+                }
+            case FO_NONE:
+                return D3DTEXF_NONE;
+                break;
+            }
+            break;
+        }
+
+        return 0;
+	}
+
+	D3D9Mappings::D3DTexType D3D9Mappings::get(TextureType texType)
+	{
+		switch( texType )
+		{
+		case TEX_TYPE_1D :
+		case TEX_TYPE_2D :
+			return D3D9Mappings::D3D_TEX_TYPE_NORMAL;
+		case TEX_TYPE_CUBE_MAP :
+			return D3D9Mappings::D3D_TEX_TYPE_CUBE;
+		case TEX_TYPE_3D :
+            return D3D9Mappings::D3D_TEX_TYPE_VOLUME;
+		}
+		return D3D9Mappings::D3D_TEX_TYPE_NONE;
+	}
+
+    DWORD D3D9Mappings::get(GpuBufferUsage usage)
+    {
+        DWORD ret = 0;
+        if (usage & GBU_DYNAMIC)
+        {
+            ret |= D3DUSAGE_DYNAMIC;
+        }
+
+        return ret;
+    }
+
+    DWORD D3D9Mappings::get(GpuLockOptions options, GpuBufferUsage usage)
+    {
+        DWORD ret = 0;
+        if (options == GBL_WRITE_ONLY_DISCARD)
+        {
+            // D3D doesn't like discard or no_overwrite on non-dynamic buffers
+            if (usage & GBU_DYNAMIC)
+                ret |= D3DLOCK_DISCARD;
+        }
+        
+		if (options == GBL_READ_ONLY)
+        {
+			ret |= D3DLOCK_READONLY;
+        }
+
+        if (options == GBL_WRITE_ONLY_NO_OVERWRITE)
+        {
+            // D3D doesn't like discard or no_overwrite on non-dynamic buffers
+            if (usage & GBU_DYNAMIC)
+                ret |= D3DLOCK_NOOVERWRITE;
+        }
+
+        return ret;
+    }
+
+    D3DFORMAT D3D9Mappings::get(IndexType itype)
+    {
+        if (itype == IT_32BIT)
+        {
+            return D3DFMT_INDEX32;
+        }
+        else
+        {
+            return D3DFMT_INDEX16;
+        }
+    }
+
+	D3DDECLTYPE D3D9Mappings::get(VertexElementType vType)
+	{
+		switch (vType)
+		{
+		case VET_COLOR:
+		case VET_COLOR_ABGR:
+		case VET_COLOR_ARGB:
+			return D3DDECLTYPE_D3DCOLOR;
+			break;
+		case VET_FLOAT1:
+			return D3DDECLTYPE_FLOAT1;
+			break;
+		case VET_FLOAT2:
+			return D3DDECLTYPE_FLOAT2;
+			break;
+		case VET_FLOAT3:
+			return D3DDECLTYPE_FLOAT3;
+			break;
+		case VET_FLOAT4:
+			return D3DDECLTYPE_FLOAT4;
+			break;
+        case VET_SHORT2:
+			return D3DDECLTYPE_SHORT2;
+			break;
+        case VET_SHORT4:
+			return D3DDECLTYPE_SHORT4;
+			break;
+        case VET_UBYTE4:
+            return D3DDECLTYPE_UBYTE4;
+            break;
+		}
+
+		return D3DDECLTYPE_FLOAT3;
+	}
+
+	D3DDECLUSAGE D3D9Mappings::get(VertexElementSemantic sem)
+	{
+		switch (sem)
+		{
+		case VES_BLEND_INDICES:
+			return D3DDECLUSAGE_BLENDINDICES;
+		case VES_BLEND_WEIGHTS:
+			return D3DDECLUSAGE_BLENDWEIGHT;
+		case VES_COLOR:
+			return D3DDECLUSAGE_COLOR;
+		case VES_NORMAL:
+			return D3DDECLUSAGE_NORMAL;
+		case VES_POSITION:
+			return D3DDECLUSAGE_POSITION;
+		case VES_TEXCOORD:
+			return D3DDECLUSAGE_TEXCOORD;
+		case VES_BITANGENT:
+			return D3DDECLUSAGE_BINORMAL;
+		case VES_TANGENT:
+			return D3DDECLUSAGE_TANGENT;
+		default:
+			BS_EXCEPT(RenderingAPIException, "Invalid semantic for D3D9 render system: " + toString(sem));
+		}
+
+		return D3DDECLUSAGE_POSITION;
+	}
+
+	VertexElementSemantic D3D9Mappings::get(D3DDECLUSAGE sem)
+	{
+		switch (sem)
+		{
+		case D3DDECLUSAGE_BLENDINDICES:
+			return VES_BLEND_INDICES;
+		case D3DDECLUSAGE_BLENDWEIGHT:
+			return VES_BLEND_WEIGHTS;
+		case D3DDECLUSAGE_COLOR:
+			return VES_COLOR;
+		case D3DDECLUSAGE_NORMAL:
+			return VES_NORMAL;
+		case D3DDECLUSAGE_POSITION:
+			return VES_POSITION;
+		case D3DDECLUSAGE_TEXCOORD:
+			return VES_TEXCOORD;
+		case D3DDECLUSAGE_BINORMAL:
+			return VES_BITANGENT;
+		case D3DDECLUSAGE_TANGENT:
+			return VES_TANGENT;
+		default:
+			BS_EXCEPT(RenderingAPIException, "Invalid semantic for D3D9 render system: " + toString(sem));
+		}
+
+		return VES_POSITION;
+	}
+
+	D3DXMATRIX D3D9Mappings::makeD3DXMatrix(const Matrix4& mat)
+	{
+		// Transpose matrix
+		// D3D9 uses row vectors i.e. V*M
+		return D3DXMATRIX(
+            mat[0][0], mat[1][0], mat[2][0], mat[3][0],
+            mat[0][1], mat[1][1], mat[2][1], mat[3][1],
+            mat[0][2], mat[1][2], mat[2][2], mat[3][2],
+            mat[0][3], mat[1][3], mat[2][3], mat[3][3]);
+	}
+
+	Matrix4 D3D9Mappings::convertD3DXMatrix(const D3DXMATRIX& mat)
+	{
+		return Matrix4(
+            mat.m[0][0], mat.m[1][0], mat.m[2][0], mat.m[3][0],
+            mat.m[0][1], mat.m[1][1], mat.m[2][1], mat.m[3][1],
+            mat.m[0][2], mat.m[1][2], mat.m[2][2], mat.m[3][2],
+            mat.m[0][3], mat.m[1][3], mat.m[2][3], mat.m[3][3]);
+	}
+
+	PixelFormat D3D9Mappings::_getPF(D3DFORMAT d3dPF)
+	{
+		switch(d3dPF)
+		{
+		case D3DFMT_R8G8B8:
+			return PF_B8G8R8;
+		case D3DFMT_A8R8G8B8:
+			return PF_B8G8R8A8;
+		case D3DFMT_A8B8G8R8:
+			return PF_R8G8B8A8;
+		case D3DFMT_X8B8G8R8:
+			return PF_R8G8B8X8;
+		case D3DFMT_X8R8G8B8:
+			return PF_B8G8R8X8;
+		case D3DFMT_R16F:
+			return PF_FLOAT16_R;
+		case D3DFMT_A16B16G16R16F:
+			return PF_FLOAT16_RGBA;
+		case D3DFMT_R32F:
+			return PF_FLOAT32_R;
+		case D3DFMT_G32R32F: // TODO - For some reason G and R are flipped in DX9 which might not be compatible with other render systems directly
+			return PF_FLOAT32_RG;
+		case D3DFMT_A32B32G32R32F:
+			return PF_FLOAT32_RGBA;
+		case D3DFMT_G16R16F: // TODO - For some reason G and R are flipped in DX9 which might not be compatible with other render systems directly
+			return PF_FLOAT16_RG;
+		case D3DFMT_DXT1:
+			return PF_BC1;
+		case D3DFMT_DXT3:
+			return PF_BC2;
+		case D3DFMT_DXT5:
+			return PF_BC3;
+		case D3DFMT_D24S8:
+			return PF_D24S8;
+		case D3DFMT_D32F_LOCKABLE:
+			return PF_D32;
+		case D3DFMT_D16:
+			return PF_D16;
+		case D3DFMT_A2B10G10R10:
+			return PF_UNORM_R10G10B10A2;
+		default:
+			return PF_UNKNOWN;
+		}
+	}
+
+	D3DFORMAT D3D9Mappings::_getPF(PixelFormat pf)
+	{
+		// DX9 uses different format semantics than most render systems, where most significant bit is signified by the
+		// first channel letter. For example in RGBA8 format, R is most-significant byte. Which is why most formats map to their
+		// reverse version in-engine as seen below.
+		// (This is not the case for floating point formats, EXCEPT for green-red one)
+		switch(pf)
+		{
+		case PF_B8G8R8A8:
+			return D3DFMT_A8R8G8B8;
+		case PF_R8G8B8X8:
+			return D3DFMT_X8B8G8R8;
+		case PF_B8G8R8X8:
+			return D3DFMT_X8R8G8B8;
+		case PF_FLOAT16_R:
+			return D3DFMT_R16F;
+		case PF_FLOAT16_RG:
+			return D3DFMT_G16R16F;
+		case PF_FLOAT16_RGBA:
+			return D3DFMT_A16B16G16R16F;
+		case PF_FLOAT32_R:
+			return D3DFMT_R32F;
+		case PF_FLOAT32_RG:
+			return D3DFMT_G32R32F;
+		case PF_FLOAT32_RGBA:
+			return D3DFMT_A32B32G32R32F;
+		case PF_BC1:
+		case PF_BC1a:
+			return D3DFMT_DXT1;
+		case PF_BC2:
+			return D3DFMT_DXT3;
+		case PF_BC3:
+			return D3DFMT_DXT5;
+		case PF_D24S8:
+			return D3DFMT_D24S8;
+		case PF_D32:
+			return D3DFMT_D32F_LOCKABLE;
+		case PF_D16:
+			return D3DFMT_D16;
+		case PF_UNORM_R10G10B10A2:
+			return D3DFMT_A2B10G10R10;
+		case PF_UNKNOWN:
+		default:
+			return D3DFMT_UNKNOWN;
+		}
+	}
+
+	PixelFormat D3D9Mappings::_getClosestSupportedPF(PixelFormat enginePF)
+	{
+		if (_getPF(enginePF) != D3DFMT_UNKNOWN)
+			return enginePF;
+
+		switch(enginePF)
+		{
+		case PF_R8:
+			return PF_B8G8R8X8;
+		case PF_R8G8:
+			return PF_B8G8R8X8;
+		case PF_B8G8R8:
+			return PF_B8G8R8X8;
+		case PF_A8R8G8B8:
+			return PF_B8G8R8A8;
+		case PF_A8B8G8R8:
+			return PF_R8G8B8A8;
+		case PF_R8G8B8:
+			return PF_B8G8R8;
+		case PF_FLOAT16_RGB:
+			return PF_FLOAT16_RGBA;
+		case PF_FLOAT32_RGB:
+			return PF_FLOAT32_RGBA;
+		case PF_D32_S8X24:
+			return PF_D24S8;
+		case PF_UNKNOWN:
+		default:
+			return PF_B8G8R8A8;
+		}
+	}
+
+	PixelFormat D3D9Mappings::_getClosestSupportedRenderTargetPF(PixelFormat enginePF)
+	{
+		switch(enginePF)
+		{
+		case PF_B8G8R8A8:
+			return PF_B8G8R8A8;
+		case PF_B8G8R8X8:
+			return PF_B8G8R8X8;
+		default:
+			return PF_B8G8R8A8;
+		}
+	}
+
+	PixelFormat D3D9Mappings::_getClosestSupportedDepthStencilPF(PixelFormat enginePF)
+	{
+		switch(enginePF)
+		{
+		case PF_D24S8:
+			return PF_D24S8;
+		case PF_D32:
+			return PF_D32;
+		case PF_D16:
+			return PF_D16;
+		default:
+			return PF_D24S8;
+		}
+	}
+}

+ 1 - 1
BansheeGLRenderAPI/Include/BsGLRenderAPI.h

@@ -4,7 +4,7 @@
 #include "BsRenderAPI.h"
 #include "BsRenderAPI.h"
 #include "BsGLHardwareBufferManager.h"
 #include "BsGLHardwareBufferManager.h"
 #include "BsGLSLProgramFactory.h"
 #include "BsGLSLProgramFactory.h"
-#include "BsVector4.h"
+#include "BsMatrix4.h"
 
 
 namespace BansheeEngine 
 namespace BansheeEngine 
 {
 {

+ 1 - 0
BansheeSL/Source/BsSLFXCompiler.cpp

@@ -9,6 +9,7 @@
 #include "BsDebug.h"
 #include "BsDebug.h"
 #include "BsShaderManager.h"
 #include "BsShaderManager.h"
 #include "BsShaderInclude.h"
 #include "BsShaderInclude.h"
+#include "BsMatrix4.h"
 
 
 extern "C" {
 extern "C" {
 #include "BsMMAlloc.h"
 #include "BsMMAlloc.h"