Jump to content
  • Advertisement
Sign in to follow this  
thedodgeruk

loops in shaders ? help

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

i have been reading that conditcion statments in shader files are incrediblly slow

if / else statments

would a look up table be faster or, would the time to set one up , wuld make it slower?

for loops are also slow i have beeen told, is there an alternative to this aas well ???

Share this post


Link to post
Share on other sites
Advertisement
Branches are really bad, if adjacent fragments branch differently. Basically, as long as the graphics card can batch together adjacent fragments and perform the exact same operations on all of them (with different data of course) you are fine.

Keep in mind though, that branches do take a few cycles.

As for the special case of loops:

If you use loops with a compile time constant as the number of iterations, the compiler can unroll the loop, which completely frees you from the conditional branches. And you can't have diverging control flows for adjacent fragments.

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!