Skip to main content
1 of 3
russ
  • 2.4k
  • 10
  • 20

Do modern GPUs contain barrel shifters?

I'm aware that most modern GPUs, although designed for floating point, are more or less equivalent in integer performance these days, with a few caveats like the lack of a fused multiply add. I'm not sure how this applies to shift operations though. I'm doing Marching Cubes on GPU, initially writing out a 32-bit packed position for each surface cube then unpacking these in a later pass to the actual vertices in that cube, like this :

ivec3 unpackedPos = ivec3( packedPos >> 20 & 0x3FF,
                         packedPos >> 10 & 0x3FF,
                         packedPos & 0x3FF);

It just occurred to me to wonder if shader units have barrel shifters in them these days? Am I doing 2 shifts here or 30?

russ
  • 2.4k
  • 10
  • 20