update bitflags to 2.3 (#8728)

# Objective

- Update bitflags to 2.3
This commit is contained in:
François 2023-06-01 10:41:42 +02:00 committed by GitHub
parent bad754a986
commit bea7fd1c0b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
14 changed files with 33 additions and 25 deletions

View file

@ -31,5 +31,5 @@ bevy_math = { path = "../bevy_math", version = "0.11.0-dev" }
bevy_utils = { path = "../bevy_utils", version = "0.11.0-dev" } bevy_utils = { path = "../bevy_utils", version = "0.11.0-dev" }
serde = { version = "1", features = ["derive"] } serde = { version = "1", features = ["derive"] }
bitflags = "1.2" bitflags = "2.3"
radsort = "0.1" radsort = "0.1"

View file

@ -26,7 +26,7 @@ bevy_window = { path = "../bevy_window", version = "0.11.0-dev" }
bevy_derive = { path = "../bevy_derive", version = "0.11.0-dev" } bevy_derive = { path = "../bevy_derive", version = "0.11.0-dev" }
# other # other
bitflags = "1.2" bitflags = "2.3"
# direct dependency required for derive macro # direct dependency required for derive macro
bytemuck = { version = "1", features = ["derive"] } bytemuck = { version = "1", features = ["derive"] }
radsort = "0.1" radsort = "0.1"

View file

@ -829,7 +829,7 @@ pub fn prepare_lights(
.xyz() .xyz()
.extend(1.0 / (light.range * light.range)), .extend(1.0 / (light.range * light.range)),
position_radius: light.transform.translation().extend(light.radius), position_radius: light.transform.translation().extend(light.radius),
flags: flags.bits, flags: flags.bits(),
shadow_depth_bias: light.shadow_depth_bias, shadow_depth_bias: light.shadow_depth_bias,
shadow_normal_bias: light.shadow_normal_bias, shadow_normal_bias: light.shadow_normal_bias,
spot_light_tan_angle, spot_light_tan_angle,
@ -876,7 +876,7 @@ pub fn prepare_lights(
color: Vec4::from_slice(&light.color.as_linear_rgba_f32()) * intensity, color: Vec4::from_slice(&light.color.as_linear_rgba_f32()) * intensity,
// direction is negated to be ready for N.L // direction is negated to be ready for N.L
dir_to_light: light.transform.back(), dir_to_light: light.transform.back(),
flags: flags.bits, flags: flags.bits(),
shadow_depth_bias: light.shadow_depth_bias, shadow_depth_bias: light.shadow_depth_bias,
shadow_normal_bias: light.shadow_normal_bias, shadow_normal_bias: light.shadow_normal_bias,
num_cascades: num_cascades as u32, num_cascades: num_cascades as u32,

View file

@ -181,7 +181,7 @@ pub fn extract_meshes(
flags |= MeshFlags::SIGN_DETERMINANT_MODEL_3X3; flags |= MeshFlags::SIGN_DETERMINANT_MODEL_3X3;
} }
let uniform = MeshUniform { let uniform = MeshUniform {
flags: flags.bits, flags: flags.bits(),
transform, transform,
previous_transform, previous_transform,
inverse_transpose_model: transform.inverse().transpose(), inverse_transpose_model: transform.inverse().transpose(),
@ -571,6 +571,7 @@ impl MeshPipeline {
} }
bitflags::bitflags! { bitflags::bitflags! {
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
#[repr(transparent)] #[repr(transparent)]
// NOTE: Apparently quadro drivers support up to 64x MSAA. // NOTE: Apparently quadro drivers support up to 64x MSAA.
/// MSAA uses the highest 3 bits for the MSAA log2(sample count) to support up to 128x MSAA. /// MSAA uses the highest 3 bits for the MSAA log2(sample count) to support up to 128x MSAA.
@ -622,7 +623,7 @@ impl MeshPipelineKey {
pub fn from_msaa_samples(msaa_samples: u32) -> Self { pub fn from_msaa_samples(msaa_samples: u32) -> Self {
let msaa_bits = let msaa_bits =
(msaa_samples.trailing_zeros() & Self::MSAA_MASK_BITS) << Self::MSAA_SHIFT_BITS; (msaa_samples.trailing_zeros() & Self::MSAA_MASK_BITS) << Self::MSAA_SHIFT_BITS;
Self::from_bits(msaa_bits).unwrap() Self::from_bits_retain(msaa_bits)
} }
pub fn from_hdr(hdr: bool) -> Self { pub fn from_hdr(hdr: bool) -> Self {
@ -634,19 +635,19 @@ impl MeshPipelineKey {
} }
pub fn msaa_samples(&self) -> u32 { pub fn msaa_samples(&self) -> u32 {
1 << ((self.bits >> Self::MSAA_SHIFT_BITS) & Self::MSAA_MASK_BITS) 1 << ((self.bits() >> Self::MSAA_SHIFT_BITS) & Self::MSAA_MASK_BITS)
} }
pub fn from_primitive_topology(primitive_topology: PrimitiveTopology) -> Self { pub fn from_primitive_topology(primitive_topology: PrimitiveTopology) -> Self {
let primitive_topology_bits = ((primitive_topology as u32) let primitive_topology_bits = ((primitive_topology as u32)
& Self::PRIMITIVE_TOPOLOGY_MASK_BITS) & Self::PRIMITIVE_TOPOLOGY_MASK_BITS)
<< Self::PRIMITIVE_TOPOLOGY_SHIFT_BITS; << Self::PRIMITIVE_TOPOLOGY_SHIFT_BITS;
Self::from_bits(primitive_topology_bits).unwrap() Self::from_bits_retain(primitive_topology_bits)
} }
pub fn primitive_topology(&self) -> PrimitiveTopology { pub fn primitive_topology(&self) -> PrimitiveTopology {
let primitive_topology_bits = let primitive_topology_bits = (self.bits() >> Self::PRIMITIVE_TOPOLOGY_SHIFT_BITS)
(self.bits >> Self::PRIMITIVE_TOPOLOGY_SHIFT_BITS) & Self::PRIMITIVE_TOPOLOGY_MASK_BITS; & Self::PRIMITIVE_TOPOLOGY_MASK_BITS;
match primitive_topology_bits { match primitive_topology_bits {
x if x == PrimitiveTopology::PointList as u32 => PrimitiveTopology::PointList, x if x == PrimitiveTopology::PointList as u32 => PrimitiveTopology::PointList,
x if x == PrimitiveTopology::LineList as u32 => PrimitiveTopology::LineList, x if x == PrimitiveTopology::LineList as u32 => PrimitiveTopology::LineList,

View file

@ -62,7 +62,7 @@ wgpu-hal = "0.16.0"
codespan-reporting = "0.11.0" codespan-reporting = "0.11.0"
naga = { version = "0.12.0", features = ["wgsl-in"] } naga = { version = "0.12.0", features = ["wgsl-in"] }
serde = { version = "1", features = ["derive"] } serde = { version = "1", features = ["derive"] }
bitflags = "1.2.1" bitflags = "2.3"
smallvec = { version = "1.6", features = ["union", "const_generics"] } smallvec = { version = "1.6", features = ["union", "const_generics"] }
once_cell = "1.4.1" # TODO: replace once_cell with std equivalent if/when this lands: https://github.com/rust-lang/rfcs/pull/2788 once_cell = "1.4.1" # TODO: replace once_cell with std equivalent if/when this lands: https://github.com/rust-lang/rfcs/pull/2788
downcast-rs = "1.2.0" downcast-rs = "1.2.0"

View file

@ -555,7 +555,7 @@ impl RenderAsset for Image {
} }
bitflags::bitflags! { bitflags::bitflags! {
#[derive(Default)] #[derive(Default, Clone, Copy, Eq, PartialEq, Debug)]
#[repr(transparent)] #[repr(transparent)]
pub struct CompressedImageFormats: u32 { pub struct CompressedImageFormats: u32 {
const NONE = 0; const NONE = 0;

View file

@ -63,12 +63,14 @@ impl std::cmp::PartialEq<&Visibility> for Visibility {
} }
bitflags::bitflags! { bitflags::bitflags! {
#[derive(Reflect)] #[derive(Clone, Debug, Eq, PartialEq)]
pub(super) struct ComputedVisibilityFlags: u8 { pub(super) struct ComputedVisibilityFlags: u8 {
const VISIBLE_IN_VIEW = 1 << 0; const VISIBLE_IN_VIEW = 1 << 0;
const VISIBLE_IN_HIERARCHY = 1 << 1; const VISIBLE_IN_HIERARCHY = 1 << 1;
} }
} }
bevy_reflect::impl_reflect_value!(ComputedVisibilityFlags);
bevy_reflect::impl_from_reflect_value!(ComputedVisibilityFlags);
/// Algorithmically-computed indication of whether an entity is visible and should be extracted for rendering /// Algorithmically-computed indication of whether an entity is visible and should be extracted for rendering
#[derive(Component, Clone, Reflect, Debug, Eq, PartialEq)] #[derive(Component, Clone, Reflect, Debug, Eq, PartialEq)]
@ -95,7 +97,7 @@ impl ComputedVisibility {
/// Reading it during [`Update`](bevy_app::Update) will yield the value from the previous frame. /// Reading it during [`Update`](bevy_app::Update) will yield the value from the previous frame.
#[inline] #[inline]
pub fn is_visible(&self) -> bool { pub fn is_visible(&self) -> bool {
self.flags.bits == ComputedVisibilityFlags::all().bits self.flags.bits() == ComputedVisibilityFlags::all().bits()
} }
/// Whether this entity is visible in the entity hierarchy, which is determined by the [`Visibility`] component. /// Whether this entity is visible in the entity hierarchy, which is determined by the [`Visibility`] component.

View file

@ -30,4 +30,4 @@ fixedbitset = "0.4"
guillotiere = "0.6.0" guillotiere = "0.6.0"
thiserror = "1.0" thiserror = "1.0"
rectangle-pack = "0.4" rectangle-pack = "0.4"
bitflags = "1.2" bitflags = "2.3"

View file

@ -152,7 +152,7 @@ pub fn extract_mesh2d(
( (
Mesh2dHandle(handle.0.clone_weak()), Mesh2dHandle(handle.0.clone_weak()),
Mesh2dUniform { Mesh2dUniform {
flags: MeshFlags::empty().bits, flags: MeshFlags::empty().bits(),
transform, transform,
inverse_transpose_model: transform.inverse().transpose(), inverse_transpose_model: transform.inverse().transpose(),
}, },
@ -283,6 +283,7 @@ impl Mesh2dPipeline {
} }
bitflags::bitflags! { bitflags::bitflags! {
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
#[repr(transparent)] #[repr(transparent)]
// NOTE: Apparently quadro drivers support up to 64x MSAA. // NOTE: Apparently quadro drivers support up to 64x MSAA.
// MSAA uses the highest 3 bits for the MSAA log2(sample count) to support up to 128x MSAA. // MSAA uses the highest 3 bits for the MSAA log2(sample count) to support up to 128x MSAA.
@ -318,7 +319,7 @@ impl Mesh2dPipelineKey {
pub fn from_msaa_samples(msaa_samples: u32) -> Self { pub fn from_msaa_samples(msaa_samples: u32) -> Self {
let msaa_bits = let msaa_bits =
(msaa_samples.trailing_zeros() & Self::MSAA_MASK_BITS) << Self::MSAA_SHIFT_BITS; (msaa_samples.trailing_zeros() & Self::MSAA_MASK_BITS) << Self::MSAA_SHIFT_BITS;
Self::from_bits(msaa_bits).unwrap() Self::from_bits_retain(msaa_bits)
} }
pub fn from_hdr(hdr: bool) -> Self { pub fn from_hdr(hdr: bool) -> Self {
@ -330,19 +331,19 @@ impl Mesh2dPipelineKey {
} }
pub fn msaa_samples(&self) -> u32 { pub fn msaa_samples(&self) -> u32 {
1 << ((self.bits >> Self::MSAA_SHIFT_BITS) & Self::MSAA_MASK_BITS) 1 << ((self.bits() >> Self::MSAA_SHIFT_BITS) & Self::MSAA_MASK_BITS)
} }
pub fn from_primitive_topology(primitive_topology: PrimitiveTopology) -> Self { pub fn from_primitive_topology(primitive_topology: PrimitiveTopology) -> Self {
let primitive_topology_bits = ((primitive_topology as u32) let primitive_topology_bits = ((primitive_topology as u32)
& Self::PRIMITIVE_TOPOLOGY_MASK_BITS) & Self::PRIMITIVE_TOPOLOGY_MASK_BITS)
<< Self::PRIMITIVE_TOPOLOGY_SHIFT_BITS; << Self::PRIMITIVE_TOPOLOGY_SHIFT_BITS;
Self::from_bits(primitive_topology_bits).unwrap() Self::from_bits_retain(primitive_topology_bits)
} }
pub fn primitive_topology(&self) -> PrimitiveTopology { pub fn primitive_topology(&self) -> PrimitiveTopology {
let primitive_topology_bits = let primitive_topology_bits = (self.bits() >> Self::PRIMITIVE_TOPOLOGY_SHIFT_BITS)
(self.bits >> Self::PRIMITIVE_TOPOLOGY_SHIFT_BITS) & Self::PRIMITIVE_TOPOLOGY_MASK_BITS; & Self::PRIMITIVE_TOPOLOGY_MASK_BITS;
match primitive_topology_bits { match primitive_topology_bits {
x if x == PrimitiveTopology::PointList as u32 => PrimitiveTopology::PointList, x if x == PrimitiveTopology::PointList as u32 => PrimitiveTopology::PointList,
x if x == PrimitiveTopology::LineList as u32 => PrimitiveTopology::LineList, x if x == PrimitiveTopology::LineList as u32 => PrimitiveTopology::LineList,

View file

@ -137,6 +137,7 @@ impl FromWorld for SpritePipeline {
} }
bitflags::bitflags! { bitflags::bitflags! {
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
#[repr(transparent)] #[repr(transparent)]
// NOTE: Apparently quadro drivers support up to 64x MSAA. // NOTE: Apparently quadro drivers support up to 64x MSAA.
// MSAA uses the highest 3 bits for the MSAA log2(sample count) to support up to 128x MSAA. // MSAA uses the highest 3 bits for the MSAA log2(sample count) to support up to 128x MSAA.
@ -170,12 +171,12 @@ impl SpritePipelineKey {
pub const fn from_msaa_samples(msaa_samples: u32) -> Self { pub const fn from_msaa_samples(msaa_samples: u32) -> Self {
let msaa_bits = let msaa_bits =
(msaa_samples.trailing_zeros() & Self::MSAA_MASK_BITS) << Self::MSAA_SHIFT_BITS; (msaa_samples.trailing_zeros() & Self::MSAA_MASK_BITS) << Self::MSAA_SHIFT_BITS;
Self::from_bits_truncate(msaa_bits) Self::from_bits_retain(msaa_bits)
} }
#[inline] #[inline]
pub const fn msaa_samples(&self) -> u32 { pub const fn msaa_samples(&self) -> u32 {
1 << ((self.bits >> Self::MSAA_SHIFT_BITS) & Self::MSAA_MASK_BITS) 1 << ((self.bits() >> Self::MSAA_SHIFT_BITS) & Self::MSAA_MASK_BITS)
} }
#[inline] #[inline]

View file

@ -10,4 +10,4 @@ license = "MIT OR Apache-2.0"
toml_edit = "0.19" toml_edit = "0.19"
tera = "1.15" tera = "1.15"
serde = { version = "1.0", features = [ "derive" ] } serde = { version = "1.0", features = [ "derive" ] }
bitflags = "1.3" bitflags = "2.3"

View file

@ -4,6 +4,7 @@ mod examples;
mod features; mod features;
bitflags! { bitflags! {
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
struct Command: u32 { struct Command: u32 {
const CHECK_MISSING = 0b00000001; const CHECK_MISSING = 0b00000001;
const UPDATE = 0b00000010; const UPDATE = 0b00000010;
@ -11,6 +12,7 @@ bitflags! {
} }
bitflags! { bitflags! {
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
struct Target: u32 { struct Target: u32 {
const EXAMPLES = 0b00000001; const EXAMPLES = 0b00000001;
const FEATURES = 0b00000010; const FEATURES = 0b00000010;

View file

@ -8,4 +8,4 @@ license = "MIT OR Apache-2.0"
[dependencies] [dependencies]
xshell = "0.2" xshell = "0.2"
bitflags = "1.3" bitflags = "2.3"

View file

@ -3,6 +3,7 @@ use xshell::{cmd, Shell};
use bitflags::bitflags; use bitflags::bitflags;
bitflags! { bitflags! {
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
struct Check: u32 { struct Check: u32 {
const FORMAT = 0b00000001; const FORMAT = 0b00000001;
const CLIPPY = 0b00000010; const CLIPPY = 0b00000010;