From 1654588d3cf2f06d6ecf60c9a8f1141a85a92522 Mon Sep 17 00:00:00 2001 From: Asger Nyman Christiansen Date: Thu, 15 Feb 2024 12:06:57 +0100 Subject: [PATCH] Allow mip maps for non power of two textures --- src/core/texture.rs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/core/texture.rs b/src/core/texture.rs index dd0c2b7d..2f0c8379 100644 --- a/src/core/texture.rs +++ b/src/core/texture.rs @@ -355,12 +355,10 @@ fn calculate_number_of_mip_maps( height: u32, depth: Option, ) -> 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 }