Loading or pushing and popping matrices?
Hi,
I'd like to know which of the following methods is faster in OpenGL when it comes to loading/resetting the modelview and projection matrices:
- to load the matrix by using glLoadMatrixf
- to rely on a set of glPushMatrix/glPopMatrix calls
At the moment I am using a combination of the two, but I tend to self-convince myself that glLoadMatrixf should be faster.
Which is the fastest method in your personal experience?
i would think that push/pop is faster
since loadmatrix would result in sending the matrix to the gpu, while push/pop tells the gpu with a command what to do..
i dont know if this is true, but it should be correct
since loadmatrix would result in sending the matrix to the gpu, while push/pop tells the gpu with a command what to do..
i dont know if this is true, but it should be correct
If the GPU supports a matrix stack on board, then glPush and pop will be faster but I doubt that any of them do.
Also, don't worry about it. Don't optimize too early.
If you have the matrix ready, just use glLoadMatrix. It's only 16 floats that will be sent.
Also, don't worry about it. Don't optimize too early.
If you have the matrix ready, just use glLoadMatrix. It's only 16 floats that will be sent.
GPUs don't have hardware matrix stacks. The current matrices are pushed down to the card when you make a draw call, along with other relevant state.
LoadMatrix is essentially a memory copy. PushMatrix is essentially a pointer increment and a memory copy. (I don't know if drivers implement some kind of adaptive growth strategy, but even if they do, the costs will get amortized quickly.) Either way, it doesn't matter at all. Don't concern yourself with such trivial nonsense.
LoadMatrix is essentially a memory copy. PushMatrix is essentially a pointer increment and a memory copy. (I don't know if drivers implement some kind of adaptive growth strategy, but even if they do, the costs will get amortized quickly.) Either way, it doesn't matter at all. Don't concern yourself with such trivial nonsense.
I was thinking that maybe OpenGL does some sort of 'state init' processing whenever a modelview or projection matrix is loaded and that maybe pushing/popping simply pushed/popped that 'state' making it the fastest method of the two.
But I'm glad I was overcomplicating this issue and that there are no performance issues involved!
Thanks to all for the invaluable input given.
But I'm glad I was overcomplicating this issue and that there are no performance issues involved!
Thanks to all for the invaluable input given.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement