Home › In a fragment shader, BRANCHING on a uniform vs …
In a fragment shader, BRANCHING on a uniform vs a varying / per-fragment value differs because of which property?
AUniform branch is coherent in a warp + varying diverges
BVarying branches are zero-cost on modern GPUs nowadays
CBoth produce identical assembly always on a GPU device
DUniform branches are always slower than varying branches
Answer & Solution
Correct answer: A. Uniform branch is coherent in a warp + varying diverges
LearnOpenGL + NVIDIA programming guide: GPU executes SIMT warps; varying branches force serialisation of paths. Uniform branches are coherent → cheap.
Related questions
Per LearnOpenGL (compute shaders), the WORKGROUP for a GLSL compute shader is invoked via For UNIFORM BUFFER OBJECTS (UBO) and SHADER STORAGE BUFFER OBJECTS (SSBO), the key differePer LearnOpenGL (Normal Mapping), normals stored in a normal map are most commonly in whicPer LearnOpenGL (Lighting), the BLINN-PHONG specular highlight uses which vector instead oPer The Book of Shaders, a SDF-based circle shape in a fragment shader at point uv (centrePer Microsoft HLSL docs, a vertex shader output marked SV_POSITION corresponds to which GLPer LearnOpenGL, the CLIP space output (gl_Position) is converted to NDC by which operatioPer LearnOpenGL (Transformations), the standard order of matrix multiplication for a verte