Skip to content

Commit

Permalink
Use Bitflags Unknown Bit Check (#6967)
Browse files Browse the repository at this point in the history
  • Loading branch information
cwfitzgerald authored Jan 22, 2025
1 parent da3c15b commit 3dd925b
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions wgpu-core/src/device/resource.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ use crate::{
};

use arrayvec::ArrayVec;
use bitflags::Flags;
use smallvec::SmallVec;
use wgt::{
math::align_to, DeviceLostReason, TextureFormat, TextureSampleType, TextureViewDimension,
Expand Down Expand Up @@ -495,9 +496,7 @@ impl Device {
self.require_downlevel_flags(wgt::DownlevelFlags::UNRESTRICTED_INDEX_BUFFER)?;
}

if desc.usage.is_empty()
|| desc.usage | wgt::BufferUsages::all() != wgt::BufferUsages::all()
{
if desc.usage.is_empty() || desc.usage.contains_unknown_bits() {
return Err(resource::CreateBufferError::InvalidUsage(desc.usage));
}

Expand Down Expand Up @@ -731,9 +730,7 @@ impl Device {

self.check_is_valid()?;

if desc.usage.is_empty()
|| desc.usage | wgt::TextureUsages::all() != wgt::TextureUsages::all()
{
if desc.usage.is_empty() || desc.usage.contains_unknown_bits() {
return Err(CreateTextureError::InvalidUsage(desc.usage));
}

Expand Down Expand Up @@ -1848,7 +1845,7 @@ impl Device {
})?;
}

if entry.visibility | wgt::ShaderStages::all() != wgt::ShaderStages::all() {
if entry.visibility.contains_unknown_bits() {
return Err(
binding_model::CreateBindGroupLayoutError::InvalidVisibility(entry.visibility),
);
Expand Down Expand Up @@ -3077,7 +3074,7 @@ impl Device {
if let Some(cs) = cs.as_ref() {
target_specified = true;
let error = 'error: {
if cs.write_mask | wgt::ColorWrites::all() != wgt::ColorWrites::all() {
if cs.write_mask.contains_unknown_bits() {
break 'error Some(pipeline::ColorStateError::InvalidWriteMask(
cs.write_mask,
));
Expand Down

0 comments on commit 3dd925b

Please sign in to comment.