Skip to main content
added 116 characters in body
Source Link
russ
  • 2.4k
  • 10
  • 20

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?

EDIT>> I'm an idiot... Thanks for the answers guys, useful to know, but I've been going about this all wrong. I should just be using the RGB10_A2UI texture format then packing/ unpacking with a single image load/store instruction instead of messing around with bitshifts myself.

RE_EDIT>> Or not... This method apparently works on red boxes but not on green ones, so it's back to bit-shifts.

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?

EDIT>> I'm an idiot... Thanks for the answers guys, useful to know, but I've been going about this all wrong. I should just be using the RGB10_A2UI texture format then packing/ unpacking with a single image load/store instruction instead of messing around with bitshifts myself.

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?

EDIT>> I'm an idiot... Thanks for the answers guys, useful to know, but I've been going about this all wrong. I should just be using the RGB10_A2UI texture format then packing/ unpacking with a single image load/store instruction instead of messing around with bitshifts myself.

RE_EDIT>> Or not... This method apparently works on red boxes but not on green ones, so it's back to bit-shifts.

added 284 characters in body
Source Link
russ
  • 2.4k
  • 10
  • 20

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?

EDIT>> I'm an idiot... Thanks for the answers guys, useful to know, but I've been going about this all wrong. I should just be using the RGB10_A2UI texture format then packing/ unpacking with a single image load/store instruction instead of messing around with bitshifts myself.

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?

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?

EDIT>> I'm an idiot... Thanks for the answers guys, useful to know, but I've been going about this all wrong. I should just be using the RGB10_A2UI texture format then packing/ unpacking with a single image load/store instruction instead of messing around with bitshifts myself.

Source Link
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?