|Hosting by Solid Eight Studios ,PhotoTangler Collage Maker|
Question submitted by (04 August 2000)
|Return to The Archives|
|I have read in many tutorials that aligning memory correctly can give a large performance boost, how should your vertices be aligned for the best performance, and how do you do this? Also I program Opengl and was wondering whether sorting all the data so that unnesecary texture changes are avoided will give a large performance increase?|
Most of your C/C++ compilers default to 8-byte memory alignment, which is
fine. Don't sweat this detail.
Sorting textures, on the other hand, is something you'll want to spend some time on. The reason this is an issue, is because the 3D cards don't actually render from their texture memory. They copy the current texture into a temporary buffer that has faster access during rendering. This is why a texture change is so expensive - they have to copy the texture to this temporary buffer. The buffer can only hold so much, which is why so many cards were bound to 256x256 textures for a long time.
This is less of an issue with newer cards, but it's still something to be concerned about.
Other state changes can also cause a performance hit, but again, this is less of an issue with newer cards.
Response provided by Paul Nettle
This article was originally an entry in flipCode's Ask Midnight, a Question and Answer column with Paul Nettle that's no longer active.