fix alpha, remove sound for dbus toasts

This commit is contained in:
galister
2024-02-22 00:32:10 +01:00
parent 4f99862108
commit ce573f52ea
6 changed files with 58 additions and 18 deletions

View File

@@ -158,7 +158,7 @@ impl NotificationManager {
let toast = Toast::new(msg.title, msg.content.unwrap_or_else(|| "".into())) let toast = Toast::new(msg.title, msg.content.unwrap_or_else(|| "".into()))
.with_timeout(msg.timeout.unwrap_or(5.)) .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) { match sender.try_send(toast) {
Ok(_) => {} Ok(_) => {}
@@ -187,9 +187,9 @@ fn parse_dbus(msg: &dbus::Message) -> anyhow::Result<Toast> {
}; };
Ok(Toast::new(title.into(), body.into()) Ok(Toast::new(title.into(), body.into())
.with_sound(true)
.with_timeout(5.0) .with_timeout(5.0)
.with_opacity(1.0)) .with_opacity(1.0))
// leave the audio part to the desktop env
} }
#[allow(non_snake_case)] #[allow(non_snake_case)]

View File

@@ -173,8 +173,6 @@ pub fn openvr_run(running: Arc<AtomicBool>) -> Result<(), BackendError> {
continue; continue;
}; };
log::info!("Creating overlay: {}", state.name);
overlays.add(OverlayData { overlays.add(OverlayData {
state, state,
backend, backend,
@@ -183,7 +181,6 @@ pub fn openvr_run(running: Arc<AtomicBool>) -> Result<(), BackendError> {
} }
TaskType::DropOverlay(sel) => { TaskType::DropOverlay(sel) => {
if let Some(o) = overlays.mut_by_selector(&sel) { if let Some(o) = overlays.mut_by_selector(&sel) {
log::info!("Dropping overlay: {}", o.state.name);
o.destroy(&mut overlay_mngr); o.destroy(&mut overlay_mngr);
overlays.drop_by_selector(&sel); overlays.drop_by_selector(&sel);
} }

View File

@@ -7,6 +7,7 @@ use openxr as xr;
use smallvec::SmallVec; use smallvec::SmallVec;
use vulkano::{ use vulkano::{
image::{sampler::Filter, sys::RawImage, view::ImageView, ImageCreateInfo, ImageUsage}, image::{sampler::Filter, sys::RawImage, view::ImageView, ImageCreateInfo, ImageUsage},
pipeline::graphics::color_blend::AttachmentBlend,
Handle, Handle,
}; };
@@ -38,6 +39,7 @@ pub(super) fn create_swapchain_render_data(
shaders.get("vert_common").unwrap().clone(), // want panic shaders.get("vert_common").unwrap().clone(), // want panic
shaders.get("frag_srgb").unwrap().clone(), // want panic shaders.get("frag_srgb").unwrap().clone(), // want panic
graphics.native_format, graphics.native_format,
Some(AttachmentBlend::alpha()),
)?; )?;
let images = swapchain let images = swapchain

View File

@@ -19,27 +19,34 @@ use vulkano::{
#[cfg(feature = "openxr")] #[cfg(feature = "openxr")]
use {ash::vk, std::os::raw::c_void, vulkano::swapchain::Surface}; 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::{ use vulkano::{
buffer::{ buffer::{
allocator::{SubbufferAllocator, SubbufferAllocatorCreateInfo}, allocator::{SubbufferAllocator, SubbufferAllocatorCreateInfo},
Buffer, BufferContents, BufferCreateInfo, BufferUsage, Subbuffer, Buffer, BufferContents, BufferCreateInfo, BufferUsage, Subbuffer,
}, },
command_buffer::CommandBufferInheritanceRenderingInfo,
command_buffer::{ command_buffer::{
allocator::{StandardCommandBufferAllocator, StandardCommandBufferAllocatorCreateInfo}, allocator::{StandardCommandBufferAllocator, StandardCommandBufferAllocatorCreateInfo},
sys::{CommandBufferBeginInfo, RawRecordingCommandBuffer}, sys::{CommandBufferBeginInfo, RawRecordingCommandBuffer},
CommandBuffer, CommandBufferExecFuture, CommandBufferInheritanceInfo, CommandBuffer, CommandBufferExecFuture, CommandBufferInheritanceInfo,
CommandBufferInheritanceRenderPassInfo, CommandBufferInheritanceRenderPassType, CommandBufferInheritanceRenderPassInfo, CommandBufferInheritanceRenderPassType,
CommandBufferLevel, CommandBufferUsage, CopyBufferToImageInfo, RecordingCommandBuffer, CommandBufferInheritanceRenderingInfo, CommandBufferLevel, CommandBufferUsage,
RenderPassBeginInfo, RenderingAttachmentInfo, RenderingInfo, SubpassBeginInfo, CopyBufferToImageInfo, RecordingCommandBuffer, RenderPassBeginInfo,
SubpassContents, SubpassEndInfo, RenderingAttachmentInfo, RenderingInfo, SubpassBeginInfo, SubpassContents, SubpassEndInfo,
}, },
descriptor_set::{ descriptor_set::{
allocator::StandardDescriptorSetAllocator, DescriptorSet, WriteDescriptorSet, allocator::StandardDescriptorSetAllocator, DescriptorSet, WriteDescriptorSet,
}, },
device::Features,
device::{ device::{
physical::PhysicalDevice, Device, DeviceCreateInfo, DeviceExtensions, Queue, physical::PhysicalDevice, Device, DeviceCreateInfo, DeviceExtensions, Features, Queue,
QueueCreateInfo, QueueFlags, QueueCreateInfo, QueueFlags,
}, },
format::Format, format::Format,
@@ -61,7 +68,9 @@ use vulkano::{
}, },
pipeline::{ pipeline::{
graphics::{ graphics::{
color_blend::{AttachmentBlend, ColorBlendAttachmentState, ColorBlendState}, color_blend::{
AttachmentBlend, BlendFactor, BlendOp, ColorBlendAttachmentState, ColorBlendState,
},
input_assembly::InputAssemblyState, input_assembly::InputAssemblyState,
multisample::MultisampleState, multisample::MultisampleState,
rasterization::RasterizationState, rasterization::RasterizationState,
@@ -699,6 +708,7 @@ impl WlxGraphics {
vert: Arc<ShaderModule>, vert: Arc<ShaderModule>,
frag: Arc<ShaderModule>, frag: Arc<ShaderModule>,
format: Format, format: Format,
blend: Option<AttachmentBlend>,
) -> anyhow::Result<Arc<WlxPipeline<WlxPipelineLegacy>>> { ) -> anyhow::Result<Arc<WlxPipeline<WlxPipelineLegacy>>> {
Ok(Arc::new(WlxPipeline::<WlxPipelineLegacy>::new( Ok(Arc::new(WlxPipeline::<WlxPipelineLegacy>::new(
render_target, render_target,
@@ -706,6 +716,7 @@ impl WlxGraphics {
vert, vert,
frag, frag,
format, format,
blend,
)?)) )?))
} }
@@ -715,6 +726,7 @@ impl WlxGraphics {
vert: Arc<ShaderModule>, vert: Arc<ShaderModule>,
frag: Arc<ShaderModule>, frag: Arc<ShaderModule>,
format: Format, format: Format,
blend: Option<AttachmentBlend>,
initial_layout: ImageLayout, initial_layout: ImageLayout,
final_layout: ImageLayout, final_layout: ImageLayout,
) -> anyhow::Result<Arc<WlxPipeline<WlxPipelineLegacy>>> { ) -> anyhow::Result<Arc<WlxPipeline<WlxPipelineLegacy>>> {
@@ -724,6 +736,7 @@ impl WlxGraphics {
vert, vert,
frag, frag,
format, format,
blend,
initial_layout, initial_layout,
final_layout, final_layout,
)?)) )?))
@@ -735,12 +748,14 @@ impl WlxGraphics {
vert: Arc<ShaderModule>, vert: Arc<ShaderModule>,
frag: Arc<ShaderModule>, frag: Arc<ShaderModule>,
format: Format, format: Format,
blend: Option<AttachmentBlend>,
) -> anyhow::Result<Arc<WlxPipeline<WlxPipelineDynamic>>> { ) -> anyhow::Result<Arc<WlxPipeline<WlxPipelineDynamic>>> {
Ok(Arc::new(WlxPipeline::<WlxPipelineDynamic>::new( Ok(Arc::new(WlxPipeline::<WlxPipelineDynamic>::new(
self.clone(), self.clone(),
vert, vert,
frag, frag,
format, format,
blend,
)?)) )?))
} }
@@ -978,6 +993,7 @@ impl WlxPipeline<WlxPipelineDynamic> {
vert: Arc<ShaderModule>, vert: Arc<ShaderModule>,
frag: Arc<ShaderModule>, frag: Arc<ShaderModule>,
format: Format, format: Format,
blend: Option<AttachmentBlend>,
) -> anyhow::Result<Self> { ) -> anyhow::Result<Self> {
let vep = vert.entry_point("main").unwrap(); // want panic let vep = vert.entry_point("main").unwrap(); // want panic
let fep = frag.entry_point("main").unwrap(); // want panic let fep = frag.entry_point("main").unwrap(); // want panic
@@ -1012,7 +1028,7 @@ impl WlxPipeline<WlxPipelineDynamic> {
multisample_state: Some(MultisampleState::default()), multisample_state: Some(MultisampleState::default()),
color_blend_state: Some(ColorBlendState { color_blend_state: Some(ColorBlendState {
attachments: vec![ColorBlendAttachmentState { attachments: vec![ColorBlendAttachmentState {
blend: Some(AttachmentBlend::alpha()), blend,
..Default::default() ..Default::default()
}], }],
..Default::default() ..Default::default()
@@ -1054,6 +1070,7 @@ impl WlxPipeline<WlxPipelineLegacy> {
vert: Arc<ShaderModule>, vert: Arc<ShaderModule>,
frag: Arc<ShaderModule>, frag: Arc<ShaderModule>,
format: Format, format: Format,
blend: Option<AttachmentBlend>,
) -> anyhow::Result<Self> { ) -> anyhow::Result<Self> {
let render_pass = vulkano::single_pass_renderpass!( let render_pass = vulkano::single_pass_renderpass!(
graphics.device.clone(), graphics.device.clone(),
@@ -1071,7 +1088,15 @@ impl WlxPipeline<WlxPipelineLegacy> {
}, },
)?; )?;
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( fn new_with_layout(
@@ -1080,6 +1105,7 @@ impl WlxPipeline<WlxPipelineLegacy> {
vert: Arc<ShaderModule>, vert: Arc<ShaderModule>,
frag: Arc<ShaderModule>, frag: Arc<ShaderModule>,
format: Format, format: Format,
blend: Option<AttachmentBlend>,
initial_layout: ImageLayout, initial_layout: ImageLayout,
final_layout: ImageLayout, final_layout: ImageLayout,
) -> anyhow::Result<Self> { ) -> anyhow::Result<Self> {
@@ -1106,7 +1132,15 @@ impl WlxPipeline<WlxPipelineLegacy> {
let render_pass = RenderPass::new(graphics.device.clone(), render_pass_description)?; 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( fn new_from_pass(
@@ -1116,6 +1150,7 @@ impl WlxPipeline<WlxPipelineLegacy> {
vert: Arc<ShaderModule>, vert: Arc<ShaderModule>,
frag: Arc<ShaderModule>, frag: Arc<ShaderModule>,
format: Format, format: Format,
blend: Option<AttachmentBlend>,
) -> anyhow::Result<Self> { ) -> anyhow::Result<Self> {
let vep = vert.entry_point("main").unwrap(); // want panic let vep = vert.entry_point("main").unwrap(); // want panic
let fep = frag.entry_point("main").unwrap(); // want panic let fep = frag.entry_point("main").unwrap(); // want panic
@@ -1151,7 +1186,7 @@ impl WlxPipeline<WlxPipelineLegacy> {
viewport_state: Some(ViewportState::default()), viewport_state: Some(ViewportState::default()),
color_blend_state: Some(ColorBlendState { color_blend_state: Some(ColorBlendState {
attachments: vec![ColorBlendAttachmentState { attachments: vec![ColorBlendAttachmentState {
blend: Some(AttachmentBlend::alpha()), blend,
..Default::default() ..Default::default()
}], }],
..Default::default() ..Default::default()

View File

@@ -13,7 +13,9 @@ use crate::{
input::{Haptics, InteractionHandler, PointerHit, PointerMode}, input::{Haptics, InteractionHandler, PointerHit, PointerMode},
overlay::{OverlayBackend, OverlayRenderer}, overlay::{OverlayBackend, OverlayRenderer},
}, },
graphics::{WlxCommandBuffer, WlxGraphics, WlxPass, WlxPipeline, WlxPipelineLegacy}, graphics::{
WlxCommandBuffer, WlxGraphics, WlxPass, WlxPipeline, WlxPipelineLegacy, BLEND_ALPHA,
},
state::AppState, state::AppState,
}; };
@@ -243,6 +245,7 @@ impl<D, S> Canvas<D, S> {
shaders.get("vert_common").unwrap().clone(), // want panic shaders.get("vert_common").unwrap().clone(), // want panic
shaders.get("frag_color").unwrap().clone(), // want panic shaders.get("frag_color").unwrap().clone(), // want panic
format, format,
Some(BLEND_ALPHA),
)?; )?;
let pipeline_fg_glyph = graphics.create_pipeline( let pipeline_fg_glyph = graphics.create_pipeline(
@@ -250,6 +253,7 @@ impl<D, S> Canvas<D, S> {
shaders.get("vert_common").unwrap().clone(), // want panic shaders.get("vert_common").unwrap().clone(), // want panic
shaders.get("frag_glyph").unwrap().clone(), // want panic shaders.get("frag_glyph").unwrap().clone(), // want panic
format, format,
Some(BLEND_ALPHA),
)?; )?;
let vertex_buffer = let vertex_buffer =
@@ -260,6 +264,7 @@ impl<D, S> Canvas<D, S> {
shaders.get("vert_common").unwrap().clone(), // want panic shaders.get("vert_common").unwrap().clone(), // want panic
shaders.get("frag_sprite").unwrap().clone(), // want panic shaders.get("frag_sprite").unwrap().clone(), // want panic
format, format,
Some(BLEND_ALPHA),
ImageLayout::TransferSrcOptimal, ImageLayout::TransferSrcOptimal,
ImageLayout::TransferSrcOptimal, ImageLayout::TransferSrcOptimal,
)?; )?;

View File

@@ -43,7 +43,7 @@ use crate::{
overlay::{OverlayData, OverlayRenderer, OverlayState, SplitOverlayBackend}, overlay::{OverlayData, OverlayRenderer, OverlayState, SplitOverlayBackend},
}, },
config::def_pw_tokens, 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}, hid::{MOUSE_LEFT, MOUSE_MIDDLE, MOUSE_RIGHT},
state::{AppSession, AppState}, state::{AppSession, AppState},
}; };
@@ -152,6 +152,7 @@ impl ScreenPipeline {
shaders.get("vert_common").unwrap().clone(), // want panic shaders.get("vert_common").unwrap().clone(), // want panic
shaders.get("frag_sprite").unwrap().clone(), // want panic shaders.get("frag_sprite").unwrap().clone(), // want panic
app.graphics.native_format, app.graphics.native_format,
Some(BLEND_ALPHA),
)?; )?;
let extentf = [extent[0] as f32, extent[1] as f32]; let extentf = [extent[0] as f32, extent[1] as f32];