Skip to content

Halve export lookahead VRAM via 8-bit downconvert - #431

Open
RufanMelfor wants to merge 2 commits into
reco-project:mainfrom
RufanMelfor:feat/lookahead-8bit-downconvert
Open

Halve export lookahead VRAM via 8-bit downconvert#431
RufanMelfor wants to merge 2 commits into
reco-project:mainfrom
RufanMelfor:feat/lookahead-8bit-downconvert

Conversation

@RufanMelfor

@RufanMelfor RufanMelfor commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Adds an opt-in export setting that buffers the lookahead window at 8-bit
instead of the source's native bit depth, roughly halving its VRAM cost on
10-bit footage (e.g. DJI Action 4 HEVC). This lets a longer lookahead fit on
lower-VRAM cards; sources that are already 8-bit are unaffected.

  • New render::lookahead_downconvert GPU pass (WGSL shader) that downconverts
    buffered lookahead frames to 8-bit before they enter the VRAM pool.
  • --export-lookahead-8bit CLI flag and a matching GUI checkbox under the
    lookahead/smoothness slider in the export panel.
  • The same buffered frames feed the final render, so enabling this trades a
    little gradient smoothness (sky, grass, floodlit surfaces) for memory —
    intended for VRAM-constrained setups, off by default.

Test plan

  • cargo fmt --all -- --check
  • cargo build --workspace --all-targets (excluding reco-obs/rig-calib,
    which require GStreamer/libcamera dev packages not present in this
    environment)
  • cargo test --workspace — all passing tests green; the two
    interop::cuda tests and matroska_reader_sees_partial_writes fail
    identically on plain main/origin/main (pre-existing
    environment/timing issues, unrelated to this change)
  • New unit test: render::lookahead_downconvert::tests::y_plane_downconvert_matches_expected_8bit_values
8Bit Look a Head

RufanMelfor and others added 2 commits July 16, 2026 13:08
…bit downconvert

The lookahead pool's VRAM cost scales with source bit depth; 10-bit
DJI footage with AI tracking enabled could exceed the budget on
smaller GPUs (see FRICTION.md for the full root-cause writeup).

Adds an opt-in LookaheadBitDepth::Reduced8Bit mode that downconverts
each buffered frame to 8-bit NV12 via a small GPU render pass
(lookahead_downconvert.wgsl) instead of the default bit-exact copy.
Implemented for both the cross-platform VramPool (Linux/macOS) and
Windows' D3D11 staging/import path (D3d11StagingPool::plane_source +
an explicit device.poll to close a cross-API sync gap between the
D3D11 write and the wgpu DX12 read of the same shared-handle slot).

Verified end-to-end with a real export against 3840x2880 10-bit HEVC
DJI footage + live AI tracking on an RTX 3060 Ti: VRAM budget dropped
from "needs 4.71 GB" to "needs 2.36 GB" (exactly half) with a clean
150/150 frame encode, no hangs or corruption. Linux/macOS path is
code-reviewed and test-covered but not live-verified this session
(no such hardware available) - see FRICTION.md.

Wired through StitchJob::lookahead_reduced_bit_depth(bool), the CLI
--lookahead-reduced-bit-depth flag, and a reco-gui export panel
checkbox. Default is Native (bit-exact), so existing behavior is
unchanged unless a caller opts in.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
…gin/main

The Tip component is defined by a separate fork-only commit not
included in this cherry-pick. Keep the plain CheckBox to match
origin/main's UI conventions; the explanatory text moves to a comment.
@github-actions

github-actions Bot commented Jul 16, 2026

Copy link
Copy Markdown

All contributors have signed the CLA. Thank you!
Posted by the CLA Assistant Lite bot.

@RufanMelfor

Copy link
Copy Markdown
Contributor Author

I have read the CLA Document and I hereby sign the CLA

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: In review

Development

Successfully merging this pull request may close these issues.

2 participants