← All resources

gpu conditionals - 2025

Auto-discovered

Blog Advanced

Inigo Quilez

Visit resource ↗

Description

gpu conditionals - 2025 is a single technical article by Inigo Quilez on his iquilezles.org site about how GPUs handle simple conditionals in shaders.

It corrects a common claim that ternary operators or short if selections are costly branches that should be rewritten with step and mix masking. Quilez shows that selecting among a few register values is a conditional move, not a branch, and compares GLSL ternaries with AMD and Microsoft compiler listings that use compares and cndmask or movc. He also argues that step-based "optimizations" often run slower because they still pay for selects plus extra arithmetic.

It is for intermediate to advanced shader authors who tune GLSL or HLSL hot paths and read generated ISA occasionally.

The page is a free HTML article with code snippets and compiler dumps; no download is required.

It is useful as a concise counter to brittle micro-optimization folklore when choosing between ternaries and arithmetic masking.