diff --git a/server/encoder/encoder_settings.cpp b/server/encoder/encoder_settings.cpp index 99de6ae0..ca812f2b 100644 --- a/server/encoder/encoder_settings.cpp +++ b/server/encoder/encoder_settings.cpp @@ -328,6 +328,37 @@ std::array get_encoder_settings(wivrn_vk_bundle & bundle, c if (std::ranges::contains(res, video_codec::h264, &encoder_settings::codec) or std::ranges::contains(res, video_codec::raw, &encoder_settings::codec)) bit_depth = 8; + else + bit_depth = 10; + + auto check_format = [&](vk::Format format) { + try + { + auto props = bundle.physical_device.getImageFormatProperties( + format, + vk::ImageType::e2D, + vk::ImageTiling::eOptimal, + vk::ImageUsageFlagBits::eStorage | vk::ImageUsageFlagBits::eTransferSrc); + return props.maxArrayLayers >= 3 and + props.maxExtent.depth >= 1 and + props.maxExtent.width >= width and + props.maxExtent.height >= height; + } + catch (vk::FormatNotSupportedError &) + { + return false; + } + }; + + if (bit_depth == 10 and not check_format(vk::Format::eR10X6UnormPack16)) + { + U_LOG_W("GPU does not have sufficient support for 10-bit images, reverting to 8"); + bit_depth = 8; + } + if (bit_depth == 8 and not check_format(vk::Format::eR8Unorm)) + { + U_LOG_W("GPU does not have sufficient support for 8-bit images"); + } for (auto & i: res) i.bit_depth = bit_depth.value_or(10);