Thread: DirectX Output Descriptor Query - only 1 putput shown for two found adapters

  1. #1
    Registered User
    Join Date
    Jan 2010
    Posts
    233

    Lightbulb DirectX Output Descriptor Query - only 1 putput shown for two found adapters

    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:

    DirectX Output Descriptor Query - only 1 putput shown for two found adapters-outputs-jpg

    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

  2. #2
    Registered User
    Join Date
    Dec 2017
    Posts
    1,664
    I think you are basically correct that it only shows the displays for the active adapter. You should rewrite the code so that the EnumOutputs loop is inside the EnumAdapters loop so you can see which adapter the display is connected to (as you say, probably the AMD one).
    Code:
    for (UINT i = 0; mdxgiFactory->EnumAdapters(i, &adapter) != DXGI_ERROR_NOT_FOUND; ++i)
    {
        DXGI_ADAPTER_DESC desc;
        adapter->GetDesc(&desc);
     
    //  whatever else you've hidden here, presumably at least printing the adapter name
     
        LogAdapterOutputs(adapter);
        ReleaseCom(adapter);
     
    //    adapterList.push_back(adapter); // don't need this or the vector
    }
    BTW, there's no need to put the word "iteration" in front of the word "loop". What would a loop do if not iterate?
    All truths are half-truths. - A.N. Whitehead

  3. #3
    Registered User
    Join Date
    Jan 2010
    Posts
    233
    All noted John thanks very much for your reply

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Initialize vectors from streams via itr adapters
    By sean_cantab in forum C++ Programming
    Replies: 15
    Last Post: 12-01-2016, 08:48 AM
  2. Can't get Blutooth adapters working
    By geek@02 in forum Tech Board
    Replies: 1
    Last Post: 05-19-2012, 04:58 AM
  3. Getting Information about Network Adapters
    By Mastadex in forum Windows Programming
    Replies: 0
    Last Post: 01-11-2010, 02:03 PM
  4. using cat to putput data and save
    By bigmac(rexdale) in forum Linux Programming
    Replies: 8
    Last Post: 12-17-2007, 08:29 AM
  5. dialog box shown => message ?
    By vovor in forum Windows Programming
    Replies: 1
    Last Post: 10-14-2002, 11:31 PM

Tags for this Thread