Jump to content
  • Advertisement
Sign in to follow this  
Jiraya

DX11 Is there any advantage in using float2 for POSITION in shaders?

Recommended Posts

For a 2D game, does using a float2 for position increases performance in any way?

I know that in the end the vertex shader will have to return a float4 anyway, but does using a float2 decreases the amount of data that will have to be sent from the CPU to the GPU?

 

Share this post


Link to post
Share on other sites
Advertisement

Seems like you already answered your question. "Increase performance" is a very vague term, in order to quantify performance you need metrics. In either case since you mentioned a 2D use case, if all your objects are in the same place ( ie no parallax ), the using just 2 floats to represent position makes sense. There are certain inherent behavior of the GPU that you cannot control and which may have no bearing on what you put in, with the vertex shader position output size being one of those. The general guidance is to use the smallest type( size and count ) possible while maintaining enough precision in order to reduce the amount of data transferred from CPU to GPU ( bandwidth ).

Share this post


Link to post
Share on other sites

Yes, but this only becomes an issue if you have a truly massive amount of vertices.

Note that the worst case vertex size is that which is just over multiples of 32 bytes, since the vertex cache is usually partitioned at that size. If you're under that anyway, don't worry.

Share this post


Link to post
Share on other sites

1 - Smaller graphical assets, smaller installer package / download.

2 - Faster loading to the GPU.

3 - Faster rendering, less verts to process.

 

Seems like a win-win situation to me.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Advertisement
×

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!