float[] → Vertex[] – decreases performance by 1000%

David d at dav1d.de
Tue Jul 24 11:38:04 PDT 2012


I am writing a game engine, well I was using a float[] array to store my 
vertices, this worked well, but I have to send more and more uv 
coordinates (and other information) which needn't be stored as `float`'s 
so I moved from a float-Array to a Vertex Array:
https://github.com/Dav1dde/BraLa/blob/master/brala/dine/builder/tessellator.d#L30 


align(1) struct Vertex {
     float x;
     float y;
     float z;
     float nx;
     float ny;
     float nz;
     float u_terrain;
     float v_terrain;
     float u_biome;
     float v_biome;
}

Everything is still a float, so it's easier. Nothing wrong with that or? 
Well this change decreases my performance by 1000%. My frame rate drops 
from ~12ms per frame to ~120ms per frame. I tried to find the bottleneck 
with `perf` but no results (the time is not spent in the game/engine).

The commit:
https://github.com/Dav1dde/BraLa/commit/02a37a0e46f195f5a46404747d659d26490e6c32

I hope you can see anything wrong. I have no idea!


More information about the Digitalmars-d-learn mailing list