pipewire: better desktop compatibility (Niri)
This commit is contained in:
640
Cargo.lock
generated
640
Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
@@ -53,7 +53,7 @@ sysinfo = { version = "0.30.0", optional = true }
|
|||||||
thiserror = "1.0.56"
|
thiserror = "1.0.56"
|
||||||
vulkano = { git = "https://github.com/vulkano-rs/vulkano", rev = "94f50f1" }
|
vulkano = { git = "https://github.com/vulkano-rs/vulkano", rev = "94f50f1" }
|
||||||
vulkano-shaders = { git = "https://github.com/vulkano-rs/vulkano", rev = "94f50f1" }
|
vulkano-shaders = { git = "https://github.com/vulkano-rs/vulkano", rev = "94f50f1" }
|
||||||
wlx-capture = { git = "https://github.com/galister/wlx-capture", tag = "v0.3.8", default-features = false }
|
wlx-capture = { git = "https://github.com/galister/wlx-capture", tag = "v0.3.9", default-features = false }
|
||||||
winit = { version = "0.29.15", optional = true }
|
winit = { version = "0.29.15", optional = true }
|
||||||
xdg = "2.5.2"
|
xdg = "2.5.2"
|
||||||
log-panics = { version = "2.1.0", features = ["with-backtrace"] }
|
log-panics = { version = "2.1.0", features = ["with-backtrace"] }
|
||||||
|
|||||||
@@ -92,10 +92,12 @@ use vulkano::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
use wlx_capture::frame::{
|
use wlx_capture::frame::{
|
||||||
DmabufFrame, FourCC, DRM_FORMAT_ABGR8888, DRM_FORMAT_ARGB8888, DRM_FORMAT_XBGR8888,
|
DmabufFrame, FourCC, DRM_FORMAT_ABGR2101010, DRM_FORMAT_ABGR8888, DRM_FORMAT_ARGB8888,
|
||||||
DRM_FORMAT_XRGB8888,
|
DRM_FORMAT_XBGR2101010, DRM_FORMAT_XBGR8888, DRM_FORMAT_XRGB8888,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
pub const DRM_FORMAT_MOD_INVALID: u64 = 0xff_ffff_ffff_ffff;
|
||||||
|
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
#[derive(BufferContents, Vertex, Copy, Clone, Debug)]
|
#[derive(BufferContents, Vertex, Copy, Clone, Debug)]
|
||||||
pub struct Vert2Uv {
|
pub struct Vert2Uv {
|
||||||
@@ -742,18 +744,24 @@ impl WlxGraphics {
|
|||||||
|
|
||||||
let format = fourcc_to_vk(frame.format.fourcc)?;
|
let format = fourcc_to_vk(frame.format.fourcc)?;
|
||||||
|
|
||||||
let layouts: Vec<SubresourceLayout> = (0..frame.num_planes)
|
let mut tiling: ImageTiling = ImageTiling::Optimal;
|
||||||
.map(|i| {
|
let mut modifiers: Vec<u64> = vec![];
|
||||||
|
let mut layouts: Vec<SubresourceLayout> = vec![];
|
||||||
|
|
||||||
|
if frame.format.modifier != DRM_FORMAT_MOD_INVALID {
|
||||||
|
(0..frame.num_planes).for_each(|i| {
|
||||||
let plane = &frame.planes[i];
|
let plane = &frame.planes[i];
|
||||||
SubresourceLayout {
|
layouts.push(SubresourceLayout {
|
||||||
offset: plane.offset as _,
|
offset: plane.offset as _,
|
||||||
size: 0,
|
size: 0,
|
||||||
row_pitch: plane.stride as _,
|
row_pitch: plane.stride as _,
|
||||||
array_pitch: None,
|
array_pitch: None,
|
||||||
depth_pitch: None,
|
depth_pitch: None,
|
||||||
}
|
});
|
||||||
})
|
modifiers.push(frame.format.modifier);
|
||||||
.collect();
|
});
|
||||||
|
tiling = ImageTiling::DrmFormatModifier;
|
||||||
|
};
|
||||||
|
|
||||||
let image = unsafe {
|
let image = unsafe {
|
||||||
RawImage::new_unchecked(
|
RawImage::new_unchecked(
|
||||||
@@ -763,8 +771,8 @@ impl WlxGraphics {
|
|||||||
extent,
|
extent,
|
||||||
usage: ImageUsage::SAMPLED,
|
usage: ImageUsage::SAMPLED,
|
||||||
external_memory_handle_types: ExternalMemoryHandleTypes::DMA_BUF,
|
external_memory_handle_types: ExternalMemoryHandleTypes::DMA_BUF,
|
||||||
tiling: ImageTiling::DrmFormatModifier,
|
tiling,
|
||||||
drm_format_modifiers: vec![frame.format.modifier],
|
drm_format_modifiers: modifiers,
|
||||||
drm_format_modifier_plane_layouts: layouts,
|
drm_format_modifier_plane_layouts: layouts,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
},
|
||||||
@@ -1556,6 +1564,8 @@ pub fn fourcc_to_vk(fourcc: FourCC) -> anyhow::Result<Format> {
|
|||||||
DRM_FORMAT_XBGR8888 => Ok(Format::R8G8B8A8_UNORM),
|
DRM_FORMAT_XBGR8888 => Ok(Format::R8G8B8A8_UNORM),
|
||||||
DRM_FORMAT_ARGB8888 => Ok(Format::B8G8R8A8_UNORM),
|
DRM_FORMAT_ARGB8888 => Ok(Format::B8G8R8A8_UNORM),
|
||||||
DRM_FORMAT_XRGB8888 => Ok(Format::B8G8R8A8_UNORM),
|
DRM_FORMAT_XRGB8888 => Ok(Format::B8G8R8A8_UNORM),
|
||||||
|
DRM_FORMAT_ABGR2101010 => Ok(Format::A2B10G10R10_UNORM_PACK32),
|
||||||
|
DRM_FORMAT_XBGR2101010 => Ok(Format::A2B10G10R10_UNORM_PACK32),
|
||||||
_ => bail!("Unsupported format {}", fourcc),
|
_ => bail!("Unsupported format {}", fourcc),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ impl OverlayRenderer for MirrorRenderer {
|
|||||||
self.name.clone(),
|
self.name.clone(),
|
||||||
pw_result.node_id
|
pw_result.node_id
|
||||||
);
|
);
|
||||||
let capture = PipewireCapture::new(self.name.clone(), pw_result.node_id, 60);
|
let capture = PipewireCapture::new(self.name.clone(), pw_result.node_id);
|
||||||
self.renderer = Some(ScreenRenderer::new_raw(
|
self.renderer = Some(ScreenRenderer::new_raw(
|
||||||
self.name.clone(),
|
self.name.clone(),
|
||||||
Box::new(capture),
|
Box::new(capture),
|
||||||
|
|||||||
@@ -14,8 +14,8 @@ use vulkano::{
|
|||||||
};
|
};
|
||||||
use wlx_capture::{
|
use wlx_capture::{
|
||||||
frame::{
|
frame::{
|
||||||
DrmFormat, MouseMeta, WlxFrame, DRM_FORMAT_ABGR8888, DRM_FORMAT_ARGB8888,
|
DrmFormat, MouseMeta, WlxFrame, DRM_FORMAT_ABGR2101010, DRM_FORMAT_ABGR8888,
|
||||||
DRM_FORMAT_XBGR8888, DRM_FORMAT_XRGB8888,
|
DRM_FORMAT_ARGB8888, DRM_FORMAT_XBGR2101010, DRM_FORMAT_XBGR8888, DRM_FORMAT_XRGB8888,
|
||||||
},
|
},
|
||||||
WlxCapture,
|
WlxCapture,
|
||||||
};
|
};
|
||||||
@@ -44,7 +44,10 @@ use crate::{
|
|||||||
overlay::{OverlayRenderer, OverlayState, SplitOverlayBackend},
|
overlay::{OverlayRenderer, OverlayState, SplitOverlayBackend},
|
||||||
},
|
},
|
||||||
config::{def_pw_tokens, PwTokenMap},
|
config::{def_pw_tokens, PwTokenMap},
|
||||||
graphics::{fourcc_to_vk, WlxCommandBuffer, WlxPipeline, WlxPipelineLegacy, DMA_BUF_SUPPORTED},
|
graphics::{
|
||||||
|
fourcc_to_vk, WlxCommandBuffer, WlxPipeline, WlxPipelineLegacy, DMA_BUF_SUPPORTED,
|
||||||
|
DRM_FORMAT_MOD_INVALID,
|
||||||
|
},
|
||||||
hid::{MOUSE_LEFT, MOUSE_MIDDLE, MOUSE_RIGHT},
|
hid::{MOUSE_LEFT, MOUSE_MIDDLE, MOUSE_RIGHT},
|
||||||
state::{AppSession, AppState, ScreenMeta},
|
state::{AppSession, AppState, ScreenMeta},
|
||||||
};
|
};
|
||||||
@@ -316,7 +319,7 @@ impl ScreenRenderer {
|
|||||||
let select_screen_result =
|
let select_screen_result =
|
||||||
futures::executor::block_on(pipewire_select_screen(token, embed_mouse, true, true))?;
|
futures::executor::block_on(pipewire_select_screen(token, embed_mouse, true, true))?;
|
||||||
|
|
||||||
let capture = PipewireCapture::new(name, select_screen_result.node_id, 60);
|
let capture = PipewireCapture::new(name, select_screen_result.node_id);
|
||||||
|
|
||||||
Ok((
|
Ok((
|
||||||
ScreenRenderer {
|
ScreenRenderer {
|
||||||
@@ -373,7 +376,10 @@ impl OverlayRenderer for ScreenRenderer {
|
|||||||
DRM_FORMAT_XBGR8888.into(),
|
DRM_FORMAT_XBGR8888.into(),
|
||||||
DRM_FORMAT_ARGB8888.into(),
|
DRM_FORMAT_ARGB8888.into(),
|
||||||
DRM_FORMAT_XRGB8888.into(),
|
DRM_FORMAT_XRGB8888.into(),
|
||||||
|
DRM_FORMAT_ABGR2101010.into(),
|
||||||
|
DRM_FORMAT_XBGR2101010.into(),
|
||||||
];
|
];
|
||||||
|
|
||||||
let mut final_formats = vec![];
|
let mut final_formats = vec![];
|
||||||
|
|
||||||
for &f in &possible_formats {
|
for &f in &possible_formats {
|
||||||
@@ -384,7 +390,7 @@ impl OverlayRenderer for ScreenRenderer {
|
|||||||
else {
|
else {
|
||||||
continue;
|
continue;
|
||||||
};
|
};
|
||||||
final_formats.push(DrmFormat {
|
let mut fmt = DrmFormat {
|
||||||
fourcc: f,
|
fourcc: f,
|
||||||
modifiers: props
|
modifiers: props
|
||||||
.drm_format_modifier_properties
|
.drm_format_modifier_properties
|
||||||
@@ -393,7 +399,13 @@ impl OverlayRenderer for ScreenRenderer {
|
|||||||
.filter(|m| m.drm_format_modifier_plane_count == 1)
|
.filter(|m| m.drm_format_modifier_plane_count == 1)
|
||||||
.map(|m| m.drm_format_modifier)
|
.map(|m| m.drm_format_modifier)
|
||||||
.collect(),
|
.collect(),
|
||||||
})
|
};
|
||||||
|
fmt.modifiers.push(DRM_FORMAT_MOD_INVALID); // implicit modifiers support
|
||||||
|
final_formats.push(fmt);
|
||||||
|
}
|
||||||
|
log::debug!("Supported DRM formats:");
|
||||||
|
for f in &final_formats {
|
||||||
|
log::debug!(" {} {:?}", f.fourcc, f.modifiers);
|
||||||
}
|
}
|
||||||
final_formats
|
final_formats
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user