[PATCH 1/5] wined3d: Use a bitmask for the {v, p}s_const_f fields in struct wined3d_saved_states.

Henri Verbeet hverbeet at gmail.com
Tue Feb 11 10:32:41 CST 2020


On Mon, 10 Feb 2020 at 23:06, Matteo Bruni <mbruni at 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.



More information about the wine-devel mailing list