Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Batch renderer submit optimization #40

Open
LPeter1997 opened this issue Jul 10, 2015 · 3 comments
Open

Batch renderer submit optimization #40

LPeter1997 opened this issue Jul 10, 2015 · 3 comments

Comments

@LPeter1997
Copy link

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.

@PedDavid
Copy link

PedDavid commented Sep 4, 2015

Nice one! Just got 200 fps's for free 👍 I think you should make a pull request

@Luminiscental
Copy link

This breaks rotation and scale for the transformation though...

@eatplayhate
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants