Skip to content

Commit

Permalink
fix(image cache): 🐛 fix loading errors & textures not being srgb
Browse files Browse the repository at this point in the history
  • Loading branch information
melody-rs committed Nov 30, 2023
1 parent e1deae2 commit 8036f50
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions crates/graphics/src/texture_loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ fn load_wgpu_texture_from_path(
dimension: wgpu::TextureDimension::D2,
mip_level_count: 1,
sample_count: 1,
format: wgpu::TextureFormat::Rgba8Unorm,
format: wgpu::TextureFormat::Rgba8UnormSrgb,
usage: wgpu::TextureUsages::COPY_SRC
| wgpu::TextureUsages::COPY_DST
| wgpu::TextureUsages::TEXTURE_BINDING,
Expand All @@ -92,7 +92,10 @@ fn load_wgpu_texture_from_path(
fn supported_uri_to_path(uri: &str) -> Option<&camino::Utf8Path> {
uri.strip_prefix(PROTOCOL)
.map(camino::Utf8Path::new)
.filter(|path| path.extension().filter(|&ext| ext != "svg").is_some())
.filter(|path| {
let extension = path.extension();
extension.is_some_and(|ext| ext != "svg") || extension.is_none()
})
}

impl Texture {
Expand Down

0 comments on commit 8036f50

Please sign in to comment.