From 5c30529e1875ed492c1bfee9bbbbcf03447d7625 Mon Sep 17 00:00:00 2001 From: Anees Iqbal Date: Fri, 27 Nov 2026 14:50:54 -0800 Subject: [PATCH] :art: Build the AV1 helpers only where their callers build On the Mac target clippy found AV1 helpers dead whose callers build on other hosts alone. The card tests' judgement, the streams' grain statistics and the decoder's film grain alteration serve the VA-API and NVIDIA card tests, which build on Linux; the arms' AV1 limits and declines serve the VA-API and NVDEC arms, which build on Linux and Windows. Each is now built under the cfg its callers build under. --- crates/reims-vgpu-video/src/codec/av1/decoder.rs | 2 +- crates/reims-vgpu-video/src/codec/av1/tests.rs | 9 ++++++--- crates/reims-vgpu-video/src/vaapi/va/av1.rs | 2 +- crates/reims-vgpu/src/graphics/av1.rs | 10 +++++++++- 4 files changed, 17 insertions(+), 6 deletions(-) diff --git a/crates/reims-vgpu-video/src/codec/av1/decoder.rs b/crates/reims-vgpu-video/src/codec/av1/decoder.rs index 73c5e036a..905bf6067 100644 --- a/crates/reims-vgpu-video/src/codec/av1/decoder.rs +++ b/crates/reims-vgpu-video/src/codec/av1/decoder.rs @@ -206,7 +206,7 @@ impl Decoder { /// the accelerator is handed them, the slots keeping what the stream coded: the card tests' /// decodes of a stream without its grain, so that what is output is the decoded frame /// alone, and with grain of other parameters, which their grain check must refuse. - #[cfg(test)] + #[cfg(all(test, target_os = "linux"))] pub(crate) fn alter_film_grain(&mut self, alter: fn(&mut frame::FilmGrainParams)) { self.film_grain = Some(alter); } diff --git a/crates/reims-vgpu-video/src/codec/av1/tests.rs b/crates/reims-vgpu-video/src/codec/av1/tests.rs index f625efaed..9f881fca0 100644 --- a/crates/reims-vgpu-video/src/codec/av1/tests.rs +++ b/crates/reims-vgpu-video/src/codec/av1/tests.rs @@ -10,11 +10,12 @@ //! header and one key frame, as ffmpeg's libaom encoder made it (`-still-picture 1`) and its //! demux copied it out of the AVIF, byte for byte; its MD5 is libdav1d's decode of the AVIF. -#[cfg(unix)] +// The card tests' helpers, for the VA-API and NVIDIA modules' card tests, which build on Linux. +#[cfg(target_os = "linux")] mod card; mod fuzz; -#[cfg(unix)] +#[cfg(target_os = "linux")] pub(crate) use card::{ CardFrame, NO_GRAIN, ReadFrame, WRONG_GRAIN, card_streams, grain_refused, judge, }; @@ -35,7 +36,7 @@ pub(crate) struct Stream { pub(crate) md5_without_grain: Option<&'static str>, /// Its film grain residual's statistics, where it applies grain: its `.grain` file, from /// libdav1d's decode with grain and without (`ReadFrame`, `Residual`). - #[cfg_attr(not(unix), expect(dead_code, reason = "read by the card tests alone"))] + #[cfg(target_os = "linux")] pub(crate) grain: Option<&'static str>, /// `UpscaledWidth` and `FrameHeight` of its frames. pub(crate) size: (u32, u32), @@ -51,6 +52,7 @@ macro_rules! stream { ivf: include_bytes!(concat!("tests/streams/", $name, ".ivf")), md5: include_str!(concat!("tests/streams/", $name, ".md5")), md5_without_grain: None, + #[cfg(target_os = "linux")] grain: None, size: $size, bit_depth: $depth, @@ -65,6 +67,7 @@ pub(crate) const STREAMS: &[Stream] = &[ stream!("aom-tiles", (640, 360), 8, true), Stream { md5_without_grain: Some(include_str!("tests/streams/aom-grain.nograin.md5")), + #[cfg(target_os = "linux")] grain: Some(include_str!("tests/streams/aom-grain.grain")), ..stream!("aom-grain", (352, 288), 8, true) }, diff --git a/crates/reims-vgpu-video/src/vaapi/va/av1.rs b/crates/reims-vgpu-video/src/vaapi/va/av1.rs index 44901a9b7..57331dfd4 100644 --- a/crates/reims-vgpu-video/src/vaapi/va/av1.rs +++ b/crates/reims-vgpu-video/src/vaapi/va/av1.rs @@ -39,7 +39,7 @@ impl Av1Decoder { /// Has the driver apply grain of the parameters `alter` makes of each frame's (the codec /// decoder's `alter_film_grain`), for the card tests. - #[cfg(test)] + #[cfg(all(test, target_os = "linux"))] pub(crate) fn alter_film_grain( &mut self, alter: fn(&mut crate::codec::av1::frame::FilmGrainParams), diff --git a/crates/reims-vgpu/src/graphics/av1.rs b/crates/reims-vgpu/src/graphics/av1.rs index 5839a6fe4..460a0aca8 100644 --- a/crates/reims-vgpu/src/graphics/av1.rs +++ b/crates/reims-vgpu/src/graphics/av1.rs @@ -10,7 +10,10 @@ //! the guest's output formats (two planes, 10 bits at most) would cut, and High (profile 1) is //! 4:4:4, which no arm's AV1 decoder lands; either is refused at its session's start. -use reims_vgpu_video::paravirt::{self, Stream}; +use reims_vgpu_video::paravirt; +// What the arms decline, where an arm builds: VA-API's on Linux and Windows, NVDEC's on Linux. +#[cfg(any(target_os = "linux", windows))] +use reims_vgpu_video::paravirt::Stream; /// AV1 among the arm's codec numbers (`RGFX_VIDEO_CODEC_*`), as the host's own code numbers it: /// far from the device's own numbers, and never written to the guest. @@ -38,6 +41,7 @@ pub struct GuestAv1 { impl GuestAv1 { /// The codec module's limits of the arm's AV1 decoder. + #[cfg(any(target_os = "linux", windows))] pub(crate) fn limits(self) -> reims_vgpu_video::codec::av1::Limits { reims_vgpu_video::codec::av1::Limits { max_width: self.max_width, @@ -61,6 +65,7 @@ pub(crate) fn vt_decoder() -> paravirt::Decoder { /// takes (Main, 4:2:0) of a depth or a size past the arm's; `None` where it decodes them. A /// frame the hardware fails, such as NVDEC's of a superres sequence, fails to the guest where /// it fails (`graphics::nvidia`). +#[cfg(any(target_os = "linux", windows))] pub(crate) fn declines(name: &str, av1: Option, stream: &Stream) -> Option { let Some(av1) = av1 else { return Some(format!("{name} decodes no AV1")); @@ -99,6 +104,7 @@ pub(crate) fn declines(name: &str, av1: Option, stream: &Stream) -> Op mod tests { use super::*; + #[cfg(any(target_os = "linux", windows))] fn stream(bits: u8, chroma: u8, width: u32, height: u32) -> Stream { Stream { codec: paravirt::Codec::Av1, @@ -112,6 +118,7 @@ mod tests { } } + #[cfg(any(target_os = "linux", windows))] const ARM: GuestAv1 = GuestAv1 { max_width: 8192, max_height: 4352, @@ -128,6 +135,7 @@ mod tests { } #[test] + #[cfg(any(target_os = "linux", windows))] fn a_stream_past_the_arms_depth_size_or_subsampling_is_declined() { assert_eq!(declines("A", Some(ARM), &stream(8, 1, 1920, 1080)), None); assert_eq!(declines("A", Some(ARM), &stream(10, 1, 8192, 4352)), None);