loops in shaders ? help

Started by
0 comments, last by Ohforf sake 13 years, 1 month ago
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 ???
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.

This topic is closed to new replies.

Advertisement