Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save rygorous/94fd3c33afe4e650ec5bda386cbc16bb to your computer and use it in GitHub Desktop.
Save rygorous/94fd3c33afe4e650ec5bda386cbc16bb to your computer and use it in GitHub Desktop.
uint EvenBitMask = 0x55555555u;
uint HighIndexBit = PackedIndices >> 1;
float NumWeight1 = float(countbits(EvenBitMask & ~HighIndexBit & PackedIndices));
float NumWeight2 = float(countbits(EvenBitMask & HighIndexBit & ~PackedIndices));
float NumWeight3 = float(countbits(EvenBitMask & HighIndexBit & PackedIndices));
// with NV LOP3: 1 shift, 3 LOP3, 3 pop count, 3 int->float = 10 insns total for 16 pixels
// without: 1 shift, 2 NOT, 5 AND, 3 pop count, 3 int->float = 14 insns total for 16 pixels
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment