Jump to content
  • Advertisement
Sign in to follow this  
danromeo

Does XNA 4 fx compiler support static and/or dynamic branching and if not....

This topic is 2279 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

Can't seem to find a straight forward answer to this anywhere: Does XNA 4 fx compiler support static and/or dynamic branching and if not how can I get branching working?

Thanks

Share this post


Link to post
Share on other sites
Advertisement
Dynamic branching is supported as long as you use vs_3_0 and ps_3_0 shader profiles. Static branching is supported for vs_2_0 and up, and ps_2_a and up.

Share this post


Link to post
Share on other sites
Note that the compiler tends to favour static branching, if the logic can be expressed in a static way and the instruction count doesn't skyrocket as a result.

It is possible to hint the compiler to use dynamic branching by using the [branch] attribute preceding your "if" statements. [flatten] attribute is also available to hint static branching. Loop and switch unrolling behavior can also be hinted by using similar (but different) attributes.

Share this post


Link to post
Share on other sites

[flatten] attribute is also available to hint static branching.


A static branch isn't a flattened branch, it's a branch on constant boolean register.

Share this post


Link to post
Share on other sites
I have XNA 4 with ps 3.0 and vs 3.0. I see absolutely no performance difference even when exluding huge sections of code with dynamic branching. Any suggestions?

Share this post


Link to post
Share on other sites
Could be for several reasons:

- Are you sure dynamic branching is being used? Check the assembly that is output (you can see this in PIX, for instance). For instance, if there are any tex2D instructions inside an if statement, you can't use dynamic branching.
- To see any performance improvement, large groups of pixels near each other all need to take the same branch.
- Finally, your performance bottleneck might not be your shader's instruction count at all, in which case your dynamic branching won't help.

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.

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!