Hi there,
Below is some code that just fills out a vector(array) of adapter structs with some data, using an iteration loop.
Code:
UINT i = 0;
IDXGIAdapter* adapter = nullptr;
std::vector<IDXGIAdapter*> adapterList;
while(mdxgiFactory->EnumAdapters(i, &adapter) != DXGI_ERROR_NOT_FOUND)
{
DXGI_ADAPTER_DESC desc;
adapter->GetDesc(&desc);
..... sometime later
adapterList.push_back(adapter);
++i;
}
Then an iteration loop that calls a function to log the outputs (monitors - or any type of display) for each found adapter:
Code:
for(size_t i = 0; i < adapterList.size(); ++i)
{
LogAdapterOutputs(adapterList[i]);
ReleaseCom(adapterList[i]);
}
Finally in the LogAdapterOutputs function (a user defined function fyi) there is the following:
Code:
void D3DApp::LogAdapterOutputs(IDXGIAdapter* adapter)
{
UINT i = 0;
IDXGIOutput* output = nullptr;
while(adapter->EnumOutputs(i, &output) != DXGI_ERROR_NOT_FOUND)
{
DXGI_OUTPUT_DESC desc;
output->GetDesc(&desc);
std::wstring text = L"***Output: ";
text += desc.DeviceName;
text += L"\n";
OutputDebugString(text.c_str());
}
..... some other stuff
}
Provided the adapter->EnumOutputs(i, &output) doesn't return DXGI_ERROR_NOT_FOUND it keeps going. It doesn't run for very long as usually obviously there is only 1 display (the computer monitor) or in some cases maybe a handful more.
All works (it's not my code) but it outputs the following in the debug box:
One can ignore the width and height parts they're from another iteration loop calling a function I've not shown here. However notice that for 2 found adapters namely:
AMD Radeon R5 200 Series
and
Microsoft Basic Render Driver
There is only one display shown named \\.\DISPLAY1. I'm curious as to why this is. I would have thought that even if there were only one display available both adapters would have its details stored in their relevant data. Microsoft documentation mentions something about the primary display currently in use being chosen, I'm wondering if this allows only the adapter currently serving the computer to have an output list, thus why for one of the adapters (most likely the Microsoft Basic Render Driver) no outputs are shown.
Is that why perhaps for that adapter the adapter->EnumOutputs(i, &output) function returns the error which makes the while condition in the LogAdapterOutputs function exit without printing an output for that adapter.
Hope that made some sense, thanks