From ce573f52eaa8e0fbc2cc7c8ccf4dae3385026a9b Mon Sep 17 00:00:00 2001 From: galister <22305755+galister@users.noreply.github.com> Date: Thu, 22 Feb 2024 00:32:10 +0100 Subject: [PATCH] fix alpha, remove sound for dbus toasts --- src/backend/notifications.rs | 4 +-- src/backend/openvr/mod.rs | 3 -- src/backend/openxr/swapchain.rs | 2 ++ src/graphics.rs | 57 ++++++++++++++++++++++++++------- src/gui/mod.rs | 7 +++- src/overlays/screen.rs | 3 +- 6 files changed, 58 insertions(+), 18 deletions(-) diff --git a/src/backend/notifications.rs b/src/backend/notifications.rs index b2320c7..8e0b956 100644 --- a/src/backend/notifications.rs +++ b/src/backend/notifications.rs @@ -158,7 +158,7 @@ impl NotificationManager { let toast = Toast::new(msg.title, msg.content.unwrap_or_else(|| "".into())) .with_timeout(msg.timeout.unwrap_or(5.)) - .with_sound(msg.volume.unwrap_or(0.) > 0.1); + .with_sound(msg.volume.unwrap_or(-1.) >= 0.); // XSOverlay still plays at 0, match sender.try_send(toast) { Ok(_) => {} @@ -187,9 +187,9 @@ fn parse_dbus(msg: &dbus::Message) -> anyhow::Result { }; Ok(Toast::new(title.into(), body.into()) - .with_sound(true) .with_timeout(5.0) .with_opacity(1.0)) + // leave the audio part to the desktop env } #[allow(non_snake_case)] diff --git a/src/backend/openvr/mod.rs b/src/backend/openvr/mod.rs index 2f94e8f..3a3ffcf 100644 --- a/src/backend/openvr/mod.rs +++ b/src/backend/openvr/mod.rs @@ -173,8 +173,6 @@ pub fn openvr_run(running: Arc) -> Result<(), BackendError> { continue; }; - log::info!("Creating overlay: {}", state.name); - overlays.add(OverlayData { state, backend, @@ -183,7 +181,6 @@ pub fn openvr_run(running: Arc) -> Result<(), BackendError> { } TaskType::DropOverlay(sel) => { if let Some(o) = overlays.mut_by_selector(&sel) { - log::info!("Dropping overlay: {}", o.state.name); o.destroy(&mut overlay_mngr); overlays.drop_by_selector(&sel); } diff --git a/src/backend/openxr/swapchain.rs b/src/backend/openxr/swapchain.rs index 0ae1792..65bd89e 100644 --- a/src/backend/openxr/swapchain.rs +++ b/src/backend/openxr/swapchain.rs @@ -7,6 +7,7 @@ use openxr as xr; use smallvec::SmallVec; use vulkano::{ image::{sampler::Filter, sys::RawImage, view::ImageView, ImageCreateInfo, ImageUsage}, + pipeline::graphics::color_blend::AttachmentBlend, Handle, }; @@ -38,6 +39,7 @@ pub(super) fn create_swapchain_render_data( shaders.get("vert_common").unwrap().clone(), // want panic shaders.get("frag_srgb").unwrap().clone(), // want panic graphics.native_format, + Some(AttachmentBlend::alpha()), )?; let images = swapchain diff --git a/src/graphics.rs b/src/graphics.rs index 01dee16..0a47629 100644 --- a/src/graphics.rs +++ b/src/graphics.rs @@ -19,27 +19,34 @@ use vulkano::{ #[cfg(feature = "openxr")] use {ash::vk, std::os::raw::c_void, vulkano::swapchain::Surface}; +pub const BLEND_ALPHA: AttachmentBlend = AttachmentBlend { + src_color_blend_factor: BlendFactor::SrcAlpha, + dst_color_blend_factor: BlendFactor::OneMinusSrcAlpha, + color_blend_op: BlendOp::Add, + src_alpha_blend_factor: BlendFactor::One, + dst_alpha_blend_factor: BlendFactor::One, + alpha_blend_op: BlendOp::Max, +}; + use vulkano::{ buffer::{ allocator::{SubbufferAllocator, SubbufferAllocatorCreateInfo}, Buffer, BufferContents, BufferCreateInfo, BufferUsage, Subbuffer, }, - command_buffer::CommandBufferInheritanceRenderingInfo, command_buffer::{ allocator::{StandardCommandBufferAllocator, StandardCommandBufferAllocatorCreateInfo}, sys::{CommandBufferBeginInfo, RawRecordingCommandBuffer}, CommandBuffer, CommandBufferExecFuture, CommandBufferInheritanceInfo, CommandBufferInheritanceRenderPassInfo, CommandBufferInheritanceRenderPassType, - CommandBufferLevel, CommandBufferUsage, CopyBufferToImageInfo, RecordingCommandBuffer, - RenderPassBeginInfo, RenderingAttachmentInfo, RenderingInfo, SubpassBeginInfo, - SubpassContents, SubpassEndInfo, + CommandBufferInheritanceRenderingInfo, CommandBufferLevel, CommandBufferUsage, + CopyBufferToImageInfo, RecordingCommandBuffer, RenderPassBeginInfo, + RenderingAttachmentInfo, RenderingInfo, SubpassBeginInfo, SubpassContents, SubpassEndInfo, }, descriptor_set::{ allocator::StandardDescriptorSetAllocator, DescriptorSet, WriteDescriptorSet, }, - device::Features, device::{ - physical::PhysicalDevice, Device, DeviceCreateInfo, DeviceExtensions, Queue, + physical::PhysicalDevice, Device, DeviceCreateInfo, DeviceExtensions, Features, Queue, QueueCreateInfo, QueueFlags, }, format::Format, @@ -61,7 +68,9 @@ use vulkano::{ }, pipeline::{ graphics::{ - color_blend::{AttachmentBlend, ColorBlendAttachmentState, ColorBlendState}, + color_blend::{ + AttachmentBlend, BlendFactor, BlendOp, ColorBlendAttachmentState, ColorBlendState, + }, input_assembly::InputAssemblyState, multisample::MultisampleState, rasterization::RasterizationState, @@ -699,6 +708,7 @@ impl WlxGraphics { vert: Arc, frag: Arc, format: Format, + blend: Option, ) -> anyhow::Result>> { Ok(Arc::new(WlxPipeline::::new( render_target, @@ -706,6 +716,7 @@ impl WlxGraphics { vert, frag, format, + blend, )?)) } @@ -715,6 +726,7 @@ impl WlxGraphics { vert: Arc, frag: Arc, format: Format, + blend: Option, initial_layout: ImageLayout, final_layout: ImageLayout, ) -> anyhow::Result>> { @@ -724,6 +736,7 @@ impl WlxGraphics { vert, frag, format, + blend, initial_layout, final_layout, )?)) @@ -735,12 +748,14 @@ impl WlxGraphics { vert: Arc, frag: Arc, format: Format, + blend: Option, ) -> anyhow::Result>> { Ok(Arc::new(WlxPipeline::::new( self.clone(), vert, frag, format, + blend, )?)) } @@ -978,6 +993,7 @@ impl WlxPipeline { vert: Arc, frag: Arc, format: Format, + blend: Option, ) -> anyhow::Result { let vep = vert.entry_point("main").unwrap(); // want panic let fep = frag.entry_point("main").unwrap(); // want panic @@ -1012,7 +1028,7 @@ impl WlxPipeline { multisample_state: Some(MultisampleState::default()), color_blend_state: Some(ColorBlendState { attachments: vec![ColorBlendAttachmentState { - blend: Some(AttachmentBlend::alpha()), + blend, ..Default::default() }], ..Default::default() @@ -1054,6 +1070,7 @@ impl WlxPipeline { vert: Arc, frag: Arc, format: Format, + blend: Option, ) -> anyhow::Result { let render_pass = vulkano::single_pass_renderpass!( graphics.device.clone(), @@ -1071,7 +1088,15 @@ impl WlxPipeline { }, )?; - Self::new_from_pass(render_target, render_pass, graphics, vert, frag, format) + Self::new_from_pass( + render_target, + render_pass, + graphics, + vert, + frag, + format, + blend, + ) } fn new_with_layout( @@ -1080,6 +1105,7 @@ impl WlxPipeline { vert: Arc, frag: Arc, format: Format, + blend: Option, initial_layout: ImageLayout, final_layout: ImageLayout, ) -> anyhow::Result { @@ -1106,7 +1132,15 @@ impl WlxPipeline { let render_pass = RenderPass::new(graphics.device.clone(), render_pass_description)?; - Self::new_from_pass(render_target, render_pass, graphics, vert, frag, format) + Self::new_from_pass( + render_target, + render_pass, + graphics, + vert, + frag, + format, + blend, + ) } fn new_from_pass( @@ -1116,6 +1150,7 @@ impl WlxPipeline { vert: Arc, frag: Arc, format: Format, + blend: Option, ) -> anyhow::Result { let vep = vert.entry_point("main").unwrap(); // want panic let fep = frag.entry_point("main").unwrap(); // want panic @@ -1151,7 +1186,7 @@ impl WlxPipeline { viewport_state: Some(ViewportState::default()), color_blend_state: Some(ColorBlendState { attachments: vec![ColorBlendAttachmentState { - blend: Some(AttachmentBlend::alpha()), + blend, ..Default::default() }], ..Default::default() diff --git a/src/gui/mod.rs b/src/gui/mod.rs index 329559f..ff9601f 100644 --- a/src/gui/mod.rs +++ b/src/gui/mod.rs @@ -13,7 +13,9 @@ use crate::{ input::{Haptics, InteractionHandler, PointerHit, PointerMode}, overlay::{OverlayBackend, OverlayRenderer}, }, - graphics::{WlxCommandBuffer, WlxGraphics, WlxPass, WlxPipeline, WlxPipelineLegacy}, + graphics::{ + WlxCommandBuffer, WlxGraphics, WlxPass, WlxPipeline, WlxPipelineLegacy, BLEND_ALPHA, + }, state::AppState, }; @@ -243,6 +245,7 @@ impl Canvas { shaders.get("vert_common").unwrap().clone(), // want panic shaders.get("frag_color").unwrap().clone(), // want panic format, + Some(BLEND_ALPHA), )?; let pipeline_fg_glyph = graphics.create_pipeline( @@ -250,6 +253,7 @@ impl Canvas { shaders.get("vert_common").unwrap().clone(), // want panic shaders.get("frag_glyph").unwrap().clone(), // want panic format, + Some(BLEND_ALPHA), )?; let vertex_buffer = @@ -260,6 +264,7 @@ impl Canvas { shaders.get("vert_common").unwrap().clone(), // want panic shaders.get("frag_sprite").unwrap().clone(), // want panic format, + Some(BLEND_ALPHA), ImageLayout::TransferSrcOptimal, ImageLayout::TransferSrcOptimal, )?; diff --git a/src/overlays/screen.rs b/src/overlays/screen.rs index b489df1..61d88a3 100644 --- a/src/overlays/screen.rs +++ b/src/overlays/screen.rs @@ -43,7 +43,7 @@ use crate::{ overlay::{OverlayData, OverlayRenderer, OverlayState, SplitOverlayBackend}, }, config::def_pw_tokens, - graphics::{fourcc_to_vk, WlxCommandBuffer, WlxPipeline, WlxPipelineLegacy}, + graphics::{fourcc_to_vk, WlxCommandBuffer, WlxPipeline, WlxPipelineLegacy, BLEND_ALPHA}, hid::{MOUSE_LEFT, MOUSE_MIDDLE, MOUSE_RIGHT}, state::{AppSession, AppState}, }; @@ -152,6 +152,7 @@ impl ScreenPipeline { shaders.get("vert_common").unwrap().clone(), // want panic shaders.get("frag_sprite").unwrap().clone(), // want panic app.graphics.native_format, + Some(BLEND_ALPHA), )?; let extentf = [extent[0] as f32, extent[1] as f32];