Truly independent web browser
Everywhere: Gate Vulkan video decoding on the feature blocklist
Zaggy1024609b22bc7fb3
diff --git a/Libraries/LibMediaCodecs/CMakeLists.txt b/Libraries/LibMediaCodecs/CMakeLists.txtindex de7d4161fb2..746e239ee7c 100644--- a/Libraries/LibMediaCodecs/CMakeLists.txt+++ b/Libraries/LibMediaCodecs/CMakeLists.txt@@ -55,7 +55,7 @@ compile_ipc(../../Services/VideoDecoderServer/VideoDecoderServerControl.ipc ../.compile_ipc(../../Services/VideoDecoderServer/VideoDecoderServerControlClient.ipc ../../Services/VideoDecoderServer/VideoDecoderServerControlClientEndpoint.h)ladybird_lib(LibMediaCodecs mediacodecs EXPLICIT_SYMBOL_EXPORT)-target_link_libraries(LibMediaCodecs PRIVATE LibCore LibGfx LibIPC LibThreading)+target_link_libraries(LibMediaCodecs PRIVATE LibCore LibGfx LibIPC LibPlatformFeatures LibThreading)target_link_libraries(LibMediaCodecs PUBLIC LibAudio)if (NOT ANDROID)diff --git a/Libraries/LibMediaCodecs/FFmpeg/FFmpegVulkanVideoDecoder.cpp b/Libraries/LibMediaCodecs/FFmpeg/FFmpegVulkanVideoDecoder.cppindex 3cad186253e..4e3900eede7 100644--- a/Libraries/LibMediaCodecs/FFmpeg/FFmpegVulkanVideoDecoder.cpp+++ b/Libraries/LibMediaCodecs/FFmpeg/FFmpegVulkanVideoDecoder.cpp@@ -16,6 +16,7 @@#include <LibMediaCodecs/FFmpeg/FFmpegVulkanVideoDecoder.h>#include <LibMediaCodecs/Limits.h>#include <LibMediaCodecs/VideoFrame.h>+#include <LibPlatformFeatures/ProcessFeatures.h>#include <LibThreading/Thread.h>#include <string.h>@@ -96,6 +97,29 @@ FFmpegFunctions const* ffmpeg_for(CodecID codec_id)}}+bool may_decode_with(FFmpegFunctions const& functions)+{+ auto feature = &functions == &FFmpegFunctions::bundled() ? PlatformFeatures::Feature::VulkanVideoBundledFFmpeg : PlatformFeatures::Feature::VulkanVideoSystemFFmpeg;+ return PlatformFeatures::ProcessFeatures::the().is_enabled(feature);+}++// Whether decoded images may be exported directly, rather than copied into images that export.+bool may_export_directly_with(FFmpegFunctions const& functions)+{+ auto feature = &functions == &FFmpegFunctions::bundled() ? PlatformFeatures::Feature::VulkanVideoBundledFFmpegDirectExport : PlatformFeatures::Feature::VulkanVideoSystemFFmpegDirectExport;+ return PlatformFeatures::ProcessFeatures::the().is_enabled(feature);+}++// FFmpeg decodes references into the output images unless it keeps a separate DPB: before 63.8.101 it does so whenever+// the driver can, and from then on whenever the driver cannot keep them apart. A later decode may be reading such an+// image, so it cannot be copied.+bool decodes_references_into_the_output(FFmpegFunctions const& functions, VkVideoDecodeCapabilityFlagsKHR flags)+{+ if (functions.avcodec_version() < AV_VERSION_INT(63, 8, 101))+ return (flags & VK_VIDEO_DECODE_CAPABILITY_DPB_AND_OUTPUT_COINCIDE_BIT_KHR) != 0;+ return (flags & VK_VIDEO_DECODE_CAPABILITY_DPB_AND_OUTPUT_DISTINCT_BIT_KHR) == 0;+}+AVCodec const* vulkan_capable_decoder(FFmpegFunctions const& functions, CodecID codec_id){auto const* codec = functions.avcodec_find_decoder_by_name(decoder_name_for(codec_id));@@ -244,7 +268,7 @@ Optional<DecoderCapabilities> FFmpegVulkanVideoDecoder::capabilities(ParsedCodecauto codec_id = codec.codec_id();auto const* functions = ffmpeg_for(codec_id);- if (functions == nullptr || !device->has_enabled_extension(decode_extension_for(codec_id)))+ if (functions == nullptr || !may_decode_with(*functions) || !device->has_enabled_extension(decode_extension_for(codec_id)))return {};if (vulkan_capable_decoder(*functions, codec_id) == nullptr)return {};@@ -363,6 +387,8 @@ Optional<DecoderCapabilities> FFmpegVulkanVideoDecoder::capabilities(ParsedCodecvideo_capabilities.pNext = &decode_capabilities;if (device->video_capabilities(profile_info, video_capabilities).is_error())return {};+ if (!may_export_directly_with(*functions) && decodes_references_into_the_output(*functions, decode_capabilities.flags))+ return {};return DecoderCapabilities { .smooth = true, .power_efficient = true };}@@ -373,7 +399,7 @@ DecoderErrorOr<NonnullOwnPtr<FFmpegVulkanVideoDecoder>> FFmpegVulkanVideoDecoderif (device == nullptr)return DecoderError::with_description(DecoderErrorCategory::NotImplemented, "No Vulkan device can decode video in this process"sv);auto const* ffmpeg = ffmpeg_for(codec_id);- if (ffmpeg == nullptr || !device->has_enabled_extension(decode_extension_for(codec_id)))+ if (ffmpeg == nullptr || !may_decode_with(*ffmpeg) || !device->has_enabled_extension(decode_extension_for(codec_id)))return DecoderError::format(DecoderErrorCategory::NotImplemented, "The Vulkan device cannot decode codec {}", codec_id);auto const& functions = *ffmpeg;@@ -505,11 +531,10 @@ DecoderErrorOr<void> FFmpegVulkanVideoDecoder::create_frames_context()// Storage use is only for FFmpeg's own filters, and can rule out the modifiers that export.vulkan_frames_context.usage = static_cast<VkImageUsageFlagBits>(vulkan_frames_context.usage & ~VK_IMAGE_USAGE_STORAGE_BIT);- // FIXME: Decide this through the feature blocklist. Until 63.20.101, FFmpeg gives a separate DPB the output's- // modifiers, which RADV lays out wrongly. Frames used as references can't be copied, since a later decode- // may be using them.- auto output_is_used_as_reference = (vulkan_frames_context.usage & VK_IMAGE_USAGE_VIDEO_DECODE_DPB_BIT_KHR) != 0;- auto copies_decoded_frames = &m_functions != &FFmpegFunctions::bundled() && m_functions.avcodec_version() < AV_VERSION_INT(63, 20, 101) && !output_is_used_as_reference;+ // Images that a later decode may be reading as references cannot be copied, which capabilities() has ruled out.+ auto copies_decoded_frames = !may_export_directly_with(m_functions);+ if (copies_decoded_frames && (vulkan_frames_context.usage & VK_IMAGE_USAGE_VIDEO_DECODE_DPB_BIT_KHR) != 0)+ return DecoderError::with_description(DecoderErrorCategory::NotImplemented, "Decoded images used as references cannot be copied for export"sv);if (!copies_decoded_frames) {m_drm_format_modifiers = m_device.exportable_drm_format_modifiers(vulkan_frames_context.format[0], vulkan_frames_context.usage, vulkan_frames_context.img_flags, vulkan_frames_context.create_pnext);diff --git a/Libraries/LibMediaCodecs/Vulkan/VulkanVideoDevice.cpp b/Libraries/LibMediaCodecs/Vulkan/VulkanVideoDevice.cppindex bfc1ef89d12..4145b3276a2 100644--- a/Libraries/LibMediaCodecs/Vulkan/VulkanVideoDevice.cpp+++ b/Libraries/LibMediaCodecs/Vulkan/VulkanVideoDevice.cpp@@ -69,18 +69,38 @@ Optional<u32> first_queue_family_with(ReadonlySpan<VkQueueFamilyProperties> famireturn {};}-bool can_decode_video(VkPhysicalDevice physical_device)+}++ErrorOr<void> VulkanVideoDevice::check_can_decode_video(VkPhysicalDevice physical_device){VkPhysicalDeviceProperties properties;vkGetPhysicalDeviceProperties(physical_device, &properties);if (properties.apiVersion < VK_API_VERSION_1_3)- return false;+ return Error::from_string_literal("The GPU's Vulkan is older than 1.3");auto extensions = device_extensions_of(physical_device);if (!all_of(required_extensions, [&](auto name) { return contains_extension(extensions, { name, strlen(name) }); }))- return false;- return first_queue_family_with(queue_families_of(physical_device), VK_QUEUE_VIDEO_DECODE_BIT_KHR).has_value();-}+ return Error::from_string_literal("The GPU cannot decode video into images that export as dma-bufs");+ // FFmpeg submits with synchronization2 and tracks its frames with timeline semaphores, without checking for either.+ VkPhysicalDeviceVulkan13Features vulkan13 {};+ vulkan13.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_3_FEATURES;+ VkPhysicalDeviceVulkan12Features vulkan12 {};+ vulkan12.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_2_FEATURES;+ vulkan12.pNext = &vulkan13;+ VkPhysicalDeviceFeatures2 features {};+ features.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2;+ features.pNext = &vulkan12;+ vkGetPhysicalDeviceFeatures2(physical_device, &features);+ if (!vulkan12.timelineSemaphore || !vulkan13.synchronization2)+ return Error::from_string_literal("The Vulkan device lacks timeline semaphores or synchronization2");++ // FFmpeg needs a family for compute and one for transfers alongside the decoding one.+ auto queue_families = queue_families_of(physical_device);+ for (auto flags : { VK_QUEUE_VIDEO_DECODE_BIT_KHR, VK_QUEUE_COMPUTE_BIT, VK_QUEUE_TRANSFER_BIT }) {+ if (!first_queue_family_with(queue_families, flags).has_value())+ return Error::from_string_literal("The Vulkan device lacks a decode, compute or transfer queue");+ }+ return {};}ErrorOr<void> VulkanVideoDevice::create_for_process(Gfx::GpuDeviceIdentity const& identity)@@ -125,8 +145,7 @@ ErrorOr<NonnullOwnPtr<VulkanVideoDevice>> VulkanVideoDevice::create(Gfx::GpuDevi}if (device->m_physical_device == VK_NULL_HANDLE)return Error::from_string_literal("The named GPU is not a Vulkan device here");- if (!can_decode_video(device->m_physical_device))- return Error::from_string_literal("The named GPU cannot decode video into images that export as dma-bufs");+ TRY(check_can_decode_video(device->m_physical_device));auto available_extensions = device_extensions_of(device->m_physical_device);for (auto const* name : required_extensions)@@ -148,10 +167,6 @@ ErrorOr<NonnullOwnPtr<VulkanVideoDevice>> VulkanVideoDevice::create(Gfx::GpuDevisupported_features.pNext = &supported_vulkan12;vkGetPhysicalDeviceFeatures2(device->m_physical_device, &supported_features);- // FFmpeg submits with synchronization2 and tracks its frames with timeline semaphores, without checking for either.- if (!supported_vulkan12.timelineSemaphore || !supported_vulkan13.synchronization2)- return Error::from_string_literal("The Vulkan device lacks timeline semaphores or synchronization2");-device->m_vulkan13_features.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_3_FEATURES;device->m_vulkan13_features.synchronization2 = VK_TRUE;device->m_vulkan12_features.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_2_FEATURES;@@ -186,13 +201,11 @@ ErrorOr<NonnullOwnPtr<VulkanVideoDevice>> VulkanVideoDevice::create(Gfx::GpuDevidevice->m_enabled_extensions.append(name);}- // FFmpeg needs a family for compute and one for transfers alongside the decoding one.auto queue_families = queue_families_of(device->m_physical_device);auto decode_family = first_queue_family_with(queue_families, VK_QUEUE_VIDEO_DECODE_BIT_KHR);auto compute_family = first_queue_family_with(queue_families, VK_QUEUE_COMPUTE_BIT);auto transfer_family = first_queue_family_with(queue_families, VK_QUEUE_TRANSFER_BIT);- if (!decode_family.has_value() || !compute_family.has_value() || !transfer_family.has_value())- return Error::from_string_literal("The Vulkan device lacks a decode, compute or transfer queue");+ VERIFY(decode_family.has_value() && compute_family.has_value() && transfer_family.has_value());device->m_compute_queue_family = *compute_family;Vector<VkDeviceQueueCreateInfo> queue_infos;diff --git a/Libraries/LibMediaCodecs/Vulkan/VulkanVideoDevice.h b/Libraries/LibMediaCodecs/Vulkan/VulkanVideoDevice.hindex 0ac46700da0..9a8c4e58a01 100644--- a/Libraries/LibMediaCodecs/Vulkan/VulkanVideoDevice.h+++ b/Libraries/LibMediaCodecs/Vulkan/VulkanVideoDevice.h@@ -38,6 +38,9 @@ public:static ErrorOr<void> create_for_process(Gfx::GpuDeviceIdentity const&);static VulkanVideoDevice* the();+ // Whether a device has what decoding through FFmpeg needs, which the system probe checks without creating one.+ static ErrorOr<void> check_can_decode_video(VkPhysicalDevice);+~VulkanVideoDevice();VkInstance instance() const { return m_instance; }diff --git a/Libraries/LibPlatformFeatures/Build.h b/Libraries/LibPlatformFeatures/Build.hindex 0c610fc10ec..3bca866646d 100644--- a/Libraries/LibPlatformFeatures/Build.h+++ b/Libraries/LibPlatformFeatures/Build.h@@ -7,6 +7,7 @@#pragma once#include <AK/Assertions.h>+#include <AK/Platform.h>#include <LibPlatformFeatures/Feature.h>namespace PlatformFeatures {@@ -18,7 +19,11 @@ struct Build {bool paints_through_vulkan { false };// Vulkan images are shared between processes as dma-bufs.bool shares_vulkan_images { false };+ // H.264 and HEVC can be decoded through an FFmpeg the system has, rather than the bundled one.+ bool has_system_ffmpeg { false };+ // Video decoded through Vulkan reaches the Compositor as shared images.+ constexpr bool decodes_video_through_vulkan() const { return shares_vulkan_images; }constexpr bool includes(Feature feature) const{@@ -27,6 +32,13 @@ struct Build {return true;case Feature::YCbCrImport:return shares_vulkan_images;+ case Feature::VulkanVideo:+ case Feature::VulkanVideoBundledFFmpeg:+ case Feature::VulkanVideoBundledFFmpegDirectExport:+ return decodes_video_through_vulkan();+ case Feature::VulkanVideoSystemFFmpeg:+ case Feature::VulkanVideoSystemFFmpegDirectExport:+ return decodes_video_through_vulkan() && has_system_ffmpeg;}VERIFY_NOT_REACHED();}@@ -34,7 +46,7 @@ struct Build {// A build with every feature, so that tests can decide them all on any platform.static constexpr Build with_every_feature(){- return { .paints_through_vulkan = true, .shares_vulkan_images = true };+ return { .paints_through_vulkan = true, .shares_vulkan_images = true, .has_system_ffmpeg = true };}};@@ -52,11 +64,18 @@ constexpr bool shares_vulkan_images = true;constexpr bool shares_vulkan_images = false;#endif+#if defined(AK_OS_LINUX) && !defined(AK_OS_ANDROID)+constexpr bool has_system_ffmpeg = true;+#else+constexpr bool has_system_ffmpeg = false;+#endif+}constexpr Build this_build {.paints_through_vulkan = Detail::paints_through_vulkan,.shares_vulkan_images = Detail::shares_vulkan_images,+ .has_system_ffmpeg = Detail::has_system_ffmpeg,};}diff --git a/Libraries/LibPlatformFeatures/Feature.cpp b/Libraries/LibPlatformFeatures/Feature.cppindex 9b1c639f6f8..40f86abad63 100644--- a/Libraries/LibPlatformFeatures/Feature.cpp+++ b/Libraries/LibPlatformFeatures/Feature.cpp@@ -15,6 +15,16 @@ StringView feature_id(Feature feature)return "gpu_painting"sv;case Feature::YCbCrImport:return "ycbcr_import"sv;+ case Feature::VulkanVideo:+ return "vulkan_video"sv;+ case Feature::VulkanVideoBundledFFmpeg:+ return "vulkan_video.bundled_ffmpeg"sv;+ case Feature::VulkanVideoBundledFFmpegDirectExport:+ return "vulkan_video.bundled_ffmpeg.direct_export"sv;+ case Feature::VulkanVideoSystemFFmpeg:+ return "vulkan_video.system_ffmpeg"sv;+ case Feature::VulkanVideoSystemFFmpegDirectExport:+ return "vulkan_video.system_ffmpeg.direct_export"sv;}VERIFY_NOT_REACHED();}@@ -34,6 +44,12 @@ FeatureProcess process_of(Feature feature)case Feature::GpuPainting:case Feature::YCbCrImport:return FeatureProcess::Compositor;+ case Feature::VulkanVideo:+ case Feature::VulkanVideoBundledFFmpeg:+ case Feature::VulkanVideoBundledFFmpegDirectExport:+ case Feature::VulkanVideoSystemFFmpeg:+ case Feature::VulkanVideoSystemFFmpegDirectExport:+ return FeatureProcess::VideoDecoderServer;}VERIFY_NOT_REACHED();}@@ -45,6 +61,15 @@ Optional<Feature> dependency_of(Feature feature)return {};case Feature::YCbCrImport:return Feature::GpuPainting;+ case Feature::VulkanVideo:+ return Feature::YCbCrImport;+ case Feature::VulkanVideoBundledFFmpeg:+ case Feature::VulkanVideoSystemFFmpeg:+ return Feature::VulkanVideo;+ case Feature::VulkanVideoBundledFFmpegDirectExport:+ return Feature::VulkanVideoBundledFFmpeg;+ case Feature::VulkanVideoSystemFFmpegDirectExport:+ return Feature::VulkanVideoSystemFFmpeg;}VERIFY_NOT_REACHED();}@@ -54,6 +79,8 @@ StringView process_name(FeatureProcess process)switch (process) {case FeatureProcess::Compositor:return "Compositor"sv;+ case FeatureProcess::VideoDecoderServer:+ return "VideoDecoderServer"sv;}VERIFY_NOT_REACHED();}diff --git a/Libraries/LibPlatformFeatures/Feature.h b/Libraries/LibPlatformFeatures/Feature.hindex 1702068aa1c..5e0f19ecd8e 100644--- a/Libraries/LibPlatformFeatures/Feature.h+++ b/Libraries/LibPlatformFeatures/Feature.h@@ -16,17 +16,28 @@ namespace PlatformFeatures {// The process that uses a feature, and the only one told whether it is enabled.enum class FeatureProcess : u8 {Compositor,+ VideoDecoderServer,};// A feature is only enabled while the feature it depends on is, so each one is declared after its dependency.enum class Feature : u8 {GpuPainting,YCbCrImport,+ VulkanVideo,+ VulkanVideoBundledFFmpeg,+ VulkanVideoBundledFFmpegDirectExport,+ VulkanVideoSystemFFmpeg,+ VulkanVideoSystemFFmpegDirectExport,};constexpr Array all_features {Feature::GpuPainting,Feature::YCbCrImport,+ Feature::VulkanVideo,+ Feature::VulkanVideoBundledFFmpeg,+ Feature::VulkanVideoBundledFFmpegDirectExport,+ Feature::VulkanVideoSystemFFmpeg,+ Feature::VulkanVideoSystemFFmpegDirectExport,};StringView feature_id(Feature);diff --git a/Libraries/LibPlatformFeatures/SystemFacts.cpp b/Libraries/LibPlatformFeatures/SystemFacts.cppindex 97d63264288..9b0ec42a4ea 100644--- a/Libraries/LibPlatformFeatures/SystemFacts.cpp+++ b/Libraries/LibPlatformFeatures/SystemFacts.cpp@@ -13,6 +13,25 @@ namespace PlatformFeatures {// most 255 bytes, each of which may have become a three-byte replacement character.static constexpr size_t maximum_string_length = 1024;+static JsonObject video_decode_to_json(VideoDecodeFacts const& facts)+{+ JsonObject object;+ object.set("supported"sv, facts.supported);+ object.set("dpb_and_output_coincide"sv, facts.dpb_and_output_coincide);+ object.set("dpb_and_output_distinct"sv, facts.dpb_and_output_distinct);+ object.set("dpb_supports_drm_format_modifiers"sv, facts.dpb_supports_drm_format_modifiers);+ return object;+}++static JsonObject ffmpeg_to_json(FFmpegFacts const& facts)+{+ JsonObject object;+ object.set("avcodec_version"sv, facts.avcodec_version);+ object.set("avutil_version"sv, facts.avutil_version);+ object.set("shares_bundled_struct_layouts"sv, facts.shares_bundled_struct_layouts);+ return object;+}+JsonObject SystemFacts::to_json() const{JsonObject object;@@ -28,8 +47,18 @@ JsonObject SystemFacts::to_json() constgpu_object.set("api_version"sv, gpu->api_version);gpu_object.set("device_identity"sv, gpu->device_identity);gpu_object.set("supports_ycbcr_sampling"sv, gpu->supports_ycbcr_sampling);+ if (gpu->cannot_decode_video_because.has_value())+ gpu_object.set("cannot_decode_video_because"sv, *gpu->cannot_decode_video_because);+ gpu_object.set("h264"sv, video_decode_to_json(gpu->h264));+ gpu_object.set("h265"sv, video_decode_to_json(gpu->h265));+ gpu_object.set("vp9"sv, video_decode_to_json(gpu->vp9));+ gpu_object.set("av1"sv, video_decode_to_json(gpu->av1));object.set("gpu"sv, move(gpu_object));}+ if (bundled_ffmpeg.has_value())+ object.set("bundled_ffmpeg"sv, ffmpeg_to_json(*bundled_ffmpeg));+ if (system_ffmpeg.has_value())+ object.set("system_ffmpeg"sv, ffmpeg_to_json(*system_ffmpeg));return object;}@@ -59,6 +88,33 @@ static ErrorOr<String> read_string(JsonObject const& object, StringView key)return *value;}+static ErrorOr<JsonObject const*> read_object(JsonObject const& object, StringView key)+{+ auto value = object.get_object(key);+ if (!value.has_value())+ return Error::from_string_literal("System facts are missing an object");+ return &value.value();+}++static ErrorOr<VideoDecodeFacts> video_decode_from_json(JsonObject const& object)+{+ VideoDecodeFacts facts;+ facts.supported = TRY(read_bool(object, "supported"sv));+ facts.dpb_and_output_coincide = TRY(read_bool(object, "dpb_and_output_coincide"sv));+ facts.dpb_and_output_distinct = TRY(read_bool(object, "dpb_and_output_distinct"sv));+ facts.dpb_supports_drm_format_modifiers = TRY(read_bool(object, "dpb_supports_drm_format_modifiers"sv));+ return facts;+}++static ErrorOr<FFmpegFacts> ffmpeg_from_json(JsonObject const& object)+{+ FFmpegFacts facts;+ facts.avcodec_version = TRY(read_u32(object, "avcodec_version"sv));+ facts.avutil_version = TRY(read_u32(object, "avutil_version"sv));+ facts.shares_bundled_struct_layouts = TRY(read_bool(object, "shares_bundled_struct_layouts"sv));+ return facts;+}+ErrorOr<SystemFacts> SystemFacts::from_json(StringView json){auto value = TRY(JsonValue::from_string(json));@@ -71,22 +127,30 @@ ErrorOr<SystemFacts> SystemFacts::from_json(JsonObject const& object){SystemFacts facts;if (object.has("gpu"sv)) {- auto gpu_object = object.get_object("gpu"sv);- if (!gpu_object.has_value())- return Error::from_string_literal("The GPU's system facts are not an object");+ auto const& gpu_object = *TRY(read_object(object, "gpu"sv));GpuFacts gpu;- gpu.vendor_id = TRY(read_u32(*gpu_object, "vendor_id"sv));- gpu.device_id = TRY(read_u32(*gpu_object, "device_id"sv));- gpu.device_name = TRY(read_string(*gpu_object, "device_name"sv));- gpu.driver_id = TRY(read_u32(*gpu_object, "driver_id"sv));- gpu.driver_name = TRY(read_string(*gpu_object, "driver_name"sv));- gpu.driver_info = TRY(read_string(*gpu_object, "driver_info"sv));- gpu.driver_version = TRY(read_u32(*gpu_object, "driver_version"sv));- gpu.api_version = TRY(read_u32(*gpu_object, "api_version"sv));- gpu.device_identity = TRY(read_string(*gpu_object, "device_identity"sv));- gpu.supports_ycbcr_sampling = TRY(read_bool(*gpu_object, "supports_ycbcr_sampling"sv));+ gpu.vendor_id = TRY(read_u32(gpu_object, "vendor_id"sv));+ gpu.device_id = TRY(read_u32(gpu_object, "device_id"sv));+ gpu.device_name = TRY(read_string(gpu_object, "device_name"sv));+ gpu.driver_id = TRY(read_u32(gpu_object, "driver_id"sv));+ gpu.driver_name = TRY(read_string(gpu_object, "driver_name"sv));+ gpu.driver_info = TRY(read_string(gpu_object, "driver_info"sv));+ gpu.driver_version = TRY(read_u32(gpu_object, "driver_version"sv));+ gpu.api_version = TRY(read_u32(gpu_object, "api_version"sv));+ gpu.device_identity = TRY(read_string(gpu_object, "device_identity"sv));+ gpu.supports_ycbcr_sampling = TRY(read_bool(gpu_object, "supports_ycbcr_sampling"sv));+ if (gpu_object.has("cannot_decode_video_because"sv))+ gpu.cannot_decode_video_because = TRY(read_string(gpu_object, "cannot_decode_video_because"sv));+ gpu.h264 = TRY(video_decode_from_json(*TRY(read_object(gpu_object, "h264"sv))));+ gpu.h265 = TRY(video_decode_from_json(*TRY(read_object(gpu_object, "h265"sv))));+ gpu.vp9 = TRY(video_decode_from_json(*TRY(read_object(gpu_object, "vp9"sv))));+ gpu.av1 = TRY(video_decode_from_json(*TRY(read_object(gpu_object, "av1"sv))));facts.gpu = move(gpu);}+ if (object.has("bundled_ffmpeg"sv))+ facts.bundled_ffmpeg = TRY(ffmpeg_from_json(*TRY(read_object(object, "bundled_ffmpeg"sv))));+ if (object.has("system_ffmpeg"sv))+ facts.system_ffmpeg = TRY(ffmpeg_from_json(*TRY(read_object(object, "system_ffmpeg"sv))));return facts;}diff --git a/Libraries/LibPlatformFeatures/SystemFacts.h b/Libraries/LibPlatformFeatures/SystemFacts.hindex ea476692737..04c5642b0b3 100644--- a/Libraries/LibPlatformFeatures/SystemFacts.h+++ b/Libraries/LibPlatformFeatures/SystemFacts.h@@ -13,6 +13,18 @@namespace PlatformFeatures {+// What the GPU can do when decoding one codec through Vulkan, for its most common 8-bit 4:2:0 profile.+struct VideoDecodeFacts {+ bool supported { false };+ // VK_VIDEO_DECODE_CAPABILITY_DPB_AND_OUTPUT_COINCIDE_BIT_KHR and _DISTINCT_BIT_KHR.+ bool dpb_and_output_coincide { false };+ bool dpb_and_output_distinct { false };+ // Whether any format for images used only as references can be tiled under a DRM format modifier.+ bool dpb_supports_drm_format_modifiers { false };++ bool operator==(VideoDecodeFacts const&) const = default;+};+// The GPU that presents, as Vulkan describes it.struct GpuFacts {u32 vendor_id { 0 };@@ -28,13 +40,33 @@ struct GpuFacts {String device_identity;bool supports_ycbcr_sampling { false };+ // Set when the device lacks something decoding through FFmpeg needs.+ Optional<String> cannot_decode_video_because;+ VideoDecodeFacts h264;+ VideoDecodeFacts h265;+ VideoDecodeFacts vp9;+ VideoDecodeFacts av1;bool operator==(GpuFacts const&) const = default;};+struct FFmpegFacts {+ // The libraries' versions are packed like FFmpeg's AV_VERSION_INT.+ static constexpr u32 version(u32 major, u32 minor, u32 micro) { return major << 16 | minor << 8 | micro; }++ u32 avcodec_version { 0 };+ u32 avutil_version { 0 };+ // Whether the library lays out the structs the decoders reach into the way the bundled one does.+ bool shares_bundled_struct_layouts { false };++ bool operator==(FFmpegFacts const&) const = default;+};+// Everything the blocklist decides from, collected by the system probe.struct SystemFacts {Optional<GpuFacts> gpu;+ Optional<FFmpegFacts> bundled_ffmpeg;+ Optional<FFmpegFacts> system_ffmpeg;// Set instead of the facts when the probe crashed, hung or reported something unreadable. Never serialized.Optional<String> probe_failure;diff --git a/Libraries/LibWebView/Application.cpp b/Libraries/LibWebView/Application.cppindex 90546d9dc7f..e7332dffb95 100644--- a/Libraries/LibWebView/Application.cpp+++ b/Libraries/LibWebView/Application.cpp@@ -1936,7 +1936,7 @@ ErrorOr<void> Application::launch_services()return {};}-static constexpr u32 system_facts_cache_format = 1;+static constexpr u32 system_facts_cache_format = 2;static ByteString platform_features_cache_path(){@@ -2050,6 +2050,11 @@ void Application::when_platform_features_are_current(Function<void()> callback)callback();}+PlatformFeatures::ProcessFeatures Application::platform_features_for(FeatureProcess process) const+{+ return m_platform_feature_decisions->features_for(process);+}+ErrorOr<void> Application::launch_compositor_process(){VERIFY(!m_compositor_client);diff --git a/Libraries/LibWebView/Application.h b/Libraries/LibWebView/Application.hindex 6e7c9a57b8f..2abd8a813a0 100644--- a/Libraries/LibWebView/Application.h+++ b/Libraries/LibWebView/Application.h@@ -397,6 +397,7 @@ public:// Calls back once the features are decided from this launch's probe rather than from cached facts.void when_platform_features_are_current(Function<void()>);+ PlatformFeatures::ProcessFeatures platform_features_for(FeatureProcess) const;protected:explicit Application(Optional<ByteString> ladybird_binary_path = {});diff --git a/Libraries/LibWebView/HelperProcess.cpp b/Libraries/LibWebView/HelperProcess.cppindex 271f964689d..96a5f0738af 100644--- a/Libraries/LibWebView/HelperProcess.cpp+++ b/Libraries/LibWebView/HelperProcess.cpp@@ -500,6 +500,7 @@ ErrorOr<NonnullRefPtr<VideoDecoderServerControlClient>> launch_video_decoder_serarguments.append("--gpu-device"sv);arguments.append(gpu_device_identity->to_byte_string());}+ arguments.append(ByteString::formatted("--platform-features={}", WebView::Application::the().platform_features_for(PlatformFeatures::FeatureProcess::VideoDecoderServer).to_byte_string()));if (auto server = mach_server_name(); server.has_value()) {arguments.append("--mach-server-name"sv);arguments.append(server.value());@@ -697,10 +698,13 @@ ErrorOr<MediaServerClientConnection> connect_new_media_server_client(RefPtr<Medicontroller = TRY(launch_media_server_process(owner_child_id));controller->on_request_audio_server_connection = move(connect_audio_server);// Each MediaServer has a VideoDecoderServer of its own, which lives as long as the controller holding it. The- // server is launched once the Compositor has named the GPU that hardware decoders must output to.+ // server is launched once the Compositor has named the GPU that hardware decoders must output to, and once this+ // launch's probe has decided what the server may use there.controller->on_request_video_decoder_server_connection = [video_decoder_server = make_ref_counted<VideoDecoderServerHolder>(), owner_child_id](auto answer) {- Application::the().when_compositor_gpu_device_identity_is_known([video_decoder_server, owner_child_id, answer = move(answer)](auto const& gpu_device_identity) {- answer(connect_new_video_decoder_server_client(video_decoder_server->controller, owner_child_id, gpu_device_identity));+ Application::the().when_compositor_gpu_device_identity_is_known([video_decoder_server, owner_child_id, answer = move(answer)](auto const& gpu_device_identity) mutable {+ Application::the().when_platform_features_are_current([video_decoder_server, owner_child_id, gpu_device_identity, answer = move(answer)] {+ answer(connect_new_video_decoder_server_client(video_decoder_server->controller, owner_child_id, gpu_device_identity));+ });});};}diff --git a/Libraries/LibWebView/PlatformFeatureDecisions.cpp b/Libraries/LibWebView/PlatformFeatureDecisions.cppindex 751068bf72b..25f236ae094 100644--- a/Libraries/LibWebView/PlatformFeatureDecisions.cpp+++ b/Libraries/LibWebView/PlatformFeatureDecisions.cpp@@ -8,10 +8,35 @@namespace WebView {+using PlatformFeatures::FFmpegFacts;+using PlatformFeatures::VideoDecodeFacts;++// Until 63.20.101, FFmpeg gives a separate DPB the output's DRM format modifiers, which RADV lays out wrongly at some+// resolutions (#12902). FFmpeg decodes into a separate DPB on drivers that cannot decode into the output.+static bool system_ffmpeg_gives_a_separate_dpb_the_output_modifiers(SystemFacts const& facts)+{+ if (!facts.gpu.has_value() || !facts.system_ffmpeg.has_value())+ return false;+ if (facts.system_ffmpeg->avcodec_version >= FFmpegFacts::version(63, 20, 101))+ return false;+ auto uses_a_separate_dpb_without_modifiers = [](VideoDecodeFacts const& codec) {+ return codec.supported && !codec.dpb_and_output_coincide && !codec.dpb_supports_drm_format_modifiers;+ };+ return uses_a_separate_dpb_without_modifiers(facts.gpu->h264) || uses_a_separate_dpb_without_modifiers(facts.gpu->h265);+}++static constexpr Array s_blocklist_rules {+ BlocklistRule {+ "system-ffmpeg-separate-dpb-modifiers"sv,+ Feature::VulkanVideoSystemFFmpegDirectExport,+ "The system FFmpeg predates 63.20.101 and gives a separate DPB the output's DRM format modifiers, which corrupts video on RADV (#12902)"sv,+ system_ffmpeg_gives_a_separate_dpb_the_output_modifiers,+ },+};+ReadonlySpan<BlocklistRule> blocklist_rules(){- static constexpr Array<BlocklistRule, 0> rules {};- return rules;+ return s_blocklist_rules;}static Optional<String> missing_capability(Feature feature, SystemFacts const& facts, PlatformFeatures::Build const& build)@@ -31,6 +56,29 @@ static Optional<String> missing_capability(Feature feature, SystemFacts const& fif (!facts.gpu.has_value() || !facts.gpu->supports_ycbcr_sampling)return "The GPU does not support YCbCr sampling"_string;return {};+ case Feature::VulkanVideo:+ if (!facts.gpu.has_value())+ return "No Vulkan device was found"_string;+ if (facts.gpu->cannot_decode_video_because.has_value())+ return *facts.gpu->cannot_decode_video_because;+ return {};+ case Feature::VulkanVideoBundledFFmpeg:+ if (!facts.bundled_ffmpeg.has_value())+ return "The bundled FFmpeg was not described"_string;+ if (!facts.gpu.has_value() || !(facts.gpu->vp9.supported || facts.gpu->av1.supported))+ return "The GPU decodes neither VP9 nor AV1 through Vulkan"_string;+ return {};+ case Feature::VulkanVideoSystemFFmpeg:+ if (!facts.system_ffmpeg.has_value())+ return "No system FFmpeg was found"_string;+ if (!facts.system_ffmpeg->shares_bundled_struct_layouts)+ return "The system FFmpeg's structs are not laid out like the bundled one's"_string;+ if (!facts.gpu.has_value() || !(facts.gpu->h264.supported || facts.gpu->h265.supported))+ return "The GPU decodes neither H.264 nor HEVC through Vulkan"_string;+ return {};+ case Feature::VulkanVideoBundledFFmpegDirectExport:+ case Feature::VulkanVideoSystemFFmpegDirectExport:+ return {};}VERIFY_NOT_REACHED();}diff --git a/Services/SystemProbe/CMakeLists.txt b/Services/SystemProbe/CMakeLists.txtindex 028228e4dd5..b628fc5c8bc 100644--- a/Services/SystemProbe/CMakeLists.txt+++ b/Services/SystemProbe/CMakeLists.txt@@ -6,6 +6,10 @@ if (HAS_VULKAN)list(APPEND SOURCES VulkanDescription.cpp)endif()+if (USE_VULKAN_DMABUF_IMAGES)+ list(APPEND SOURCES FFmpegDescription.cpp VulkanVideoDescription.cpp)+endif()+add_executable(SystemProbe ${SOURCES})target_include_directories(SystemProbe PRIVATE ${LADYBIRD_SOURCE_DIR}/Services/)@@ -13,5 +17,8 @@ target_link_libraries(SystemProbe PRIVATE LibCore LibGfx LibMain LibPlatformFeatif (HAS_VULKAN)target_link_libraries(SystemProbe PRIVATE Vulkan::Vulkan)endif()+if (USE_VULKAN_DMABUF_IMAGES)+ target_link_libraries(SystemProbe PRIVATE LibMediaCodecs)+endif()ladybird_sign_helper_process(SystemProbe)diff --git a/Services/SystemProbe/FFmpegDescription.cpp b/Services/SystemProbe/FFmpegDescription.cppnew file mode 100644index 00000000000..c29fb7650a4--- /dev/null+++ b/Services/SystemProbe/FFmpegDescription.cpp@@ -0,0 +1,34 @@+/*+ * Copyright (c) 2026-present, the Ladybird developers.+ *+ * SPDX-License-Identifier: BSD-2-Clause+ */++#include <LibMediaCodecs/FFmpeg/FFmpegFunctions.h>+#include <LibMediaCodecs/FFmpeg/SystemFFmpeg.h>+#include <LibPlatformFeatures/Build.h>+#include <SystemProbe/FFmpegDescription.h>++static PlatformFeatures::FFmpegFacts describe_ffmpeg(Media::FFmpeg::FFmpegFunctions const& functions, bool shares_bundled_struct_layouts)+{+ return {+ .avcodec_version = functions.avcodec_version(),+ .avutil_version = functions.avutil_version(),+ .shares_bundled_struct_layouts = shares_bundled_struct_layouts,+ };+}++PlatformFeatures::FFmpegFacts describe_bundled_ffmpeg()+{+ return describe_ffmpeg(Media::FFmpeg::FFmpegFunctions::bundled(), true);+}++Optional<PlatformFeatures::FFmpegFacts> describe_system_ffmpeg()+{+ if constexpr (PlatformFeatures::this_build.has_system_ffmpeg) {+ Media::FFmpeg::SystemFFmpeg::load();+ if (auto const* system_ffmpeg = Media::FFmpeg::SystemFFmpeg::the())+ return describe_ffmpeg(system_ffmpeg->functions(), system_ffmpeg->shares_bundled_struct_layouts());+ }+ return {};+}diff --git a/Services/SystemProbe/FFmpegDescription.h b/Services/SystemProbe/FFmpegDescription.hnew file mode 100644index 00000000000..5cf335044f4--- /dev/null+++ b/Services/SystemProbe/FFmpegDescription.h@@ -0,0 +1,14 @@+/*+ * Copyright (c) 2026-present, the Ladybird developers.+ *+ * SPDX-License-Identifier: BSD-2-Clause+ */++#pragma once++#include <AK/Optional.h>+#include <LibPlatformFeatures/SystemFacts.h>++// Only builds that decode video through Vulkan define these.+PlatformFeatures::FFmpegFacts describe_bundled_ffmpeg();+Optional<PlatformFeatures::FFmpegFacts> describe_system_ffmpeg();diff --git a/Services/SystemProbe/VulkanDescription.cpp b/Services/SystemProbe/VulkanDescription.cppindex 827e20a7b6d..adbb457027a 100644--- a/Services/SystemProbe/VulkanDescription.cpp+++ b/Services/SystemProbe/VulkanDescription.cpp@@ -4,8 +4,9 @@* SPDX-License-Identifier: BSD-2-Clause*/-#include <LibGfx/VulkanContext.h>+#include <LibPlatformFeatures/Build.h>#include <SystemProbe/VulkanDescription.h>+#include <SystemProbe/VulkanVideoDescription.h>#include <string.h>static String string_from_driver(char const* characters, size_t capacity)@@ -56,5 +57,9 @@ Optional<PlatformFeatures::GpuFacts> describe_gpu_through_vulkan(Optional<Gfx::Ggpu.api_version = properties.properties.apiVersion;gpu.device_identity = MUST(String::from_byte_string(Gfx::gpu_device_identity_of(physical_device.value()).to_byte_string()));gpu.supports_ycbcr_sampling = Gfx::device_can_sample_through_ycbcr_conversion(physical_device.value());+ if constexpr (PlatformFeatures::this_build.decodes_video_through_vulkan())+ describe_video_decoding_through_vulkan(gpu, instance, physical_device.value());+ else+ gpu.cannot_decode_video_because = "Video is not decoded through Vulkan on this platform"_string;return gpu;}diff --git a/Services/SystemProbe/VulkanDescription.h b/Services/SystemProbe/VulkanDescription.hindex 1771e87e110..098106d26e5 100644--- a/Services/SystemProbe/VulkanDescription.h+++ b/Services/SystemProbe/VulkanDescription.h@@ -10,5 +10,5 @@#include <LibGfx/GpuDeviceIdentity.h>#include <LibPlatformFeatures/SystemFacts.h>-// Only builds that paint through Vulkan define these.+// Only builds that paint through Vulkan define this.Optional<PlatformFeatures::GpuFacts> describe_gpu_through_vulkan(Optional<Gfx::GpuDeviceIdentity> const& preferred_device);diff --git a/Services/SystemProbe/VulkanVideoDescription.cpp b/Services/SystemProbe/VulkanVideoDescription.cppnew file mode 100644index 00000000000..6678b7d61f2--- /dev/null+++ b/Services/SystemProbe/VulkanVideoDescription.cpp@@ -0,0 +1,113 @@+/*+ * Copyright (c) 2026-present, the Ladybird developers.+ *+ * SPDX-License-Identifier: BSD-2-Clause+ */++#include <AK/AnyOf.h>+#include <AK/Vector.h>+#include <LibMediaCodecs/Vulkan/VulkanVideoDevice.h>+#include <SystemProbe/VulkanVideoDescription.h>++struct VideoDecodeQuery {+ VkPhysicalDevice physical_device { VK_NULL_HANDLE };+ Vector<VkExtensionProperties> extensions;+ PFN_vkGetPhysicalDeviceVideoCapabilitiesKHR get_capabilities { nullptr };+ PFN_vkGetPhysicalDeviceVideoFormatPropertiesKHR get_formats { nullptr };+};++// Asks about the codec's 8-bit 4:2:0 profile, which every stream the decoders take in that codec can be decoded under.+static PlatformFeatures::VideoDecodeFacts describe_video_decoding(VideoDecodeQuery const& query, StringView extension, VkVideoCodecOperationFlagBitsKHR operation, void* codec_profile, void* codec_capabilities)+{+ PlatformFeatures::VideoDecodeFacts facts;+ auto has_extension = any_of(query.extensions, [&](auto const& properties) { return StringView { properties.extensionName, strlen(properties.extensionName) } == extension; });+ if (!has_extension || query.get_capabilities == nullptr || query.get_formats == nullptr)+ return facts;++ VkVideoProfileInfoKHR profile {};+ profile.sType = VK_STRUCTURE_TYPE_VIDEO_PROFILE_INFO_KHR;+ profile.pNext = codec_profile;+ profile.videoCodecOperation = operation;+ profile.chromaSubsampling = VK_VIDEO_CHROMA_SUBSAMPLING_420_BIT_KHR;+ profile.lumaBitDepth = VK_VIDEO_COMPONENT_BIT_DEPTH_8_BIT_KHR;+ profile.chromaBitDepth = VK_VIDEO_COMPONENT_BIT_DEPTH_8_BIT_KHR;++ VkVideoDecodeCapabilitiesKHR decode_capabilities {};+ decode_capabilities.sType = VK_STRUCTURE_TYPE_VIDEO_DECODE_CAPABILITIES_KHR;+ decode_capabilities.pNext = codec_capabilities;+ VkVideoCapabilitiesKHR capabilities {};+ capabilities.sType = VK_STRUCTURE_TYPE_VIDEO_CAPABILITIES_KHR;+ capabilities.pNext = &decode_capabilities;+ if (query.get_capabilities(query.physical_device, &profile, &capabilities) != VK_SUCCESS)+ return facts;++ facts.supported = true;+ facts.dpb_and_output_coincide = (decode_capabilities.flags & VK_VIDEO_DECODE_CAPABILITY_DPB_AND_OUTPUT_COINCIDE_BIT_KHR) != 0;+ facts.dpb_and_output_distinct = (decode_capabilities.flags & VK_VIDEO_DECODE_CAPABILITY_DPB_AND_OUTPUT_DISTINCT_BIT_KHR) != 0;++ VkVideoProfileListInfoKHR profile_list {};+ profile_list.sType = VK_STRUCTURE_TYPE_VIDEO_PROFILE_LIST_INFO_KHR;+ profile_list.profileCount = 1;+ profile_list.pProfiles = &profile;+ VkPhysicalDeviceVideoFormatInfoKHR format_info {};+ format_info.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VIDEO_FORMAT_INFO_KHR;+ format_info.pNext = &profile_list;+ format_info.imageUsage = VK_IMAGE_USAGE_VIDEO_DECODE_DPB_BIT_KHR;+ u32 format_count = 0;+ if (query.get_formats(query.physical_device, &format_info, &format_count, nullptr) != VK_SUCCESS)+ return facts;+ Vector<VkVideoFormatPropertiesKHR> formats;+ formats.resize(format_count);+ for (auto& format : formats)+ format.sType = VK_STRUCTURE_TYPE_VIDEO_FORMAT_PROPERTIES_KHR;+ if (query.get_formats(query.physical_device, &format_info, &format_count, formats.data()) != VK_SUCCESS)+ return facts;+ facts.dpb_supports_drm_format_modifiers = any_of(formats, [](auto const& format) { return format.imageTiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT; });+ return facts;+}++void describe_video_decoding_through_vulkan(PlatformFeatures::GpuFacts& gpu, VkInstance instance, VkPhysicalDevice physical_device)+{+ if (auto result = Media::VulkanVideoDevice::check_can_decode_video(physical_device); result.is_error()) {+ gpu.cannot_decode_video_because = MUST(String::from_utf8(result.error().string_literal()));+ return;+ }++ VideoDecodeQuery query;+ query.physical_device = physical_device;+ u32 extension_count = 0;+ vkEnumerateDeviceExtensionProperties(physical_device, nullptr, &extension_count, nullptr);+ query.extensions.resize(extension_count);+ vkEnumerateDeviceExtensionProperties(physical_device, nullptr, &extension_count, query.extensions.data());+ query.get_capabilities = reinterpret_cast<PFN_vkGetPhysicalDeviceVideoCapabilitiesKHR>(vkGetInstanceProcAddr(instance, "vkGetPhysicalDeviceVideoCapabilitiesKHR"));+ query.get_formats = reinterpret_cast<PFN_vkGetPhysicalDeviceVideoFormatPropertiesKHR>(vkGetInstanceProcAddr(instance, "vkGetPhysicalDeviceVideoFormatPropertiesKHR"));++ VkVideoDecodeH264ProfileInfoKHR h264_profile {};+ h264_profile.sType = VK_STRUCTURE_TYPE_VIDEO_DECODE_H264_PROFILE_INFO_KHR;+ h264_profile.stdProfileIdc = STD_VIDEO_H264_PROFILE_IDC_HIGH;+ h264_profile.pictureLayout = VK_VIDEO_DECODE_H264_PICTURE_LAYOUT_PROGRESSIVE_KHR;+ VkVideoDecodeH264CapabilitiesKHR h264_capabilities {};+ h264_capabilities.sType = VK_STRUCTURE_TYPE_VIDEO_DECODE_H264_CAPABILITIES_KHR;+ gpu.h264 = describe_video_decoding(query, VK_KHR_VIDEO_DECODE_H264_EXTENSION_NAME ""sv, VK_VIDEO_CODEC_OPERATION_DECODE_H264_BIT_KHR, &h264_profile, &h264_capabilities);++ VkVideoDecodeH265ProfileInfoKHR h265_profile {};+ h265_profile.sType = VK_STRUCTURE_TYPE_VIDEO_DECODE_H265_PROFILE_INFO_KHR;+ h265_profile.stdProfileIdc = STD_VIDEO_H265_PROFILE_IDC_MAIN;+ VkVideoDecodeH265CapabilitiesKHR h265_capabilities {};+ h265_capabilities.sType = VK_STRUCTURE_TYPE_VIDEO_DECODE_H265_CAPABILITIES_KHR;+ gpu.h265 = describe_video_decoding(query, VK_KHR_VIDEO_DECODE_H265_EXTENSION_NAME ""sv, VK_VIDEO_CODEC_OPERATION_DECODE_H265_BIT_KHR, &h265_profile, &h265_capabilities);++ VkVideoDecodeVP9ProfileInfoKHR vp9_profile {};+ vp9_profile.sType = VK_STRUCTURE_TYPE_VIDEO_DECODE_VP9_PROFILE_INFO_KHR;+ vp9_profile.stdProfile = STD_VIDEO_VP9_PROFILE_0;+ VkVideoDecodeVP9CapabilitiesKHR vp9_capabilities {};+ vp9_capabilities.sType = VK_STRUCTURE_TYPE_VIDEO_DECODE_VP9_CAPABILITIES_KHR;+ gpu.vp9 = describe_video_decoding(query, VK_KHR_VIDEO_DECODE_VP9_EXTENSION_NAME ""sv, VK_VIDEO_CODEC_OPERATION_DECODE_VP9_BIT_KHR, &vp9_profile, &vp9_capabilities);++ VkVideoDecodeAV1ProfileInfoKHR av1_profile {};+ av1_profile.sType = VK_STRUCTURE_TYPE_VIDEO_DECODE_AV1_PROFILE_INFO_KHR;+ av1_profile.stdProfile = STD_VIDEO_AV1_PROFILE_MAIN;+ VkVideoDecodeAV1CapabilitiesKHR av1_capabilities {};+ av1_capabilities.sType = VK_STRUCTURE_TYPE_VIDEO_DECODE_AV1_CAPABILITIES_KHR;+ gpu.av1 = describe_video_decoding(query, VK_KHR_VIDEO_DECODE_AV1_EXTENSION_NAME ""sv, VK_VIDEO_CODEC_OPERATION_DECODE_AV1_BIT_KHR, &av1_profile, &av1_capabilities);+}diff --git a/Services/SystemProbe/VulkanVideoDescription.h b/Services/SystemProbe/VulkanVideoDescription.hnew file mode 100644index 00000000000..0a4af5aacb8--- /dev/null+++ b/Services/SystemProbe/VulkanVideoDescription.h@@ -0,0 +1,13 @@+/*+ * Copyright (c) 2026-present, the Ladybird developers.+ *+ * SPDX-License-Identifier: BSD-2-Clause+ */++#pragma once++#include <LibGfx/VulkanContext.h>+#include <LibPlatformFeatures/SystemFacts.h>++// Only builds that decode video through Vulkan define this.+void describe_video_decoding_through_vulkan(PlatformFeatures::GpuFacts&, VkInstance, VkPhysicalDevice);diff --git a/Services/SystemProbe/main.cpp b/Services/SystemProbe/main.cppindex ccfc5c7f725..3caf0c2400a 100644--- a/Services/SystemProbe/main.cpp+++ b/Services/SystemProbe/main.cpp@@ -10,6 +10,7 @@#include <LibMain/Main.h>#include <LibPlatformFeatures/Build.h>#include <LibPlatformFeatures/SystemFacts.h>+#include <SystemProbe/FFmpegDescription.h>#include <SystemProbe/VulkanDescription.h>// Describes the system for the Browser's feature blocklist, and exits. It takes nothing but its arguments and writes@@ -33,6 +34,10 @@ ErrorOr<int> ladybird_main(Main::Arguments arguments)PlatformFeatures::SystemFacts facts;if constexpr (PlatformFeatures::this_build.paints_through_vulkan)facts.gpu = describe_gpu_through_vulkan(preferred_device);+ if constexpr (PlatformFeatures::this_build.decodes_video_through_vulkan()) {+ facts.bundled_ffmpeg = describe_bundled_ffmpeg();+ facts.system_ffmpeg = describe_system_ffmpeg();+ }auto report = facts.to_json().serialized();auto output = TRY(Core::File::standard_output());diff --git a/Services/VideoDecoderServer/CMakeLists.txt b/Services/VideoDecoderServer/CMakeLists.txtindex d3cefc2dcc9..4abd89233e5 100644--- a/Services/VideoDecoderServer/CMakeLists.txt+++ b/Services/VideoDecoderServer/CMakeLists.txt@@ -21,7 +21,7 @@ add_dependencies(videodecoderserverservicetarget_include_directories(videodecoderserverservice PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/../..)target_include_directories(videodecoderserverservice PRIVATE ${LADYBIRD_SOURCE_DIR}/Services/)-target_link_libraries(VideoDecoderServer PRIVATE videodecoderserverservice LibCore LibGfx LibMain LibMediaCodecs LibSandbox)+target_link_libraries(VideoDecoderServer PRIVATE videodecoderserverservice LibCore LibGfx LibMain LibMediaCodecs LibPlatformFeatures LibSandbox)target_link_libraries(videodecoderserverservice PRIVATE LibCore LibIPC LibMediaCodecs)if (WIN32)diff --git a/Services/VideoDecoderServer/main.cpp b/Services/VideoDecoderServer/main.cppindex cf647c50aba..5c175af44fa 100644--- a/Services/VideoDecoderServer/main.cpp+++ b/Services/VideoDecoderServer/main.cpp@@ -19,6 +19,7 @@#include <LibMediaCodecs/HardwareVideoDecoders.h>#include <LibMediaCodecs/VideoDecoderRegistry.h>#include <LibMediaCodecs/Vulkan/VulkanVideoDevice.h>+#include <LibPlatformFeatures/ProcessFeatures.h>#include <VideoDecoderServer/ControlConnection.h>#include <VideoDecoderServer/Sandbox.h>@@ -52,6 +53,7 @@ ErrorOr<int> ladybird_main(Main::Arguments arguments)bool disable_sandbox = false;bool host_software_decoders = false;StringView gpu_device;+ StringView platform_features;Core::ArgsParser args_parser;args_parser.add_option(stats_log_directory, "Directory for process statistics logs", "stats-log-dir", 0, "directory");@@ -61,8 +63,12 @@ ErrorOr<int> ladybird_main(Main::Arguments arguments)args_parser.add_option(disable_sandbox, "Disable process sandboxing", "disable-sandbox");args_parser.add_option(host_software_decoders, "Host software decoders, for testing", "host-software-decoders");args_parser.add_option(gpu_device, "The GPU to decode on, as the Compositor identifies it", "gpu-device", 0, "identity");+ args_parser.add_option(platform_features, "The platform features the Browser decided this process may use", "platform-features", 0, "feature,...");args_parser.parse(arguments);+ PlatformFeatures::ProcessFeatures::initialize_for_current_process(TRY(PlatformFeatures::ProcessFeatures::from_string(PlatformFeatures::FeatureProcess::VideoDecoderServer, platform_features)));+ auto const& features = PlatformFeatures::ProcessFeatures::the();+if (crash_report_fd >= 0) {if (auto result = Core::CrashHandler::initialize(crash_report_fd); result.is_error())warnln("Could not install crash report handler: {}", result.error());@@ -80,7 +86,7 @@ ErrorOr<int> ladybird_main(Main::Arguments arguments)auto stats_log = TRY(Core::StatsLog::create(stats_log_directory, "VideoDecoderServer"sv));Optional<Gfx::GpuDeviceIdentity> gpu_device_identity;- if (!gpu_device.is_empty()) {+ if (!gpu_device.is_empty() && features.is_enabled(PlatformFeatures::Feature::VulkanVideo)) {gpu_device_identity = Gfx::GpuDeviceIdentity::from_string(gpu_device);if (!gpu_device_identity.has_value())return Error::from_string_literal("Malformed GPU device identity");diff --git a/Tests/LibWebView/TestPlatformFeatures.cpp b/Tests/LibWebView/TestPlatformFeatures.cppindex f8b77f4e28d..05a50c24553 100644--- a/Tests/LibWebView/TestPlatformFeatures.cpp+++ b/Tests/LibWebView/TestPlatformFeatures.cpp@@ -8,8 +8,10 @@#include <LibWebView/PlatformFeatureDecisions.h>using PlatformFeatures::Build;+using PlatformFeatures::FFmpegFacts;using PlatformFeatures::GpuFacts;using PlatformFeatures::ProcessFeatures;+using PlatformFeatures::VideoDecodeFacts;using WebView::BlocklistRule;using WebView::Feature;using WebView::FeatureOverrides;@@ -18,8 +20,13 @@ using WebView::FeatureStatus;using WebView::PlatformFeatureDecisions;using WebView::SystemFacts;-static SystemFacts facts_with_a_gpu()+static constexpr FFmpegFacts ffmpeg_9_0 { .avcodec_version = FFmpegFacts::version(63, 1, 102), .avutil_version = FFmpegFacts::version(61, 1, 102), .shares_bundled_struct_layouts = true };++// As NVIDIA's driver reports them: references are decoded into the output, and no modifier tiles a DPB.+static SystemFacts facts_with_a_coinciding_dpb(){+ VideoDecodeFacts coinciding_dpb { .supported = true, .dpb_and_output_coincide = true, .dpb_and_output_distinct = false, .dpb_supports_drm_format_modifiers = false };+GpuFacts gpu;gpu.vendor_id = 0x10de;gpu.device_id = 0x2204;@@ -31,9 +38,34 @@ static SystemFacts facts_with_a_gpu()gpu.api_version = 0x4040df;gpu.device_identity = "7709ab0ea273f34e0bb993d4328b5309"_string;gpu.supports_ycbcr_sampling = true;+ gpu.h264 = coinciding_dpb;+ gpu.h265 = coinciding_dpb;+ gpu.vp9 = coinciding_dpb;+ gpu.av1 = coinciding_dpb;SystemFacts facts;facts.gpu = move(gpu);+ facts.bundled_ffmpeg = ffmpeg_9_0;+ facts.system_ffmpeg = ffmpeg_9_0;+ return facts;+}++// RADV on RDNA2 decodes into images apart from its references, which it cannot tile under a modifier.+static SystemFacts facts_with_a_separate_dpb()+{+ VideoDecodeFacts separate_dpb { .supported = true, .dpb_and_output_coincide = false, .dpb_and_output_distinct = true, .dpb_supports_drm_format_modifiers = false };++ auto facts = facts_with_a_coinciding_dpb();+ facts.gpu->vendor_id = 0x1002;+ facts.gpu->device_id = 0x73df;+ facts.gpu->device_name = "AMD Radeon RX 6700 XT (RADV NAVI22)"_string;+ facts.gpu->driver_id = 3;+ facts.gpu->driver_name = "radv"_string;+ facts.gpu->driver_info = "Mesa 26.2.5"_string;+ facts.gpu->h264 = separate_dpb;+ facts.gpu->h265 = separate_dpb;+ facts.gpu->vp9 = separate_dpb;+ facts.gpu->av1 = separate_dpb;return facts;}@@ -46,11 +78,16 @@ static constexpr Array test_rules {BlocklistRule { "test-nvidia-ycbcr"sv, Feature::YCbCrImport, "NVIDIA cannot import video, for this test"sv, matches_nvidia },};-static PlatformFeatureDecisions evaluate(SystemFacts const& facts, FeatureOverrides const& overrides = {}, HashMap<Feature, String> const& runtime_failures = {})+static PlatformFeatureDecisions evaluate_with_test_rules(SystemFacts const& facts, FeatureOverrides const& overrides = {}, HashMap<Feature, String> const& runtime_failures = {}){return PlatformFeatureDecisions::evaluate(facts, overrides, runtime_failures, test_rules, Build::with_every_feature());}+static PlatformFeatureDecisions evaluate(SystemFacts const& facts, FeatureOverrides const& overrides = {})+{+ return PlatformFeatureDecisions::evaluate(facts, overrides, {}, WebView::blocklist_rules(), Build::with_every_feature());+}+TEST_CASE(every_dependency_is_declared_before_its_dependents){for (auto feature : PlatformFeatures::all_features) {@@ -82,27 +119,27 @@ TEST_CASE(a_feature_the_build_lacks_is_never_enabled)TEST_CASE(a_matching_rule_blocklists_its_feature){- auto decisions = evaluate(facts_with_a_gpu());+ auto decisions = evaluate_with_test_rules(facts_with_a_coinciding_dpb());EXPECT(decisions.is_enabled(Feature::GpuPainting));auto const& status = decisions.status_of(Feature::YCbCrImport);EXPECT_EQ(status.state, FeatureStatus::State::Blocklisted);EXPECT_EQ(status.rule_id, "test-nvidia-ycbcr"sv);- auto facts = facts_with_a_gpu();- facts.gpu->vendor_id = 0x1002;- EXPECT(evaluate(facts).is_enabled(Feature::YCbCrImport));+ EXPECT(evaluate_with_test_rules(facts_with_a_separate_dpb()).is_enabled(Feature::YCbCrImport));}TEST_CASE(without_a_gpu_nothing_is_enabled){- SystemFacts facts;+ auto facts = facts_with_a_coinciding_dpb();+ facts.gpu.clear();auto decisions = evaluate(facts);EXPECT_EQ(decisions.status_of(Feature::GpuPainting).state, FeatureStatus::State::Unsupported);- auto const& status = decisions.status_of(Feature::YCbCrImport);- EXPECT_EQ(status.state, FeatureStatus::State::BlockedByDependency);- EXPECT_EQ(status.blocking_feature, Feature::GpuPainting);+ for (auto feature : PlatformFeatures::all_features) {+ if (feature != Feature::GpuPainting)+ EXPECT_EQ(decisions.status_of(feature).blocking_feature, Feature::GpuPainting);+ }}TEST_CASE(a_failed_probe_turns_off_gpu_painting)@@ -115,21 +152,117 @@ TEST_CASE(a_failed_probe_turns_off_gpu_painting)EXPECT(status.reason.contains("The probe crashed"sv));}-TEST_CASE(a_missing_capability_is_unsupported_rather_than_blocklisted)+TEST_CASE(a_missing_capability_blocks_dependents_with_the_root_cause)+{+ auto facts = facts_with_a_separate_dpb();+ facts.gpu->supports_ycbcr_sampling = false;+ auto decisions = evaluate(facts);++ EXPECT(decisions.is_enabled(Feature::GpuPainting));+ EXPECT_EQ(decisions.status_of(Feature::YCbCrImport).state, FeatureStatus::State::Unsupported);+ for (auto feature : { Feature::VulkanVideo, Feature::VulkanVideoSystemFFmpeg, Feature::VulkanVideoSystemFFmpegDirectExport }) {+ auto const& status = decisions.status_of(feature);+ EXPECT_EQ(status.state, FeatureStatus::State::BlockedByDependency);+ EXPECT_EQ(status.blocking_feature, Feature::YCbCrImport);+ }+}++TEST_CASE(old_system_ffmpeg_with_a_separate_dpb_blocks_only_its_direct_export)+{+ auto decisions = evaluate(facts_with_a_separate_dpb());++ auto const& status = decisions.status_of(Feature::VulkanVideoSystemFFmpegDirectExport);+ EXPECT_EQ(status.state, FeatureStatus::State::Blocklisted);+ EXPECT_EQ(status.rule_id, "system-ffmpeg-separate-dpb-modifiers"sv);++ EXPECT(decisions.is_enabled(Feature::VulkanVideoSystemFFmpeg));+ EXPECT(decisions.is_enabled(Feature::VulkanVideoBundledFFmpegDirectExport));+}++TEST_CASE(fixed_system_ffmpeg_exports_directly)+{+ auto facts = facts_with_a_separate_dpb();+ facts.system_ffmpeg->avcodec_version = FFmpegFacts::version(63, 20, 101);+ EXPECT(evaluate(facts).is_enabled(Feature::VulkanVideoSystemFFmpegDirectExport));+}++TEST_CASE(a_coinciding_dpb_exports_directly_on_old_system_ffmpeg)+{+ EXPECT(evaluate(facts_with_a_coinciding_dpb()).is_enabled(Feature::VulkanVideoSystemFFmpegDirectExport));+}++TEST_CASE(a_gpu_that_cannot_decode_turns_off_vulkan_video)+{+ auto facts = facts_with_a_coinciding_dpb();+ facts.gpu->cannot_decode_video_because = "The GPU's Vulkan is older than 1.3"_string;+ auto decisions = evaluate(facts);++ auto const& status = decisions.status_of(Feature::VulkanVideo);+ EXPECT_EQ(status.state, FeatureStatus::State::Unsupported);+ EXPECT_EQ(status.reason, "The GPU's Vulkan is older than 1.3"sv);+ EXPECT(decisions.is_enabled(Feature::YCbCrImport));+}++TEST_CASE(each_ffmpeg_needs_a_codec_the_gpu_decodes)+{+ auto facts = facts_with_a_coinciding_dpb();+ facts.gpu->h264.supported = false;+ facts.gpu->h265.supported = false;+ auto decisions = evaluate(facts);+ EXPECT_EQ(decisions.status_of(Feature::VulkanVideoSystemFFmpeg).state, FeatureStatus::State::Unsupported);+ EXPECT(decisions.is_enabled(Feature::VulkanVideoBundledFFmpeg));+}++TEST_CASE(system_ffmpeg_needs_matching_struct_layouts){- auto facts = facts_with_a_gpu();+ auto facts = facts_with_a_coinciding_dpb();+ facts.system_ffmpeg->shares_bundled_struct_layouts = false;+ auto decisions = evaluate(facts);+ EXPECT_EQ(decisions.status_of(Feature::VulkanVideoSystemFFmpeg).state, FeatureStatus::State::Unsupported);+ EXPECT(decisions.is_enabled(Feature::VulkanVideoBundledFFmpeg));++ facts.system_ffmpeg.clear();+ EXPECT_EQ(evaluate(facts).status_of(Feature::VulkanVideoSystemFFmpeg).state, FeatureStatus::State::Unsupported);+}++TEST_CASE(force_enabling_cannot_supply_a_capability)+{+ auto facts = facts_with_a_coinciding_dpb();facts.gpu->supports_ycbcr_sampling = false;- EXPECT_EQ(evaluate(facts).status_of(Feature::YCbCrImport).state, FeatureStatus::State::Unsupported);+ FeatureOverrides overrides;+ overrides.force_enabled.set(Feature::YCbCrImport);+ EXPECT_EQ(evaluate(facts, overrides).status_of(Feature::YCbCrImport).state, FeatureStatus::State::Unsupported);+}++TEST_CASE(force_enabling_overrides_the_blocklist)+{+ FeatureOverrides overrides;+ overrides.force_enabled.set(Feature::VulkanVideoSystemFFmpegDirectExport);+ auto decisions = evaluate(facts_with_a_separate_dpb(), overrides);+ EXPECT(decisions.is_enabled(Feature::VulkanVideoSystemFFmpegDirectExport));+ EXPECT(decisions.status_of(Feature::VulkanVideoSystemFFmpegDirectExport).forced);+ EXPECT_EQ(decisions.status_of(Feature::VulkanVideoSystemFFmpegDirectExport).rule_id, "system-ffmpeg-separate-dpb-modifiers"sv);+}++TEST_CASE(each_process_is_given_only_its_own_features)+{+ auto decisions = evaluate(facts_with_a_separate_dpb());+ EXPECT_EQ(decisions.features_for(FeatureProcess::Compositor).to_byte_string(), "gpu_painting,ycbcr_import"sv);+ EXPECT_EQ(decisions.features_for(FeatureProcess::VideoDecoderServer).to_byte_string(),+ "vulkan_video,vulkan_video.bundled_ffmpeg,vulkan_video.bundled_ffmpeg.direct_export,vulkan_video.system_ffmpeg"sv);}TEST_CASE(disabling_a_feature_turns_off_its_dependents_with_the_root_cause){FeatureOverrides overrides;overrides.disabled.set(Feature::GpuPainting);- auto decisions = evaluate(facts_with_a_gpu(), overrides);+ auto decisions = evaluate_with_test_rules(facts_with_a_coinciding_dpb(), overrides);EXPECT_EQ(decisions.status_of(Feature::GpuPainting).state, FeatureStatus::State::DisabledByUser);- EXPECT_EQ(decisions.status_of(Feature::YCbCrImport).blocking_feature, Feature::GpuPainting);+ for (auto feature : PlatformFeatures::all_features) {+ if (feature != Feature::GpuPainting)+ EXPECT_EQ(decisions.status_of(feature).blocking_feature, Feature::GpuPainting);+ }}TEST_CASE(force_enabling_overrides_rules_and_disables)@@ -137,16 +270,14 @@ TEST_CASE(force_enabling_overrides_rules_and_disables)FeatureOverrides overrides;overrides.force_enabled.set(Feature::YCbCrImport);overrides.disabled.set(Feature::YCbCrImport);- auto decisions = evaluate(facts_with_a_gpu(), overrides);+ auto decisions = evaluate_with_test_rules(facts_with_a_coinciding_dpb(), overrides);EXPECT(decisions.is_enabled(Feature::YCbCrImport));EXPECT(decisions.status_of(Feature::YCbCrImport).forced);EXPECT_EQ(decisions.status_of(Feature::YCbCrImport).rule_id, "test-nvidia-ycbcr"sv);overrides.disabled.clear();- auto facts = facts_with_a_gpu();- facts.gpu->vendor_id = 0x1002;- decisions = evaluate(facts, overrides);+ decisions = evaluate_with_test_rules(facts_with_a_separate_dpb(), overrides);EXPECT(!decisions.status_of(Feature::YCbCrImport).forced);EXPECT(decisions.status_of(Feature::YCbCrImport).reason.is_empty());}@@ -155,7 +286,7 @@ TEST_CASE(a_disabled_feature_still_names_the_rule_that_matched_it){FeatureOverrides overrides;overrides.disabled.set(Feature::YCbCrImport);- auto decisions = evaluate(facts_with_a_gpu(), overrides);+ auto decisions = evaluate_with_test_rules(facts_with_a_coinciding_dpb(), overrides);auto const& status = decisions.status_of(Feature::YCbCrImport);EXPECT_EQ(status.state, FeatureStatus::State::DisabledByUser);EXPECT_EQ(status.rule_id, "test-nvidia-ycbcr"sv);@@ -166,27 +297,18 @@ TEST_CASE(force_enabling_does_not_reach_past_a_dependency)FeatureOverrides overrides;overrides.disabled.set(Feature::GpuPainting);overrides.force_enabled.set(Feature::YCbCrImport);- auto decisions = evaluate(facts_with_a_gpu(), overrides);+ auto decisions = evaluate_with_test_rules(facts_with_a_coinciding_dpb(), overrides);EXPECT_EQ(decisions.status_of(Feature::YCbCrImport).state, FeatureStatus::State::BlockedByDependency);}-TEST_CASE(force_enabling_cannot_supply_a_capability)-{- auto facts = facts_with_a_gpu();- facts.gpu->supports_ycbcr_sampling = false;- FeatureOverrides overrides;- overrides.force_enabled.set(Feature::YCbCrImport);- EXPECT_EQ(evaluate(facts, overrides).status_of(Feature::YCbCrImport).state, FeatureStatus::State::Unsupported);-}-TEST_CASE(runtime_failures_win_over_force_enabling){FeatureOverrides overrides;overrides.force_enabled.set(Feature::GpuPainting);HashMap<Feature, String> runtime_failures;runtime_failures.set(Feature::GpuPainting, "The Compositor crashed repeatedly"_string);- auto decisions = evaluate(facts_with_a_gpu(), overrides, runtime_failures);+ auto decisions = evaluate_with_test_rules(facts_with_a_coinciding_dpb(), overrides, runtime_failures);EXPECT_EQ(decisions.status_of(Feature::GpuPainting).state, FeatureStatus::State::FailedAtRuntime);EXPECT_EQ(decisions.status_of(Feature::YCbCrImport).blocking_feature, Feature::GpuPainting);@@ -194,46 +316,44 @@ TEST_CASE(runtime_failures_win_over_force_enabling)TEST_CASE(overrides_that_turn_everything_off_need_no_facts){- EXPECT(!PlatformFeatureDecisions::decides_without_facts(FeatureProcess::Compositor, {}, Build::with_every_feature()));-- FeatureOverrides overrides;- overrides.disabled.set(Feature::GpuPainting);- EXPECT(PlatformFeatureDecisions::decides_without_facts(FeatureProcess::Compositor, overrides, Build::with_every_feature()));+ for (auto process : { FeatureProcess::Compositor, FeatureProcess::VideoDecoderServer }) {+ EXPECT(!PlatformFeatureDecisions::decides_without_facts(process, {}, Build::with_every_feature()));- overrides.force_enabled.set(Feature::GpuPainting);- EXPECT(!PlatformFeatureDecisions::decides_without_facts(FeatureProcess::Compositor, overrides, Build::with_every_feature()));-}+ FeatureOverrides overrides;+ overrides.disabled.set(Feature::GpuPainting);+ EXPECT(PlatformFeatureDecisions::decides_without_facts(process, overrides, Build::with_every_feature()));-TEST_CASE(each_process_is_given_its_enabled_features)-{- auto facts = facts_with_a_gpu();- facts.gpu->vendor_id = 0x1002;- EXPECT_EQ(evaluate(facts).features_for(FeatureProcess::Compositor).to_byte_string(), "gpu_painting,ycbcr_import"sv);- EXPECT_EQ(evaluate(facts_with_a_gpu()).features_for(FeatureProcess::Compositor).to_byte_string(), "gpu_painting"sv);+ overrides.force_enabled.set(Feature::GpuPainting);+ EXPECT(!PlatformFeatureDecisions::decides_without_facts(process, overrides, Build::with_every_feature()));+ }}TEST_CASE(process_features_round_trip_through_their_text_form){- auto features = MUST(ProcessFeatures::from_string(FeatureProcess::Compositor, "ycbcr_import,gpu_painting"sv));- EXPECT(features.is_enabled(Feature::GpuPainting));- EXPECT(features.is_enabled(Feature::YCbCrImport));- EXPECT_EQ(features.to_byte_string(), "gpu_painting,ycbcr_import"sv);+ auto features = MUST(ProcessFeatures::from_string(FeatureProcess::VideoDecoderServer, "vulkan_video.system_ffmpeg,vulkan_video"sv));+ EXPECT(features.is_enabled(Feature::VulkanVideo));+ EXPECT(features.is_enabled(Feature::VulkanVideoSystemFFmpeg));+ EXPECT(!features.is_enabled(Feature::VulkanVideoBundledFFmpeg));+ EXPECT_EQ(features.to_byte_string(), "vulkan_video,vulkan_video.system_ffmpeg"sv);auto none = MUST(ProcessFeatures::from_string(FeatureProcess::Compositor, ""sv));EXPECT(!none.is_enabled(Feature::GpuPainting));}-TEST_CASE(process_features_reject_unknown_features)+TEST_CASE(process_features_reject_unknown_and_foreign_features){EXPECT(ProcessFeatures::from_string(FeatureProcess::Compositor, "gpu_painting,teleportation"sv).is_error());+ EXPECT(ProcessFeatures::from_string(FeatureProcess::Compositor, "vulkan_video"sv).is_error());}TEST_CASE(system_facts_round_trip_through_json){- auto facts = facts_with_a_gpu();+ auto facts = facts_with_a_separate_dpb();+ facts.gpu->cannot_decode_video_because = "Nothing, this is a test"_string;EXPECT(MUST(SystemFacts::from_json(facts.to_json().serialized())) == facts);facts.gpu.clear();+ facts.system_ffmpeg.clear();EXPECT(MUST(SystemFacts::from_json(facts.to_json().serialized())) == facts);}@@ -242,9 +362,9 @@ TEST_CASE(system_facts_reject_malformed_json)EXPECT(SystemFacts::from_json("[]"sv).is_error());EXPECT(SystemFacts::from_json("{\"gpu\":3}"sv).is_error());- auto facts = facts_with_a_gpu();+ auto facts = facts_with_a_separate_dpb();auto json = facts.to_json();- json.get_object("gpu"sv)->remove("supports_ycbcr_sampling"sv);+ json.get_object("gpu"sv)->remove("h264"sv);EXPECT(SystemFacts::from_json(json.serialized()).is_error());facts.gpu->driver_info = MUST(String::repeated('x', 1025));