From c3177c64691b498ac5c031611953da33b7a4c577 Mon Sep 17 00:00:00 2001 From: Julian Orth Date: Fri, 28 Nov 2025 15:02:46 +0100 Subject: [PATCH] formats: add support for additional formats --- jay-config/src/video.rs | 8 +++ src/format.rs | 81 ++++++++++++++++++++++++ toml-config/src/config/parsers/format.rs | 8 +++ 3 files changed, 97 insertions(+) diff --git a/jay-config/src/video.rs b/jay-config/src/video.rs index f9f9cb6f..1ad31411 100644 --- a/jay-config/src/video.rs +++ b/jay-config/src/video.rs @@ -727,6 +727,14 @@ impl Format { pub const XBGR16161616: Self = Self(25); pub const ABGR16161616F: Self = Self(26); pub const XBGR16161616F: Self = Self(27); + pub const BGR161616: Self = Self(28); + pub const R16F: Self = Self(29); + pub const GR1616F: Self = Self(30); + pub const BGR161616F: Self = Self(31); + pub const R32F: Self = Self(32); + pub const GR3232F: Self = Self(33); + pub const BGR323232F: Self = Self(34); + pub const ABGR32323232F: Self = Self(35); } /// A color space. diff --git a/src/format.rs b/src/format.rs index cd8d1f2b..300c25ef 100644 --- a/src/format.rs +++ b/src/format.rs @@ -449,6 +449,71 @@ static XBGR16161616F: &Format = &Format { ..default(ConfigFormat::XBGR16161616F) }; +static BGR161616: &Format = &Format { + name: "bgr161616", + vk_format: vk::Format::R16G16B16_UNORM, + bpp: 6, + drm: fourcc_code('B', 'G', '4', '8'), + ..default(ConfigFormat::BGR161616) +}; + +static R16F: &Format = &Format { + name: "r16f", + vk_format: vk::Format::R16_SFLOAT, + bpp: 2, + drm: fourcc_code('R', ' ', ' ', 'H'), + ..default(ConfigFormat::R16F) +}; + +static GR1616F: &Format = &Format { + name: "gr1616f", + vk_format: vk::Format::R16G16_SFLOAT, + bpp: 4, + drm: fourcc_code('G', 'R', ' ', 'H'), + ..default(ConfigFormat::GR1616F) +}; + +static BGR161616F: &Format = &Format { + name: "bgr161616f", + vk_format: vk::Format::R16G16B16_SFLOAT, + bpp: 6, + drm: fourcc_code('B', 'G', 'R', 'H'), + ..default(ConfigFormat::BGR161616F) +}; + +static R32F: &Format = &Format { + name: "r32f", + vk_format: vk::Format::R32_SFLOAT, + bpp: 4, + drm: fourcc_code('R', ' ', ' ', 'F'), + ..default(ConfigFormat::R32F) +}; + +static GR3232F: &Format = &Format { + name: "gr3232f", + vk_format: vk::Format::R32G32_SFLOAT, + bpp: 8, + drm: fourcc_code('G', 'R', ' ', 'F'), + ..default(ConfigFormat::GR3232F) +}; + +static BGR323232F: &Format = &Format { + name: "bgr323232f", + vk_format: vk::Format::R32G32B32_SFLOAT, + bpp: 12, + drm: fourcc_code('B', 'G', 'R', 'F'), + ..default(ConfigFormat::BGR323232F) +}; + +static ABGR32323232F: &Format = &Format { + name: "abgr32323232f", + vk_format: vk::Format::R32G32B32A32_SFLOAT, + bpp: 16, + drm: fourcc_code('A', 'B', '8', 'F'), + has_alpha: true, + ..default(ConfigFormat::ABGR32323232F) +}; + pub static FORMATS: &[Format] = &[ *ARGB8888, *XRGB8888, @@ -498,4 +563,20 @@ pub static FORMATS: &[Format] = &[ *ABGR16161616F, #[cfg(target_endian = "little")] *XBGR16161616F, + #[cfg(target_endian = "little")] + *BGR161616, + #[cfg(target_endian = "little")] + *R16F, + #[cfg(target_endian = "little")] + *GR1616F, + #[cfg(target_endian = "little")] + *BGR161616F, + #[cfg(target_endian = "little")] + *R32F, + #[cfg(target_endian = "little")] + *GR3232F, + #[cfg(target_endian = "little")] + *BGR323232F, + #[cfg(target_endian = "little")] + *ABGR32323232F, ]; diff --git a/toml-config/src/config/parsers/format.rs b/toml-config/src/config/parsers/format.rs index 32c9494b..7755b555 100644 --- a/toml-config/src/config/parsers/format.rs +++ b/toml-config/src/config/parsers/format.rs @@ -52,6 +52,14 @@ impl Parser for FormatParser { "xbgr16161616" => Format::XBGR16161616, "abgr16161616f" => Format::ABGR16161616F, "xbgr16161616f" => Format::XBGR16161616F, + "bgr161616" => Format::BGR161616, + "r16f" => Format::R16F, + "gr1616f" => Format::GR1616F, + "bgr161616f" => Format::BGR161616F, + "r32f" => Format::R32F, + "gr3232f" => Format::GR3232F, + "bgr323232f" => Format::BGR323232F, + "abgr32323232f" => Format::ABGR32323232F, _ => return Err(FormatParserError::UnknownFormat(string.to_string()).spanned(span)), }; Ok(format)