mirror of
https://github.com/storytold/wgpu.git
synced 2026-11-19 14:01:08 +01:00
Add is_power_of_two function (#603)
This commit is contained in:
1 parent
72bc709bc0
commit
0fd809014d
1 file changed
+5
-6
@@ -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
|
||||
);
|
||||
|
||||
Reference in new issue
Block a user