Skip to content

Commit

Permalink
Allow mip maps for non power of two textures
Browse files Browse the repository at this point in the history
  • Loading branch information
asny committed Feb 15, 2024
1 parent 850af2f commit 1654588
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/core/texture.rs
Original file line number Diff line number Diff line change
Expand Up @@ -355,12 +355,10 @@ fn calculate_number_of_mip_maps(
height: u32,
depth: Option<u32>,
) -> u32 {
if mip_map_filter.is_some()
&& width == height
&& depth.map(|d| d == width).unwrap_or(true)
&& width.is_power_of_two()
{
(width as f64).log2() as u32 + 1
if mip_map_filter.is_some() {
let max_size = width.max(height).max(depth.unwrap_or(0));
let power_of_two = max_size.next_power_of_two();
(power_of_two as f64).log2() as u32
} else {
1
}
Expand Down

0 comments on commit 1654588

Please sign in to comment.