Reputation: 489
I need to decide whether I should use GL_UNSIGNED_SHORT or GL_FLOAT for my (static) VBO for vertices. Shorts use 2 times less memory but does it also reduce rendering speed (because the GPU has to convert them to floats)? Same thing for texture coordinates, I could use GL_UNSIGNED_BYTE for smaller textures and GL_UNSIGNED_SHORT for larger ones (using a texture matrix to map to 0-1), but I am worried it might reduce rendering speed.
Upvotes: 1
Views: 705
Reputation: 181705
Converting a short to a float should be a pretty cheap operation. I would think that the savings in memory bandwidth would outweigh the extra processing cost.
But without actually testing it, this remains nothing but a wild guess.
Upvotes: 2
Reputation: 473182
For any modern hardware (DX10-capable or better), you can assume that attribute reading performance is always dominated by the memory access, not by the transformation from integer to float. Essentially it is free.
This is mostly true of DX9-class hardware too, but some hardware has certain vertex formats that it doesn't work well with.
That being said, I wouldn't be so sure about being able to use unsigned bytes for texture coordinates. You usually need greater precision than per-texel for texture coordinates in most models. Unsigned shorts are usually fine, but there just isn't enough precision in bytes to make it work.
Upvotes: 3