Jump to content

View more

Image of the Day

The night is still, but the invasion brings chaos. #screenshotsaturday #hanako #indiegame #gameart #ue4 #samurai https://t.co/cgILXuokoS
IOTD | Top Screenshots

The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.


Sign up now

Single vector passing faster than seperate floats ?

4: Adsense

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   

1522
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.


#2 Hodgman   Moderators   

50638
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   

1522
Like
1Likes
Like

Posted 06 May 2013 - 07:17 AM

Sorry I meant in a constant buffer.



#4 Hodgman   Moderators   

50638
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   

1522
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.