Search code examples
c++directx-11dxgi

DXGI EnumOutputs - no DXGI_OUTPUT_DESC and empty display modes array


Just encountered strange problem when trying to get available display modes. Let me explain...

At first, I enumerate available adapters and push then to std::vector and this works fine:

for(UINT i = 0; pFactory->EnumAdapters(i, &pAdapter) != DXGI_ERROR_NOT_FOUND; ++i)
    vAdapters->push_back(pAdapter);

Then I populate combobox with these adapters and allow to select one I want to use.

When I try to enumerate outputs and get available display modes, first I get selected adapter from combobox:

IDXGIAdapter* pSelectedAdapter = (*vAdapters)[index];

I checked address of selected adapter, and it matches with obtained one during enumeration of adapters.

Then, trying to enumerate outputs and get their description:

IDXGIOutput* pOutput;
DXGI_OUTPUT_DESC *odesc = 0;
for(UINT i = 0; pSelectedAdapter->EnumOutputs(i, &pOutput) != DXGI_ERROR_NOT_FOUND; ++i)
{
    pOutput->GetDesc(odesc);
}

And there is the problem. Loop finds my two monitors and returns pOutput pointer for all of them, but when I try to fire GetDesc(odesc), odesc is not returned. It looks like pOutput pointer is pointing to... empty object. Enumerating available display modes results in 0 available modes, no matter which back buffer format I want to check modes for.

Thanks, Patryk


Solution

  • You're passing in a null pointer to GetDesc when it's expecting a pointer to a DXGI_OUTPUT_DESC structure. Try below:

    IDXGIOutput* pOutput;
    DXGI_OUTPUT_DESC odesc;
    for(UINT i = 0; pSelectedAdapter->EnumOutputs(i, &pOutput) != DXGI_ERROR_NOT_FOUND; ++i)
    {
        pOutput->GetDesc(&odesc);
    }