Skip to content

Commit 4191f5c

Browse files
committed
improve get_optimal_texture_sample_type
1 parent f54333e commit 4191f5c

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

sugarloaf/src/components/layer/atlas.rs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,22 @@ impl Atlas {
7272

7373
fn get_bytes_per_pixel(&self) -> u32 {
7474
match self.texture.format() {
75+
// 16-bit float formats (F16)
76+
wgpu::TextureFormat::R16Float => 2,
77+
wgpu::TextureFormat::Rg16Float => 4,
7578
wgpu::TextureFormat::Rgba16Float => 8,
79+
// 8-bit unorm formats
80+
wgpu::TextureFormat::R8Unorm => 1,
81+
wgpu::TextureFormat::Rg8Unorm => 2,
7682
wgpu::TextureFormat::Rgba8Unorm => 4,
77-
_ => 4,
83+
// Fallback for any unexpected format
84+
_ => {
85+
tracing::warn!(
86+
"Unexpected texture format in atlas: {:?}, assuming 4 bytes per pixel",
87+
self.texture.format()
88+
);
89+
4
90+
}
7891
}
7992
}
8093

0 commit comments

Comments
 (0)