diff --git a/code_markup/src/colors.rs b/code_markup/src/colors.rs index b2c4c8a298..bf64fd7b95 100644 --- a/code_markup/src/colors.rs +++ b/code_markup/src/colors.rs @@ -1,4 +1,4 @@ -use palette::{FromColor, Hsv, Srgb}; +use palette::{FromColor, Hsv, LinSrgb, Srgb}; pub type RgbaTup = (f32, f32, f32, f32); pub const WHITE: RgbaTup = (1.0, 1.0, 1.0, 1.0); @@ -12,11 +12,11 @@ pub fn from_hsb(hue: usize, saturation: usize, brightness: usize) -> RgbaTup { } pub fn from_hsba(hue: usize, saturation: usize, brightness: usize, alpha: f32) -> RgbaTup { - let rgb = Srgb::from_color(Hsv::new( + let rgb = LinSrgb::from(Srgb::from_color(Hsv::new( hue as f32, (saturation as f32) / 100.0, (brightness as f32) / 100.0, - )); + ))); (rgb.red, rgb.green, rgb.blue, alpha) } diff --git a/editor/src/editor/main.rs b/editor/src/editor/main.rs index 5dbfac12f7..cac5843445 100644 --- a/editor/src/editor/main.rs +++ b/editor/src/editor/main.rs @@ -74,7 +74,7 @@ fn run_event_loop(project_dir_path_opt: Option<&Path>) -> Result<(), Box) -> Result<(), Box) -> Result<(), Box) -> Result<(), Box Result<(wgpu::Device, wgpu::Queue), wgpu::RequestDeviceError> { +) -> Result<(wgpu::Device, wgpu::Queue, wgpu::TextureFormat), wgpu::RequestDeviceError> { if force_fallback_adapter { log::error!("Falling back to software renderer. GPU acceleration has been disabled."); } @@ -418,7 +416,13 @@ async fn create_device( If you're running this from inside nix, follow the instructions here to resolve this: https://github.com/rtfeldman/roc/blob/trunk/BUILDING_FROM_SOURCE.md#editor "#); - adapter + let color_format = surface.get_preferred_format(&adapter).unwrap(); + + if color_format != wgpu::TextureFormat::Bgra8UnormSrgb { + log::warn!("Your preferred TextureFormat {:?} is different than expected. Colors may look different, please report this issue on github and tag @Anton-4.", color_format); + } + + let request_res = adapter .request_device( &wgpu::DeviceDescriptor { label: None, @@ -427,7 +431,12 @@ async fn create_device( }, None, ) - .await + .await; + + match request_res { + Ok((device, queue)) => Ok((device, queue, color_format)), + Err(err) => Err(err), + } } fn draw_rects( diff --git a/editor/src/graphics/colors.rs b/editor/src/graphics/colors.rs index 924c9ab301..67dc2801a8 100644 --- a/editor/src/graphics/colors.rs +++ b/editor/src/graphics/colors.rs @@ -1,4 +1,4 @@ -use palette::{FromColor, Hsv, Srgb}; +use palette::{FromColor, Hsv, LinSrgb, Srgb}; pub type RgbaTup = (f32, f32, f32, f32); pub const WHITE: RgbaTup = (1.0, 1.0, 1.0, 1.0); @@ -21,11 +21,11 @@ pub fn from_hsb(hue: usize, saturation: usize, brightness: usize) -> RgbaTup { } pub fn from_hsba(hue: usize, saturation: usize, brightness: usize, alpha: f32) -> RgbaTup { - let rgb = Srgb::from_color(Hsv::new( + let rgb = LinSrgb::from(Srgb::from_color(Hsv::new( hue as f32, (saturation as f32) / 100.0, (brightness as f32) / 100.0, - )); + ))); (rgb.red, rgb.green, rgb.blue, alpha) }