diff --git a/wgpu-core/src/conv.rs b/wgpu-core/src/conv.rs index e4bfce1afd..9e9de04073 100644 --- a/wgpu-core/src/conv.rs +++ b/wgpu-core/src/conv.rs @@ -436,6 +436,10 @@ fn checked_u32_as_u16(value: u32) -> u16 { value as u16 } +fn is_power_of_two(val: u32) -> bool { + val != 0 && (val & (val - 1)) == 0 +} + pub fn map_texture_dimension_size( dimension: wgt::TextureDimension, Extent3d { @@ -458,12 +462,7 @@ pub fn map_texture_dimension_size( D2 => { assert_eq!(depth, 1); assert!( - sample_size == 1 - || sample_size == 2 - || sample_size == 4 - || sample_size == 8 - || sample_size == 16 - || sample_size == 32, + sample_size <= 32 && is_power_of_two(sample_size), "Invalid sample_count of {}", sample_size );