🆕 Offer the VA-API driver's encoders on Linux's rt platform

Since the cutover a guest on an AMD or Intel Linux host was offered no
hardware video encoder: the rt arm opened VA-API with `encodes: false`, as rt
read no encoder's sources for the driver. The previous commit writes them on
the device's GPU, so the arm now answers the driver's encoders.

What changes for the guest, on a Linux host whose VA-API driver encodes: the
caps list the driver's H.264 and HEVC encode entries, its profiles, sizes and
rate controls, so an x86 guest's VideoToolbox finds a hardware encoder
(AppleGVA's) and an arm64 guest's paravirtual encoder list names one for each
codec the driver encodes. Each session's frames are written by the GPU into
the encoder's input, else uploaded by the CPU at the GPU's refusal, said once
a session. Codecs, profiles and sizes stay the driver's answers. NVIDIA hosts
are unchanged (NVENC), and so is Windows, which answers no encoder: rt imports
no shared Direct3D 12 texture there.

the_rt_platforms_va_api_arm_decodes_alone held the old answer; it is now
the_rt_platforms_va_api_arm_answers_the_drivers_decoders_and_encoders,
which holds the arm's caps and guest encoders equal to the driver's.
This commit is contained in:
Anees Iqbal committed 2026-11-20 22:48:57 -08:00
1 parent 13fb154934
commit ad8ef4392b
2 files changed
+25 -16

No files matched your search

+3 -3
View File
@@ -228,8 +228,8 @@ impl std::fmt::Display for DisplayAt<'_> {
/// (`host_gpus::render_node_at`), as [`open`] opens it; `None`, logged, where its GPU has none.
/// Its pictures land by the driver's video processing or the CPU's copy, as its GPU copies
/// ([`fill::DeviceFills`]) make no copier; a reference picture is not decoded into its cache
/// ([`CachedReferences::Apart`]); and no encoder is answered yet, though the GPU copies give an
/// encode session a filler (`fill`).
/// ([`CachedReferences::Apart`]); and the driver's encoders are answered, their sessions' frames
/// written into the encoders' inputs by the GPU (`fill`), else uploaded by the CPU.
#[cfg(unix)]
pub(crate) fn open_on_rt(
device: &RtDevice,
@@ -244,7 +244,7 @@ pub(crate) fn open_on_rt(
.map(|dir| dir.join("device-checks").join("va-targets"));
let rules = PlatformRules {
references: CachedReferences::Apart,
encodes: false,
encodes: true,
};
let copies: Arc<dyn GpuCopies<reims_vgpu_vulkan::RtPlatform>> =
Arc::new(fill::DeviceFills::new(device, &runtime));
+22 -13
View File
@@ -293,28 +293,22 @@ fn caches_are_dma_bufs_where_either_of_the_drivers_checks_passed() {
);
}
/// On the rt platform the VA-API arm answers what the driver decodes and no encoder (the platform
/// releases no encoder's sources to the driver yet), and writes into the device's caches where the
/// driver's check of decodes into targets passed a codec, or its import check a format: rt's
/// exported blocks, as dma-bufs, take the pictures no later one predicts from, decoded there, or
/// the pictures the driver's video processing writes there.
/// On the rt platform the VA-API arm answers what the driver decodes and what it encodes, as the
/// driver answers them, the encode sessions' frames written into their encoders' inputs by the
/// GPU (`fill`); and it writes into the device's caches where the driver's check of decodes into
/// targets passed a codec, or its import check a format: rt's exported blocks, as dma-bufs, take
/// the pictures no later one predicts from, decoded there, or the pictures the driver's video
/// processing writes there. The VA-API hosts' drivers encode.
/// The rt device must be of a GPU the arm runs on (`video_choice::tested_gpu::check_rt`).
#[test]
#[ignore = "needs a VA-API GPU: run on the VA-API host"]
fn the_rt_platforms_va_api_arm_decodes_alone() {
fn the_rt_platforms_va_api_arm_answers_the_drivers_decoders_and_encoders() {
let platform = crate::rt_test_end::platform();
crate::entry::run(|_| {
let device = platform.system_default_device().expect("an rt device");
crate::graphics::video_choice::tested_gpu::check_rt(&device, Arm::VaApi);
let runtime = crate::video::runtime::PlatformRuntime::of(&platform);
let video = open_on_rt(&device, runtime).expect("VA-API on the rt device's GPU");
let caps = video.caps();
assert!(!caps.is_empty());
assert!(
caps.iter().all(|c| c.direction == RGFX_VIDEO_DECODE),
"{caps:?}"
);
assert!(video.guest_encoders().is_empty());
assert!(video.guest_decodes());
assert!(video.lands_in_device_caches());
let gpu = device.host_gpu();
@@ -324,6 +318,21 @@ fn the_rt_platforms_va_api_arm_decodes_alone() {
crate::video::runtime::PlatformRuntime::of(&platform),
)
.expect("a VA display");
let capabilities = display.capabilities().expect("the driver's capabilities");
let supports = encoder_support(&display);
assert!(!supports.is_empty(), "the VA-API host's driver encodes");
let mut answered = caps_of(&capabilities);
answered.extend(encode::encode_caps_of(&supports, &capabilities));
let caps = video.caps();
assert_eq!(caps, answered);
assert!(
caps.iter().any(|c| c.direction == RGFX_VIDEO_DECODE)
&& caps.iter().any(|c| c.direction == RGFX_VIDEO_ENCODE),
"{caps:?}"
);
let encoders = video.guest_encoders();
assert!(!encoders.is_empty());
assert_eq!(encoders, encode::guest_encoders(&supports));
let checks = TargetChecks::of(&display, None);
let passed = [
(TargetCodec::H264, TargetFormat::Nv12),