//===========================================================================// // Copyright (C) Microsoft Corporation. All rights reserved. // //===========================================================================// #pragma once #define MLR_GOSVERTEXPOOL_HPP #include #include #include extern bool MLRVertexLimitReached; namespace MidLevelRenderer { //########################################################################## //###################### GOSVertexPool ############################### //########################################################################## class GOSVertexPool { public: GOSVertexPool(); void Reset(); // //------------------------------------------------------------------------------------------------------------ // int GetLength () { Check_Object(this); return vertices.GetLength()-1; } unsigned GetLast () { Check_Object(this); return lastUsed; } int Increase (int add=1) { Check_Object(this); lastUsed += add; Verify(lastUsed (Limits::Max_Number_Vertices_Per_Frame - 2000)); return lastUsed; } GOSVertex* GetActualVertexPool(bool db=false) { Check_Object(this); if(db) { return verticesDB.GetData(); } else { return (GOSVertex*)((char*)(vertices.GetData() + lastUsed)+vertexAlignment); } } // //------------------------------------------------------------------------------------------------------------ // int GetLength2UV () { Check_Object(this); return vertices2uv.GetLength()-1; } unsigned GetLast2UV () { Check_Object(this); return lastUsed2uv; } int Increase2UV (int add=1) { Check_Object(this); lastUsed2uv += add; Verify(lastUsed2uv vertices; // , Max_Number_Vertices_Per_Frame+4*Max_Number_ScreenQuads_Per_Frame Stuff::DynamicArrayOf vertices2uv; // , Max_Number_Vertices_Per_Frame+4*Max_Number_ScreenQuads_Per_Frame Stuff::DynamicArrayOf indices; // , Max_Number_Vertices_Per_Frame Stuff::DynamicArrayOf verticesDB; // , Max_Number_Vertices_Per_Mesh Stuff::DynamicArrayOf vertices2uvDB; // , Max_Number_Vertices_Per_Mesh Stuff::DynamicArrayOf indicesDB; // , Max_Number_Vertices_Per_Mesh private: GOSVertexPool(const GOSVertexPool&); }; //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ inline GOSVertexPool::GOSVertexPool() { Verify(gos_GetCurrentHeap() == Heap); lastUsed = 0; lastUsed2uv = 0; lastUsedIndex = 0; gos_PushCurrentHeap(StaticHeap); vertices.SetLength(Limits::Max_Number_Vertices_Per_Frame+4*Limits::Max_Number_ScreenQuads_Per_Frame+1); vertices2uv.SetLength(Limits::Max_Number_Vertices_Per_Frame+4*Limits::Max_Number_ScreenQuads_Per_Frame+1); indices.SetLength(Limits::Max_Number_Vertices_Per_Frame+16); verticesDB.SetLength(2*Limits::Max_Number_Vertices_Per_Mesh); vertices2uvDB.SetLength(2*Limits::Max_Number_Vertices_Per_Mesh); indicesDB.SetLength(2*Limits::Max_Number_Vertices_Per_Mesh); gos_PopCurrentHeap(); vertexAlignment=32-( (int)vertices.GetData() & 31 ); vertexAlignment2uv=32-( (int)vertices2uv.GetData() & 31 ); indicesAlignment=32-( (int)indices.GetData() & 31 ); } inline void GOSVertexPool::Reset() { Check_Object(this); lastUsed = 0; lastUsed2uv = 0; lastUsedIndex = 0; MLRVertexLimitReached = false; } }