On Mon, 10 Feb 2020 at 23:06, Matteo Bruni mbruni@codeweavers.com wrote:
+static void wined3d_bitmask_set_bits(DWORD *bitmask, unsigned int offset, unsigned int count) +{
- const unsigned int word_bit_count = sizeof(*bitmask) * CHAR_BIT;
- const unsigned int shift = offset % word_bit_count;
- bitmask += offset / word_bit_count;
- *bitmask |= ~0u >> (word_bit_count - min(count, word_bit_count)) << shift;
- ++bitmask;
- count -= min(count, word_bit_count - shift);
- if (!count)
return;
- if (count >= word_bit_count)
- {
memset(bitmask, 0xffu, count / CHAR_BIT);
bitmask += count / word_bit_count;
count = count % word_bit_count;
if (!count)
return;
- }
- *bitmask |= (1u << count) - 1;
+}
Does this intentionally not handle 0 count? I also suspect this has some room for simplification.