Jump to content
  • Advertisement
Sign in to follow this  
lipsryme

Single vector passing faster than seperate floats ?

This topic is 1875 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Edited by lipsryme

Share this post


Link to post
Share on other sites
Advertisement

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

Share this post


Link to post
Share on other sites

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!)

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!