Single vector passing faster than seperate floats ?

Started by
3 comments, last by lipsryme 10 years, 11 months ago

Is it actually faster to pass e.g. 4 float variables as a 4-component vector then just as 4 separate float variables ?

At least somebody told me that. I don't see the difference since it's just a 16 byte aligned array that is being transfered as a constant buffer to the gpu or not ? Is there some secret gpu magic going on that I'm missing ? rolleyes.gif

Advertisement

What do you mean specifically by "pass"? In a texture? As a vertex component? As a uniform variable? etc...

Sorry I meant in a constant buffer.

Constant buffers lay out their members according to certain packing rules.

If you put four floats next to each other, the final cbuffer layout is the same as if you just used a float4.

This is different to D3D9, where no packing occurred -- with D3D9 uniforms, every uniform variable is rouned up to a multiple of 16 bytes, so 4 floats takes the same space as 4 float4's (i.e. the 4 floats are padded out to 64 btyes, so a single float4 is much preferable!)

Ah I see. Thanks.

This topic is closed to new replies.

Advertisement