Browse Source

More documentation

Marko Pintera 11 years ago
parent
commit
57d22576dd

+ 0 - 22
BansheeEditor/Source/BsEditorApplication.cpp

@@ -44,28 +44,6 @@ namespace BansheeEngine
 	EditorApplication::EditorApplication(RenderSystemPlugin renderSystemPlugin)
 		:mActiveRSPlugin(renderSystemPlugin)
 	{
-		// START DEBUG
-		
-		class TmpClass
-		{
-		public:
-			void someMEthod(int a)
-			{
-				b = a;
-			}
-
-			int b;
-		};
-
-		TmpClass instance;
-		Event<void (int)> myEvent;
-		HEvent evSomeMethod = myEvent.connect(std::bind(&TmpClass::someMEthod, instance, std::placeholders::_1));
-
-		evSomeMethod.disconnect();
-		myEvent(5);
-
-		// END DEBUG
-
 		RENDER_WINDOW_DESC renderWindowDesc;
 		renderWindowDesc.width = 1280;
 		renderWindowDesc.height = 720;

+ 35 - 0
BansheeEngine.sln

@@ -159,6 +159,23 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "BansheeEditor", "BansheeEdi
 		{07B0C186-5173-46F2-BE26-7E4148BD0CCA} = {07B0C186-5173-46F2-BE26-7E4148BD0CCA}
 	EndProjectSection
 EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ExampleProject", "ExampleProject\ExampleProject.vcxproj", "{4E02D5FE-5A98-49C1-93FD-DF841A9FA3DB}"
+	ProjectSection(ProjectDependencies) = postProject
+		{4F05EF0A-B8DE-424B-8848-6ECEE9D99912} = {4F05EF0A-B8DE-424B-8848-6ECEE9D99912}
+		{9B21D41C-516B-43BF-9B10-E99B599C7589} = {9B21D41C-516B-43BF-9B10-E99B599C7589}
+		{122B7A22-0C62-4B35-B661-EBF3F394EA79} = {122B7A22-0C62-4B35-B661-EBF3F394EA79}
+		{CC7F9445-71C9-4559-9976-FF0A64DCB582} = {CC7F9445-71C9-4559-9976-FF0A64DCB582}
+		{1437BB4E-DDB3-4307-AA41-8C035DA3014B} = {1437BB4E-DDB3-4307-AA41-8C035DA3014B}
+		{F58FF869-2EA6-4FFF-AB84-328C531BA9D9} = {F58FF869-2EA6-4FFF-AB84-328C531BA9D9}
+		{08975177-4A13-4EE7-BB21-3BB92FB3F3CC} = {08975177-4A13-4EE7-BB21-3BB92FB3F3CC}
+		{AB6C9284-D1CB-4AAD-BA4B-8A9E81AD1A73} = {AB6C9284-D1CB-4AAD-BA4B-8A9E81AD1A73}
+		{07B0C186-5173-46F2-BE26-7E4148BD0CCA} = {07B0C186-5173-46F2-BE26-7E4148BD0CCA}
+		{7F449698-73DF-4203-9F31-0877DBF01695} = {7F449698-73DF-4203-9F31-0877DBF01695}
+		{41CC18CE-139E-45A5-A9AA-336CBA2E1521} = {41CC18CE-139E-45A5-A9AA-336CBA2E1521}
+		{BFEBBAF8-8A84-4899-8899-D0D7196AF9A1} = {BFEBBAF8-8A84-4899-8899-D0D7196AF9A1}
+		{796B6DFF-BA04-42B7-A43A-2B14D707A33A} = {796B6DFF-BA04-42B7-A43A-2B14D707A33A}
+	EndProjectSection
+EndProject
 Global
 	GlobalSection(SolutionConfigurationPlatforms) = preSolution
 		Debug|Mixed Platforms = Debug|Mixed Platforms
@@ -514,6 +531,24 @@ Global
 		{67137A0D-7A67-4D0C-9FBF-AF904FABEF05}.Release|Win32.Build.0 = Release|Win32
 		{67137A0D-7A67-4D0C-9FBF-AF904FABEF05}.Release|x64.ActiveCfg = Release|x64
 		{67137A0D-7A67-4D0C-9FBF-AF904FABEF05}.Release|x64.Build.0 = Release|x64
+		{4E02D5FE-5A98-49C1-93FD-DF841A9FA3DB}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32
+		{4E02D5FE-5A98-49C1-93FD-DF841A9FA3DB}.Debug|Mixed Platforms.Build.0 = Debug|Win32
+		{4E02D5FE-5A98-49C1-93FD-DF841A9FA3DB}.Debug|Win32.ActiveCfg = Debug|Win32
+		{4E02D5FE-5A98-49C1-93FD-DF841A9FA3DB}.Debug|Win32.Build.0 = Debug|Win32
+		{4E02D5FE-5A98-49C1-93FD-DF841A9FA3DB}.Debug|x64.ActiveCfg = Debug|x64
+		{4E02D5FE-5A98-49C1-93FD-DF841A9FA3DB}.Debug|x64.Build.0 = Debug|x64
+		{4E02D5FE-5A98-49C1-93FD-DF841A9FA3DB}.DebugRelease|Mixed Platforms.ActiveCfg = Release|Win32
+		{4E02D5FE-5A98-49C1-93FD-DF841A9FA3DB}.DebugRelease|Mixed Platforms.Build.0 = Release|Win32
+		{4E02D5FE-5A98-49C1-93FD-DF841A9FA3DB}.DebugRelease|Win32.ActiveCfg = Release|Win32
+		{4E02D5FE-5A98-49C1-93FD-DF841A9FA3DB}.DebugRelease|Win32.Build.0 = Release|Win32
+		{4E02D5FE-5A98-49C1-93FD-DF841A9FA3DB}.DebugRelease|x64.ActiveCfg = Release|x64
+		{4E02D5FE-5A98-49C1-93FD-DF841A9FA3DB}.DebugRelease|x64.Build.0 = Release|x64
+		{4E02D5FE-5A98-49C1-93FD-DF841A9FA3DB}.Release|Mixed Platforms.ActiveCfg = Release|Win32
+		{4E02D5FE-5A98-49C1-93FD-DF841A9FA3DB}.Release|Mixed Platforms.Build.0 = Release|Win32
+		{4E02D5FE-5A98-49C1-93FD-DF841A9FA3DB}.Release|Win32.ActiveCfg = Release|Win32
+		{4E02D5FE-5A98-49C1-93FD-DF841A9FA3DB}.Release|Win32.Build.0 = Release|Win32
+		{4E02D5FE-5A98-49C1-93FD-DF841A9FA3DB}.Release|x64.ActiveCfg = Release|x64
+		{4E02D5FE-5A98-49C1-93FD-DF841A9FA3DB}.Release|x64.Build.0 = Release|x64
 	EndGlobalSection
 	GlobalSection(SolutionProperties) = preSolution
 		HideSolutionNode = FALSE

+ 130 - 14
CamelotCore/Include/CmMeshData.h

@@ -10,6 +10,10 @@
 
 namespace BansheeEngine
 {
+	/**
+	 * @brief	Iterator that allows you to easily populate or read vertex elements
+	 *			in MeshData.
+	 */
 	template<class T>
 	class VertexElemIter
 	{
@@ -26,23 +30,37 @@ namespace BansheeEngine
 			mEnd = mData + byteStride * numElements;
 		}
 
+		/**
+		 * @brief	Adds a new value to the iterators current position and
+		 *			advances the iterator.
+		 */
 		void addValue(T& value)
 		{
 			setValue(value);
 			moveNext();
 		}
 
+		/**
+		 * @brief	Sets a new value at the iterators current position.
+		 */
 		void setValue(T& value)
 		{
 			memcpy(mData, &value, sizeof(T));
 		}
 
+		/**
+		 * @brief	Returns the value at the iterators current position.
+		 */
 		T& getValue()
 		{
 			return *((T*)mData);
 		}
 
-		void moveNext()
+		/**
+		 * @brief	Moves the iterator to the next position. Returns true
+		 *			if there are more elements.
+		 */
+		bool moveNext()
 		{
 #ifdef CM_DEBUG_MODE
 			if(mData >= mEnd)
@@ -52,8 +70,13 @@ namespace BansheeEngine
 #endif
 
 			mData += mByteStride;
+
+			return mData < mEnd;
 		}
 
+		/**
+		 * @brief	Returns the number of elements this iterator can iterate over.
+		 */
 		UINT32 getNumElements() const { return mNumElements; }
 
 	private:
@@ -63,9 +86,16 @@ namespace BansheeEngine
 		UINT32 mNumElements;
 	};
 
+	/**
+	 * @brief	Used for initializing, updating and reading mesh data from Meshes.
+	 */
 	class CM_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, IndexBuffer::IndexType indexType = IndexBuffer::IT_32BIT);
 		~MeshData();
 
@@ -141,12 +171,34 @@ namespace BansheeEngine
 		 */
 		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.
+		 */
 		IndexBuffer::IndexType getIndexType() const { return mIndexType; }
 
 		/**
@@ -161,18 +213,94 @@ namespace BansheeEngine
 		 * @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	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();
 
 	private:
-		friend class Mesh; // To avoid polluting the public interface with a bunch of nearly useless methods for outside world
+		/**
+		 * @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 MeshHeap;
 
 		UINT32 mDescBuilding;
@@ -188,18 +316,6 @@ namespace BansheeEngine
 
 		VertexDataDescPtr mVertexData;
 
-		UINT8* getIndexData() const { return getData(); }
-		UINT8* getStreamData(UINT32 streamIdx) const;
-
-		UINT32 getIndexBufferOffset() const;
-		UINT32 getStreamOffset(UINT32 streamIdx = 0) const;
-
-		UINT32 getIndexBufferSize() const;
-		UINT32 getStreamSize(UINT32 streamIdx) const;
-		UINT32 getStreamSize() const;
-
-		void getDataForIterator(VertexElementSemantic semantic, UINT32 semanticIdx, UINT32 streamIdx, UINT8*& data, UINT32& stride) const;
-
 		/************************************************************************/
 		/* 								SERIALIZATION                      		*/
 		/************************************************************************/

+ 145 - 41
CamelotCore/Include/CmMeshHeap.h

@@ -8,8 +8,8 @@
 namespace BansheeEngine
 {
 	/**
-	 * @brief	Mesh heap allows you to quickly allocate and deallocate a 
-	 * 			large amounts of temporary meshes without the large overhead of normal Mesh creation.
+	 * @brief	Mesh heap allows you to quickly allocate and deallocate a large amounts of temporary 
+	 *			meshes without the large overhead of normal Mesh creation.
 	 * 			Only requirement is that meshes share the same vertex description and index type.
 	 * 			
 	 * @note	This class should be considered as a replacement for a normal Mesh if you are constantly 
@@ -18,26 +18,35 @@ namespace BansheeEngine
 	 * 			which may severely limit performance. Primary purpose of this class is to avoid
 	 * 			those sync points by not forcing you to discard contents.
 	 * 			
-	 *			Only downside is that this class may allocate 2-3x (or more) memory than it is actually needed
+	 *			Downside is that this class may allocate 2-3x (or more) memory than it is actually needed
 	 *			for your data.
 	 *			
-	 *			Sim thread only.
+	 *			Sim thread except where noted otherwise.
 	 */
 	class CM_EXPORT MeshHeap : public CoreObject
 	{
+		/**
+		 * @brief	Signifies how is a data chunk used.
+		 */
 		enum class UseFlags
 		{
-			Used,
-			CPUFree,
-			GPUFree,
-			Free
+			Used, /**< Data chunk is used by both CPU and GPU. */
+			CPUFree, /**< Data chunk was released by CPU but not GPU. */
+			GPUFree, /**< Data chunk was released by GPU but not CPU. */
+			Free /**< Data chunk was released by both CPU and GPU. */
 		};
 
+		/**
+		 * @brief	Represents a continuous chunk of memory.
+		 */
 		struct ChunkData
 		{
 			UINT32 start, size;
 		};
 
+		/**
+		 * @brief	Represents an allocated piece of data representing a mesh.
+		 */
 		struct AllocatedData
 		{
 			UINT32 vertChunkIdx;
@@ -47,6 +56,9 @@ namespace BansheeEngine
 			UINT32 eventQueryIdx;
 		};
 
+		/**
+		 * @brief	Data about a GPU query.
+		 */
 		struct QueryData
 		{
 			EventQueryPtr query;
@@ -57,51 +69,37 @@ namespace BansheeEngine
 		~MeshHeap();
 
 		/**
+		 * @brief	Allocates a new mesh in the heap, expanding the heap if needed. Mesh will be initialized
+		 *			with the provided meshData. You may use the returned transient mesh for drawing.
+		 *
 		 * @note	Offsets provided by MeshData are ignored. MeshHeap will determine
 		 * 			where the data will be written internally.
 		 */
 		TransientMeshPtr alloc(const MeshDataPtr& meshData, DrawOperationType drawOp = DOT_TRIANGLE_LIST);
+
+		/**
+		 * @brief	Deallocates the provided mesh and makes that room on the heap re-usable as soon as the GPU
+		 *			is also done with the mesh.
+		 */
 		void dealloc(const TransientMeshPtr& mesh);
 
+		/**
+		 * @brief	Creates a new mesh heap.
+		 *
+		 * @param	numVertices	Initial number of vertices the heap may store. This will grow automatically if needed.
+		 * @param	numIndices	Initial number of indices the heap may store. This will grow automatically if needed.
+		 * @param	vertexDesc	Description of the stored vertices.
+		 * @param	indexType	Type of the stored indices.
+		 */
 		static MeshHeapPtr create(UINT32 numVertices, UINT32 numIndices, 
 			const VertexDataDescPtr& vertexDesc, IndexBuffer::IndexType indexType = IndexBuffer::IT_32BIT);
 
-	private:
-		UINT32 mNumVertices; // Core thread
-		UINT32 mNumIndices; // Core thread
-
-		std::shared_ptr<VertexData> mVertexData; // Core thread
-		std::shared_ptr<IndexData> mIndexData; // Core thread
-
-		Vector<UINT8*> mCPUVertexData; // Core thread
-		UINT8* mCPUIndexData; // Core thread
-
-		VertexDataDescPtr mVertexDesc; // Immutable
-		IndexBuffer::IndexType mIndexType; // Immutable
-
-		Map<UINT32, TransientMeshPtr> mMeshes; // Sim thread
-		UINT32 mNextFreeId; // Sim thread
-
-		Map<UINT32, AllocatedData> mMeshAllocData; // Core thread
-
-		Vector<ChunkData> mVertChunks; // Core thread
-		Vector<ChunkData> mIdxChunks; // Core thread
-
-		Stack<UINT32> mEmptyVertChunks; // Core thread
-		Stack<UINT32> mEmptyIdxChunks; // Core thread
-
-		List<UINT32> mFreeVertChunks; // Core thread
-		List<UINT32> mFreeIdxChunks; // Core thread
-
-		Vector<QueryData> mEventQueries; // Core thread
-		Stack<UINT32> mFreeEventQueries; // Core thread
-
-		UINT32 mNextQueryId;
-
-		static const float GrowPercent;
 	private:
 		friend class TransientMesh;
 
+		/**
+		 * @copydoc	create
+		 */
 		MeshHeap(UINT32 numVertices, UINT32 numIndices, 
 			const VertexDataDescPtr& vertexDesc, IndexBuffer::IndexType indexType = IndexBuffer::IT_32BIT);
 
@@ -115,24 +113,130 @@ namespace BansheeEngine
 		 */
 		virtual void destroy_internal();
 
+		/**
+		 * @brief	Allocates a new mesh in the heap, expanding the heap if needed. 
+		 *
+		 * @param	meshId		Unique mesh ID.
+		 * @param	meshData	Data to initialize the new mesh with.
+		 *
+		 * @note	Core thread.
+		 */
 		void allocInternal(UINT32 meshId, const MeshDataPtr& meshData);
+
+		/**
+		 * @brief	Deallocates the mesh with the provided ID. Freed memory
+		 *			will be re-used as soon as the GPU is done with the mesh
+		 *
+		 * @note	Core thread.
+		 */
 		void deallocInternal(UINT32 meshId);
 
+		/**
+		 * @brief	Resizes the vertex buffers so they max contain the provided
+		 *			number of vertices.
+		 *
+		 * @note	Core thread.
+		 */
 		void growVertexBuffer(UINT32 numVertices);
+
+		/**
+		 * @brief	Resizes the index buffer so they max contain the provided
+		 *			number of indices.
+		 *
+		 * @note	Core thread.
+		 */
 		void growIndexBuffer(UINT32 numIndices);
 
+		/**
+		 * @brief	Creates a new event query or returns an existing one from the pool
+		 *			if available. Returned value is an index into mEventQueries array.
+		 *
+		 * @note	Core thread.
+		 */
 		UINT32 createEventQuery();
+
+		/**
+		 * @brief	Frees the event query with the specified index and returns it to the
+		 *			pool so it may be reused later.
+		 *
+		 * @note	Core thread.
+		 */
 		void freeEventQuery(UINT32 idx);
 
+		/**
+		 * @brief	Gets internal vertex data for all the meshes.
+		 */
 		std::shared_ptr<VertexData> getVertexData() const;
+
+		/**
+		 * @brief	Gets internal index data for all the meshes.
+		 */
 		std::shared_ptr<IndexData> getIndexData() const;
 
+		/**
+		 * @brief	Returns the offset in vertices from the start of the buffer
+		 *			to the first vertex of the mesh with the provided ID.
+		 */
 		UINT32 getVertexOffset(UINT32 meshId) const;
+
+		/**
+		 * @brief	Returns the offset in indices from the start of the buffer
+		 *			to the first index of the mesh with the provided ID.
+		 */
 		UINT32 getIndexOffset(UINT32 meshId) const;
 
+		/**
+		 * @brief	Called by the render system when a mesh gets queued to the GPU.
+		 */
 		void notifyUsedOnGPU(UINT32 meshId);
+
+		/**
+		 * @brief	Called by an GPU event query when GPU processes the query. Normally
+		 *			signals the heap that the GPU is done with the mesh.
+		 */
 		void queryTriggered(UINT32 meshId, UINT32 queryId);
 
+		/**
+		 * @brief	Attempts to reorganize the vertex and index buffer chunks in order to 
+		 *			in order to make free memory contigous.
+		 *
+		 * @note	This will not actually copy any data from index/vertex buffers, and will only
+		 *			modify the chunk descriptors.
+		 */
 		void mergeWithNearbyChunks(UINT32 chunkVertIdx, UINT32 chunkIdxIdx);
+
+	private:
+		UINT32 mNumVertices; // Core thread
+		UINT32 mNumIndices; // Core thread
+
+		std::shared_ptr<VertexData> mVertexData; // Core thread
+		std::shared_ptr<IndexData> mIndexData; // Core thread
+
+		Vector<UINT8*> mCPUVertexData; // Core thread
+		UINT8* mCPUIndexData; // Core thread
+
+		VertexDataDescPtr mVertexDesc; // Immutable
+		IndexBuffer::IndexType mIndexType; // Immutable
+
+		Map<UINT32, TransientMeshPtr> mMeshes; // Sim thread
+		UINT32 mNextFreeId; // Sim thread
+
+		Map<UINT32, AllocatedData> mMeshAllocData; // Core thread
+
+		Vector<ChunkData> mVertChunks; // Core thread
+		Vector<ChunkData> mIdxChunks; // Core thread
+
+		Stack<UINT32> mEmptyVertChunks; // Core thread
+		Stack<UINT32> mEmptyIdxChunks; // Core thread
+
+		List<UINT32> mFreeVertChunks; // Core thread
+		List<UINT32> mFreeIdxChunks; // Core thread
+
+		Vector<QueryData> mEventQueries; // Core thread
+		Stack<UINT32> mFreeEventQueries; // Core thread
+
+		UINT32 mNextQueryId;
+
+		static const float GrowPercent;
 	};
 }

+ 44 - 2
CamelotCore/Include/CmTextureView.h

@@ -18,6 +18,17 @@ namespace BansheeEngine
 		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).
+	 *
+	 * @note	Right now texture views are only used for very specific internal purposes, 
+	 *			but a more general use might come in the future.
+	 */
 	class CM_EXPORT TextureView : public CoreObject
 	{
 	public:
@@ -35,17 +46,48 @@ namespace BansheeEngine
 
 		virtual ~TextureView();
 
-		virtual void initialize(TexturePtr texture, TEXTURE_VIEW_DESC& _desc);
-
+		/**
+		 * @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.
+		 */
 		TexturePtr getTexture() const { return mOwnerTexture; }
 
+	protected:
+		/**
+		 * @brief	Initializes the texture view. This must be called right after construction.
+		 */
+		virtual void initialize(TexturePtr texture, TEXTURE_VIEW_DESC& _desc);
+
 	protected:
 		friend class Texture;
 

+ 41 - 19
CamelotCore/Include/CmVertexData.h

@@ -6,42 +6,64 @@
 
 namespace BansheeEngine 
 {
-	/** \addtogroup Core
-	*  @{
-	*/
-	/** \addtogroup RenderSystem
-	*  @{
-	*/
-
-	/** Summary class collecting together vertex source information. */
+	/**
+	 * @brief	Container class consisting of a set of vertex buffers and their
+	 *			declaration.
+	 *
+	 * @note	Used just for more easily passing around vertex information.
+	 */
 	class CM_EXPORT VertexData
 	{
     public:
         VertexData();
         ~VertexData();
 
-		/** Declaration of the vertex to be used in this operation. 
-		@remarks Note that this is created for you on construction.
-		*/
+		/**
+		 * @brief	Declaration used for the contained vertex buffers.
+		 */
 		VertexDeclarationPtr vertexDeclaration;
 
-		/// The number of vertices used in this operation
+		/**
+		 * @brief	Number of vertices to use.
+		 */
 		UINT32 vertexCount;
 
+		/**
+		 * @brief	Assigns a new vertex buffer to the specified index.
+		 */
 		void setBuffer(UINT32 index, VertexBufferPtr buffer);
-		/// Gets the buffer bound to the given source index
+
+		/**
+		 * @brief	Retrieves a vertex buffer from the specified index.
+		 */
 		VertexBufferPtr getBuffer(UINT32 index) const;
+
+		/**
+		 * @brief	Returns a list of all bound vertex buffers.
+		 */
 		const UnorderedMap<UINT32, VertexBufferPtr>& getBuffers() const { return mVertexBuffers; }
-		/// Gets whether a buffer is bound to the given source index
+
+		/**
+		 * @brief	Checks if there is a buffer at the specified index.
+		 */
 		bool isBufferBound(UINT32 index) const;
 
-		UINT32 getBufferCount(void) const { return (UINT32)mVertexBuffers.size(); }
-		UINT32 getMaxBufferIndex(void) const { return (UINT32)mVertexBuffers.size(); }
+		/**
+		 * @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:
-		/** The vertex buffer bindings to be used. 
-		@remarks Note that this is created for you on construction.
-		*/
 		UnorderedMap<UINT32, VertexBufferPtr> mVertexBuffers;
+
+		UINT32 mMaxBufferIdx = 0;
 	};
 }

+ 9 - 0
CamelotCore/Source/CmVertexData.cpp

@@ -21,6 +21,8 @@ namespace BansheeEngine
 	void VertexData::setBuffer(UINT32 index, VertexBufferPtr buffer)
 	{
 		mVertexBuffers[index] = buffer;
+
+		recalculateMaxIndex();
 	}
 
 	VertexBufferPtr VertexData::getBuffer(UINT32 index) const
@@ -45,4 +47,11 @@ namespace BansheeEngine
 
 		return false;
 	}
+
+	void VertexData::recalculateMaxIndex()
+	{
+		mMaxBufferIdx = 0;
+		for (auto& bufferData : mVertexBuffers)
+			mMaxBufferIdx = std::max(bufferData.first, mMaxBufferIdx);
+	}
 }

+ 152 - 0
ExampleProject/ExampleProject.vcxproj

@@ -0,0 +1,152 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <ItemGroup Label="ProjectConfigurations">
+    <ProjectConfiguration Include="Debug|Win32">
+      <Configuration>Debug</Configuration>
+      <Platform>Win32</Platform>
+    </ProjectConfiguration>
+    <ProjectConfiguration Include="Debug|x64">
+      <Configuration>Debug</Configuration>
+      <Platform>x64</Platform>
+    </ProjectConfiguration>
+    <ProjectConfiguration Include="Release|Win32">
+      <Configuration>Release</Configuration>
+      <Platform>Win32</Platform>
+    </ProjectConfiguration>
+    <ProjectConfiguration Include="Release|x64">
+      <Configuration>Release</Configuration>
+      <Platform>x64</Platform>
+    </ProjectConfiguration>
+  </ItemGroup>
+  <PropertyGroup Label="Globals">
+    <ProjectGuid>{4E02D5FE-5A98-49C1-93FD-DF841A9FA3DB}</ProjectGuid>
+    <RootNamespace>ExampleProject</RootNamespace>
+  </PropertyGroup>
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
+    <ConfigurationType>Application</ConfigurationType>
+    <UseDebugLibraries>true</UseDebugLibraries>
+    <PlatformToolset>v120</PlatformToolset>
+    <CharacterSet>NotSet</CharacterSet>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
+    <ConfigurationType>Application</ConfigurationType>
+    <UseDebugLibraries>true</UseDebugLibraries>
+    <PlatformToolset>v120</PlatformToolset>
+    <CharacterSet>NotSet</CharacterSet>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
+    <ConfigurationType>Application</ConfigurationType>
+    <UseDebugLibraries>false</UseDebugLibraries>
+    <PlatformToolset>v120</PlatformToolset>
+    <WholeProgramOptimization>true</WholeProgramOptimization>
+    <CharacterSet>NotSet</CharacterSet>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
+    <ConfigurationType>Application</ConfigurationType>
+    <UseDebugLibraries>false</UseDebugLibraries>
+    <PlatformToolset>v120</PlatformToolset>
+    <WholeProgramOptimization>true</WholeProgramOptimization>
+    <CharacterSet>NotSet</CharacterSet>
+  </PropertyGroup>
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+  <ImportGroup Label="ExtensionSettings">
+  </ImportGroup>
+  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+  </ImportGroup>
+  <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+  </ImportGroup>
+  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+  </ImportGroup>
+  <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+  </ImportGroup>
+  <PropertyGroup Label="UserMacros" />
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+    <OutDir>..\bin\x86\$(Configuration)\</OutDir>
+    <IntDir>..\bin\$(Platform)\$(Configuration)\</IntDir>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+    <IntDir>..\bin\$(Platform)\$(Configuration)\</IntDir>
+    <OutDir>..\bin\$(Platform)\$(Configuration)\</OutDir>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+    <OutDir>..\bin\x86\$(Configuration)\</OutDir>
+    <IntDir>..\bin\$(Platform)\$(Configuration)\</IntDir>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+    <IntDir>..\bin\$(Platform)\$(Configuration)\</IntDir>
+    <OutDir>..\bin\$(Platform)\$(Configuration)\</OutDir>
+  </PropertyGroup>
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+    <ClCompile>
+      <WarningLevel>Level3</WarningLevel>
+      <Optimization>Disabled</Optimization>
+      <SDLCheck>true</SDLCheck>
+      <AdditionalIncludeDirectories>.\Include;..\CamelotCore\Include;..\CamelotUtility\Include;..\Dependencies\Include;..\BansheeEngine\Include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+    </ClCompile>
+    <Link>
+      <GenerateDebugInformation>true</GenerateDebugInformation>
+      <AdditionalLibraryDirectories>..\lib\x86\$(Configuration);..\Dependencies\lib\x86\Debug;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+      <AdditionalDependencies>CamelotCore.lib;CamelotUtility.lib;BansheeEngine.lib;%(AdditionalDependencies)</AdditionalDependencies>
+    </Link>
+  </ItemDefinitionGroup>
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+    <ClCompile>
+      <WarningLevel>Level3</WarningLevel>
+      <Optimization>Disabled</Optimization>
+      <SDLCheck>true</SDLCheck>
+      <AdditionalIncludeDirectories>.\Include;..\CamelotCore\Include;..\CamelotUtility\Include;..\Dependencies\Include;..\BansheeEngine\Include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+    </ClCompile>
+    <Link>
+      <GenerateDebugInformation>true</GenerateDebugInformation>
+      <AdditionalLibraryDirectories>..\lib\x64\$(Configuration);..\Dependencies\lib\x64\Debug;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+      <AdditionalDependencies>CamelotCore.lib;CamelotUtility.lib;BansheeEngine.lib;%(AdditionalDependencies)</AdditionalDependencies>
+    </Link>
+  </ItemDefinitionGroup>
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+    <ClCompile>
+      <WarningLevel>Level3</WarningLevel>
+      <Optimization>MaxSpeed</Optimization>
+      <FunctionLevelLinking>true</FunctionLevelLinking>
+      <IntrinsicFunctions>true</IntrinsicFunctions>
+      <SDLCheck>true</SDLCheck>
+      <AdditionalIncludeDirectories>.\Include;..\CamelotCore\Include;..\CamelotUtility\Include;..\Dependencies\Include;..\BansheeEngine\Include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+      <DebugInformationFormat>None</DebugInformationFormat>
+    </ClCompile>
+    <Link>
+      <GenerateDebugInformation>false</GenerateDebugInformation>
+      <EnableCOMDATFolding>true</EnableCOMDATFolding>
+      <OptimizeReferences>true</OptimizeReferences>
+      <AdditionalLibraryDirectories>..\lib\x86\$(Configuration);..\Dependencies\lib\x86\Debug;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+      <AdditionalDependencies>CamelotCore.lib;CamelotUtility.lib;BansheeEngine.lib;%(AdditionalDependencies)</AdditionalDependencies>
+    </Link>
+  </ItemDefinitionGroup>
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+    <ClCompile>
+      <WarningLevel>Level3</WarningLevel>
+      <Optimization>MaxSpeed</Optimization>
+      <FunctionLevelLinking>true</FunctionLevelLinking>
+      <IntrinsicFunctions>true</IntrinsicFunctions>
+      <SDLCheck>true</SDLCheck>
+      <AdditionalIncludeDirectories>.\Include;..\CamelotCore\Include;..\CamelotUtility\Include;..\Dependencies\Include;..\BansheeEngine\Include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+      <DebugInformationFormat>None</DebugInformationFormat>
+    </ClCompile>
+    <Link>
+      <GenerateDebugInformation>false</GenerateDebugInformation>
+      <EnableCOMDATFolding>true</EnableCOMDATFolding>
+      <OptimizeReferences>true</OptimizeReferences>
+      <AdditionalLibraryDirectories>..\lib\x64\$(Configuration);..\Dependencies\lib\x64\Debug;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+      <AdditionalDependencies>CamelotCore.lib;CamelotUtility.lib;BansheeEngine.lib;%(AdditionalDependencies)</AdditionalDependencies>
+    </Link>
+  </ItemDefinitionGroup>
+  <ItemGroup>
+    <ClCompile Include="Main\Source.cpp" />
+  </ItemGroup>
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+  <ImportGroup Label="ExtensionTargets">
+  </ImportGroup>
+</Project>

+ 22 - 0
ExampleProject/ExampleProject.vcxproj.filters

@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <ItemGroup>
+    <Filter Include="Source Files">
+      <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
+      <Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
+    </Filter>
+    <Filter Include="Header Files">
+      <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
+      <Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
+    </Filter>
+    <Filter Include="Resource Files">
+      <UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
+      <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
+    </Filter>
+  </ItemGroup>
+  <ItemGroup>
+    <ClCompile Include="Main\Source.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+  </ItemGroup>
+</Project>

+ 41 - 0
ExampleProject/Main/Source.cpp

@@ -0,0 +1,41 @@
+#include "stdafx.h"
+#include <windows.h>
+
+#include "BsApplication.h"
+#include "CmRenderWindow.h"
+#include "CmSceneObject.h"
+
+using namespace BansheeEngine;
+
+void setUpExample();
+
+int CALLBACK WinMain(
+	_In_  HINSTANCE hInstance,
+	_In_  HINSTANCE hPrevInstance,
+	_In_  LPSTR lpCmdLine,
+	_In_  int nCmdShow
+	)
+{
+	RENDER_WINDOW_DESC renderWindowDesc;
+	renderWindowDesc.width = 1280;
+	renderWindowDesc.height = 720;
+	renderWindowDesc.title = "Banshee Example App";
+	renderWindowDesc.fullscreen = false;
+
+	gBansheeApp().startUp(renderWindowDesc, "CamelotD3D11RenderSystem", "BansheeForwardRenderer"); // TODO - Use enums instead of names. BansheeApp is a high level system that doesn't need to be as customizable.
+	setUpExample();
+	
+	gBansheeApp().runMainLoop();
+	gBansheeApp().shutDown();
+
+	return 0;
+}
+
+void setUpExample()
+{
+	HSceneObject exampleSO = SceneObject::create("Example");
+
+
+
+	// TODO - add ExampleGUI component
+}