Source

Branch

1/ @AgileJebrim

@NOTimothyLottes

How reliable in your experience in code like that is the compilation to avoid branches?

2/ @NOTimothyLottes

@AgileJebrim

Lots of stuff can get mapped by the compiler to V_CNDMASK_B32 instead of branching by using mix(a,b,bool) syntax. I rarely use branching because of how horrible the code generation is. No way to express that the common path stay code linear either, etc.

3/ @AgileJebrim

@NOTimothyLottes

I know in CUDA-land that it likes to create branches for ternaries if it contains more than 4 total instructions in a statement.

4/ @NOTimothyLottes

@AgileJebrim

But the real problem is lacking of explicit controls, and lacking implicit branch hints (wave-uniform/non-uniform, expected branch hit rate, etc). Better if we could just do explicit ASM style branch instructions and labels.

5/ @AgileJebrim

@NOTimothyLottes

Well I seek to ban branches entirely, so that’s the exact opposite of what I want.

6/ @NOTimothyLottes

@AgileJebrim

If your shader I

7/ @AgileJebrim

@NOTimothyLottes

I avoid the duplication of instruction patterns too. I feel it’s a failure to properly parallelize if you’re repeating the same instructions instead of data parallelizing further.

8/ @AgileJebrim

@NOTimothyLottes

One more reason why I avoid functions.