Sign in to follow this  

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

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

This topic is 2061 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.

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