Browse Source

More documentation
VAO tested and working

Marko Pintera 11 years ago
parent
commit
6a28795343

+ 0 - 9
BoostPort.txt

@@ -1,14 +1,5 @@
  - Ability to construct Module using startUp without having to do allocation outside of it
 
-DEBUG CODE in GLRenderSystem::beginDraw()
-
-		GLuint VAOID[1];
-		glGenVertexArrays(1, &VAOID[0]);
-		glBindVertexArray(VAOID[0]);
-
-I'll probably want a system like PipelineManager where it saves all VS and VB combinations and retuns vertex array for it.
- - Those vertex arrays should probably be saved in the vertex shader
-
 Create a proper git repo of dependencies folder
 
 Shutdown issues (can't repro atm but they're there):

+ 28 - 53
CamelotCore/Include/CmIndexBuffer.h

@@ -1,74 +1,49 @@
-/*
------------------------------------------------------------------------------
-This source file is part of OGRE
-    (Object-oriented Graphics Rendering Engine)
-For the latest info, see http://www.ogre3d.org/
+#pragma once
 
-Copyright (c) 2000-2011 Torus Knot Software Ltd
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
------------------------------------------------------------------------------
-*/
-#ifndef __HardwareIndexBuffer__
-#define __HardwareIndexBuffer__
-
-// Precompiler options
 #include "CmPrerequisites.h"
 #include "CmHardwareBuffer.h"
 #include "CmCoreObject.h"
 
 namespace BansheeEngine 
 {
-	/** \addtogroup Core
-	*  @{
-	*/
-	/** \addtogroup RenderSystem
-	*  @{
-	*/
-	/** Specialisation of HardwareBuffer for vertex index buffers, still abstract. */
+	/**
+	 * @brief	Hardware buffer that hold indices that reference vertices in a vertex buffer.
+	 */
     class CM_EXPORT IndexBuffer : public HardwareBuffer, public CoreObject
     {
 	public:
-		enum IndexType {
+		/**
+		 * @brief	Type of the indices used, used for determining size.
+		 */
+		enum IndexType 
+		{
 			IT_16BIT,
 			IT_32BIT
 		};
 
 		~IndexBuffer();
-		/// Return the manager of this buffer, if any
-		HardwareBufferManager* getManager() const { return mMgr; }
-		/// Get the type of indexes used in this buffer
-		IndexType getType(void) const { return mIndexType; }
-		/// Get the number of indexes in this buffer
-		UINT32 getNumIndexes(void) const { return mNumIndexes; }
-		/// Get the size in bytes of each index
-		UINT32 getIndexSize(void) const { return mIndexSize; }
+
+		/**
+		 * @brief	Returns the type of indices stored.
+		 */
+		IndexType getType() const { return mIndexType; }
+
+		/**
+		 * @brief	Returns the number of indices this buffer can hold.
+		 */
+		UINT32 getNumIndexes() const { return mNumIndexes; }
+
+		/**
+		 * @brief	Returns the size of a single index in bytes.
+		 */
+		UINT32 getIndexSize() const { return mIndexSize; }
+
+	protected:
+		IndexBuffer(IndexType idxType, UINT32 numIndexes, GpuBufferUsage usage, bool useSystemMemory);
 
 	protected:
-		HardwareBufferManager* mMgr;
 		IndexType mIndexType;
 		UINT32 mNumIndexes;
 		UINT32 mIndexSize;
-
-		IndexBuffer(HardwareBufferManager* mgr, IndexType idxType, UINT32 numIndexes, GpuBufferUsage usage, bool useSystemMemory);
     };
-	/** @} */
-}
-#endif
-
+}

+ 6 - 23
CamelotCore/Include/CmIndexData.h

@@ -5,35 +5,18 @@
 
 namespace BansheeEngine 
 {
-	/** Summary class collecting together index data source information. */
+	/**
+	 * @brief	Container that holds data about indices in a subset of an index buffer.
+	 */
 	class CM_EXPORT IndexData
 	{
     public:
         IndexData();
         ~IndexData();
-		/// pointer to the HardwareIndexBuffer to use, must be specified if useIndexes = true
-		IndexBufferPtr indexBuffer;
 
-		/// index in the buffer to start from for this operation
-		UINT32 indexStart;
+		IndexBufferPtr indexBuffer; /**< Reference to an index buffer to fetch the indices from. */
 
-		/// The number of indexes to use from the buffer
-		UINT32 indexCount;
-
-		/** Re-order the indexes in this index data structure to be more
-			vertex cache friendly; that is to re-use the same vertices as close
-			together as possible. 
-		@remarks
-			Can only be used for index data which consists of triangle lists.
-			It would in fact be pointless to use it on triangle strips or fans
-			in any case.
-		*/
-		void optimiseVertexCacheTriList(void);
-
-	protected:
-		/// Protected copy constructor, to prevent misuse
-		IndexData(const IndexData& rhs); /* do nothing, should not use */
-		/// Protected operator=, to prevent misuse
-		IndexData& operator=(const IndexData& rhs); /* do not use */
+		UINT32 indexStart; /**< Starting index of the subset. */
+		UINT32 indexCount; /**< Number of indices in the subset. */
 	};
 }

+ 7 - 42
CamelotCore/Source/CmIndexBuffer.cpp

@@ -1,47 +1,12 @@
-/*
------------------------------------------------------------------------------
-This source file is part of OGRE
-    (Object-oriented Graphics Rendering Engine)
-For the latest info, see http://www.ogre3d.org/
-
-Copyright (c) 2000-2011 Torus Knot Software Ltd
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
------------------------------------------------------------------------------
-*/
-
 #include "CmIndexBuffer.h"
 #include "CmHardwareBufferManager.h"
 #include "CmRenderSystem.h"
 
-namespace BansheeEngine {
-
-    //-----------------------------------------------------------------------------
-    IndexBuffer::IndexBuffer(HardwareBufferManager* mgr, IndexType idxType, 
-        UINT32 numIndexes, GpuBufferUsage usage, 
-        bool useSystemMemory) 
-        : HardwareBuffer(usage, useSystemMemory)
-		, mMgr(mgr)
-		, mIndexType(idxType)
-		, mNumIndexes(numIndexes)
+namespace BansheeEngine 
+{
+    IndexBuffer::IndexBuffer(IndexType idxType, UINT32 numIndexes, GpuBufferUsage usage, bool useSystemMemory) 
+        : HardwareBuffer(usage, useSystemMemory), mIndexType(idxType), mNumIndexes(numIndexes)
     {
-        // Calculate the size of the indexes
         switch (mIndexType)
         {
         case IT_16BIT:
@@ -51,12 +16,12 @@ namespace BansheeEngine {
             mIndexSize = sizeof(unsigned int);
             break;
         }
+
         mSizeInBytes = mIndexSize * mNumIndexes;
     }
-    //-----------------------------------------------------------------------------
+
     IndexBuffer::~IndexBuffer()
     {
 
     }
-}
-
+}

+ 3 - 203
CamelotCore/Source/CmIndexData.cpp

@@ -10,209 +10,9 @@
 namespace BansheeEngine 
 {
 	IndexData::IndexData()
-	{
-		indexCount = 0;
-		indexStart = 0;
-	}
+		:indexCount(0), indexStart(0)
+	{ }
 
 	IndexData::~IndexData()
-	{
-	}
-
-	// Local Utility class for vertex cache optimizer
-	class Triangle
-    {
-    public:
-		enum EdgeMatchType {
-			AB, BC, CA, ANY, NONE
-		};
-
-		UINT32 a, b, c;		
-
-		inline Triangle()
-		{
-		}
-
-		inline Triangle( UINT32 ta, UINT32 tb, UINT32 tc ) 
-			: a( ta ), b( tb ), c( tc )
-		{
-		}
-
-		inline Triangle( UINT32 t[3] )
-			: a( t[0] ), b( t[1] ), c( t[2] )
-		{
-		}
-
-		inline Triangle( const Triangle& t )
-			: a( t.a ), b( t.b ), c( t.c )
-		{
-		}
-
-		inline bool sharesEdge(const Triangle& t) const
-		{
-			return(	a == t.a && b == t.c ||
-					a == t.b && b == t.a ||
-					a == t.c && b == t.b ||
-					b == t.a && c == t.c ||
-					b == t.b && c == t.a ||
-					b == t.c && c == t.b ||
-					c == t.a && a == t.c ||
-					c == t.b && a == t.a ||
-					c == t.c && a == t.b );
-		}
-
-		inline bool sharesEdge(const UINT32 ea, const UINT32 eb, const Triangle& t) const
-		{
-			return(	ea == t.a && eb == t.c ||
-					ea == t.b && eb == t.a ||
-					ea == t.c && eb == t.b );	
-		}
-
-		inline bool sharesEdge(const EdgeMatchType edge, const Triangle& t) const
-		{
-			if (edge == AB)
-				return sharesEdge(a, b, t);
-			else if (edge == BC)
-				return sharesEdge(b, c, t);
-			else if (edge == CA)
-				return sharesEdge(c, a, t);
-			else
-				return (edge == ANY) == sharesEdge(t);
-		}
-
-		inline EdgeMatchType endoSharedEdge(const Triangle& t) const
-		{
-			if (sharesEdge(a, b, t)) return AB;
-			if (sharesEdge(b, c, t)) return BC;
-			if (sharesEdge(c, a, t)) return CA;
-			return NONE;
-		}
-
-		inline EdgeMatchType exoSharedEdge(const Triangle& t) const
-		{
-			return t.endoSharedEdge(*this);
-		}
-
-		inline void shiftClockwise()
-		{
-			UINT32 t = a;
-			a = c;
-			c = b;
-			b = t;
-		}
-
-		inline void shiftCounterClockwise()
-		{
-			UINT32 t = a;
-			a = b;
-			b = c;
-			c = t;
-		}
-	};
-
-	void IndexData::optimiseVertexCacheTriList(void)
-	{
-		if (indexBuffer->isLocked()) return;
-
-		void *buffer = indexBuffer->lock(GBL_READ_WRITE);
-
-		Triangle* triangles;
-		UINT32 *dest;
-
-		UINT32 nIndexes = indexCount;
-		UINT32 nTriangles = nIndexes / 3;
-		UINT32 i, j;
-		UINT16 *source = 0;
-
-		if (indexBuffer->getType() == IndexBuffer::IT_16BIT)
-		{
-			triangles = (Triangle*) malloc(sizeof(Triangle) * nTriangles);
-			source = (UINT16 *)buffer;
-			dest = (UINT32 *)triangles;
-			for (i = 0; i < nIndexes; ++i) dest[i] = source[i];
-		}
-		else
-			triangles = (Triangle*)buffer;
-
-		// sort triangles based on shared edges
-		UINT32 *destlist = (UINT32*)malloc(sizeof(UINT32) * nTriangles);
-		unsigned char *visited = (unsigned char*)malloc(sizeof(unsigned char) * nTriangles);
-
-		for (i = 0; i < nTriangles; ++i) visited[i] = 0;
-
-		UINT32 start = 0, ti = 0, destcount = 0;
-
-		bool found = false;
-		for (i = 0; i < nTriangles; ++i)
-		{
-			if (found)
-				found = false;
-			else
-			{
-				while (visited[start++]);
-				ti = start - 1;
-			}
-
-			destlist[destcount++] = ti;
-			visited[ti] = 1;
-
-			for (j = start; j < nTriangles; ++j)
-			{
-				if (visited[j]) continue;
-				
-				if (triangles[ti].sharesEdge(triangles[j]))
-				{
-					found = true;
-					ti = static_cast<UINT32>(j);
-					break;
-				}
-			}
-		}
-
-		if (indexBuffer->getType() == IndexBuffer::IT_16BIT)
-		{
-			// reorder the indexbuffer
-			j = 0;
-			for (i = 0; i < nTriangles; ++i)
-			{
-				Triangle *t = &triangles[destlist[i]];
-				source[j++] = (UINT16)t->a;
-				source[j++] = (UINT16)t->b;
-				source[j++] = (UINT16)t->c;
-			}
-			free(triangles);
-		}
-		else
-		{
-			UINT32 *reflist = (UINT32*)malloc(sizeof(UINT32) * nTriangles);
-
-			// fill the referencebuffer
-			for (i = 0; i < nTriangles; ++i)
-				reflist[destlist[i]] = static_cast<UINT32>(i);
-			
-			// reorder the indexbuffer
-			for (i = 0; i < nTriangles; ++i)
-			{
-				j = destlist[i];
-				if (i == j) continue; // do not move triangle
-
-				// swap triangles
-
-				Triangle t = triangles[i];
-				triangles[i] = triangles[j];
-				triangles[j] = t;
-
-				// change reference
-				destlist[reflist[i]] = static_cast<UINT32>(j);
-				// destlist[i] = i; // not needed, it will not be used
-			}
-
-			free(reflist);
-		}
-
-		free(destlist);
-		free(visited);
-					
-		indexBuffer->unlock();
-	}
+	{ }
 }

+ 1 - 1
CamelotD3D11RenderSystem/Include/CmD3D11IndexBuffer.h

@@ -34,7 +34,7 @@ namespace BansheeEngine
 	protected:
 		friend class D3D11HardwareBufferManager;
 
-		D3D11IndexBuffer(D3D11Device& device, HardwareBufferManager* mgr, IndexType idxType, UINT32 numIndexes, 
+		D3D11IndexBuffer(D3D11Device& device, IndexType idxType, UINT32 numIndexes, 
 			GpuBufferUsage usage, bool useSystemMem);
 
 		/**

+ 22 - 22
CamelotD3D11RenderSystem/Include/CmD3D11VideoMode.h

@@ -3,27 +3,27 @@
 #include "CmD3D11Prerequisites.h"
 
 namespace BansheeEngine
-{
-	class CM_D3D11_EXPORT D3D11VideoMode
-	{
-	public:
-		D3D11VideoMode();
-		D3D11VideoMode(const D3D11VideoMode& ob);
-		D3D11VideoMode(DXGI_OUTPUT_DESC d3ddm, DXGI_MODE_DESC modeDesc);
-		~D3D11VideoMode();
-
-		UINT32 getWidth() const { return mModeDesc.Width; }
-		UINT32 getHeight() const { return mModeDesc.Height; }
-		DXGI_FORMAT getFormat() const { return mModeDesc.Format; }
-		DXGI_RATIONAL getRefreshRate() const { return mModeDesc.RefreshRate; }
-		UINT32 getColorDepth() const;
-		DXGI_OUTPUT_DESC getDisplayMode() const { return mDisplayMode; }
-		DXGI_MODE_DESC getModeDesc() const { return mModeDesc; }
-		String getDescription() const;
-
-	private:
-		DXGI_OUTPUT_DESC	mDisplayMode;
-		DXGI_MODE_DESC		mModeDesc;
-		UINT32				modeNumber;
+{
+	class CM_D3D11_EXPORT D3D11VideoMode
+	{
+	public:
+		D3D11VideoMode();
+		D3D11VideoMode(const D3D11VideoMode& ob);
+		D3D11VideoMode(DXGI_OUTPUT_DESC d3ddm, DXGI_MODE_DESC modeDesc);
+		~D3D11VideoMode();
+
+		UINT32 getWidth() const { return mModeDesc.Width; }
+		UINT32 getHeight() const { return mModeDesc.Height; }
+		DXGI_FORMAT getFormat() const { return mModeDesc.Format; }
+		DXGI_RATIONAL getRefreshRate() const { return mModeDesc.RefreshRate; }
+		UINT32 getColorDepth() const;
+		DXGI_OUTPUT_DESC getDisplayMode() const { return mDisplayMode; }
+		DXGI_MODE_DESC getModeDesc() const { return mModeDesc; }
+		String getDescription() const;
+
+	private:
+		DXGI_OUTPUT_DESC	mDisplayMode;
+		DXGI_MODE_DESC		mModeDesc;
+		UINT32				modeNumber;
 	};
 }

+ 1 - 1
CamelotD3D11RenderSystem/Source/CmD3D11HardwareBufferManager.cpp

@@ -27,7 +27,7 @@ namespace BansheeEngine
 	IndexBufferPtr D3D11HardwareBufferManager::createIndexBufferImpl(IndexBuffer::IndexType itype, 
 		UINT32 numIndexes, GpuBufferUsage usage)
 	{
-		D3D11IndexBuffer* buffer = new (cm_alloc<D3D11IndexBuffer, PoolAlloc>()) D3D11IndexBuffer(mDevice, this, itype, numIndexes, usage, false);
+		D3D11IndexBuffer* buffer = new (cm_alloc<D3D11IndexBuffer, PoolAlloc>()) D3D11IndexBuffer(mDevice, itype, numIndexes, usage, false);
 
 		return cm_core_ptr<D3D11IndexBuffer, PoolAlloc>(buffer);
 	}

+ 2 - 2
CamelotD3D11RenderSystem/Source/CmD3D11IndexBuffer.cpp

@@ -3,9 +3,9 @@
 
 namespace BansheeEngine
 {
-	D3D11IndexBuffer::D3D11IndexBuffer(D3D11Device& device, HardwareBufferManager* mgr, IndexType idxType, UINT32 numIndexes, 
+	D3D11IndexBuffer::D3D11IndexBuffer(D3D11Device& device, IndexType idxType, UINT32 numIndexes, 
 		GpuBufferUsage usage, bool useSystemMem)
-		:IndexBuffer(mgr, idxType, numIndexes, usage, useSystemMem), mDevice(device), mBuffer(nullptr)
+		:IndexBuffer(idxType, numIndexes, usage, useSystemMem), mDevice(device), mBuffer(nullptr)
 	{
 
 	}

+ 7 - 42
CamelotD3D9Renderer/Include/CmD3D9IndexBuffer.h

@@ -1,40 +1,11 @@
-/*
------------------------------------------------------------------------------
-This source file is part of OGRE
-    (Object-oriented Graphics Rendering Engine)
-For the latest info, see http://www.ogre3d.org/
-
-Copyright (c) 2000-2011 Torus Knot Software Ltd
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
------------------------------------------------------------------------------
-*/
-#ifndef __D3D9HARDWAREINDEXBUFFER_H__
-#define __D3D9HARDWAREINDEXBUFFER_H__
+#pragma once
 
 #include "CmD3D9Prerequisites.h"
 #include "CmIndexBuffer.h"
 #include "CmD3D9Resource.h"
 
-namespace BansheeEngine { 
-
-
+namespace BansheeEngine 
+{ 
     class CM_D3D9_EXPORT D3D9IndexBuffer : public IndexBuffer, public D3D9Resource
     {
   
@@ -61,7 +32,7 @@ namespace BansheeEngine {
 		void createBuffer(IDirect3DDevice9* d3d9Device, D3DPOOL ePool);
 	
 		/// Get the D3D-specific index buffer
-        IDirect3DIndexBuffer9* getD3DIndexBuffer(void);		
+        IDirect3DIndexBuffer9* getD3DIndexBuffer();		
 
 	protected:
 		struct BufferResources
@@ -77,13 +48,12 @@ namespace BansheeEngine {
 	protected:
 		friend class D3D9HardwareBufferManager;
 
-		D3D9IndexBuffer(HardwareBufferManager* mgr, IndexType idxType, UINT32 numIndexes, 
-			GpuBufferUsage usage, bool useSystemMem);
+		D3D9IndexBuffer(IndexType idxType, UINT32 numIndexes, GpuBufferUsage usage, bool useSystemMem);
 
 		/** See HardwareBuffer. */
 		void* lockImpl(UINT32 offset, UINT32 length, GpuLockOptions options);
 		/** See HardwareBuffer. */
-		void unlockImpl(void);
+		void unlockImpl();
 		// updates buffer resources from system memory buffer.
 		bool updateBufferResources(const char* systemMemoryBuffer, BufferResources* bufferResources);
 
@@ -105,9 +75,4 @@ namespace BansheeEngine {
 		D3DINDEXBUFFER_DESC			mBufferDesc;					// Buffer description.		
 		char*						mSystemMemoryBuffer;			// Consistent system memory buffer for multiple devices support.
     };
-}
-
-
-
-#endif
-
+}

+ 1 - 1
CamelotD3D9Renderer/Source/CmD3D9HardwareBufferManager.cpp

@@ -28,7 +28,7 @@ namespace BansheeEngine
     {
 		assert (numIndexes > 0);
 
-		D3D9IndexBuffer* buffer = new (cm_alloc<D3D9IndexBuffer, PoolAlloc>()) D3D9IndexBuffer(this, itype, numIndexes, usage, false);
+		D3D9IndexBuffer* buffer = new (cm_alloc<D3D9IndexBuffer, PoolAlloc>()) D3D9IndexBuffer(itype, numIndexes, usage, false);
 		return cm_core_ptr<D3D9IndexBuffer, PoolAlloc>(buffer);
     }
 

+ 21 - 55
CamelotD3D9Renderer/Source/CmD3D9IndexBuffer.cpp

@@ -1,30 +1,3 @@
-/*
------------------------------------------------------------------------------
-This source file is part of OGRE
-    (Object-oriented Graphics Rendering Engine)
-For the latest info, see http://www.ogre3d.org/
-
-Copyright (c) 2000-2011 Torus Knot Software Ltd
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
-----------------------------------------------------------------------------
-*/
 #include "CmD3D9IndexBuffer.h"
 #include "CmD3D9Mappings.h"
 #include "CmException.h"
@@ -33,20 +6,17 @@ THE SOFTWARE.
 #include "CmD3D9Device.h"
 #include "CmD3D9ResourceManager.h"
 
-namespace BansheeEngine {
-
-	//---------------------------------------------------------------------
-    D3D9IndexBuffer::D3D9IndexBuffer(HardwareBufferManager* mgr, IndexBuffer::IndexType idxType, 
-        UINT32 numIndexes, GpuBufferUsage usage,
-        bool useSystemMemory)
-        : IndexBuffer(mgr, idxType, numIndexes, usage, useSystemMemory)
+namespace BansheeEngine 
+{
+    D3D9IndexBuffer::D3D9IndexBuffer(IndexBuffer::IndexType idxType, UINT32 numIndexes, GpuBufferUsage usage, bool useSystemMemory)
+        : IndexBuffer(idxType, numIndexes, usage, useSystemMemory)
     {
 			
     }
-	//---------------------------------------------------------------------
+
     D3D9IndexBuffer::~D3D9IndexBuffer()
     { }
-	//---------------------------------------------------------------------
+
 	void D3D9IndexBuffer::initialize_internal()
 	{
 		D3D9_DEVICE_ACCESS_CRITICAL_SECTION
@@ -73,7 +43,7 @@ namespace BansheeEngine {
 
 		IndexBuffer::initialize_internal();
 	}
-	//---------------------------------------------------------------------
+
 	void D3D9IndexBuffer::destroy_internal()
 	{
 		D3D9_DEVICE_ACCESS_CRITICAL_SECTION
@@ -96,9 +66,8 @@ namespace BansheeEngine {
 
 		IndexBuffer::destroy_internal();
 	}
-	//---------------------------------------------------------------------
-    void* D3D9IndexBuffer::lockImpl(UINT32 offset, 
-        UINT32 length, GpuLockOptions options)
+
+    void* D3D9IndexBuffer::lockImpl(UINT32 offset, UINT32 length, GpuLockOptions options)
     {		
 		D3D9_DEVICE_ACCESS_CRITICAL_SECTION
 
@@ -136,7 +105,7 @@ namespace BansheeEngine {
 
 		return mSystemMemoryBuffer + offset;		
     }
-	//---------------------------------------------------------------------
+
 	void D3D9IndexBuffer::unlockImpl(void)
     {	
 		D3D9_DEVICE_ACCESS_CRITICAL_SECTION
@@ -158,7 +127,7 @@ namespace BansheeEngine {
 			++it;
 		}			
     }
-	//---------------------------------------------------------------------
+
     void D3D9IndexBuffer::readData(UINT32 offset, UINT32 length, 
         void* pDest)
     {
@@ -169,9 +138,8 @@ namespace BansheeEngine {
         this->unlock();
 
     }
-	//---------------------------------------------------------------------
-    void D3D9IndexBuffer::writeData(UINT32 offset, UINT32 length, 
-            const void* pSource, BufferWriteType writeFlags)
+
+    void D3D9IndexBuffer::writeData(UINT32 offset, UINT32 length,  const void* pSource, BufferWriteType writeFlags)
     {
 		GpuLockOptions lockOption = GBL_WRITE_ONLY;
 		if(writeFlags == BufferWriteType::Discard)
@@ -185,7 +153,7 @@ namespace BansheeEngine {
         memcpy(pDst, pSource, length);
         this->unlock();    
 	}
-	//---------------------------------------------------------------------
+
 	void D3D9IndexBuffer::notifyOnDeviceCreate(IDirect3DDevice9* d3d9Device)
 	{			
 		D3D9_DEVICE_ACCESS_CRITICAL_SECTION
@@ -194,7 +162,7 @@ namespace BansheeEngine {
 			createBuffer(d3d9Device, mBufferDesc.Pool);	
 
 	}
-	//---------------------------------------------------------------------
+
 	void D3D9IndexBuffer::notifyOnDeviceDestroy(IDirect3DDevice9* d3d9Device)
 	{		
 		D3D9_DEVICE_ACCESS_CRITICAL_SECTION
@@ -211,7 +179,7 @@ namespace BansheeEngine {
 			mMapDeviceToBufferResources.erase(it);
 		}
 	}
-	//---------------------------------------------------------------------
+
 	void D3D9IndexBuffer::notifyOnDeviceLost(IDirect3DDevice9* d3d9Device)
 	{		
 		D3D9_DEVICE_ACCESS_CRITICAL_SECTION
@@ -226,7 +194,7 @@ namespace BansheeEngine {
 			}					
 		}
 	}
-	//---------------------------------------------------------------------
+
 	void D3D9IndexBuffer::notifyOnDeviceReset(IDirect3DDevice9* d3d9Device)
 	{		
 		D3D9_DEVICE_ACCESS_CRITICAL_SECTION
@@ -234,7 +202,7 @@ namespace BansheeEngine {
 		if (D3D9RenderSystem::getResourceManager()->getCreationPolicy() == RCP_CREATE_ON_ALL_DEVICES)
 			createBuffer(d3d9Device, mBufferDesc.Pool);		
 	}
-	//---------------------------------------------------------------------
+
 	void D3D9IndexBuffer::createBuffer(IDirect3DDevice9* d3d9Device, D3DPOOL ePool)
 	{
 		D3D9_DEVICE_ACCESS_CRITICAL_SECTION
@@ -290,8 +258,7 @@ namespace BansheeEngine {
 		}		
 	}
 
-	//---------------------------------------------------------------------
-	IDirect3DIndexBuffer9* D3D9IndexBuffer::getD3DIndexBuffer(void)
+	IDirect3DIndexBuffer9* D3D9IndexBuffer::getD3DIndexBuffer()
 	{		
 		IDirect3DDevice9* d3d9Device = D3D9RenderSystem::getActiveD3D9Device();
 		DeviceToBufferResourcesIterator it;
@@ -315,9 +282,8 @@ namespace BansheeEngine {
 
 		return it->second->mBuffer;
 	}
-	//---------------------------------------------------------------------
-	bool D3D9IndexBuffer::updateBufferResources(const char* systemMemoryBuffer,
-		BufferResources* bufferResources)
+
+	bool D3D9IndexBuffer::updateBufferResources(const char* systemMemoryBuffer, BufferResources* bufferResources)
 	{
 		assert(bufferResources != NULL);
 		assert(bufferResources->mBuffer != NULL);

+ 2 - 32
CamelotGLRenderer/Include/CmGLHardwareBufferManager.h

@@ -1,32 +1,4 @@
-/*
------------------------------------------------------------------------------
-This source file is part of OGRE
-    (Object-oriented Graphics Rendering Engine)
-For the latest info, see http://www.ogre3d.org/
-
-Copyright (c) 2000-2011 Torus Knot Software Ltd
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
------------------------------------------------------------------------------
-*/
-#ifndef __GLHARWAREBUFFERMANAGER_H__
-#define __GLHARWAREBUFFERMANAGER_H__
+#pragma once
 
 #include "CmGLPrerequisites.h"
 #include "CmHardwareBufferManager.h"
@@ -96,6 +68,4 @@ namespace BansheeEngine {
 		GpuBufferPtr createGpuBufferImpl(UINT32 elementCount, UINT32 elementSize, 
 			GpuBufferType type, GpuBufferUsage usage, bool randomGpuWrite = false, bool useCounter = false);
     };
-}
-
-#endif // __GLHARWAREBUFFERMANAGER_H__
+}

+ 1 - 28
CamelotGLRenderer/Include/CmGLIndexBuffer.h

@@ -1,30 +1,3 @@
-/*
------------------------------------------------------------------------------
-This source file is part of OGRE
-    (Object-oriented Graphics Rendering Engine)
-For the latest info, see http://www.ogre3d.org/
-
-Copyright (c) 2000-2011 Torus Knot Software Ltd
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
------------------------------------------------------------------------------
-*/
 #pragma once
 
 #include "CmGLPrerequisites.h"
@@ -47,7 +20,7 @@ namespace BansheeEngine
 	protected:
 		friend class GLHardwareBufferManager;
 
-		GLIndexBuffer(HardwareBufferManager* mgr, IndexType idxType, UINT32 numIndexes, 
+		GLIndexBuffer(IndexType idxType, UINT32 numIndexes, 
 			GpuBufferUsage usage); 
 
 		/** See HardwareBuffer. */

+ 17 - 22
CamelotGLRenderer/Source/CmGLHardwareBufferManager.cpp

@@ -34,9 +34,8 @@ THE SOFTWARE.
 #include "CmRenderSystem.h"
 #include "CmRenderSystemCapabilities.h"
 
-namespace BansheeEngine {
-    //-----------------------------------------------------------------------
-	// Scratch pool management (32 bit structure)
+namespace BansheeEngine 
+{
 	struct GLScratchBufferAlloc
 	{
 		/// Size in bytes
@@ -44,9 +43,10 @@ namespace BansheeEngine {
 		/// Free? (pack with size)
 		UINT32 free: 1;
 	};
+
 	#define SCRATCH_POOL_SIZE 1 * 1024 * 1024
 	#define SCRATCH_ALIGNMENT 32
-	//---------------------------------------------------------------------
+
     GLHardwareBufferManager::GLHardwareBufferManager() 
 		: mScratchBufferPool(NULL), mMapBufferThreshold(CM_GL_DEFAULT_MAP_BUFFER_THRESHOLD)
     {
@@ -74,37 +74,34 @@ namespace BansheeEngine {
 #	endif
 
     }
-    //-----------------------------------------------------------------------
+
     GLHardwareBufferManager::~GLHardwareBufferManager()
     {
 		_aligned_free(mScratchBufferPool);
     }
-    //-----------------------------------------------------------------------
+
     VertexBufferPtr GLHardwareBufferManager::createVertexBufferImpl(
         UINT32 vertexSize, UINT32 numVerts, GpuBufferUsage usage, bool streamOut)
     {
 		return cm_core_ptr<GLVertexBuffer, PoolAlloc>(new (cm_alloc<GLVertexBuffer, PoolAlloc>()) GLVertexBuffer(vertexSize, numVerts, usage));
     }
-    //-----------------------------------------------------------------------
-    IndexBufferPtr 
-    GLHardwareBufferManager::createIndexBufferImpl(
-        IndexBuffer::IndexType itype, UINT32 numIndexes, 
-        GpuBufferUsage usage)
+
+    IndexBufferPtr GLHardwareBufferManager::createIndexBufferImpl(IndexBuffer::IndexType itype, UINT32 numIndexes, GpuBufferUsage usage)
     {
-		return cm_core_ptr<GLIndexBuffer, PoolAlloc>(new (cm_alloc<GLIndexBuffer, PoolAlloc>()) GLIndexBuffer(this, itype, numIndexes, usage));
+		return cm_core_ptr<GLIndexBuffer, PoolAlloc>(new (cm_alloc<GLIndexBuffer, PoolAlloc>()) GLIndexBuffer(itype, numIndexes, usage));
     }
-	//---------------------------------------------------------------------
+
 	GpuParamBlockBufferPtr GLHardwareBufferManager::createGpuParamBlockBufferImpl()
 	{
 		return cm_core_ptr<GLGpuParamBlockBuffer, PoolAlloc>(new (cm_alloc<GLGpuParamBlockBuffer, PoolAlloc>()) GLGpuParamBlockBuffer());
 	}
-	//---------------------------------------------------------------------
+
 	GpuBufferPtr GLHardwareBufferManager::createGpuBufferImpl(UINT32 elementCount, UINT32 elementSize, 
 		GpuBufferType type, GpuBufferUsage usage, bool randomGpuWrite, bool useCounter)
 	{
 		return cm_core_ptr<GLGpuBuffer, PoolAlloc>(new (cm_alloc<GLGpuBuffer, PoolAlloc>()) GLGpuBuffer(elementCount, elementSize, type, usage, randomGpuWrite, useCounter));
 	}
-    //---------------------------------------------------------------------
+
     GLenum GLHardwareBufferManager::getGLUsage(unsigned int usage)
     {
         switch(usage)
@@ -117,7 +114,7 @@ namespace BansheeEngine {
             return GL_DYNAMIC_DRAW;
         };
     }
-    //---------------------------------------------------------------------
+
     GLenum GLHardwareBufferManager::getGLType(unsigned int type)
     {
         switch(type)
@@ -141,7 +138,7 @@ namespace BansheeEngine {
                 return 0;
         };
     }
-	//---------------------------------------------------------------------
+
 	void* GLHardwareBufferManager::allocateScratch(UINT32 size)
 	{
 		// simple forward link search based on alloc sizes
@@ -194,7 +191,7 @@ namespace BansheeEngine {
 		return 0;
 
 	}
-	//---------------------------------------------------------------------
+
 	void GLHardwareBufferManager::deallocateScratch(void* ptr)
 	{
 		CM_LOCK_MUTEX(mScratchMutex)
@@ -246,15 +243,13 @@ namespace BansheeEngine {
 
 		// Should never get here unless there's a corruption
 		assert (false && "Memory deallocation error");
-
-
 	}
-	//---------------------------------------------------------------------
+
 	const UINT32 GLHardwareBufferManager::getGLMapBufferThreshold() const
 	{
 		return mMapBufferThreshold;
 	}
-	//---------------------------------------------------------------------
+
 	void GLHardwareBufferManager::setGLMapBufferThreshold(const UINT32 value)
 	{
 		mMapBufferThreshold = value;

+ 4 - 33
CamelotGLRenderer/Source/CmGLIndexBuffer.cpp

@@ -1,39 +1,11 @@
-/*
------------------------------------------------------------------------------
-This source file is part of OGRE
-    (Object-oriented Graphics Rendering Engine)
-For the latest info, see http://www.ogre3d.org/
-
-Copyright (c) 2000-2011 Torus Knot Software Ltd
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
------------------------------------------------------------------------------
-*/
 #include "CmGLIndexBuffer.h"
 #include "CmGLHardwareBufferManager.h"
 #include "CmException.h"
 
 namespace BansheeEngine 
 {
-    GLIndexBuffer::GLIndexBuffer(HardwareBufferManager* mgr, IndexType idxType,
-        UINT32 numIndexes, GpuBufferUsage usage)
-        : IndexBuffer(mgr, idxType, numIndexes, usage, false)
+    GLIndexBuffer::GLIndexBuffer(IndexType idxType, UINT32 numIndexes, GpuBufferUsage usage)
+        : IndexBuffer(idxType, numIndexes, usage, false)
     {  }
 
     GLIndexBuffer::~GLIndexBuffer()
@@ -65,8 +37,7 @@ namespace BansheeEngine
 		IndexBuffer::destroy_internal();
 	}
 
-    void* GLIndexBuffer::lockImpl(UINT32 offset, 
-        UINT32 length, GpuLockOptions options)
+    void* GLIndexBuffer::lockImpl(UINT32 offset, UINT32 length, GpuLockOptions options)
     {
         GLenum access = 0;
         if(mIsLocked)
@@ -104,7 +75,7 @@ namespace BansheeEngine
 		return retPtr;
     }
 
-	void GLIndexBuffer::unlockImpl(void)
+	void GLIndexBuffer::unlockImpl()
     {
 		glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, mBufferId);
 

+ 18 - 18
CamelotGLRenderer/Source/CmGLRenderSystem.cpp

@@ -330,70 +330,70 @@ namespace BansheeEngine
 
 			switch(paramDesc.type)
 			{
-			case GCT_FLOAT1:
+			case GPDT_FLOAT1:
 				glProgramUniform1fv(glProgram, paramDesc.gpuMemOffset, paramDesc.arraySize, (GLfloat*)ptrData);
 				break;
-			case GCT_FLOAT2:
+			case GPDT_FLOAT2:
 				glProgramUniform2fv(glProgram, paramDesc.gpuMemOffset, paramDesc.arraySize, (GLfloat*)ptrData);
 				break;
-			case GCT_FLOAT3:
+			case GPDT_FLOAT3:
 				glProgramUniform3fv(glProgram, paramDesc.gpuMemOffset, paramDesc.arraySize, (GLfloat*)ptrData);
 				break;
-			case GCT_FLOAT4:
+			case GPDT_FLOAT4:
 				glProgramUniform4fv(glProgram, paramDesc.gpuMemOffset, paramDesc.arraySize, (GLfloat*)ptrData);
 				break;
-			case GCT_MATRIX_2X2:
+			case GPDT_MATRIX_2X2:
 				glProgramUniformMatrix2fv(glProgram, paramDesc.gpuMemOffset, paramDesc.arraySize, 
 					GL_FALSE, (GLfloat*)ptrData);
 				break;
-			case GCT_MATRIX_2X3:
+			case GPDT_MATRIX_2X3:
 				glProgramUniformMatrix2x3fv(glProgram, paramDesc.gpuMemOffset, paramDesc.arraySize, 
 					GL_FALSE, (GLfloat*)ptrData);
 				break;
-			case GCT_MATRIX_2X4:
+			case GPDT_MATRIX_2X4:
 				glProgramUniformMatrix2x4fv(glProgram, paramDesc.gpuMemOffset, paramDesc.arraySize, 
 					GL_FALSE, (GLfloat*)ptrData);
 				break;
-			case GCT_MATRIX_3X2:
+			case GPDT_MATRIX_3X2:
 				glProgramUniformMatrix3x2fv(glProgram, paramDesc.gpuMemOffset, paramDesc.arraySize, 
 					GL_FALSE, (GLfloat*)ptrData);
 				break;
-			case GCT_MATRIX_3X3:
+			case GPDT_MATRIX_3X3:
 				glProgramUniformMatrix3fv(glProgram, paramDesc.gpuMemOffset, paramDesc.arraySize, 
 					GL_FALSE, (GLfloat*)ptrData);
 				break;
-			case GCT_MATRIX_3X4:
+			case GPDT_MATRIX_3X4:
 				glProgramUniformMatrix3x4fv(glProgram, paramDesc.gpuMemOffset, paramDesc.arraySize, 
 					GL_FALSE, (GLfloat*)ptrData);
 				break;
-			case GCT_MATRIX_4X2:
+			case GPDT_MATRIX_4X2:
 				glProgramUniformMatrix4x2fv(glProgram, paramDesc.gpuMemOffset, paramDesc.arraySize, 
 					GL_FALSE, (GLfloat*)ptrData);
 				break;
-			case GCT_MATRIX_4X3:
+			case GPDT_MATRIX_4X3:
 				glProgramUniformMatrix4x3fv(glProgram, paramDesc.gpuMemOffset, paramDesc.arraySize, 
 					GL_FALSE, (GLfloat*)ptrData);
 				break;
-			case GCT_MATRIX_4X4:
+			case GPDT_MATRIX_4X4:
 				glProgramUniformMatrix4fv(glProgram, paramDesc.gpuMemOffset, paramDesc.arraySize, 
 					GL_FALSE, (GLfloat*)ptrData);
 				break;
-			case GCT_INT1:
+			case GPDT_INT1:
 				glProgramUniform1iv(glProgram, paramDesc.gpuMemOffset, paramDesc.arraySize, (GLint*)ptrData);
 				break;
-			case GCT_INT2:
+			case GPDT_INT2:
 				glProgramUniform2iv(glProgram, paramDesc.gpuMemOffset, paramDesc.arraySize, (GLint*)ptrData);
 				break;
-			case GCT_INT3:
+			case GPDT_INT3:
 				glProgramUniform3iv(glProgram, paramDesc.gpuMemOffset, paramDesc.arraySize, (GLint*)ptrData);
 				break;
-			case GCT_INT4:
+			case GPDT_INT4:
 				glProgramUniform4iv(glProgram, paramDesc.gpuMemOffset, paramDesc.arraySize, (GLint*)ptrData);
 				break;
 			case GPDT_BOOL:
 				glProgramUniform1uiv(glProgram, paramDesc.gpuMemOffset, paramDesc.arraySize, (GLuint*)ptrData);
 				break;
-			case GCT_UNKNOWN:
+			case GPDT_UNKNOWN:
 				break;
 			}
 		}