diff --git a/Cargo.lock b/Cargo.lock index 04ec15834..e6c2ebc9c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -191,6 +191,12 @@ version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" +[[package]] +name = "bitflags" +version = "2.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "487f1e0fcbe47deb8b0574e646def1c903389d95241dd1bbcc6ce4a715dfc0c1" + [[package]] name = "block" version = "0.1.6" @@ -296,7 +302,7 @@ version = "0.24.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f425db7937052c684daec3bd6375c8abe2d146dca4b8b143d6db777c39138f3a" dependencies = [ - "bitflags", + "bitflags 1.3.2", "block", "cocoa-foundation", "core-foundation", @@ -312,7 +318,7 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7ade49b65d560ca58c403a479bb396592b155c0185eada742ee323d1d68d6318" dependencies = [ - "bitflags", + "bitflags 1.3.2", "block", "core-foundation", "core-graphics-types", @@ -400,7 +406,7 @@ version = "0.22.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2581bbab3b8ffc6fcbd550bf46c355135d16e9ff2a6ea032ad6b9bf1d7efe4fb" dependencies = [ - "bitflags", + "bitflags 1.3.2", "core-foundation", "core-graphics-types", "foreign-types 0.3.2", @@ -413,7 +419,7 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3a68b68b3446082644c91ac778bf50cd4104bfb002b5a6a7c44cca5a2c70788b" dependencies = [ - "bitflags", + "bitflags 1.3.2", "core-foundation", "foreign-types 0.3.2", "libc", @@ -497,7 +503,7 @@ name = "d3d12" version = "0.6.0" source = "git+https://github.com/gfx-rs/d3d12-rs?rev=b940b1d71#b940b1d71ab7083ae80eec697872672dc1f2bd32" dependencies = [ - "bitflags", + "bitflags 1.3.2", "libloading", "winapi", ] @@ -543,7 +549,7 @@ version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "594ecd967c2f40db5dde8da4c356975fc1fe030e951c7c3962f6dc2e80042e87" dependencies = [ - "bitflags", + "bitflags 1.3.2", "byteorder", "enum_primitive", ] @@ -869,7 +875,7 @@ version = "0.26.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "74eadec9d0a5c28c54bb9882e54787275152a4e36ce206b45d7451384e5bf5fb" dependencies = [ - "bitflags", + "bitflags 1.3.2", "freetype-sys", "libc", ] @@ -1138,7 +1144,7 @@ version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7fc59e5f710e310e76e6707f86c561dd646f69a8876da9131703b2f717de818d" dependencies = [ - "bitflags", + "bitflags 1.3.2", "gpu-alloc-types", ] @@ -1148,7 +1154,7 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "54804d0d6bc9d7f26db4eaec1ad10def69b599315f487d32c334a80d1efe67a5" dependencies = [ - "bitflags", + "bitflags 1.3.2", ] [[package]] @@ -1170,7 +1176,7 @@ version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0b0c02e1ba0bdb14e965058ca34e09c020f8e507a760df1121728e0aef68d57a" dependencies = [ - "bitflags", + "bitflags 1.3.2", "gpu-descriptor-types", "hashbrown", ] @@ -1181,7 +1187,7 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "363e3677e55ad168fef68cf9de3a4a310b53124c5e784c53a1d70e92d23f2126" dependencies = [ - "bitflags", + "bitflags 1.3.2", ] [[package]] @@ -1199,7 +1205,7 @@ version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1397650ee315e8891a0df210707f0fc61771b0cc518c3023896064c5407cb3b0" dependencies = [ - "bitflags", + "bitflags 1.3.2", "com-rs", "libc", "libloading", @@ -1461,7 +1467,7 @@ version = "0.24.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "de11355d1f6781482d027a3b4d4de7825dcedb197bf573e0596d00008402d060" dependencies = [ - "bitflags", + "bitflags 1.3.2", "block", "core-graphics-types", "foreign-types 0.3.2", @@ -1511,7 +1517,7 @@ version = "0.11.0" source = "git+https://github.com/gfx-rs/naga?rev=9742f1616c3e3dd2cc9a5880616fc886c391bb9f#9742f1616c3e3dd2cc9a5880616fc886c391bb9f" dependencies = [ "bit-set", - "bitflags", + "bitflags 1.3.2", "codespan-reporting", "hexf-parse", "indexmap", @@ -1539,7 +1545,7 @@ version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "451422b7e4718271c8b5b3aadf5adedba43dc76312454b387e98fae0fc951aa0" dependencies = [ - "bitflags", + "bitflags 1.3.2", "jni-sys", "ndk-sys", "num_enum", @@ -1597,7 +1603,7 @@ version = "0.24.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fa52e972a9a719cecb6864fb88568781eb706bac2cd1d4f04a648542dbf78069" dependencies = [ - "bitflags", + "bitflags 1.3.2", "cfg-if", "libc", "memoffset", @@ -1893,7 +1899,7 @@ version = "0.17.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5d708eaf860a19b19ce538740d2b4bdeeb8337fa53f7738455e706623ad5c638" dependencies = [ - "bitflags", + "bitflags 1.3.2", "crc32fast", "flate2", "miniz_oxide 0.6.2", @@ -2032,7 +2038,7 @@ version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a" dependencies = [ - "bitflags", + "bitflags 1.3.2", ] [[package]] @@ -2065,7 +2071,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "300a51053b1cb55c80b7a9fde4120726ddf25ca241a1cbb926626f62fb136bff" dependencies = [ "base64 0.13.1", - "bitflags", + "bitflags 1.3.2", "serde", ] @@ -2112,7 +2118,7 @@ version = "0.36.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f43abb88211988493c1abb44a70efa56ff0ce98f233b7b276146f1f3f7ba9644" dependencies = [ - "bitflags", + "bitflags 1.3.2", "errno", "io-lifetimes", "libc", @@ -2322,7 +2328,7 @@ version = "0.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f307c47d32d2715eb2e0ece5589057820e0e5e70d07c247d1063e844e107f454" dependencies = [ - "bitflags", + "bitflags 1.3.2", "calloop", "dlib", "lazy_static", @@ -2367,7 +2373,7 @@ version = "0.2.0+1.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "246bfa38fe3db3f1dfc8ca5a2cdeb7348c78be2112740cc0ec8ef18b6d94f830" dependencies = [ - "bitflags", + "bitflags 1.3.2", "num-traits 0.2.15", ] @@ -2648,7 +2654,7 @@ version = "0.64.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a2287b485fa902172da3722d7e557e083afd63921777e0c6e5c0fba28e6d59d3" dependencies = [ - "bitflags", + "bitflags 1.3.2", "fslock", "lazy_static", "which", @@ -2911,7 +2917,7 @@ version = "0.29.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f3b068c05a039c9f755f881dc50f01732214f5685e379829759088967c46715" dependencies = [ - "bitflags", + "bitflags 1.3.2", "downcast-rs", "libc", "nix", @@ -2960,7 +2966,7 @@ version = "0.29.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b950621f9354b322ee817a23474e479b34be96c2e909c14f7bc0100e9a970bc6" dependencies = [ - "bitflags", + "bitflags 1.3.2", "wayland-client", "wayland-commons", "wayland-scanner", @@ -3004,7 +3010,7 @@ version = "0.15.0" dependencies = [ "arrayvec 0.7.2", "async-executor", - "bitflags", + "bitflags 2.0.2", "bytemuck", "cfg-if", "console_error_panic_hook", @@ -3044,7 +3050,7 @@ version = "0.15.0" dependencies = [ "arrayvec 0.7.2", "bit-vec", - "bitflags", + "bitflags 2.0.2", "codespan-reporting", "log", "naga", @@ -3069,7 +3075,7 @@ dependencies = [ "arrayvec 0.7.2", "ash", "bit-set", - "bitflags", + "bitflags 2.0.2", "block", "core-graphics-types", "d3d12", @@ -3117,7 +3123,7 @@ dependencies = [ name = "wgpu-types" version = "0.15.0" dependencies = [ - "bitflags", + "bitflags 2.0.2", "js-sys", "serde", "serde_json", @@ -3311,7 +3317,7 @@ version = "0.27.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bb796d6fbd86b2fd896c9471e6f04d39d750076ebe5680a3958f00f5ab97657c" dependencies = [ - "bitflags", + "bitflags 1.3.2", "cocoa", "core-foundation", "core-graphics", diff --git a/Cargo.toml b/Cargo.toml index 77b784c22..e9836167c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -48,7 +48,7 @@ version = "0.11.0" [workspace.dependencies] arrayvec = "0.7" async-executor = "1.0" -bitflags = "1" +bitflags = "2" bit-vec = "0.6" bytemuck = "1.13" cargo-run-wasm = "0.3.2" diff --git a/wgpu-core/Cargo.toml b/wgpu-core/Cargo.toml index 06adf0f9b..0c1b96609 100644 --- a/wgpu-core/Cargo.toml +++ b/wgpu-core/Cargo.toml @@ -51,7 +51,7 @@ wgsl = ["naga/wgsl-in"] [dependencies] arrayvec = "0.7" -bitflags = "1" +bitflags = "2" bit-vec = "0.6" codespan-reporting = "0.11" rustc-hash = "1.1" diff --git a/wgpu-core/src/pipeline.rs b/wgpu-core/src/pipeline.rs index 6923be65f..e1055c10a 100644 --- a/wgpu-core/src/pipeline.rs +++ b/wgpu-core/src/pipeline.rs @@ -382,6 +382,7 @@ pub enum CreateRenderPipelineError { bitflags::bitflags! { #[repr(transparent)] + #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] pub struct PipelineFlags: u32 { const BLEND_CONSTANT = 1 << 0; const STENCIL_REFERENCE = 1 << 1; diff --git a/wgpu-hal/Cargo.toml b/wgpu-hal/Cargo.toml index 6722a8d76..aaccde923 100644 --- a/wgpu-hal/Cargo.toml +++ b/wgpu-hal/Cargo.toml @@ -52,7 +52,7 @@ name = "raw-gles" required-features = ["gles"] [dependencies] -bitflags = "1" +bitflags = "2" parking_lot = ">=0.11,<0.13" profiling = { version = "1", default-features = false } raw-window-handle = "0.5" diff --git a/wgpu-hal/src/dx12/mod.rs b/wgpu-hal/src/dx12/mod.rs index 390a5693a..6cdf3ffe6 100644 --- a/wgpu-hal/src/dx12/mod.rs +++ b/wgpu-hal/src/dx12/mod.rs @@ -519,6 +519,7 @@ pub struct BindGroup { } bitflags::bitflags! { + #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] struct TableTypes: u8 { const SRV_CBV_UAV = 1 << 0; const SAMPLERS = 1 << 1; diff --git a/wgpu-hal/src/gles/mod.rs b/wgpu-hal/src/gles/mod.rs index d196b8bc4..f11286833 100644 --- a/wgpu-hal/src/gles/mod.rs +++ b/wgpu-hal/src/gles/mod.rs @@ -131,6 +131,7 @@ impl crate::Api for Api { bitflags::bitflags! { /// Flags that affect internal code paths but do not /// change the exposed feature set. + #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] struct PrivateCapabilities: u32 { /// Indicates support for `glBufferStorage` allocation. const BUFFER_ALLOCATION = 1 << 0; @@ -160,6 +161,7 @@ bitflags::bitflags! { bitflags::bitflags! { /// Flags that indicate necessary workarounds for specific devices or driver bugs + #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] struct Workarounds: u32 { // Needs workaround for Intel Mesa bug: // https://gitlab.freedesktop.org/mesa/mesa/-/issues/2565. diff --git a/wgpu-hal/src/lib.rs b/wgpu-hal/src/lib.rs index adb5fdc77..175814938 100644 --- a/wgpu-hal/src/lib.rs +++ b/wgpu-hal/src/lib.rs @@ -552,6 +552,7 @@ pub trait CommandEncoder: Send + Sync + fmt::Debug { bitflags!( /// Instance initialization flags. + #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] pub struct InstanceFlags: u32 { /// Generate debug information in shaders and objects. const DEBUG = 1 << 0; @@ -562,6 +563,7 @@ bitflags!( bitflags!( /// Pipeline layout creation flags. + #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] pub struct PipelineLayoutFlags: u32 { /// Include support for base vertex/instance drawing. const BASE_VERTEX_INSTANCE = 1 << 0; @@ -572,6 +574,7 @@ bitflags!( bitflags!( /// Pipeline layout creation flags. + #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] pub struct BindGroupLayoutFlags: u32 { /// Allows for bind group binding arrays to be shorter than the array in the BGL. const PARTIALLY_BOUND = 1 << 0; @@ -580,6 +583,7 @@ bitflags!( bitflags!( /// Texture format capability flags. + #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] pub struct TextureFormatCapabilities: u32 { /// Format can be sampled. const SAMPLED = 1 << 0; @@ -623,6 +627,7 @@ bitflags!( bitflags!( /// Texture format capability flags. + #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] pub struct FormatAspects: u8 { const COLOR = 1 << 0; const DEPTH = 1 << 1; @@ -671,6 +676,7 @@ impl From for FormatAspects { } bitflags!( + #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] pub struct MemoryFlags: u32 { const TRANSIENT = 1 << 0; const PREFER_COHERENT = 1 << 1; @@ -680,6 +686,7 @@ bitflags!( //TODO: it's not intuitive for the backends to consider `LOAD` being optional. bitflags!( + #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] pub struct AttachmentOps: u8 { const LOAD = 1 << 0; const STORE = 1 << 1; @@ -688,6 +695,7 @@ bitflags!( bitflags::bitflags! { /// Similar to `wgt::BufferUsages` but for internal use. + #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] pub struct BufferUses: u16 { /// The argument to a read-only mapping. const MAP_READ = 1 << 0; @@ -710,20 +718,21 @@ bitflags::bitflags! { /// The indirect or count buffer in a indirect draw or dispatch. const INDIRECT = 1 << 9; /// The combination of states that a buffer may be in _at the same time_. - const INCLUSIVE = Self::MAP_READ.bits | Self::COPY_SRC.bits | - Self::INDEX.bits | Self::VERTEX.bits | Self::UNIFORM.bits | - Self::STORAGE_READ.bits | Self::INDIRECT.bits; + const INCLUSIVE = Self::MAP_READ.bits() | Self::COPY_SRC.bits() | + Self::INDEX.bits() | Self::VERTEX.bits() | Self::UNIFORM.bits() | + Self::STORAGE_READ.bits() | Self::INDIRECT.bits(); /// The combination of states that a buffer must exclusively be in. - const EXCLUSIVE = Self::MAP_WRITE.bits | Self::COPY_DST.bits | Self::STORAGE_READ_WRITE.bits; + const EXCLUSIVE = Self::MAP_WRITE.bits() | Self::COPY_DST.bits() | Self::STORAGE_READ_WRITE.bits(); /// The combination of all usages that the are guaranteed to be be ordered by the hardware. /// If a usage is ordered, then if the buffer state doesn't change between draw calls, there /// are no barriers needed for synchronization. - const ORDERED = Self::INCLUSIVE.bits | Self::MAP_WRITE.bits; + const ORDERED = Self::INCLUSIVE.bits() | Self::MAP_WRITE.bits(); } } bitflags::bitflags! { /// Similar to `wgt::TextureUsages` but for internal use. + #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] pub struct TextureUses: u16 { /// The texture is in unknown state. const UNINITIALIZED = 1 << 0; @@ -746,13 +755,13 @@ bitflags::bitflags! { /// Read-write or write-only storage buffer usage. const STORAGE_READ_WRITE = 1 << 9; /// The combination of states that a texture may be in _at the same time_. - const INCLUSIVE = Self::COPY_SRC.bits | Self::RESOURCE.bits | Self::DEPTH_STENCIL_READ.bits; + const INCLUSIVE = Self::COPY_SRC.bits() | Self::RESOURCE.bits() | Self::DEPTH_STENCIL_READ.bits(); /// The combination of states that a texture must exclusively be in. - const EXCLUSIVE = Self::COPY_DST.bits | Self::COLOR_TARGET.bits | Self::DEPTH_STENCIL_WRITE.bits | Self::STORAGE_READ.bits | Self::STORAGE_READ_WRITE.bits | Self::PRESENT.bits; + const EXCLUSIVE = Self::COPY_DST.bits() | Self::COLOR_TARGET.bits() | Self::DEPTH_STENCIL_WRITE.bits() | Self::STORAGE_READ.bits() | Self::STORAGE_READ_WRITE.bits() | Self::PRESENT.bits(); /// The combination of all usages that the are guaranteed to be be ordered by the hardware. /// If a usage is ordered, then if the texture state doesn't change between draw calls, there /// are no barriers needed for synchronization. - const ORDERED = Self::INCLUSIVE.bits | Self::COLOR_TARGET.bits | Self::DEPTH_STENCIL_WRITE.bits | Self::STORAGE_READ.bits; + const ORDERED = Self::INCLUSIVE.bits() | Self::COLOR_TARGET.bits() | Self::DEPTH_STENCIL_WRITE.bits() | Self::STORAGE_READ.bits(); /// Flag used by the wgpu-core texture tracker to say a texture is in different states for every sub-resource const COMPLEX = 1 << 10; diff --git a/wgpu-hal/src/vulkan/mod.rs b/wgpu-hal/src/vulkan/mod.rs index fdee54797..27200dc4e 100644 --- a/wgpu-hal/src/vulkan/mod.rs +++ b/wgpu-hal/src/vulkan/mod.rs @@ -173,6 +173,7 @@ struct PrivateCapabilities { bitflags::bitflags!( /// Workaround flags. + #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] pub struct Workarounds: u32 { /// Only generate SPIR-V for one entry point at a time. const SEPARATE_ENTRY_POINTS = 0x1; diff --git a/wgpu-types/Cargo.toml b/wgpu-types/Cargo.toml index 9bca057d9..21aa22935 100644 --- a/wgpu-types/Cargo.toml +++ b/wgpu-types/Cargo.toml @@ -27,7 +27,7 @@ replay = ["serde"] strict_asserts = [] [dependencies] -bitflags = "1" +bitflags = "2" serde = { version = "1", features = ["serde_derive"], optional = true } [target.'cfg(target_arch = "wasm32")'.dependencies] diff --git a/wgpu-types/src/lib.rs b/wgpu-types/src/lib.rs index dbdfd1893..b4ee44906 100644 --- a/wgpu-types/src/lib.rs +++ b/wgpu-types/src/lib.rs @@ -42,9 +42,7 @@ macro_rules! impl_bitflags { D: serde::Deserializer<'de>, { let value = <_ as serde::Deserialize<'de>>::deserialize(deserializer)?; - // Note: newer version of bitflags replaced from_bits_unchecked with - // from_bits_retain which is not marked as unsafe (same implementation). - Ok(unsafe { $name::from_bits_unchecked(value) }) + Ok($name::from_bits_retain(value)) } } @@ -132,6 +130,7 @@ pub enum PowerPreference { bitflags::bitflags! { /// Represents the backends that wgpu will use. #[repr(transparent)] + #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] pub struct Backends: u32 { /// Supported on Windows, Linux/Android, and macOS/iOS via Vulkan Portability (with the Vulkan feature enabled) const VULKAN = 1 << Backend::Vulkan as u32; @@ -149,15 +148,15 @@ bitflags::bitflags! { /// All the apis that wgpu offers first tier of support for. /// /// Vulkan + Metal + DX12 + Browser WebGPU - const PRIMARY = Self::VULKAN.bits - | Self::METAL.bits - | Self::DX12.bits - | Self::BROWSER_WEBGPU.bits; + const PRIMARY = Self::VULKAN.bits() + | Self::METAL.bits() + | Self::DX12.bits() + | Self::BROWSER_WEBGPU.bits(); /// All the apis that wgpu offers second tier of support for. These may /// be unsupported/still experimental. /// /// OpenGL + DX11 - const SECONDARY = Self::GL.bits | Self::DX11.bits; + const SECONDARY = Self::GL.bits() | Self::DX11.bits(); } } @@ -214,6 +213,7 @@ bitflags::bitflags! { /// https://gpuweb.github.io/gpuweb/#enumdef-gpufeaturename). #[repr(transparent)] #[derive(Default)] + #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] pub struct Features: u64 { // // ---- Start numbering at 1 << 0 ---- @@ -1145,6 +1145,7 @@ bitflags::bitflags! { /// /// You can check whether a set of flags is compliant through the /// [`DownlevelCapabilities::is_webgpu_compliant()`] function. + #[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] pub struct DownlevelFlags: u32 { /// The device supports compiling and using compute shaders. /// @@ -1249,7 +1250,7 @@ impl DownlevelFlags { // We use manual bit twiddling to make this a const fn as `Sub` and `.remove` aren't const // WebGPU doesn't actually require aniso - Self::from_bits_truncate(Self::all().bits() & !Self::ANISOTROPIC_FILTERING.bits) + Self::from_bits_truncate(Self::all().bits() & !Self::ANISOTROPIC_FILTERING.bits()) } } @@ -1349,6 +1350,7 @@ bitflags::bitflags! { /// Corresponds to [WebGPU `GPUShaderStageFlags`]( /// https://gpuweb.github.io/gpuweb/#typedefdef-gpushaderstageflags). #[repr(transparent)] + #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] pub struct ShaderStages: u32 { /// Binding is not visible from any shader stage. const NONE = 0; @@ -1359,7 +1361,7 @@ bitflags::bitflags! { /// Binding is visible from the compute shader of a compute pipeline. const COMPUTE = 1 << 2; /// Binding is visible from the vertex and fragment shaders of a render pipeline. - const VERTEX_FRAGMENT = Self::VERTEX.bits | Self::FRAGMENT.bits; + const VERTEX_FRAGMENT = Self::VERTEX.bits() | Self::FRAGMENT.bits(); } } @@ -1774,6 +1776,7 @@ impl Default for MultisampleState { bitflags::bitflags! { /// Feature flags for a texture format. #[repr(transparent)] + #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] pub struct TextureFormatFeatureFlags: u32 { /// If not present, the texture can't be sampled with a filtering sampler. /// This may overwrite TextureSampleType::Float.filterable @@ -3631,6 +3634,7 @@ bitflags::bitflags! { /// Corresponds to [WebGPU `GPUColorWriteFlags`]( /// https://gpuweb.github.io/gpuweb/#typedefdef-gpucolorwriteflags). #[repr(transparent)] + #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] pub struct ColorWrites: u32 { /// Enable red channel writes const RED = 1 << 0; @@ -3641,9 +3645,9 @@ bitflags::bitflags! { /// Enable alpha channel writes const ALPHA = 1 << 3; /// Enable red, green, and blue channel writes - const COLOR = Self::RED.bits | Self::GREEN.bits | Self::BLUE.bits; + const COLOR = Self::RED.bits() | Self::GREEN.bits() | Self::BLUE.bits(); /// Enable writes to all channels. - const ALL = Self::RED.bits | Self::GREEN.bits | Self::BLUE.bits | Self::ALPHA.bits; + const ALL = Self::RED.bits() | Self::GREEN.bits() | Self::BLUE.bits() | Self::ALPHA.bits(); } } @@ -4191,6 +4195,7 @@ bitflags::bitflags! { /// Corresponds to [WebGPU `GPUBufferUsageFlags`]( /// https://gpuweb.github.io/gpuweb/#typedefdef-gpubufferusageflags). #[repr(transparent)] + #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] pub struct BufferUsages: u32 { /// Allow a buffer to be mapped for reading using [`Buffer::map_async`] + [`Buffer::get_mapped_range`]. /// This does not include creating a buffer with [`BufferDescriptor::mapped_at_creation`] set. @@ -4411,6 +4416,7 @@ bitflags::bitflags! { /// Corresponds to [WebGPU `GPUTextureUsageFlags`]( /// https://gpuweb.github.io/gpuweb/#typedefdef-gputextureusageflags). #[repr(transparent)] + #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] pub struct TextureUsages: u32 { /// Allows a texture to be the source in a [`CommandEncoder::copy_texture_to_buffer`] or /// [`CommandEncoder::copy_texture_to_texture`] operation. @@ -5992,6 +5998,7 @@ bitflags::bitflags! { /// the first 8 bytes being the primitive out value, the last 8 /// bytes being the compute shader invocation count. #[repr(transparent)] + #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] pub struct PipelineStatisticsTypes : u8 { /// Amount of times the vertex shader is ran. Accounts for /// the vertex cache when doing indexed rendering. diff --git a/wgpu/tests/buffer_usages.rs b/wgpu/tests/buffer_usages.rs index 7eb3f0e83..350f3a04a 100644 --- a/wgpu/tests/buffer_usages.rs +++ b/wgpu/tests/buffer_usages.rs @@ -52,7 +52,7 @@ fn buffer_usage() { Bu::MAP_WRITE | Bu::COPY_SRC | Bu::STORAGE, Bu::all(), ]; - let invalid_bits = unsafe { Bu::from_bits_unchecked(0b1111111111111) }; + let invalid_bits = Bu::from_bits_retain(0b1111111111111); let always_fail = &[Bu::empty(), invalid_bits]; try_create( diff --git a/wgpu/tests/common/mod.rs b/wgpu/tests/common/mod.rs index 319f60f7d..e50a9bdfa 100644 --- a/wgpu/tests/common/mod.rs +++ b/wgpu/tests/common/mod.rs @@ -79,6 +79,7 @@ impl Default for TestParameters { } bitflags::bitflags! { + #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] pub struct FailureReasons: u8 { const BACKEND = 1 << 0; const VENDOR = 1 << 1;