Xrgb2101010 not supported
Looks like it's not supporting 10 bit displays?
DEBUG libwayshot::dispatch: Received Buffer event
DEBUG libwayshot::dispatch: Received LinuxDmaBuf event
DEBUG libwayshot::dispatch: Received bufferdone event
DEBUG libwayshot: Received compositor frame buffer formats: [
FrameFormat {
format: Xrgb2101010,
width: 2560,
height: 1440,
stride: 10240,
},
]
DEBUG libwayshot: Selected frame buffer format: None
ERROR libwayshot: No suitable frame format found
Error: NoSupportedBufferFormat
I think, now color is mostly hardcoded to be rgba8 (and rgb8 in some occasions), so the convert.rs would need the implementation for converting it.
I don't think it's a complicated task from the looks of it, but I can't test the changes.
Can you try out if this patch works? The logic is the same as current impl with just red and blue switched around
diff --git a/libwayshot/src/convert.rs b/libwayshot/src/convert.rs
index fb3935d..569413f 100644
--- a/libwayshot/src/convert.rs
+++ b/libwayshot/src/convert.rs
@@ -9,6 +9,9 @@ pub trait Convert {
#[derive(Default)]
struct ConvertBGR10 {}
+#[derive(Default)]
+struct ConvertRGB10 {}
+
#[derive(Default)]
struct ConvertNone {}
@@ -27,6 +30,9 @@ pub fn create_converter(format: wl_shm::Format) -> Option<Box<dyn Convert>> {
match format {
wl_shm::Format::Xbgr8888 | wl_shm::Format::Abgr8888 => Some(Box::<ConvertNone>::default()),
wl_shm::Format::Xrgb8888 | wl_shm::Format::Argb8888 => Some(Box::<ConvertRGB8>::default()),
+ wl_shm::Format::Xrgb2101010 | wl_shm::Format::Argb2101010 => {
+ Some(Box::<ConvertRGB10>::default())
+ }
wl_shm::Format::Xbgr2101010 | wl_shm::Format::Abgr2101010 => {
Some(Box::<ConvertBGR10>::default())
}
@@ -74,6 +80,25 @@ impl Convert for ConvertBGR10 {
}
}
+impl Convert for ConvertRGB10 {
+ fn convert_inplace(&self, data: &mut [u8]) -> ColorType {
+ for chunk in data.chunks_exact_mut(4) {
+ let pixel = ((chunk[3] as u32) << 24)
+ | ((chunk[2] as u32) << 16)
+ | ((chunk[1] as u32) << 8)
+ | chunk[0] as u32;
+ let r = convert10_to_8(pixel >> SHIFT10BITS_1);
+ let g = convert10_to_8(pixel >> SHIFT10BITS_2);
+ let b = convert10_to_8(pixel);
+ chunk[0] = r;
+ chunk[1] = g;
+ chunk[2] = b;
+ chunk[3] = 255;
+ }
+ ColorType::Rgba8
+ }
+}
+
impl Convert for ConvertBGR888 {
fn convert_inplace(&self, _data: &mut [u8]) -> ColorType {
ColorType::Rgb8
Thanks! It works when I added this patch too
diff --git a/libwayshot/src/lib.rs b/libwayshot/src/lib.rs
index 3b358b3..01eef4d 100644
--- a/libwayshot/src/lib.rs
+++ b/libwayshot/src/lib.rs
@@ -530,7 +530,8 @@ impl WayshotConnection {
.find(|frame| {
matches!(
frame.format,
- wl_shm::Format::Xbgr2101010
+ wl_shm::Format::Xbgr2101010 |
+ wl_shm::Format::Xrgb2101010
| wl_shm::Format::Abgr2101010
| wl_shm::Format::Argb8888
| wl_shm::Format::Xrgb8888
There is problem with HDR, like washed out colors, but this is separate issue
Yeah, that's because as I said, wayshot has 8 bit color hardcoded so it is expected in current state. I think there's another issue tracking for color depth: #86
I have this fork, I'm able to take normal screenshots with it on hdr display, just not sure I'm ready to make PR https://github.com/Vityacv/wayshot
@Vityacv Please feel free to send the PR! More than happy to improve upon it and merge