unsigned short/int performance

Hello,

Has anyone noticed a performance improvement when using unsigned short instead of unsigned int for index data? I have tested multiple scenarios(on GeForce 8) and have not observed any improvements. The older GeForce 7 Programming Guide suggests to use unsigned short, at least in the case of SLI (8.6.6).

I imagine three potential reasons that I haven’t seen a performance gain: 1) newer drivers always deal with ints, so the shorts are actually converted to ints, 2) the performance improvement is only noticed in memory constrained situations or when the indices are sent across the PCI-E bus, so using shorts just uses less memory, it doesn’t put you on a fast path, 3) shorts only improve performance on ATI, which I haven’t tested.

I suppose 2 is the most likely reason why I haven’t noticed any performance improvements. Any other thoughts?

Thanks,
Patrick

I have made the same observations… switching between ints and shorts on modern hardware gains (almost?) nothing.
I guess, the main advantage today is less memory footprint. But since the ratio between per-vertex-data and per-index data is quite big, the two extra sent/saved bytes per vertex don’t seem to sum up too much difference in performance.

It provides a performance increase on mobile GPUs. The iPhone for example.
I like it for compressing data when in VRAM, but other than that would not expect to see a particular performance increase on a desktop unless it involved moving a lot of data around…

not related to indices but recently converted vertex colors from float to unsigned byte reducing the size by 3/4. didn’t noticed anything performance-wise but saved some vram.

I always wondered about this since unsigned byte is the recommended datatype but inside a vertex shader, gl_Color is a vec4, which contains floats. I assume the conversion is blazingly fast.

Patrick

I always wondered about this since unsigned byte is the recommended datatype but inside a vertex shader, gl_Color is a vec4, which contains floats. I assume the conversion is blazingly fast.

That conversion has been done since shaders first existed. Really, normalizing an (byte) int into a float is just a bitwise operation; they probably hard-wired it as part of the vertex fetch operation.

Just what I thought. Thanks!

Patrick

Again, even on mobile HW, those conversions are almost irrelevant they are so fast.

Other nice places you can use them are for texture coordinates as well.
On the iPhone you can scrunch texture coords as small as individual bytes not only for Ortho work, but also for large bits of geometry which normally require large repetitive arrays of floats.