🆕 Take HEVC 4:2:2 sessions on NVDEC where its caps list them
What the guest sees: on an arm64 guest of an NVIDIA host whose NVDEC lists
HEVC 4:2:2 at the stream's depth and size, as the RTX 5080 Laptop GPU's
does at 8, 10 and 12 bits, a VideoToolbox session of an HEVC 4:2:2 stream
now decodes on the GPU, each picture copied into the surface's 422v, x422
or tv22 (or full-range twin) with no conversion by the CPU. Its dsta was
refused before, and the guest decoded the stream in software. On a card
whose caps lack it, as the RTX 3090's do, the session is still refused at
its start, and its warning now names the caps ("NVDEC does not decode HEVC
4:2:2 at 10 bits") where it said "NVDEC's decoders here land no HEVC 4:2:2
pictures".
declines_range_extensions takes the caps' answer for 4:2:2 as it does for
4:2:0 and 4:4:4, the decoder's output being NV16 at 8 bits and P216
deeper, and the VideoToolbox decoder checks a picture's chroma format
against the surface's from the picture itself.
Shown on the host, not from a guest on that card: the card test
(an_hevc_picture_lands_in_its_guest_format_as_the_software_decode_has_it)
on the RTX 5080 Laptop GPU decoded our x265 streams of 4:2:2 at 8, 10 and
12 bits through the arm's VideoToolbox decoder into pool-laid surfaces,
every picture byte for byte as ffmpeg's software decode, beside 4:2:0 and
4:4:4 at each depth, and landed 1920x1080 4:2:2 pictures at 344 to 384 a
second (potluck job m3-max-77563). The seam test holds the session-start
decision on the 5080's and the 3090's recorded caps.
This commit is contained in:
1 parent
6450aee5e8
commit
9d69b44da1
5 files changed
+383
-31
No files matched your search
@@ -63,14 +63,16 @@
|
||||
//! where it does at 10 ([`vp9_caps`]), each sample a frame or a superframe whole, and lands as
|
||||
//! H.264's and HEVC's 4:2:0 pictures do. Its caps entry, codec 3, is skipped by an x86
|
||||
//! guest's kexts, and no device session takes it.
|
||||
//! - **HEVC's range extensions**, the codec crate's 4:2:0 and 4:4:4 at 8, 10 and 12 bits, have a
|
||||
//! paravirtual session where NVDEC's caps say it decodes HEVC at the stream's chroma format
|
||||
//! and depth into the output the decoder makes (NV12 or P016; 4:4:4's three planes, 8-bit or
|
||||
//! 16-bit), at the stream's size; elsewhere, and for every 4:2:2 stream (no decode into
|
||||
//! NVDEC's 4:2:2 outputs is built), the session is refused at its start, the reason named
|
||||
//! (`GraphicsVideo::guest_declines`), and the guest decodes in software. A 4:2:0 picture
|
||||
//! lands as Main 10's does, P016 copied into `tv20`/`tf20` at 12 bits, the two laid out
|
||||
//! alike. A 4:4:4 picture lands in the surface's 4:4:4 format of its depth (`444v`, `x444`,
|
||||
//! - **HEVC's range extensions**, the codec crate's 4:2:0, 4:2:2 and 4:4:4 at 8, 10 and 12
|
||||
//! bits, have a paravirtual session where NVDEC's caps say it decodes HEVC at the stream's
|
||||
//! chroma format and depth into the output the decoder makes (NV12 or P016; NV16 or P216;
|
||||
//! 4:4:4's three planes, 8-bit or 16-bit), at the stream's size; elsewhere the session is
|
||||
//! refused at its start, the reason named (`GraphicsVideo::guest_declines`), and the guest
|
||||
//! decodes in software. A 4:2:0 picture lands as Main 10's does, P016 copied into
|
||||
//! `tv20`/`tf20` at 12 bits, the two laid out alike. A 4:2:2 picture lands the same way in
|
||||
//! the surface's 4:2:2 format of its depth (`422v`, `x422`, `tv22` and their full-range
|
||||
//! twins), NV16 and P216 laid out as those are, the chroma as tall as the luma. A 4:4:4
|
||||
//! picture lands in the surface's 4:4:4 format of its depth (`444v`, `x444`,
|
||||
//! `tv44` and their full-range twins), its luma as it lies and its Cb and Cr interleaved into
|
||||
//! the surface's second plane; at 8 bits by the GPU where CUDA imports the device's
|
||||
//! exportable buffers: one `cuMemcpy2D` a plane within the GPU into the decoder's scratch,
|
||||
@@ -100,7 +102,7 @@ use reims_vgpu_graphics::wire::{
|
||||
RGFX_VIDEO_VP9_PROFILE_0, RGFX_VIDEO_VP9_PROFILE_2, RgfxVideoCodecCaps, RgfxVideoEncodeCaps,
|
||||
};
|
||||
use reims_vgpu_video::codec::{PictureStart, vp9};
|
||||
use reims_vgpu_video::core::backend::{BackendError as VideoError, Chroma};
|
||||
use reims_vgpu_video::core::backend::BackendError as VideoError;
|
||||
use reims_vgpu_video::core::device_memory::{
|
||||
DeviceImports, GuestTarget, MemoryIdentity, TargetPlane,
|
||||
};
|
||||
@@ -519,18 +521,13 @@ fn declines(caps: CapsOf<'_>, codec: u32, stream: &Stream) -> Option<String> {
|
||||
|
||||
/// Why NVDEC's decoders take none of `stream`'s pictures, an HEVC stream of the range
|
||||
/// extensions: `caps` of HEVC at the stream's chroma format and depth, which are to say it
|
||||
/// decodes it ([`declines_by`]); `None` where they do. A 4:2:2 stream is declined whatever they
|
||||
/// say: no decode of it into NVDEC's 4:2:2 outputs is built here.
|
||||
/// decodes it ([`declines_by`]); `None` where they do.
|
||||
fn declines_range_extensions(caps: CapsOf<'_>, stream: &Stream) -> Option<String> {
|
||||
let bits = u32::from(stream.luma_bits);
|
||||
let (chroma, what) = match stream.chroma_format_idc {
|
||||
1 => (ChromaFormat::Yuv420, "HEVC 4:2:0"),
|
||||
2 => (ChromaFormat::Yuv422, "HEVC 4:2:2"),
|
||||
3 => (ChromaFormat::Yuv444, "HEVC 4:4:4"),
|
||||
2 => {
|
||||
return Some(format!(
|
||||
"{NAME}'s decoders here land no HEVC 4:2:2 pictures"
|
||||
));
|
||||
}
|
||||
other => {
|
||||
return Some(format!(
|
||||
"{NAME} decodes HEVC of chroma_format_idc 1 to 3, not {other}"
|
||||
@@ -548,10 +545,10 @@ fn declines_range_extensions(caps: CapsOf<'_>, stream: &Stream) -> Option<String
|
||||
|
||||
/// Why NVDEC's decoder of `answer`, the caps of `what` at `chroma` and `bits`, decodes none of
|
||||
/// `stream`'s pictures: where they do not say it decodes it, into the output the decoder makes
|
||||
/// of it (4:2:0 into `SurfaceFormat::Nv12` at 8 bits and `P016` past; 4:4:4 into its three
|
||||
/// planes, `Yuv444` at 8 bits and `Yuv444_16Bit` past), at the stream's size (`nMinWidth` and
|
||||
/// `nMinHeight` up to `nMaxWidth`, `nMaxHeight` and `nMaxMBCount`), as the decoder's make checks
|
||||
/// them; `None` where they do.
|
||||
/// of it (4:2:0 into `SurfaceFormat::Nv12` at 8 bits and `P016` past; 4:2:2 into `Nv16` and
|
||||
/// `P216`; 4:4:4 into its three planes, `Yuv444` at 8 bits and `Yuv444_16Bit` past), at the
|
||||
/// stream's size (`nMinWidth` and `nMinHeight` up to `nMaxWidth`, `nMaxHeight` and
|
||||
/// `nMaxMBCount`), as the decoder's make checks them; `None` where they do.
|
||||
fn declines_by(
|
||||
answer: Result<DecodeCapabilities, String>,
|
||||
what: &str,
|
||||
@@ -566,6 +563,8 @@ fn declines_by(
|
||||
let output = match (chroma, bits > 8) {
|
||||
(ChromaFormat::Yuv444, false) => SurfaceFormat::Yuv444,
|
||||
(ChromaFormat::Yuv444, true) => SurfaceFormat::Yuv444_16Bit,
|
||||
(ChromaFormat::Yuv422, false) => SurfaceFormat::Nv16,
|
||||
(ChromaFormat::Yuv422, true) => SurfaceFormat::P216,
|
||||
(_, true) => SurfaceFormat::P016,
|
||||
(_, false) => SurfaceFormat::Nv12,
|
||||
};
|
||||
@@ -1247,11 +1246,7 @@ impl<P: Platform> NvGuestDecoder<P> {
|
||||
)));
|
||||
}
|
||||
let four_four_four = picture.four_four_four();
|
||||
let chroma = if four_four_four {
|
||||
Chroma::Yuv444
|
||||
} else {
|
||||
Chroma::Yuv420
|
||||
};
|
||||
let chroma = picture.chroma();
|
||||
if target.pixel_format().chroma() != chroma {
|
||||
let chroma = chroma.name();
|
||||
return Err(VideoError::Unsupported(format!(
|
||||
|
||||
@@ -8,6 +8,7 @@ use std::alloc::Layout;
|
||||
use std::ptr::NonNull;
|
||||
use std::sync::Arc;
|
||||
|
||||
use reims_vgpu_video::core::backend::{Chroma, PixelFormat};
|
||||
use reims_vgpu_video::core::device_memory::{DeviceMemory, HostView, MemoryLife};
|
||||
use reims_vgpu_video::core::fourcc::FourCc;
|
||||
use reims_vgpu_video::core::runtime::{ExitStep, MonoTime, Rings, TimedOut};
|
||||
@@ -659,6 +660,246 @@ fn a_videotoolbox_picture_lands_in_the_lent_surfaces_pages_as_it_reads_back() {
|
||||
});
|
||||
}
|
||||
|
||||
/// The card test's streams ([`an_hevc_picture_lands_in_its_guest_format_as_the_software_decode_has_it`]):
|
||||
/// each one's name in `RVG_NV_STREAMS`, its chroma format, depth and size. x265 wrote them from
|
||||
/// ffmpeg's `testsrc2` with no reordering (`--bframes 0`), so that decode order is display order.
|
||||
const CARD_STREAMS: [(&str, Chroma, u8, (u32, u32)); 13] = [
|
||||
("main-360p", Chroma::Yuv420, 8, (640, 360)),
|
||||
("main10-360p", Chroma::Yuv420, 10, (640, 360)),
|
||||
("main12-360p", Chroma::Yuv420, 12, (640, 360)),
|
||||
("main422-8-360p", Chroma::Yuv422, 8, (640, 360)),
|
||||
("main422-10-360p", Chroma::Yuv422, 10, (640, 360)),
|
||||
("main422-12-360p", Chroma::Yuv422, 12, (640, 360)),
|
||||
("main422-10-1366x766", Chroma::Yuv422, 10, (1366, 766)),
|
||||
("main422-8-1080p", Chroma::Yuv422, 8, (1920, 1080)),
|
||||
("main422-10-1080p", Chroma::Yuv422, 10, (1920, 1080)),
|
||||
("main422-12-1080p", Chroma::Yuv422, 12, (1920, 1080)),
|
||||
("main444-360p", Chroma::Yuv444, 8, (640, 360)),
|
||||
("main444-10-360p", Chroma::Yuv444, 10, (640, 360)),
|
||||
("main444-12-360p", Chroma::Yuv444, 12, (640, 360)),
|
||||
];
|
||||
|
||||
/// A `width` by `height` surface of `format` as CoreVideo lays out a pool's IOSurface: the luma at
|
||||
/// `luma_at`, the chroma on the next 4 KiB after it, each plane's rows 64 bytes aligned.
|
||||
fn pool_layout(format: PixelFormat, (width, height): (u32, u32), luma_at: usize) -> SurfaceLayout {
|
||||
let sample = format.bytes_per_sample();
|
||||
let columns = usize::try_from(width).expect("columns");
|
||||
let (pairs, chroma_rows) = format.chroma().plane_size(columns, height);
|
||||
let (luma_pitch, chroma_pitch) = (
|
||||
(columns * sample).next_multiple_of(64),
|
||||
(pairs * 2 * sample).next_multiple_of(64),
|
||||
);
|
||||
let rows = usize::try_from(height).expect("rows");
|
||||
let chroma_at = (luma_at + luma_pitch * rows).next_multiple_of(0x1000);
|
||||
SurfaceLayout {
|
||||
pixel_format: format.fourcc(),
|
||||
width,
|
||||
height,
|
||||
planes: vec![
|
||||
PlaneLayout {
|
||||
offset: luma_at,
|
||||
bytes_per_row: luma_pitch,
|
||||
width,
|
||||
height,
|
||||
},
|
||||
PlaneLayout {
|
||||
offset: chroma_at,
|
||||
bytes_per_row: chroma_pitch,
|
||||
width: u32::try_from(pairs).expect("pairs"),
|
||||
height: chroma_rows,
|
||||
},
|
||||
],
|
||||
bytes_per_row: 0,
|
||||
}
|
||||
}
|
||||
|
||||
/// The pictures the CPU converted into a surface's layout, process-wide, so far.
|
||||
fn converted() -> u64 {
|
||||
(reims_vgpu_vulkan::answer::counted_kinds().into_iter())
|
||||
.find(|(code, _)| *code == CONVERTED_CODE)
|
||||
.map_or(0, |(_, n)| n)
|
||||
}
|
||||
|
||||
/// HEVC's pictures of 4:2:0, 4:2:2 and 4:4:4 at 8, 10 and 12 bits ([`CARD_STREAMS`], in
|
||||
/// `RVG_NV_STREAMS`) land through a VideoToolbox decoder of the arm, its session taken where
|
||||
/// NVDEC's caps decode the stream ([`declines`]), in the surface format a guest's pool has for
|
||||
/// their chroma format and depth (`PixelFormat::of`, video range), laid out as CoreVideo lays out
|
||||
/// a pool's IOSurface ([`pool_layout`]), as the software decode has them: the SHA-256 of each
|
||||
/// frame's two planes, each row's samples alone, is its line of `NAME.sha256` (ffmpeg's decode
|
||||
/// into the planes' layout), and the bytes before the planes, past each row and past the chroma
|
||||
/// are as they were. A stream whose session the caps refuse is named with why, and not decoded.
|
||||
/// Prints a row a stream (`CARD`): the frames compared, the reasons pictures were copied by the
|
||||
/// CPU, and the CPU's conversions counted (`video-pictures-cpu-converted`), none at 4:2:2; and the
|
||||
/// rate of each 1080p stream's pictures, each decoded and landed before the next is sent, as a
|
||||
/// guest's session sends them.
|
||||
#[test]
|
||||
#[ignore = "needs an NVIDIA GPU and the card test's streams in RVG_NV_STREAMS: run on the NVIDIA host"]
|
||||
fn an_hevc_picture_lands_in_its_guest_format_as_the_software_decode_has_it() {
|
||||
use reims_vgpu_video::codec::hevc;
|
||||
use reims_vgpu_video::paravirt::Codec as StreamCodec;
|
||||
use sha2::{Digest, Sha256};
|
||||
|
||||
let dir = std::env::var_os("RVG_NV_STREAMS").expect("RVG_NV_STREAMS, the streams' directory");
|
||||
let dir = std::path::PathBuf::from(dir);
|
||||
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::Nvidia);
|
||||
let runtime = crate::video::runtime::PlatformRuntime::of(&platform);
|
||||
let gpu = super::super::video_choice::rt_nvidia_gpu(&device);
|
||||
let video = NvidiaVideo::<RtPlatform>::new(&device, gpu, &runtime);
|
||||
let video = Arc::new(video.expect("NVDEC on the device's GPU"));
|
||||
let shared = Shared(Arc::clone(&video));
|
||||
let (mut wrong, mut decoded, mut refused) = (Vec::new(), 0, 0);
|
||||
for (name, chroma, bits, (width, height)) in CARD_STREAMS {
|
||||
let read = |kind: &str| std::fs::read(dir.join(format!("{name}.{kind}")));
|
||||
let file = read("265").expect("a stream");
|
||||
let want = String::from_utf8(read("sha256").expect("its hashes")).expect("text");
|
||||
let want: Vec<&str> = want.lines().collect();
|
||||
let range_extensions = chroma != Chroma::Yuv420 || bits > 10;
|
||||
let stream = Stream {
|
||||
codec: StreamCodec::Hevc,
|
||||
profile: if range_extensions {
|
||||
4
|
||||
} else if bits > 8 {
|
||||
2
|
||||
} else {
|
||||
1
|
||||
},
|
||||
chroma_format_idc: chroma.chroma_format_idc(),
|
||||
luma_bits: bits,
|
||||
chroma_bits: bits,
|
||||
// x265's coded size: whole 8-sample blocks.
|
||||
width: width.next_multiple_of(8),
|
||||
height: height.next_multiple_of(8),
|
||||
range_extensions,
|
||||
};
|
||||
if let Some(why) = shared.guest_declines(RGFX_VIDEO_CODEC_HEVC, &stream) {
|
||||
println!("CARD {name}: refused at its start: {why}");
|
||||
refused += 1;
|
||||
continue;
|
||||
}
|
||||
let format = PixelFormat::of(chroma, bits, false).expect("a guest format");
|
||||
let luma_at = 0x400;
|
||||
let layout = pool_layout(format, (width, height), luma_at);
|
||||
let [luma, chroma_plane] = [layout.planes[0], layout.planes[1]];
|
||||
let sample = format.bytes_per_sample();
|
||||
let columns = usize::try_from(width).expect("columns");
|
||||
let (pairs, chroma_rows) = chroma.plane_size(columns, height);
|
||||
let planes = [
|
||||
(
|
||||
luma,
|
||||
columns * sample,
|
||||
usize::try_from(height).expect("rows"),
|
||||
),
|
||||
(
|
||||
chroma_plane,
|
||||
pairs * 2 * sample,
|
||||
usize::try_from(chroma_rows).expect("rows"),
|
||||
),
|
||||
];
|
||||
let chroma_end = chroma_plane.offset + chroma_plane.bytes_per_row * planes[1].2;
|
||||
let len = (chroma_end + 1).next_multiple_of(PAGE);
|
||||
let memory = PagesMemory {
|
||||
life: MemoryLife::new(),
|
||||
pages: Pages::new(len),
|
||||
};
|
||||
let output = GuestOutput {
|
||||
layout: layout.clone(),
|
||||
memory: &memory,
|
||||
buffer: None,
|
||||
};
|
||||
let mut decoder = AnnexBDecoder::new(&video.gpu, AnnexBCodec::Hevc, &runtime);
|
||||
decoder.lands_range_extensions();
|
||||
let mut guest = NvGuestDecoder::<RtPlatform> {
|
||||
decoder,
|
||||
said: Vec::new(),
|
||||
gathers: Err("the card test's".to_owned()),
|
||||
gathered: 0,
|
||||
};
|
||||
let before = converted();
|
||||
let (mut got, mut busy) = (Vec::new(), std::time::Duration::ZERO);
|
||||
for (n, unit) in hevc::nal::access_units(&file).into_iter().enumerate() {
|
||||
memory.pages.fill(UNTOUCHED);
|
||||
let start = runtime.now();
|
||||
let landed = guest.decode(&[], unit, &output);
|
||||
busy += runtime.now().saturating_duration_since(start);
|
||||
match landed {
|
||||
Ok(true) => {}
|
||||
Ok(false) => continue,
|
||||
Err(error) => panic!("{name}: access unit {n}: {error:?}"),
|
||||
}
|
||||
let bytes = memory.pages.bytes();
|
||||
assert!(
|
||||
bytes[..luma_at].iter().all(|&b| b == UNTOUCHED),
|
||||
"{name}: picture {n}: the bytes before the planes"
|
||||
);
|
||||
assert!(
|
||||
bytes[chroma_end..].iter().all(|&b| b == UNTOUCHED),
|
||||
"{name}: picture {n}: the bytes past the chroma"
|
||||
);
|
||||
let mut hash = Sha256::new();
|
||||
for (plane, row_bytes, rows) in planes {
|
||||
for row in 0..rows {
|
||||
let first = plane.offset + row * plane.bytes_per_row;
|
||||
hash.update(&bytes[first..][..row_bytes]);
|
||||
assert!(
|
||||
(bytes[first + row_bytes..first + plane.bytes_per_row].iter())
|
||||
.all(|&b| b == UNTOUCHED),
|
||||
"{name}: picture {n}: bytes past row {row} of the plane at {}",
|
||||
plane.offset
|
||||
);
|
||||
}
|
||||
}
|
||||
got.push(format!("{:x}", hash.finalize()));
|
||||
}
|
||||
let conversions = converted() - before;
|
||||
let equal = got.len() == want.len() && got.iter().zip(&want).all(|(g, w)| g == w);
|
||||
let first_wrong = (got.iter().zip(&want)).position(|(g, w)| g != w);
|
||||
let rate = if height >= 1080 {
|
||||
let pictures = u32::try_from(got.len()).expect("pictures");
|
||||
format!(
|
||||
", {:.1} pictures a second",
|
||||
f64::from(pictures) / busy.as_secs_f64()
|
||||
)
|
||||
} else {
|
||||
String::new()
|
||||
};
|
||||
println!(
|
||||
"CARD {name}: '{}' {} of {} frames, {}, CPU copies {:?}, CPU conversions {conversions}{rate}",
|
||||
format.fourcc(),
|
||||
got.len(),
|
||||
want.len(),
|
||||
if equal { "equal" } else { "NOT EQUAL" },
|
||||
guest.said,
|
||||
);
|
||||
if !equal {
|
||||
wrong.push(format!(
|
||||
"{name}: {} frames of {}, first differing {first_wrong:?}",
|
||||
got.len(),
|
||||
want.len()
|
||||
));
|
||||
}
|
||||
if chroma == Chroma::Yuv422 {
|
||||
assert_eq!(
|
||||
conversions, 0,
|
||||
"{name}: a 4:2:2 picture converted by the CPU"
|
||||
);
|
||||
}
|
||||
decoded += 1;
|
||||
}
|
||||
println!(
|
||||
"CARD_DONE decoded {decoded} refused {refused} wrong {}",
|
||||
wrong.len()
|
||||
);
|
||||
assert_eq!(
|
||||
wrong,
|
||||
Vec::<String>::new(),
|
||||
"frames unlike the software decode's"
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
/// The CPU's copy of a picture read back lands each plane's rows at the surface's offset and
|
||||
/// pitch, as many of each row's bytes as the plane's rows hold, and as many rows as both have,
|
||||
/// leaving the bytes past each row as they were; a plane whose rows lie past the surface is
|
||||
@@ -769,6 +1010,106 @@ fn a_4_4_4_pictures_cb_and_cr_are_interleaved_into_the_surfaces_chroma_plane() {
|
||||
);
|
||||
}
|
||||
|
||||
/// An HEVC 4:2:2 stream's session is taken where NVDEC's caps decode HEVC 4:2:2 at its depth
|
||||
/// into NV16 (8 bits) or P216 (past), at its size, and refused otherwise, naming why. The caps are
|
||||
/// the cards' own answers (`nvidia-probe`): the RTX 5080 Laptop GPU's (615.71.09, 2026-11-27,
|
||||
/// job m3-max-77563), HEVC 4:2:2 at 8 bits into NV16 and at 10 and 12 into P216, each from
|
||||
/// 144x144 up to 8192x8192 and 262,144 macroblocks; and the RTX 3090's (620.70.06, 2026-11-22),
|
||||
/// which lists no HEVC 4:2:2 (`cuvidGetDecoderCaps`'s `bIsSupported` 0).
|
||||
#[test]
|
||||
fn an_hevc_4_2_2_stream_is_taken_on_the_caps_that_decode_it_and_refused_on_the_rest() {
|
||||
use reims_vgpu_video::paravirt::Codec as StreamCodec;
|
||||
type Answer = Result<DecodeCapabilities, String>;
|
||||
let stream = |chroma_format_idc: u8, bits: u8, width: u32, height: u32| Stream {
|
||||
codec: StreamCodec::Hevc,
|
||||
profile: 4,
|
||||
chroma_format_idc,
|
||||
luma_bits: bits,
|
||||
chroma_bits: bits,
|
||||
width,
|
||||
height,
|
||||
range_extensions: true,
|
||||
};
|
||||
let rtx_5080 = |codec: NvdecCodec, chroma: ChromaFormat, bits: u32| -> Answer {
|
||||
let output = match (chroma, bits) {
|
||||
(ChromaFormat::Yuv422, 8) => SurfaceFormat::Nv16,
|
||||
(ChromaFormat::Yuv422, _) => SurfaceFormat::P216,
|
||||
(ChromaFormat::Yuv444, 8) => SurfaceFormat::Yuv444,
|
||||
(ChromaFormat::Yuv444, _) => SurfaceFormat::Yuv444_16Bit,
|
||||
_ => SurfaceFormat::P016,
|
||||
};
|
||||
Ok(DecodeCapabilities {
|
||||
output_formats: vec![output],
|
||||
..nvdec_answer(codec, chroma, bits, (144, 144), (8192, 8192))
|
||||
})
|
||||
};
|
||||
let rtx_3090 = |codec: NvdecCodec, chroma: ChromaFormat, bits: u32| -> Answer {
|
||||
Ok(DecodeCapabilities {
|
||||
supported: chroma != ChromaFormat::Yuv422,
|
||||
..rtx_5080(codec, chroma, bits)?
|
||||
})
|
||||
};
|
||||
for bits in [8, 10, 12] {
|
||||
for (width, height) in [(144, 144), (1920, 1080), (8192, 8192)] {
|
||||
let taken = stream(2, bits, width, height);
|
||||
assert_eq!(
|
||||
declines(&rtx_5080, RGFX_VIDEO_CODEC_HEVC, &taken),
|
||||
None,
|
||||
"{taken:?}"
|
||||
);
|
||||
}
|
||||
assert_eq!(
|
||||
declines(
|
||||
&rtx_3090,
|
||||
RGFX_VIDEO_CODEC_HEVC,
|
||||
&stream(2, bits, 1920, 1080)
|
||||
)
|
||||
.as_deref(),
|
||||
Some(format!("NVDEC does not decode HEVC 4:2:2 at {bits} bits").as_str())
|
||||
);
|
||||
// 4:4:4 is taken on both, as it was.
|
||||
assert_eq!(
|
||||
declines(
|
||||
&rtx_3090,
|
||||
RGFX_VIDEO_CODEC_HEVC,
|
||||
&stream(3, bits, 1920, 1080)
|
||||
),
|
||||
None
|
||||
);
|
||||
}
|
||||
for (declined, why) in [
|
||||
(
|
||||
stream(2, 10, 128, 128),
|
||||
"NVDEC decodes HEVC 4:2:2 from 144x144, not 128x128",
|
||||
),
|
||||
(
|
||||
stream(2, 12, 8200, 144),
|
||||
"NVDEC decodes HEVC 4:2:2 up to 8192x8192 (262144 macroblocks), not 8200x144",
|
||||
),
|
||||
] {
|
||||
assert_eq!(
|
||||
declines(&rtx_5080, RGFX_VIDEO_CODEC_HEVC, &declined).as_deref(),
|
||||
Some(why)
|
||||
);
|
||||
}
|
||||
// Caps that write 4:2:2 at 10 bits only as NV16, which the decoder does not make of it.
|
||||
let nv16_alone = |codec: NvdecCodec, chroma: ChromaFormat, bits: u32| -> Answer {
|
||||
Ok(DecodeCapabilities {
|
||||
output_formats: vec![SurfaceFormat::Nv16],
|
||||
..rtx_5080(codec, chroma, bits)?
|
||||
})
|
||||
};
|
||||
assert_eq!(
|
||||
declines(
|
||||
&nv16_alone,
|
||||
RGFX_VIDEO_CODEC_HEVC,
|
||||
&stream(2, 10, 1920, 1080)
|
||||
)
|
||||
.as_deref(),
|
||||
Some("NVDEC writes HEVC 4:2:2 at 10 bits as [Nv16], not P216")
|
||||
);
|
||||
}
|
||||
|
||||
/// What NVDEC answers of VP9 at `bit_depth`, up to `max` from `min`.
|
||||
fn vp9_answer(bit_depth: u32, max: (u32, u32), min: (u32, u32)) -> DecodeCapabilities {
|
||||
DecodeCapabilities {
|
||||
|
||||
@@ -1885,14 +1885,15 @@ Stages:
|
||||
decoder's sizes"), and NVDEC and VA-API also HEVC's
|
||||
range extensions, 4:2:0, 4:2:2 and 4:4:4 at 8, 10 and 12 bits,
|
||||
where the arm's own query lists a decoder of the stream: NVDEC's caps
|
||||
for its chroma format, depth and size, 4:2:2 aside, or the VA
|
||||
for its chroma format, depth and size, or the VA
|
||||
driver's decoder of the stream's range extensions profile with the
|
||||
render targets and surfaces it needs at that size (iHD's). Each
|
||||
picture lands in the format the guest's own software decoder gives
|
||||
the stream, which `TDrs` names (`PixelFormat::of`: '420v', 'x420' and
|
||||
'tv20' at 8, 10 and 12 bits of 4:2:0, '422v', 'x422' and 'tv22' of
|
||||
4:2:2, '444v', 'x444' and 'tv44' of 4:4:4, and their full-range
|
||||
forms): NVDEC's 4:2:0 and VA-API's P012 by a copy, as Main 10's;
|
||||
forms): NVDEC's 4:2:0 and 4:2:2 (NV16, P216) and VA-API's P012 by a
|
||||
copy, as Main 10's;
|
||||
NVDEC's three 4:4:4 planes interleaved by the runtime device's GPU at
|
||||
8 bits where CUDA imports the device's exportable buffers, else by
|
||||
the CPU; VA-API's XYUV split by the runtime device's GPU where the
|
||||
@@ -1909,7 +1910,8 @@ Stages:
|
||||
(a stream of a coded size outside its decoder's, as HEVC under
|
||||
NVDEC's 144x144; a range extensions stream on a VA driver without
|
||||
its decoder, radeonsi's, or on an NVIDIA GPU whose caps lack it,
|
||||
and HEVC 4:2:2 on NVDEC: the arm's `guest_declines`), is then
|
||||
as the RTX 3090's lack HEVC 4:2:2: the arm's `guest_declines`), is
|
||||
then
|
||||
refused at
|
||||
the session's start, not at
|
||||
each tile or frame, and every tile a session takes lands in the
|
||||
|
||||
@@ -77,8 +77,9 @@ or has no player for them at all:
|
||||
- **HEVC at 4:2:2, 4:4:4 or 12 bits on arm64 guests.** These decode on your GPU where its own
|
||||
driver offers them, and in the guest's software where it doesn't. The AMD GPUs we test on, a
|
||||
Radeon 780M and an RX 7900 XTX, offer none of them. NVIDIA GPUs decode 4:2:0 and 4:4:4 up to
|
||||
12 bits but not 4:2:2, even on a card whose decoder handles it, such as the RTX 5080 Laptop GPU
|
||||
we test on: we haven't built that part yet. An Intel Iris Xe decodes all of them, except 4:2:0
|
||||
12 bits, and 4:2:2 where the card's decoder handles it, such as the RTX 5080 Laptop GPU's; an
|
||||
RTX 3090's doesn't. We've checked the 5080's 4:2:2 pictures on the host, not yet from an arm64
|
||||
guest on that card. An Intel Iris Xe decodes all of them, except 4:2:0
|
||||
video at 8 or 10 bits that uses HEVC's range extensions profiles, which we don't take from
|
||||
Intel's driver yet.
|
||||
- **JPEG decoding on arm64 guests.** macOS 14.6.1 and 26.6.2 look for Apple's own JPEG and scaler
|
||||
|
||||
+14
-1
@@ -512,7 +512,10 @@ host's surface has another layout, each picture it converts on the CPU counted
|
||||
| RTX 3090, 620.70.06 | 4:2:0, 8, 10 and 12 bits | NV12, P016 | `420v`, `x420`, `tv20` | a copy, as Main and Main 10's |
|
||||
| | 4:4:4, 8 bits | three planes | `444v` | the GPU's interleave where CUDA imports the device's buffers, else the CPU's |
|
||||
| | 4:4:4, 10 and 12 bits | three planes of 16-bit samples | `x444`, `tv44` | the CPU's interleave |
|
||||
| | 4:2:2 | none built | | refused |
|
||||
| | 4:2:2 | none: NVDEC lists no HEVC 4:2:2 | | refused |
|
||||
| RTX 5080 Laptop GPU, 615.71.09 | 4:2:2, 8 bits | NV16 | `422v` | a copy, as Main's |
|
||||
| | 4:2:2, 10 and 12 bits | P216 | `x422`, `tv22` | a copy, as Main 10's |
|
||||
| | 4:2:0 and 4:4:4 | as the RTX 3090's | | |
|
||||
| Radeon 780M, radeonsi | any | none: no decoder listed | | refused |
|
||||
|
||||
The full-range forms land as the video-range ones. Our streams of the 4:2:0 range extensions
|
||||
@@ -534,6 +537,16 @@ one that allows none (2026-11-27):
|
||||
pictures converted by the CPU and 50 interleaved by the GPU. Its session of a 4:2:2 stream was
|
||||
refused at its start, as `NVDEC's decoders here land no HEVC 4:2:2 pictures (HEVC
|
||||
general_profile_idc 4, chroma_format_idc 2, luma 10 bits, chroma 10 bits, 640x360)`.
|
||||
- On the RTX 5080 Laptop GPU (615.71.09), no arm64 guest has run; its 4:2:2 is checked on the
|
||||
host alone. The arm's VideoToolbox decoder, its sessions taken on the card's own caps (the card
|
||||
test `an_hevc_picture_lands_in_its_guest_format_as_the_software_decode_has_it` in
|
||||
`graphics/nvidia/tests.rs`, potluck job m3-max-77563), decoded our x265 streams of 4:2:2 at 8,
|
||||
10 and 12 bits, at 640x360 and 1920x1080 and at 10 bits at 1366x766, into `422v`, `x422` and
|
||||
`tv22` surfaces laid out as a pool's IOSurface, every picture byte for byte as ffmpeg's software
|
||||
decode of the stream, with none copied or converted by the CPU; and 4:2:0 and 4:4:4 at 8, 10
|
||||
and 12 bits, every picture the same too. It decoded and landed the 1920x1080 4:2:2 pictures at
|
||||
344 to 384 a second, each landed before the next was sent (a debug build). How fast a guest
|
||||
decodes them there is not measured.
|
||||
- On the Radeon 780M (m3-max-77300), each hardware session of a range extensions stream was
|
||||
refused at its start, the warning naming the decoder radeonsi lacks, as `VA-API: the driver
|
||||
has no HEVCMain422_10 decoder (HEVC general_profile_idc 4, chroma_format_idc 2, luma 10
|
||||
|
||||
Reference in new issue
Block a user