Skip to content

Decoding: GPU and CPU together faster with big GPUs - #511

Merged
JeromeMartinez merged 3 commits into
MediaArea:mainfrom
JeromeMartinez:HybridOutput
Oct 29, 2026
Merged

JeromeMartinez merged 3 commits into
MediaArea:mainfrom
JeromeMartinez:HybridOutput

Conversation

@JeromeMartinez

Copy link
Copy Markdown
Member

With a big GPU, --decoder auto (GPU and CPU together) was not faster than --decoder vulkan (GPU alone), sometimes slower. Two limits:

  • Hash computing: 1 thread computes the MD5 of 8 frames in SIMD lanes, about 22 frames per second with 6464x4852 RGB 16-bit frames, as fast as the GPU alone. Frames waited for an output thread, the decoders waited for the frames in flight, and the GPU was idle 25% of the time in auto.
    → Twice more output threads and frames in flight, so a second thread computes hashes in lanes.
  • 1 frame at a time on the GPU: the FFmpeg Vulkan FFV1 decoder waits for the previous frame before the next one, so a big GPU is not fully used.
    → A second FFmpeg decoder with Vulkan, on the same device (a second device is slower, the GPU switches between devices), only with NVIDIA GPUs with at least 64 streaming multiprocessors (VK_NV_shader_sm_builtins). It starts after the first decoder decoded a frame: initializing both at the same time lost the device (VK_ERROR_DEVICE_LOST).

More frames in flight only when the decoding is fast. Peak memory in auto with 6K5K16bit frames: 5.4-5.8 GB instead of 4.0 GB.

With fast decoders, 1 thread computing the MD5 of 8 frames in
SIMD lanes (about 22 frames per second) was slower than the decoders:
frames waited for an output thread and the decoders waited for the
frames in flight (GPU idle 25% of the time, auto not faster than Vulkan).
Twice more output threads and frames in flight, so a second thread
computes hashes in lanes.
Same speed with slower decoders, more memory.
The FFmpeg Vulkan FFV1 decoder waits for the previous frame before the
next one, a big GPU is not fully used. A second FFmpeg decoder with
Vulkan on the same device decodes other frames in parallel.
Not faster on low end cards, so only with NVIDIA GPUs with at least 64
streaming multiprocessors (VK_NV_shader_sm_builtins).
The second decoder starts after the first one decoded a frame: both
initializations at the same time lost the device (VK_ERROR_DEVICE_LOST).
Its threads and counters have their own names in the trace (thread names
numbered by the trace are read as frame counts by test/decoders.sh), its
stages are counted with the ones of the first decoder.
auto uses the second FFmpeg decoder with Vulkan only with a big GPU,
values with vulkan twice (e.g. internal+vulkan+vulkan) always use it.
@JeromeMartinez
JeromeMartinez merged commit 5853ccb into MediaArea:main Oct 29, 2026
3 checks passed
@JeromeMartinez
JeromeMartinez deleted the HybridOutput branch October 29, 2026 11:04
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