Just a small test here to feature use of multiple GPUs within single Media Foundation pipeline. The initial idea here is pretty simple: quite so many systems are equipped with multiple GPUs, some have “free” onboard Intel GPU idling in presence of regular video card. Some other systems have integrated “iGPU” and discrete “dGPU” seamlessly blended by DXGI.
Media Foundation API does not bring any specific feature set to leverage multiple GPUs at a time, but this is surely possible to take advantage of.
The application creates a 20 second long video clips by combining GPUs: one GPU is used for video rendering and another is a host of hardware H.264 video encoding. No system memory is used for uncompressed video: system memory jumps in first to receive encoded H.264 bitstream. The Media Foundation pipeline hence is:
- Media Source generating video frames off its video stream using the first GPU
- Transform to combine multiple GPUs
- H.264 video encoder transform specific to second GPU
- Stock MP4 Media Sink
The pipeline runs in a single media session pretty much like normal pipeline. Media Foundation is designed in the way that primitives do not have to be aligned in their GPU usage with the pipeline. Surely they have to share devices and textures so that they all could operate together, but pipeline itself does not put much of limitations there.
Microsoft Windows [Version 10.0.18363.815] (c) 2019 Microsoft Corporation. All rights reserved. C:\Temp>HeterogeneousRecordFile.exe HeterogeneousRecordFile.exe 20200502.1-11-gd3d16d5 (Release) d3d16d51e7f2a098c5765d445714f14051c7a68d HEAD -> master, origin/master 2020-05-09 23:51:54 +0300 -- Found 2 DXGI adapters Trying heterogeneous configurationsâ€¦ Using NVIDIA GeForce GTX 1650 to render video and Intel(R) HD Graphics 4600 to encode the content Using filename HeterogeneousRecordFile-20200509-235406.mp4 for recording Using Intel(R) HD Graphics 4600 to render video and NVIDIA GeForce GTX 1650 to encode the content Using filename HeterogeneousRecordFile-20200509-235411.mp4 for recording Trying trivial configuration with loopback data transferâ€¦ Using NVIDIA GeForce GTX 1650 to render video and NVIDIA GeForce GTX 1650 to encode the content Using filename HeterogeneousRecordFile-20200509-235416.mp4 for recording Using Intel(R) HD Graphics 4600 to render video and Intel(R) HD Graphics 4600 to encode the content Using filename HeterogeneousRecordFile-20200509-235419.mp4 for recording
This is just a simple use case, I believe there can be other: GPUs are pretty powerful for certain specific tasks, and they are also equipped with video specific ASICs.
- 64-bit: HeterogeneousRecordFile.exe (in .ZIP archive)
- License: This software is free to use