Skip to content

Run the temporal camera filter on Vulkan compute with CPU fallback - #1

Merged
RyanTheTide merged 9 commits into
mainfrom
feat/vulkan-temporal
Nov 6, 2026
Merged

RyanTheTide merged 9 commits into
mainfrom
feat/vulkan-temporal

Conversation

@RyanTheTide

@RyanTheTide RyanTheTide commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

The always-on temporal camera filter spends CPU time on every frame. Add cdn-backend-gpu.so, a Vulkan compute version of that stage. It is opt-in with temporal-backend = gpu (or --temporal-backend gpu), and auto stays on the CPU. On the Neo the GPU path costs about 3.3 times the CPU path's energy today, so it should not be the default until it is cheaper. With the GPU asked for, it falls back to the CPU when the plugin or device is unavailable or processing fails. --backend cpu forces the CPU for both stages, and the low-light backend remains independently triggered.

The compute shaders reproduce the CPU noise estimator, fixed-point history, motion tests, edge-preserving luma filter and both chroma passes. An optional companion entry preserves backend ABI v1 while importing linear NV12 DMA-BUF planes with producer-fence waits and foreign ownership transfers. Unsupported imports use one upload. Output copies into the existing PipeWire memory buffer.

Validation on Radeon RX 7900 XTX / RADV NAVI31:

  • Warnings-as-errors builds: 7/7 tests passed with GPU enabled, 5/5 with it disabled.
  • Upload: 320 generated frames across five geometries through 1080p matched CPU byte for byte, with equal noise estimates.
  • Actual DMA-BUF import: 48 frames across shared/split fd pools matched CPU, including offsets, padded strides, reuse, reset and rejected bounds. The import entry is tested directly, with no upload fallback.
  • Offline NV12 benchmark: 12 paired 1080p frames, maximum error 0, infinite Y/UV PSNR on every frame. Paced 30 fps benchmark smoke runs also completed.

Neo (J700), live camera at 1080p30: the default runs temporal cpu (18.2 ms per frame) and --temporal-backend gpu runs on the A18 Pro with imported DMA-BUFs and no upload (6.0 ms per frame), 300 frames each, no AVCs with SELinux enforcing. Build with -Dgpu=enabled -Dwerror=true on the Neo: 7/7 tests passed on the real GPU (CDN_TEST_REQUIRE_GPU=1).

Power on the Neo from 11-01 is in the validation notes. The other Macs' paired rows are still to do, and they only matter for when auto can move to the GPU.

RyanTheTide and others added 5 commits November 1, 2026 16:11
…lback

Reproduce the CPU fixed-point filter and noise estimator in a GPU plugin, prefer it for the temporal stage, and add parity and paced benchmark tooling. Hardware measurements remain pending.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Cover single and split plane DMA-BUF offsets, padded strides and invalid buffer ranges without a camera. Keep software Vulkan test workers bounded.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Cache successful loads while allowing missing or invalid plugins to be retried after installation. Test the optional DMA-BUF companion and legacy ABI v1 plugins without a GPU.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Drop old camera-pool references after synchronous processing completes, and probe DMA-BUF support again for the next stream. Document CPU fallback warmup.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The Vulkan loader pkg-config file may be installed without development headers. Auto mode should omit the plugin in that case; explicitly enabled builds should explain the missing dependency at configuration.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Export linear allocations on the build GPU and pass them through the plugin companion ABI. Compare every output byte and noise estimate to CPU across offset/stride variations, pool reuse, resets and rejected bounds, without a camera.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Document exact RADV upload and DMA-BUF parity, strict enabled/disabled builds, and historical CPU reference rows. Keep paired Apple camera latency, CPU, GPU busy and power results pending.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Measured this branch live on the Neo (fleet14b, 1080p30, camera open, 10 s means of the SMC PPMC rail at real governor clocks). Camera node alone 1637 mW. CPU backend 2034 mW (+397 mW, 42% of one core, 14.3 ms per frame). This Vulkan backend 2960 mW (+1323 mW, 3.5% CPU, 6.1 ms per frame). So today it costs about 3.3x the CPU backend in energy. Please keep auto on the CPU, with the GPU opt-in, until the GPU path is cheaper than the CPU. Look first at per-frame submit/fence waits holding GPU clocks, the output copy and the dispatch count per frame. For reference, macOS runs this filter on the AVE's MCTF hardware (VideoToolbox AppleMCTF), not on the GPU.

On the Neo at 1080p30 the Vulkan path costs about 3.3 times the CPU
path's extra energy (+1323 mW against +397 mW on the SMC PPMC rail), so
it should not be the default yet.

Add temporal-backend = auto | cpu | gpu, also --temporal-backend. auto
is the CPU for now. gpu runs the temporal stage on Vulkan compute when
the plugin and device work, else on the CPU as before. backend = cpu
still forces the CPU for both stages.

Assisted-by: LLM
Signed-off-by: Ryan Murray <[email protected]>
@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Made auto keep the temporal filter on the CPU, with the GPU opt-in through temporal-backend = gpu, and merged main in. Tested live on the Neo at 1080p30: the default ran temporal cpu and the opt-in ran temporal gpu on imported DMA-BUFs, 300 frames each. All 7 tests pass on the real GPU.

@RyanTheTide
RyanTheTide marked this pull request as ready for review November 6, 2026 03:26
@RyanTheTide
RyanTheTide merged commit 77cef5c into main Nov 6, 2026
@RyanTheTide
RyanTheTide deleted the feat/vulkan-temporal branch November 6, 2026 03:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant