Jump to content

  • Log In with Google      Sign In   
  • Create Account

Interested in a FREE copy of HTML5 game maker Construct 2?

We'll be giving away three Personal Edition licences in next Tuesday's GDNet Direct email newsletter!

Sign up from the right-hand sidebar on our homepage and read Tuesday's newsletter for details!


We're also offering banner ads on our site from just $5! 1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


Single vector passing faster than seperate floats ?


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
4 replies to this topic

#1 lipsryme   Members   -  Reputation: 1031

Like
0Likes
Like

Posted 06 May 2013 - 07:07 AM

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, 06 May 2013 - 07:08 AM.


Sponsor:

#2 Hodgman   Moderators   -  Reputation: 30964

Like
0Likes
Like

Posted 06 May 2013 - 07:13 AM

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



#3 lipsryme   Members   -  Reputation: 1031

Like
1Likes
Like

Posted 06 May 2013 - 07:17 AM

Sorry I meant in a constant buffer.



#4 Hodgman   Moderators   -  Reputation: 30964

Like
1Likes
Like

Posted 06 May 2013 - 08:57 AM

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



#5 lipsryme   Members   -  Reputation: 1031

Like
0Likes
Like

Posted 06 May 2013 - 09:03 AM

Ah I see. Thanks.






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS