瀏覽代碼

Renamed VertexIndexData into two separate files

Marko Pintera 13 年之前
父節點
當前提交
f964cb4e87

+ 2 - 1
CamelotD3D11RenderSystem/Include/CmD3D11Mappings.h

@@ -5,7 +5,8 @@
 #include "CmTexture.h"
 #include "CmPixelData.h"
 #include "CmIndexBuffer.h"
-#include "CmVertexIndexData.h"
+#include "CmVertexData.h"
+#include "CmIndexData.h"
 #include "CmSamplerState.h"
 #include "CmRenderOperation.h"
 

+ 2 - 2
CamelotGLRenderer/Source/GLSL/src/CmGLSLProgram.cpp

@@ -31,9 +31,9 @@ THE SOFTWARE.
 #include "CmGpuProgramManager.h"
 #include "CmHighLevelGpuProgramManager.h"
 #include "CmException.h"
-#include "CmVertexIndexData.h"
+#include "CmVertexData.h"
+#include "CmIndexData.h"
 #include "CmDebug.h"
-
 #include "CmGLSLProgram.h"
 #include "CmGLSLGpuProgram.h"
 #include "CmGLSLExtSupport.h"

+ 4 - 2
CamelotRenderer/CamelotRenderer.vcxproj

@@ -252,8 +252,9 @@
     <ClInclude Include="Include\CmTextureManager.h" />
     <ClInclude Include="Include\CmTextureRTTI.h" />
     <ClInclude Include="Include\CmSamplerState.h" />
+    <ClInclude Include="Include\CmIndexData.h" />
     <ClInclude Include="Include\CmVertexDeclaration.h" />
-    <ClInclude Include="Include\CmVertexIndexData.h" />
+    <ClInclude Include="Include\CmVertexData.h" />
     <ClInclude Include="Include\CmViewport.h" />
     <ClInclude Include="Include\CmWindowEventUtilities.h" />
     <ClInclude Include="Include\CmResourceRTTI.h" />
@@ -287,6 +288,7 @@
     <ClCompile Include="Source\CmGpuProgramParams.cpp" />
     <ClCompile Include="Source\CmHardwareBufferManager.cpp" />
     <ClCompile Include="Source\CmIndexBuffer.cpp" />
+    <ClCompile Include="Source\CmIndexData.cpp" />
     <ClCompile Include="Source\CmOcclusionQuery.cpp" />
     <ClCompile Include="Source\CmPixelBuffer.cpp" />
     <ClCompile Include="Source\CmTextureView.cpp" />
@@ -323,7 +325,7 @@
     <ClCompile Include="Source\CmTextureManager.cpp" />
     <ClCompile Include="Source\CmSamplerState.cpp" />
     <ClCompile Include="Source\CmVertexDeclaration.cpp" />
-    <ClCompile Include="Source\CmVertexIndexData.cpp" />
+    <ClCompile Include="Source\CmVertexData.cpp" />
     <ClCompile Include="Source\CmViewport.cpp" />
     <ClCompile Include="Source\CmWindowEventUtilities.cpp" />
     <ClCompile Include="Source\CmGameObject.cpp" />

+ 12 - 6
CamelotRenderer/CamelotRenderer.vcxproj.filters

@@ -113,9 +113,6 @@
     <ClInclude Include="Include\CmPrerequisites.h">
       <Filter>Header Files</Filter>
     </ClInclude>
-    <ClInclude Include="Include\CmVertexIndexData.h">
-      <Filter>Header Files\RenderSystem</Filter>
-    </ClInclude>
     <ClInclude Include="Include\CmRenderWindow.h">
       <Filter>Header Files\RenderSystem</Filter>
     </ClInclude>
@@ -362,6 +359,12 @@
     <ClInclude Include="Include\CmTextureView.h">
       <Filter>Header Files\RenderSystem</Filter>
     </ClInclude>
+    <ClInclude Include="Include\CmIndexData.h">
+      <Filter>Header Files\RenderSystem</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\CmVertexData.h">
+      <Filter>Header Files\RenderSystem</Filter>
+    </ClInclude>
   </ItemGroup>
   <ItemGroup>
     <ClCompile Include="Source\CamelotRenderer.cpp">
@@ -418,9 +421,6 @@
     <ClCompile Include="Source\CmRenderWindow.cpp">
       <Filter>Source Files\RenderSystem</Filter>
     </ClCompile>
-    <ClCompile Include="Source\CmVertexIndexData.cpp">
-      <Filter>Source Files\RenderSystem</Filter>
-    </ClCompile>
     <ClCompile Include="Source\CmImporter.cpp">
       <Filter>Source Files\Importer</Filter>
     </ClCompile>
@@ -547,5 +547,11 @@
     <ClCompile Include="Source\CmTextureView.cpp">
       <Filter>Source Files\RenderSystem</Filter>
     </ClCompile>
+    <ClCompile Include="Source\CmIndexData.cpp">
+      <Filter>Source Files\RenderSystem</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\CmVertexData.cpp">
+      <Filter>Source Files\RenderSystem</Filter>
+    </ClCompile>
   </ItemGroup>
 </Project>

+ 2 - 1
CamelotRenderer/Include/CmCamera.h

@@ -38,7 +38,8 @@ THE SOFTWARE.
 #include "CmVector3.h"
 #include "CmVector2.h"
 #include "CmAxisAlignedBox.h"
-#include "CmVertexIndexData.h"
+#include "CmVertexData.h"
+#include "CmIndexData.h"
 #include "CmPlane.h"
 #include "CmQuaternion.h"
 #include "CmCommonEnums.h"

+ 46 - 0
CamelotRenderer/Include/CmIndexData.h

@@ -0,0 +1,46 @@
+#pragma once
+
+#include "CmPrerequisites.h"
+#include "CmIndexBuffer.h"
+
+namespace CamelotEngine 
+{
+	/** Summary class collecting together index data source information. */
+	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;
+
+		/// The number of indexes to use from the buffer
+		UINT32 indexCount;
+
+		/** Clones this index data, potentially including replicating the index buffer.
+		@param copyData Whether to create new buffers too or just reference the existing ones
+		@param mgr If supplied, the buffer manager through which copies should be made
+		@remarks The caller is expected to delete the returned pointer when finished
+		*/
+		IndexData* clone(bool copyData = true, HardwareBufferManager* mgr = 0) const;
+
+		/** 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 */
+	};
+}

+ 2 - 1
CamelotRenderer/Include/CmMesh.h

@@ -3,7 +3,8 @@
 #include "CmPrerequisites.h"
 #include "CmResource.h"
 #include "CmMeshData.h"
-#include "CmVertexIndexData.h"
+#include "CmVertexData.h"
+#include "CmIndexData.h"
 #include "CmRenderOperation.h"
 
 namespace CamelotEngine

+ 2 - 1
CamelotRenderer/Include/CmRenderOperation.h

@@ -29,7 +29,8 @@ THE SOFTWARE.
 
 #include "CmPrerequisites.h"
 #include "CmVertexDeclaration.h"
-#include "CmVertexIndexData.h"
+#include "CmVertexData.h"
+#include "CmIndexData.h"
 
 namespace CamelotEngine 
 {

+ 0 - 44
CamelotRenderer/Include/CmVertexIndexData.h → CamelotRenderer/Include/CmVertexData.h

@@ -31,7 +31,6 @@ THE SOFTWARE.
 #include "CmPrerequisites.h"
 #include "CmVertexDeclaration.h"
 #include "CmVertexBuffer.h"
-#include "CmIndexBuffer.h"
 
 namespace CamelotEngine {
 	/** \addtogroup Core
@@ -41,10 +40,6 @@ namespace CamelotEngine {
 	*  @{
 	*/
 
-	/// Define a list of usage flags
-	typedef vector<GpuBufferUsage>::type BufferUsageList;
-
-
 	/** Summary class collecting together vertex source information. */
 	class CM_EXPORT VertexData
 	{
@@ -112,45 +107,6 @@ namespace CamelotEngine {
 		unordered_map<UINT32, VertexBufferPtr>::type mVertexBuffers;
 	};
 
-	/** Summary class collecting together index data source information. */
-	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;
-
-		/// The number of indexes to use from the buffer
-		UINT32 indexCount;
-
-		/** Clones this index data, potentially including replicating the index buffer.
-		@param copyData Whether to create new buffers too or just reference the existing ones
-		@param mgr If supplied, the buffer manager through which copies should be made
-		@remarks The caller is expected to delete the returned pointer when finished
-		*/
-		IndexData* clone(bool copyData = true, HardwareBufferManager* mgr = 0) const;
-
-		/** 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 */
-	};
-
 	/** Vertex cache profiler.
 	@remarks
 		Utility class for evaluating the effectiveness of the use of the vertex

+ 2 - 1
CamelotRenderer/Source/CmHardwareBufferManager.cpp

@@ -27,7 +27,8 @@ THE SOFTWARE.
 */
 
 #include "CmHardwareBufferManager.h"
-#include "CmVertexIndexData.h"
+#include "CmVertexData.h"
+#include "CmIndexData.h"
 #include "CmVertexDeclaration.h"
 
 namespace CamelotEngine {

+ 240 - 0
CamelotRenderer/Source/CmIndexData.cpp

@@ -0,0 +1,240 @@
+#include "CmIndexData.h"
+#include "CmHardwareBufferManager.h"
+#include "CmVertexBuffer.h"
+#include "CmIndexBuffer.h"
+#include "CmVector3.h"
+#include "CmAxisAlignedBox.h"
+#include "CmException.h"
+#include "CmRenderSystem.h"
+
+namespace CamelotEngine 
+{
+	IndexData::IndexData()
+	{
+		indexCount = 0;
+		indexStart = 0;
+	}
+
+	IndexData::~IndexData()
+	{
+	}
+
+	IndexData* IndexData::clone(bool copyData, HardwareBufferManager* mgr) const
+	{
+		HardwareBufferManager* pManager = mgr ? mgr : HardwareBufferManager::instancePtr();
+		IndexData* dest = new IndexData();
+		if (indexBuffer.get())
+		{
+            if (copyData)
+            {
+			    dest->indexBuffer = pManager->createIndexBuffer(indexBuffer->getType(), indexBuffer->getNumIndexes(),
+				    indexBuffer->getUsage());
+			    dest->indexBuffer->copyData(*indexBuffer, 0, 0, indexBuffer->getSizeInBytes(), true);
+            }
+            else
+            {
+                dest->indexBuffer = indexBuffer;
+            }
+        }
+		dest->indexCount = indexCount;
+		dest->indexStart = indexStart;
+		return dest;
+	}
+
+	// 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();
+	}
+}

+ 2 - 232
CamelotRenderer/Source/CmVertexIndexData.cpp → CamelotRenderer/Source/CmVertexData.cpp

@@ -26,12 +26,11 @@ THE SOFTWARE.
 -----------------------------------------------------------------------------
 */
 
-#include "CmVertexIndexData.h"
+#include "CmIndexData.h"
+#include "CmVertexData.h"
 #include "CmHardwareBufferManager.h"
 #include "CmVertexBuffer.h"
-#include "CmIndexBuffer.h"
 #include "CmVector3.h"
-#include "CmAxisAlignedBox.h"
 #include "CmException.h"
 #include "CmRenderSystem.h"
 
@@ -214,235 +213,6 @@ namespace CamelotEngine
 		} // each buffer
 	}
 
-	IndexData::IndexData()
-	{
-		indexCount = 0;
-		indexStart = 0;
-	}
-
-	IndexData::~IndexData()
-	{
-	}
-
-	IndexData* IndexData::clone(bool copyData, HardwareBufferManager* mgr) const
-	{
-		HardwareBufferManager* pManager = mgr ? mgr : HardwareBufferManager::instancePtr();
-		IndexData* dest = new IndexData();
-		if (indexBuffer.get())
-		{
-            if (copyData)
-            {
-			    dest->indexBuffer = pManager->createIndexBuffer(indexBuffer->getType(), indexBuffer->getNumIndexes(),
-				    indexBuffer->getUsage());
-			    dest->indexBuffer->copyData(*indexBuffer, 0, 0, indexBuffer->getSizeInBytes(), true);
-            }
-            else
-            {
-                dest->indexBuffer = indexBuffer;
-            }
-        }
-		dest->indexCount = indexCount;
-		dest->indexStart = indexStart;
-		return dest;
-	}
-
-	// 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();
-	}
-
 	void VertexCacheProfiler::profile(const IndexBufferPtr& indexBuffer)
     {
 		if (indexBuffer->isLocked()) return;

+ 20 - 21
CamelotRenderer/TODO.txt

@@ -14,36 +14,35 @@
 
 
 >>>>>>>>>>FINAL SPRINT BEFORE EDITOR WORK
-Make sure that I am able to blit contents from render textures on all render systems
-Get rid of SurfaceDesc in CmRenderTarget. I should probably add a resource view similar as I did with buffers.
- - Also in render and multirender textures whenever get depth stencil surface I always use 0 mip and 0 face, however it should use a surface desc same as color surface
- - Take care of handling texture UAVs too
-Once I get DX11 running make sure to test if driver complains about missing shader attributes or invalid size ones
- Working generic buffers
- A way to bind buffers to a Pass, while specifying buffer range
- Better creation of PrimaryWindow
-  - RENDERWINDOWDESC accepts a "externalWindow" flag and an "externalHandle" so when creating the primary window with RenderSystem::initialize we don't always need to create a new window
-  - Actually new OpenGL seems to support creating context without a window with the help of wglCreateContextAttribsARB and wglMakeCurrent:
- GpuParams support for bools, buffers, structs
- Static/Dynamic usage for GpuParamBlocks
- Ability to switch out GpuParamBlocks
-  - Ability to mark param blocks as "Shared". Those would not get created with every pass instance and would require user to actually create and assign them
+Pass
+ - A way to bind buffers to a Pass, while specifying buffer range
+ - GpuParams support for bools, buffers, structs
+ - Fix MaterialRTTI saving (Save params per gpuprogram is simplest and cleanest) (Maybe wait until I have the Parser sorted out?)
+ - Fix how and when is GpuParamBlock created/destroyed. Needs to happen on the render thread
+
+Shader parser (possible leave for later? But it might require Resource changes)
+ - Static/Dynamic usage for GpuParamBlocks
+ - Ability to mark param blocks as "Shared". Those would not get created with every pass instance and would require user to actually create and assign them
    - I can't think of any way I can do this without a preprocessor
    - (In editor it might work via GUI, but what if someone doesn't want to use the editor and only uses the engine core?)
    - Use a simple .shader file in which you specify individual GPU programs, include files, material parameters (whether they're visible
      to user or just rendering system), input parameters (useful for GLSL which doesn't have semantics as I can provide my own semantics)
 	  - File format would be simple, and parser would just parse line by line, with possible option blocks
    - Issue of include files remains. How do I reference them? By path most definitely but I'd have to reference the source asset path...And in the current design source asset can move.
- Smart way of initializing GpuParamBlocks (without duplicates)
- Fix MaterialRTTI saving (Save params per gpuprogram is simplest and cleanest)
- Make sure that gpu programs assigned to Pass don't share parameters of different types
- Make RenderTexture and DepthStenciLTexture use common interface
- Fix how and when is GpuParamBlock created/destroyed. Needs to happen on the render thread
+   - Smart way of initializing GpuParamBlocks (without duplicates) (This probably won't be a separate task, as user will specify params manually if I go the parser route)
+   - Make sure that gpu programs assigned to Pass don't share parameters of different types (A task I can ignore if I go the parser route)
+ 
  Refactor how we handle RenderTargets (no attach/detach, and no waitForVSync propery in RenderSystem)
  waitForVsync can probably be moved somewhere other than being directly in RenderSystem? (where is it in DX11?)
 
- Think about how to manage resources. For example check VertexBuffer is VertexData class. How and when is that freed?
- - Big problem is also that RenderSystem in a lot of cases holds raw pointers, so what happens when resource get destroyed and RS tries to use it?
+Go through RenderSystem classes and make sure we don't hold any raw pointer references.
+
+Can be delayed:
+ Make sure that I am able to blit contents from render textures on all render systems
+ Once I get DX11 running make sure to test if driver complains about missing shader attributes or invalid size ones
+ Better creation of PrimaryWindow
+  - RENDERWINDOWDESC accepts a "externalWindow" flag and an "externalHandle" so when creating the primary window with RenderSystem::initialize we don't always need to create a new window
+  - Actually new OpenGL seems to support creating context without a window with the help of wglCreateContextAttribsARB and wglMakeCurrent:
 
 >>>>>>>>>>>>>>>START WORKING ON THE EDITOR!