Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use numeric constants to define wgpu_types::Features values. #2817

Merged

Conversation

jimblandy
Copy link
Member

@jimblandy jimblandy commented Jun 28, 2022

As an incidental change, #2802 (de5fe90) changed the definitions of the bitflags in wgpu_types::Features from looking like this:

const DEPTH24UNORM_STENCIL8 = 1 << 1;

to this:

const DEPTH24UNORM_STENCIL8 = Self::DEPTH_CLIP_CONTROL.bits << 1;

The intention was to make it easier to insert new flags at a logical point in the list, and have the numbers automatically update themselves.

Unfortunately, cbindgen can't cope with the new style of definition. It produces definitions for these flags that look like this:

#define WGPUFeatures_DEPTH24UNORM_STENCIL8 (uint64_t)((WGPUFeatures_DEPTH_CLIP_CONTROL).bits << 1)

These are integer values, so the .bits field access is bogus.

This commit changes the definitions back to using direct numbering, which cbindgen doesn't choke on.

As an incidental change, wgpu#2802 (de5fe90) changed the definitions
of the bitflags in `wgpu_types::Features` from looking like this:

    const DEPTH24UNORM_STENCIL8 = 1 << 1;

to this:

    const DEPTH24UNORM_STENCIL8 = Self::DEPTH_CLIP_CONTROL.bits << 1;

The intention was to make it easier to insert new flags at a logical
point in the list, and have the numbers automatically update
themselves.

Unfortunately, `cbindgen` can't cope with the new style of definition.
It produces definitions for these flags that look like this:

    #define WGPUFeatures_DEPTH24UNORM_STENCIL8 (uint64_t)((WGPUFeatures_DEPTH_CLIP_CONTROL).bits << 1)

These are integer values, so the `.bits` field access is bogus.

This commit changes the definitions back to using direct numbering,
which `cbindgen` doesn't choke on.
@cwfitzgerald
Copy link
Member

Ah rip

@cwfitzgerald cwfitzgerald merged commit b370b99 into gfx-rs:master Jun 28, 2022
@jimblandy jimblandy deleted the wgpu-features-constant-bit-numbers branch June 28, 2022 16:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants