<p>It has often been recommended to avoid branching conditions in shaders.</p>

<p>Why? What happens exactly in modern GPUs in that case? 
Is it still recommended to avoid branching?</p>

CC BY-SA 4.0
2018-07-09T08:18:19.633Z
duplicate of https://computergraphics.stackexchange.com/q/259/137 and https://computergraphics.stackexchange.com/q/280/137
ratchet freak
CC BY-SA 4.0
2018-07-09T08:18:41.110Z
Possible duplicate of [Is a constant condition more costly than switching shaders?](https://computergraphics.stackexchange.com/questions/280/is-a-constant-condition-more-costly-than-switching-shaders)
ratchet freak
<shader><gpu>
How do modern GPUs handle branching instructions in shader code?
wip
# How do modern GPUs handle branching instructions in shader code?

(Asked by: username_0 on 2018-07-09)

It has often been recommended to avoid branching conditions in shaders.

Why? What happens exactly in modern GPUs in that case?
Is it still recommended to avoid branching?

**Tags:** shader, gpu

> **Comments:**
> **username_1**: duplicate of https://computergraphics.stackexchange.com/q/259/137 and https://computergraphics.stackexchange.com/q/280/137  
> **username_1**: Possible duplicate of [Is a constant condition more costly than switching shaders?](https://computergraphics.stackexchange.com/questions/280/is-a-constant-condition-more-costly-than-switching-shaders)  

---

## 0 answers

