How to support multi-GPU systems in Media Foundation?

591 views Asked by At

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.

1

There are 1 answers

2
Roman Ryltsov On

MFT instances [at instantiation stage at least] are not device specific. If you have two NVENC-enabled video adapters in your system, the encoder MFT is the same, with the same CLSID.

You specify the GPU to use by means of MFT_MESSAGE_SET_D3D_MANAGER message, which parameter wraps a D3D device and is GPU specific. This is where you select GPU for the encoder.

Also FYI NVIDIA H.264 Encoder MFT specifically fails to work correctly with anything but primary video adapter (including but not limited to this), if not everywhere the at least in great number of systems out there. In my understanding it's Nvidia's bug they are to fix in their MFT implementation.