c++windowsdirect3dms-media-foundation

How to support multi-GPU systems in Media Foundation?


I need to create D3D device and context on the correct GPU, which is the GPU implementing the encoder.

The documentation for MFT_ENUM_ADAPTER_LUID says it requires Windows 10, in reality the NVENC MFT doesn’t expose that attribute even on Win10.

The documentation for MFT_ENUM_HARDWARE_URL_Attribute says the value is the symbolic link for the device driver, in reality the NVENC MFT doesn’t return any GUID links, the value is the same as in MFT_FRIENDLY_NAME_Attribute, specifically L"NVIDIA H.264 Encoder MFT"

MFT_ENUM_HARDWARE_VENDOR_ID_Attribute appears to work OK, returns L"VEN_10DE"so I can parse that into a number and match against VendorId field of DXGI_ADAPTER_DESC structure. However the documentation for that attribute says the support is optional.

I don’t like optional, I want reliable. How to match hardware encoder MFTs to GPUs? There’re upcoming PCs with two GPUs both by AMD, like Asus FX505DY, the vendor ID trick won’t work on such systems.


Solution

  • On Win10 there is a new API call: MFTEnum2, which allows exactly this: "discover the hardware MFTs that correspond to a specific video adapter".