From 4839c0e6f609310ae24f5ee5bb9df38c070e8f74 Mon Sep 17 00:00:00 2001 From: enricobuehler Date: Thu, 9 Jul 2026 11:47:06 +0200 Subject: [PATCH] fix(ci): windows clippy + rustfmt debt from the D3D11VA push MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The windows workflow has been red since a69a83b5: clippy 1.96 rejects the two field-reassign-with-default view-desc initializers in video_d3d11.rs (now struct literals), and with clippy failing first, the rustfmt step never ran — cargo fmt --all had genuine misses queued up in video_d3d11.rs / pf-presenter d3d11.rs + vk.rs / core abr.rs + client.rs (plus this session's config.rs). Formatting only beyond the two initializers; no behaviour change. Verified: clippy -p pf-client-core --all-targets -D warnings clean on the RTX Windows box, cargo fmt --all --check clean, core lib tests green. Co-Authored-By: Claude Fable 5 --- crates/pf-client-core/src/video_d3d11.rs | 63 +++++++++++++++--------- crates/pf-presenter/src/d3d11.rs | 7 ++- crates/pf-presenter/src/vk.rs | 8 +-- crates/punktfunk-core/src/abr.rs | 25 ++++++++-- crates/punktfunk-core/src/client.rs | 2 +- crates/punktfunk-core/src/config.rs | 5 +- 6 files changed, 76 insertions(+), 34 deletions(-) diff --git a/crates/pf-client-core/src/video_d3d11.rs b/crates/pf-client-core/src/video_d3d11.rs index cb4f51d6..bc919802 100644 --- a/crates/pf-client-core/src/video_d3d11.rs +++ b/crates/pf-client-core/src/video_d3d11.rs @@ -41,12 +41,11 @@ use windows::Win32::Foundation::HANDLE; use windows::Win32::Graphics::Direct3D::{D3D_FEATURE_LEVEL_11_0, D3D_FEATURE_LEVEL_11_1}; use windows::Win32::Graphics::Direct3D11::{ D3D11CreateDevice, ID3D11Device, ID3D11DeviceContext, ID3D11Multithread, ID3D11Texture2D, - ID3D11VideoContext1, ID3D11VideoDevice, ID3D11VideoProcessor, - ID3D11VideoProcessorEnumerator, ID3D11VideoProcessorOutputView, D3D11_BIND_RENDER_TARGET, - D3D11_BIND_SHADER_RESOURCE, D3D11_CREATE_DEVICE_BGRA_SUPPORT, - D3D11_CREATE_DEVICE_VIDEO_SUPPORT, D3D11_RESOURCE_MISC_SHARED_KEYEDMUTEX, - D3D11_RESOURCE_MISC_SHARED_NTHANDLE, D3D11_SDK_VERSION, D3D11_TEXTURE2D_DESC, - D3D11_USAGE_DEFAULT, D3D11_VIDEO_FRAME_FORMAT_PROGRESSIVE, + ID3D11VideoContext1, ID3D11VideoDevice, ID3D11VideoProcessor, ID3D11VideoProcessorEnumerator, + ID3D11VideoProcessorOutputView, D3D11_BIND_RENDER_TARGET, D3D11_BIND_SHADER_RESOURCE, + D3D11_CREATE_DEVICE_BGRA_SUPPORT, D3D11_CREATE_DEVICE_VIDEO_SUPPORT, + D3D11_RESOURCE_MISC_SHARED_KEYEDMUTEX, D3D11_RESOURCE_MISC_SHARED_NTHANDLE, D3D11_SDK_VERSION, + D3D11_TEXTURE2D_DESC, D3D11_USAGE_DEFAULT, D3D11_VIDEO_FRAME_FORMAT_PROGRESSIVE, D3D11_VIDEO_PROCESSOR_CONTENT_DESC, D3D11_VIDEO_PROCESSOR_INPUT_VIEW_DESC, D3D11_VIDEO_PROCESSOR_OUTPUT_VIEW_DESC, D3D11_VIDEO_PROCESSOR_STREAM, D3D11_VIDEO_USAGE_PLAYBACK_NORMAL, D3D11_VPIV_DIMENSION_TEXTURE2D, @@ -262,7 +261,9 @@ fn create_device(luid: Option<[u8; 8]>) -> Result<(ID3D11Device, ID3D11DeviceCon } } if chosen.is_none() && luid.is_some() && fallback.is_some() { - tracing::warn!("no DXGI adapter matches the Vulkan device LUID — using the first hardware adapter"); + tracing::warn!( + "no DXGI adapter matches the Vulkan device LUID — using the first hardware adapter" + ); } let adapter = chosen .or(fallback) @@ -384,8 +385,10 @@ impl SharedRing { unsafe { device.CreateTexture2D(&desc, None, Some(&mut tex)) } .context("create shared hand-off texture")?; let tex: ID3D11Texture2D = tex.expect("CreateTexture2D succeeded"); - let mutex: IDXGIKeyedMutex = tex.cast().context("shared texture lacks IDXGIKeyedMutex")?; - let resource: IDXGIResource1 = tex.cast().context("shared texture lacks IDXGIResource1")?; + let mutex: IDXGIKeyedMutex = + tex.cast().context("shared texture lacks IDXGIKeyedMutex")?; + let resource: IDXGIResource1 = + tex.cast().context("shared texture lacks IDXGIResource1")?; let handle = unsafe { resource.CreateSharedHandle( None, @@ -394,9 +397,11 @@ impl SharedRing { ) } .context("CreateSharedHandle")?; - let mut ov_desc = D3D11_VIDEO_PROCESSOR_OUTPUT_VIEW_DESC::default(); - ov_desc.ViewDimension = D3D11_VPOV_DIMENSION_TEXTURE2D; - ov_desc.Anonymous.Texture2D.MipSlice = 0; + let ov_desc = D3D11_VIDEO_PROCESSOR_OUTPUT_VIEW_DESC { + ViewDimension: D3D11_VPOV_DIMENSION_TEXTURE2D, + // Anonymous.Texture2D.MipSlice = 0 — the zeroed default. + ..Default::default() + }; let mut out_view = None; unsafe { video_device.CreateVideoProcessorOutputView( @@ -415,8 +420,13 @@ impl SharedRing { out_view, }); } - tracing::info!(width, height, slots = RING_SLOTS, generation, - "D3D11 shared hand-off ring built (VideoProcessor → BGRA8)"); + tracing::info!( + width, + height, + slots = RING_SLOTS, + generation, + "D3D11 shared hand-off ring built (VideoProcessor → BGRA8)" + ); Ok(SharedRing { slots, vp, @@ -449,7 +459,10 @@ pub(crate) struct D3d11vaDecoder { unsafe impl Send for D3d11vaDecoder {} impl D3d11vaDecoder { - pub(crate) fn new(codec_id: ffmpeg::codec::Id, luid: Option<[u8; 8]>) -> Result { + pub(crate) fn new( + codec_id: ffmpeg::codec::Id, + luid: Option<[u8; 8]>, + ) -> Result { use ffmpeg::ffi; let (device, context) = create_device(luid)?; // The adapter must expose the codec's DXVA profile — checked here, not at the first AU. @@ -498,8 +511,8 @@ impl D3d11vaDecoder { (*ctx).get_format = Some(get_format_d3d11); (*ctx).flags |= ffi::AV_CODEC_FLAG_LOW_DELAY as i32; (*ctx).thread_count = 1; // hwaccel: threads only add latency - // On top of the DPB-based pool libavcodec sizes: margin for the frames briefly held - // between decode and the ring copy (the copy runs immediately, so this is small). + // On top of the DPB-based pool libavcodec sizes: margin for the frames briefly held + // between decode and the ring copy (the copy runs immediately, so this is small). (*ctx).extra_hw_frames = 4; let r = ffi::avcodec_open2(ctx, codec, ptr::null_mut()); if r < 0 { @@ -601,10 +614,12 @@ impl D3d11vaDecoder { let index = (*self.frame).data[1] as usize as u32; // Input view over THIS slice of the decode array (cheap per-frame object). - let mut iv_desc = D3D11_VIDEO_PROCESSOR_INPUT_VIEW_DESC::default(); - iv_desc.FourCC = 0; // surface format speaks for itself - iv_desc.ViewDimension = D3D11_VPIV_DIMENSION_TEXTURE2D; - iv_desc.Anonymous.Texture2D.MipSlice = 0; + let mut iv_desc = D3D11_VIDEO_PROCESSOR_INPUT_VIEW_DESC { + FourCC: 0, // surface format speaks for itself + ViewDimension: D3D11_VPIV_DIMENSION_TEXTURE2D, + // Anonymous.Texture2D zeroed (MipSlice 0); ArraySlice is per-frame below. + ..Default::default() + }; iv_desc.Anonymous.Texture2D.ArraySlice = index; let mut in_view = None; video_device @@ -621,8 +636,10 @@ impl D3d11vaDecoder { _ => DXGI_COLOR_SPACE_YCBCR_STUDIO_G22_LEFT_P709, }; video_context1.VideoProcessorSetStreamColorSpace1(&ring.vp, 0, in_cs); - video_context1 - .VideoProcessorSetOutputColorSpace1(&ring.vp, DXGI_COLOR_SPACE_RGB_FULL_G22_NONE_P709); + video_context1.VideoProcessorSetOutputColorSpace1( + &ring.vp, + DXGI_COLOR_SPACE_RGB_FULL_G22_NONE_P709, + ); let stream = D3D11_VIDEO_PROCESSOR_STREAM { Enable: true.into(), diff --git a/crates/pf-presenter/src/d3d11.rs b/crates/pf-presenter/src/d3d11.rs index 5dbb37c8..3e824ec7 100644 --- a/crates/pf-presenter/src/d3d11.rs +++ b/crates/pf-presenter/src/d3d11.rs @@ -125,7 +125,12 @@ pub fn import( None, ) } - .with_context(|| format!("create {}x{} {mp_format:?} external image", frame.width, frame.height))?; + .with_context(|| { + format!( + "create {}x{} {mp_format:?} external image", + frame.width, frame.height + ) + })?; let result = (|| { // The handle's importable memory types, intersected with the image's requirement. diff --git a/crates/pf-presenter/src/vk.rs b/crates/pf-presenter/src/vk.rs index e6dd7507..675b09d0 100644 --- a/crates/pf-presenter/src/vk.rs +++ b/crates/pf-presenter/src/vk.rs @@ -55,7 +55,6 @@ struct HwCtxWin { ext_mem_win32: ash::khr::external_memory_win32::Device, } - /// A submitted hardware frame parked until the in-flight fence proves the GPU reads /// done: imported dmabuf planes, or a Vulkan-Video frame (FFmpeg's image — we own only /// the plane views; dropping the frame's guard releases the AVFrame back to the pool). @@ -666,8 +665,11 @@ impl Presenter { } #[cfg(windows)] if win_capable { - device_extensions - .extend(crate::d3d11::DEVICE_EXTENSIONS.iter().map(|n| CString::from(*n))); + device_extensions.extend( + crate::d3d11::DEVICE_EXTENSIONS + .iter() + .map(|n| CString::from(*n)), + ); } if has_hdr_metadata { device_extensions.push(CString::from(ash::ext::hdr_metadata::NAME)); diff --git a/crates/punktfunk-core/src/abr.rs b/crates/punktfunk-core/src/abr.rs index 857fd39c..e61bfca0 100644 --- a/crates/punktfunk-core/src/abr.rs +++ b/crates/punktfunk-core/src/abr.rs @@ -210,7 +210,10 @@ mod tests { // One bad window is a blip — no reaction. assert_eq!(c.on_window(ticks(start, 0), 1, 0, None, false), None); // The second consecutive bad window backs off ×0.7. - assert_eq!(c.on_window(ticks(start, 1), 1, 0, None, false), Some(14_000)); + assert_eq!( + c.on_window(ticks(start, 1), 1, 0, None, false), + Some(14_000) + ); c.on_ack(14_000); // Still bad after the cooldown → another ×0.7 step from the ACKED rate. assert_eq!(c.on_window(ticks(start, 6), 1, 0, None, false), None); // bad #1 again @@ -222,7 +225,10 @@ mod tests { let mut c = BitrateController::new(20_000); let start = Instant::now(); assert_eq!(c.on_window(ticks(start, 0), 1, 0, None, false), None); - assert_eq!(c.on_window(ticks(start, 1), 1, 0, None, false), Some(14_000)); + assert_eq!( + c.on_window(ticks(start, 1), 1, 0, None, false), + Some(14_000) + ); c.on_ack(14_000); // Two more bad windows land INSIDE the 3 s cooldown (ticks 2,3 = 1.5/2.25 s) → held. assert_eq!(c.on_window(ticks(start, 2), 1, 0, None, false), None); @@ -247,7 +253,10 @@ mod tests { let mut c = BitrateController::new(20_000); let start = Instant::now(); assert_eq!(c.on_window(ticks(start, 0), 1, 0, None, false), None); - assert_eq!(c.on_window(ticks(start, 1), 1, 0, None, false), Some(14_000)); + assert_eq!( + c.on_window(ticks(start, 1), 1, 0, None, false), + Some(14_000) + ); c.on_ack(14_000); // 13 clean windows → one additive step up (14000 + 14000/16 + 1 = 14876). let up = run_clean(&mut c, start, 2, 13); @@ -264,10 +273,16 @@ mod tests { let start = Instant::now(); // Establish a ~10 ms baseline over a few clean windows. for i in 0..4 { - assert_eq!(c.on_window(ticks(start, i), 0, 0, Some(10_000), false), None); + assert_eq!( + c.on_window(ticks(start, i), 0, 0, Some(10_000), false), + None + ); } // Delay climbs 40 ms above baseline with ZERO loss — bufferbloat. Two windows → back off. - assert_eq!(c.on_window(ticks(start, 4), 0, 0, Some(50_000), false), None); + assert_eq!( + c.on_window(ticks(start, 4), 0, 0, Some(50_000), false), + None + ); assert_eq!( c.on_window(ticks(start, 5), 0, 0, Some(52_000), false), Some(14_000) diff --git a/crates/punktfunk-core/src/client.rs b/crates/punktfunk-core/src/client.rs index b022e1c6..4f9871ea 100644 --- a/crates/punktfunk-core/src/client.rs +++ b/crates/punktfunk-core/src/client.rs @@ -11,11 +11,11 @@ //! invariant) plus a blocking data-plane pump; frames cross to the embedder over a bounded //! channel. All methods are safe to call from any single embedder thread. +use crate::abr::BitrateController; use crate::config::{CompositorPref, GamepadPref, Mode, Role}; use crate::error::{PunktfunkError, Result}; use crate::input::InputEvent; use crate::packet::FLAG_PROBE; -use crate::abr::BitrateController; use crate::quic::{ endpoint, io, window_loss_ppm, BitrateChanged, ColorInfo, HdrMeta, Hello, HidOutput, LossReport, ProbeRequest, ProbeResult, Reconfigure, Reconfigured, RequestKeyframe, RichInput, diff --git a/crates/punktfunk-core/src/config.rs b/crates/punktfunk-core/src/config.rs index e733f413..b09814a4 100644 --- a/crates/punktfunk-core/src/config.rs +++ b/crates/punktfunk-core/src/config.rs @@ -453,7 +453,10 @@ mod tests { assert_eq!(p % 2, 0, "FEC requires even shards"); assert!(p <= max_shard_payload()); let wire = HEADER_LEN + p + CRYPTO_OVERHEAD; - assert!(wire <= 1452, "sealed datagram {wire} B exceeds a 1500-MTU IPv6 hop"); + assert!( + wire <= 1452, + "sealed datagram {wire} B exceeds a 1500-MTU IPv6 hop" + ); assert!(HEADER_LEN + (p + 2) + CRYPTO_OVERHEAD > 1452, "not maximal"); }