Advertisement
snake5

Speed problems, eh?

Dec 7th, 2011
236
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.94 KB | None | 0 0
  1. // why so slow (especially with different meshes / LODs)?
  2. void SMesh::DrawPart( UINT32 lod, UINT32 part, UINT32 inst )
  3. {
  4.     // cache line on "this"
  5.     SMeshLod& ml = LOD[ lod ]; // new cache line
  6.     SMeshLodPiece& mlpc = ml.Pieces[ part ]; // ...
  7.     SMeshPart& mp = Parts[ mlpc.ID ]; // ...
  8.     SMeshLodPart& mlp = mp.LODParts[ mlpc.LOD ]; // ...
  9.  
  10.     if( inst )
  11.         glDrawIndexedPrimitivesInst( PT_Triangles, mlp.TriangleCount * 3, MESH_INDEXTYPE, mlp.IBOffset, inst ); // ...
  12.     else
  13.         glDrawIndexedPrimitives( PT_Triangles, mlp.VertexCount, mlp.TriangleCount * 3, MESH_INDEXTYPE, mlp.IBOffset ); // ...
  14. }
  15. // while it might not be so bad in practice
  16. // (most arrays are allocated at +/- the same time
  17. // and thus probably at the same place,
  18. // the unexpectedly slow performance shows it is a problem
  19. // and that there's probably enough of this design
  20. // to make my old Athlon64 CPU beg for mercy.
  21. // P.S. Yes, this is my code.
  22. // P.P.S. I'm fixing it now.
  23.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement