IDXGIOutput::FindClosestMatchingMode fails when passing in certain ID3D12Devices as argument.

Author: hsiverssonCreated May 24, 2023Updated Mar 30, 2026
Labelsquestion

Hello,

We recently discovered that the call to FindClosestMatchingMode on the IDXGIOutput instance always fail with a E_INVALID_CALL return code when certain ID3D12Devices are passed in as the third argument IUnknown *pConcernedDevice.

Enabling the D3D12 Debug Layer does not provide any additional information about the issue apart from an internally thrown com_ptr exception.

I've tested converting to the newer IDXGIOutput1::FindClosestMatchingMode1 function, but it throws the same error.

We suspect this might be due to our usage of the D3D12 Agility SDK, and that this function was never updated to properly support it. We're currently using D3D12 Agility version 1.606.4.

For now, we can get away without passing any device, since we do all our format checking before even reaching this point. But it is such a small thing that can easily go unnoticed. (We've had this issue for at least a year)

ID3D12Device* ourDevice; // Assume this is a valid device
IUnknown* d3D12Device = ourDevice;

DXGI_MODE_DESC validatedMode = {};
HRESULT result = output->FindClosestMatchingMode(someModeDesc, &validatedMode, d3D12Device);

I can provide more details and testing if needed as we have a solid repro case for this.

Source: microsoft/DirectX-Graphics-Samples