Skip to content

Commit

Permalink
Log available formats and alpha modes in wgpu::window::compositor
Browse files Browse the repository at this point in the history
  • Loading branch information
hecrj committed Feb 9, 2024
1 parent 81bed94 commit 8a8c1ab
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
5 changes: 4 additions & 1 deletion examples/gradient/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,7 @@ edition = "2021"
publish = false

[dependencies]
iced = { path = "../.." }
iced.workspace = true
iced.features = ["debug"]

tracing-subscriber = "0.3"
2 changes: 2 additions & 0 deletions examples/gradient/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ use iced::{
};

pub fn main() -> iced::Result {
tracing_subscriber::fmt::init();

Gradient::run(Settings {
window: window::Settings {
transparent: true,
Expand Down
11 changes: 8 additions & 3 deletions wgpu/src/window/compositor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ impl Compositor {

let mut formats = capabilities.formats.iter().copied();

log::info!("Available formats: {formats:#?}");

let format = if color::GAMMA_CORRECTION {
formats.find(wgpu::TextureFormat::is_srgb)
} else {
Expand All @@ -80,12 +82,15 @@ impl Compositor {
capabilities.formats.first().copied()
});

let alphas = capabilities.alpha_modes;
let preferred_alpha = if alphas
let alpha_modes = capabilities.alpha_modes;

log::info!("Available alpha modes: {alpha_modes:#?}");

let preferred_alpha = if alpha_modes
.contains(&wgpu::CompositeAlphaMode::PostMultiplied)
{
wgpu::CompositeAlphaMode::PostMultiplied
} else if alphas
} else if alpha_modes
.contains(&wgpu::CompositeAlphaMode::PreMultiplied)
{
wgpu::CompositeAlphaMode::PreMultiplied
Expand Down

0 comments on commit 8a8c1ab

Please sign in to comment.