microsoft / DirectX-Graphics-Samples

This repo contains the DirectX Graphics samples that demonstrate how to build graphics intensive applications on Windows.
MIT License
5.89k stars 2k forks source link

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

Open hsiversson opened 1 year ago

hsiversson commented 1 year ago

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.

jenatali commented 1 year ago

D3D12 devices are never a valid input. Enabling the DXGI debug layer would provide an output message indicating that the passed in device doesn't support the IDXGIDevice interface.

hsiversson commented 1 year ago

@jenatali Thanks for clarifying! If this is the case, I would probably suggest to update the MSDN documentation to clarify the usage of the parameter.

Currently it just specifies this:

[in, optional] pConcernedDevice Type: IUnknown* A pointer to the Direct3D device interface. If this parameter is NULL, only modes whose format matches that of pModeToMatch will be returned; otherwise, only those formats that are supported for scan-out by the device are returned. For info about the formats that are supported for scan-out by the device at each feature level: