Skip to content

Commit

Permalink
Support (some) 10-bit displays
Browse files Browse the repository at this point in the history
  • Loading branch information
maximbaz committed Feb 26, 2025
1 parent d8f5616 commit 54b93ee
Showing 1 changed file with 21 additions and 8 deletions.
29 changes: 21 additions & 8 deletions src/frame/vulkan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -352,9 +352,12 @@ impl Vulkan {
1, frame.num_objects,
"Frames with multiple objects are not supported yet, use WLR_DRM_NO_MODIFIERS=1 as described in README and follow issue #8"
);
assert_eq!(
875713112, frame.format,
"Frame with formats other than DRM_FORMAT_XRGB8888 are not supported yet (yours is {}). If you see this issue, please open a GitHub issue (unless there's one already open) and share your format value", frame.format

let vk_format = map_drm_format(frame.format);

assert!(
vk_format.is_some(),
"Frame with formats other than DRM_FORMAT_XRGB8888 or DRM_FORMAT_XRGB2101010 are not supported yet (yours is {}). If you see this issue, please open a GitHub issue (unless there's one already open) and share your format value", frame.format
);

// External memory info
Expand All @@ -365,7 +368,7 @@ impl Vulkan {
let frame_image_create_info = vk::ImageCreateInfo::default()
.push_next(&mut frame_image_memory_info)
.image_type(vk::ImageType::TYPE_2D)
.format(vk::Format::B8G8R8A8_UNORM)
.format(vk_format.unwrap())
.extent(vk::Extent3D {
width: frame.width,
height: frame.height,
Expand Down Expand Up @@ -462,9 +465,11 @@ impl Vulkan {
"Frames with multiple objects are not supported yet, use WLR_DRM_NO_MODIFIERS=1 as described in README and follow issue #8"
);

assert_eq!(
875713112, frame.format,
"Frame with formats other than DRM_FORMAT_XRGB8888 are not supported yet (yours is {}). If you see this issue, please open a GitHub issue (unless there's one already open) and share your format value", frame.format
let vk_format = map_drm_format(frame.format);

assert!(
vk_format.is_some(),
"Frame with formats other than DRM_FORMAT_XRGB8888 or DRM_FORMAT_XRGB2101010 are not supported yet (yours is {}). If you see this issue, please open a GitHub issue (unless there's one already open) and share your format value", frame.format
);

let mut frame_image_memory_info = vk::ExternalMemoryImageCreateInfo::default()
Expand All @@ -473,7 +478,7 @@ impl Vulkan {
let frame_image_create_info = vk::ImageCreateInfo::default()
.push_next(&mut frame_image_memory_info)
.image_type(vk::ImageType::TYPE_2D)
.format(vk::Format::B8G8R8A8_UNORM)
.format(vk_format.unwrap())
.extent(vk::Extent3D {
width: frame.width,
height: frame.height,
Expand Down Expand Up @@ -893,3 +898,11 @@ fn find_memory_type_index(
})
.map(|(index, _)| index as _)
}

fn map_drm_format(format: u32) -> Option<vk::Format> {
match format {
875713112 => Some(vk::Format::B8G8R8A8_UNORM),
808669784 => Some(vk::Format::A2R10G10B10_UNORM_PACK32),
_ => None,
}
}

0 comments on commit 54b93ee

Please sign in to comment.