using unsinged byte as index data type would save memory. I’m wondering would that slow down the rendering? because i learned that on cpu any data that will be retrieved frequently should be at least 4 bytes aligned due to the way cpu instruction accesses memory. Is this also true for GPU? Thanks.
I dont know if this is true in general, but it is true on my hardware. I get better performance with unsigned shorts / ints. But there is no difference between those two.
but it is true on my hardware
I don’t know you can guarantee this but it would be what I would expect on newer gpu hardware. You would have to know how the memory fetch logic works to know for sure and since this is rarely published you can only interrupt from tests that you run.
The easiest way to find out is to profile - this should be something you can very quickly and easily set up with minimal disruption to your code.
My own hunch however is that unsigned byte indices are less likely to be supported in hardware than unsigned short or unsigned int, and if they’re not supported in hardware then at least part of the pipeline must drop back to software emulation. That’s going to seriously make any memory saving become a case of getting your priorities skewed.
However don’t take my hunch’s word for it - profile.
Thanks guys, I will try some profile later. before that I think I will just use unsigned int, after all I’m working on PC.
What’s the point of this claim? What is the connection between unsigned int data type and PCs?
I think there is some misunderstanding here. Could you explain it? Starting addresses (of a buffers) are aligned, but if you have a buffer of short values it is not true that each short location starts at 4B address.