mirror of
https://github.com/gfx-rs/wgpu.git
synced 2026-04-22 03:02:01 -04:00
Add is_power_of_two function (#603)
This commit is contained in:
committed by
Dzmitry Malyshau
parent
11a321131f
commit
b71bcc5349
@@ -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