Open LPeter1997 opened 9 years ago
Nice one! Just got 200 fps's for free :+1: I think you should make a pull request
This breaks rotation and scale for the transformation though...
Yeah this doesn't produce the same results. A better optimization is to write a SIMD multiply function and process the positions as a batch.
So the batch renderer's submit(...) function takes a lot of time, mainly because of the matrix multiplications. With a little trick I was able to cut down the time (60% to 50%). Here's what I did:
Maths::vec3f _tpos = m_TransformationBack \ position;
m_Buffer->Position = _tpos; m_Buffer->TexCoord = texCoords[0]; m_Buffer->TexID = ts; m_Buffer->Color = c; m_Buffer++;
_tpos.y += size.y;
m_Buffer->Position = _tpos; m_Buffer->TexCoord = texCoords[1]; m_Buffer->TexID = ts; m_Buffer->Color = c; m_Buffer++;
_tpos.x += size.x;
m_Buffer->Position = _tpos; m_Buffer->TexCoord = texCoords[2]; m_Buffer->TexID = ts; m_Buffer->Color = c; m_Buffer++;
_tpos.y -= size.y;
m_Buffer->Position = _tpos; m_Buffer->TexCoord = texCoords[3]; m_Buffer->TexID = ts; m_Buffer->Color = c; m_Buffer++;
So I'm saving the position, multyply it only once with the matrix, and then keep working with that. Because I don't have a very good computer, without this optimization I got around 3025 FPS. With this I've got almost 3300.