Skip to content

Commit 54b93ee

Browse files
committed
Support (some) 10-bit displays
1 parent d8f5616 commit 54b93ee

File tree

1 file changed

+21
-8
lines changed

1 file changed

+21
-8
lines changed

src/frame/vulkan.rs

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -352,9 +352,12 @@ impl Vulkan {
352352
1, frame.num_objects,
353353
"Frames with multiple objects are not supported yet, use WLR_DRM_NO_MODIFIERS=1 as described in README and follow issue #8"
354354
);
355-
assert_eq!(
356-
875713112, frame.format,
357-
"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
355+
356+
let vk_format = map_drm_format(frame.format);
357+
358+
assert!(
359+
vk_format.is_some(),
360+
"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
358361
);
359362

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

465-
assert_eq!(
466-
875713112, frame.format,
467-
"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
468+
let vk_format = map_drm_format(frame.format);
469+
470+
assert!(
471+
vk_format.is_some(),
472+
"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
468473
);
469474

470475
let mut frame_image_memory_info = vk::ExternalMemoryImageCreateInfo::default()
@@ -473,7 +478,7 @@ impl Vulkan {
473478
let frame_image_create_info = vk::ImageCreateInfo::default()
474479
.push_next(&mut frame_image_memory_info)
475480
.image_type(vk::ImageType::TYPE_2D)
476-
.format(vk::Format::B8G8R8A8_UNORM)
481+
.format(vk_format.unwrap())
477482
.extent(vk::Extent3D {
478483
width: frame.width,
479484
height: frame.height,
@@ -893,3 +898,11 @@ fn find_memory_type_index(
893898
})
894899
.map(|(index, _)| index as _)
895900
}
901+
902+
fn map_drm_format(format: u32) -> Option<vk::Format> {
903+
match format {
904+
875713112 => Some(vk::Format::B8G8R8A8_UNORM),
905+
808669784 => Some(vk::Format::A2R10G10B10_UNORM_PACK32),
906+
_ => None,
907+
}
908+
}

0 commit comments

Comments
 (0)