Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions crates/reco-cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,15 @@ enum Commands {
#[arg(long, default_value_t = 1.5)]
lookahead: f64,

/// Downconvert the lookahead pool to 8-bit before buffering,
/// roughly halving its VRAM cost on 10-bit sources (e.g. DJI
/// Action 4 HEVC) - use this if export fails with a "not enough
/// VRAM for a Ns lookahead" error. No effect on 8-bit sources.
/// The same buffered frames feed the final render too, so this
/// trades a little gradient smoothness for memory.
#[arg(long)]
lookahead_reduced_bit_depth: bool,

/// Tracking mode: "field" (ball + players, default), "ball"
/// (ball only), "sweep" (no AI, debug pan). field is robust with
/// COCO models; ball-only follows the weak COCO ball alone.
Expand Down Expand Up @@ -791,6 +800,7 @@ fn main() -> anyhow::Result<()> {
model,
detection_interval,
lookahead,
lookahead_reduced_bit_depth,
tracking,
quality_value,
preset,
Expand Down Expand Up @@ -822,6 +832,7 @@ fn main() -> anyhow::Result<()> {
model_path: model.as_deref(),
detection_interval,
lookahead,
lookahead_reduced_bit_depth,
tracking_mode: &tracking,
quality_value,
preset,
Expand Down
7 changes: 7 additions & 0 deletions crates/reco-cli/src/stitch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ pub struct StitchArgs<'a> {
pub model_path: Option<&'a str>,
pub detection_interval: u64,
pub lookahead: f64,
pub lookahead_reduced_bit_depth: bool,
pub tracking_mode: &'a str,
pub quality_value: Option<u8>,
pub preset: Option<String>,
Expand Down Expand Up @@ -153,6 +154,12 @@ pub fn run_stitch(args: StitchArgs<'_>, interrupted: &Arc<AtomicBool>) -> anyhow
"Lookahead: {:.1}s buffer enabled (AI tracking active)",
args.lookahead
);
if args.lookahead_reduced_bit_depth {
job = job.lookahead_reduced_bit_depth(true);
log::info!(
"Lookahead bit depth: reduced to 8-bit (halved VRAM, 10-bit sources only)"
);
}
} else {
log::debug!(
"Lookahead {:.1}s ignored: no AI tracking (needs --model, non-sweep); \
Expand Down
45 changes: 43 additions & 2 deletions crates/reco-core/src/interop/d3d11.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,32 @@ struct StagingState {
device: ID3D11Device,
context: ID3D11DeviceContext,
staging: Vec<ID3D11Texture2D>,
_wgpu_textures: Vec<wgpu::Texture>,
/// The imported multi-planar (NV12/P010) wgpu texture per slot. Read
/// via [`D3d11StagingPool::plane_source`] for a plane-aspect-selected
/// `copy_texture_to_texture` into a same-format destination (see
/// `session::vram_pool::VramPool::copy_from_d3d11`) - `y_views`/
/// `uv_views` below are already aspect-selected and cannot themselves
/// be the source of a texture-to-texture copy (that needs the raw
/// texture + an aspect, not a view).
wgpu_textures: Vec<wgpu::Texture>,
y_views: Vec<wgpu::TextureView>,
uv_views: Vec<wgpu::TextureView>,
event_query: ID3D11Query,
cuda_nv12: Option<Vec<crate::interop::cuda::CudaImportedNv12>>,
}

/// Borrowed handles for one D3D11 staging slot - see
/// [`D3d11StagingPool::plane_source`].
pub struct D3d11PlaneSource<'a> {
/// The raw multi-planar (NV12/P010) imported texture. Select
/// `TextureAspect::Plane0` (Y) / `Plane1` (UV) for a same-format copy.
pub texture: &'a wgpu::Texture,
/// Pre-built Y plane view (`Plane0`), for sampling in a render pass.
pub y_view: &'a wgpu::TextureView,
/// Pre-built UV plane view (`Plane1`), for sampling in a render pass.
pub uv_view: &'a wgpu::TextureView,
}

/// Double-buffered NV12 staging pool for D3D11VA -> wgpu zero-copy.
///
/// Allocates 4 staging textures (2 per camera, ping-pong) with shared
Expand Down Expand Up @@ -360,7 +379,7 @@ impl D3d11StagingPool {
device,
context,
staging: staging_textures,
_wgpu_textures: wgpu_textures,
wgpu_textures,
y_views,
uv_views,
cuda_nv12,
Expand Down Expand Up @@ -492,6 +511,28 @@ impl D3d11StagingPool {
.uv_views[slot]
}

/// Borrowed handles for one staging slot, for copying it into a
/// longer-lived pool (`session::vram_pool::VramPool::copy_from_d3d11`).
///
/// Includes both the raw multi-planar `texture` (for a plane-aspect-
/// selected `copy_texture_to_texture` when the destination format
/// matches this pool's `pixel_format` - bit-exact, no shader) and the
/// pre-built plane views (for a downconvert render pass when the
/// destination is a different, lower bit depth - a raw copy cannot
/// change bit depth, and a render pass only needs a view, not the
/// aspect-selected texture).
///
/// # Panics
/// Panics if called before the first `stage_frame` (pool not initialized).
pub fn plane_source(&self, slot: usize) -> D3d11PlaneSource<'_> {
let state = self.state.as_ref().expect("staging pool not initialized");
D3d11PlaneSource {
texture: &state.wgpu_textures[slot],
y_view: &state.y_views[slot],
uv_view: &state.uv_views[slot],
}
}

/// Number of staging slots.
pub fn n_slots(&self) -> usize {
self.n_slots
Expand Down
Loading
Loading