Search Unity

Is bit shifting operation in shaders expensive?

Discussion in 'Shaders' started by Garen_, Sep 11, 2019.

  1. Garen_

    Garen_

    Joined:
    Apr 24, 2013
    Posts:
    14
    Does anyone knows if bit shifting is an expensive operation in shaders ?

    I could do it in vertex shader instead of pixel shaders. But in general, does anyone knows if bit shifting is an expensive operation in shader?
     
  2. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    7,160
    It depends on the GPU. Modern desktop GPUs it’s the same cost as any other basic operation. For some very early DX10 GPUs and some older mobile GPUs, it could be slow.