Jump to content
  • Advertisement
Alex Fr

DX11 DXGI monitors enumeration does not give full size for Dell P2715Q monitor

Recommended Posts

I make DXGI adapters and monitors enumeration. The second monitor connected to my computer is Dell P2715Q, which has 3840*2160 resolution. However, the program reports it as 2560*1440, the second available resolution. Minimal code to reproduce:

#include "stdafx.h"
#include <Windows.h>
#include <stdio.h>
#include <tchar.h>
#include <iostream>
#include <DXGI.h>
#pragma comment(lib, "DXGI.lib")
using namespace std;

int main()
{
    IDXGIFactory1* pFactory1;

    HRESULT hr = CreateDXGIFactory1(__uuidof(IDXGIFactory1), (void**)(&pFactory1));

    if (FAILED(hr))
    {
        wcout << L"CreateDXGIFactory1 failed. " << endl;
        return 0;
    }

    for (UINT i = 0;; i++)
    {
        IDXGIAdapter1* pAdapter1 = nullptr;

        hr = pFactory1->EnumAdapters1(i, &pAdapter1);

        if (hr == DXGI_ERROR_NOT_FOUND)
        {
            // no more adapters
            break;
        }

        if (FAILED(hr))
        {
            wcout << L"EnumAdapters1 failed. " << endl;
            return 0;
        }

        DXGI_ADAPTER_DESC1 desc;

        hr = pAdapter1->GetDesc1(&desc);

        if (FAILED(hr))
        {
            wcout << L"GetDesc1 failed. " << endl;
            return 0;
        }

        wcout << L"Adapter: " << desc.Description << endl;

        for (UINT j = 0;; j++)
        {
            IDXGIOutput *pOutput = nullptr;

            HRESULT hr = pAdapter1->EnumOutputs(j, &pOutput);

            if (hr == DXGI_ERROR_NOT_FOUND)
            {
                // no more outputs
                break;
            }

            if (FAILED(hr))
            {
                wcout << L"EnumOutputs failed. " << endl;
                return 0;
            }

            DXGI_OUTPUT_DESC desc;

            hr = pOutput->GetDesc(&desc);

            if (FAILED(hr))
            {
                wcout << L"GetDesc1 failed. " << endl;
                return 0;
            }

            wcout << L"  Output: " << desc.DeviceName <<
                L"  (" << desc.DesktopCoordinates.left << L"," << desc.DesktopCoordinates.top << L")-(" <<
                (desc.DesktopCoordinates.right - desc.DesktopCoordinates.left) << L"," << 
                (desc.DesktopCoordinates.bottom - desc.DesktopCoordinates.top) << L")" << endl;

        }
    }

    return 0;
}

Program output:

Adapter: Intel(R) Iris(TM) Pro Graphics 6200
  Output: \\.\DISPLAY1  (0,0)-(1920,1200)
  Output: \\.\DISPLAY2  (1920,0)-(2560,1440)

DISPLAY2 is reported with low resolution.

 

Environment:

Windows 10 x64

Intel(R) Iris(TM) Pro Graphics 6200

DELL P2715Q

What can cause this behavior: DirectX restrictions, video memory, display adapter, driver, monitor? How can I fix this and get full available resolution?

Share this post


Link to post
Share on other sites
Advertisement
Posted (edited)

The desktop coordinate are based on the actual resolution your monitor is set, not the physical capabilities. It may also be influenced by the DPI setting ( not sure on this one, DPI management in windows sucks ).

You have to call IDXGIOutput::GetDisplayModeList to obtain the list of supported modes.

EDIT: Confirmed, it is DPI dependent ( https://msdn.microsoft.com/en-us/library/windows/desktop/bb173068(v=vs.85).aspx ) :

 

DesktopCoordinates

Type: RECT

A RECT structure containing the bounds of the output in desktop coordinates. Desktop coordinates depend on the dots per inch (DPI) of the desktop. For info about writing DPI-aware Win32 apps, see High DPI.

Edited by galop1n

Share this post


Link to post
Share on other sites

galop1n, I played with DPI by using SetProcessDpiAwareness API and setting the text size to 100% in Windows Display Settings. This helped to solve the problem, thank you for pointing in right direction.

Share this post


Link to post
Share on other sites

I got onto the same problem and that's true it depends on DPI but there is a soluition to this:

		adapterOutput->GetDesc(&desc);
		std::wcout << desc.DeviceName << std::endl;

		std::cout << "Monitor X: " << desc.DesktopCoordinates.right - desc.DesktopCoordinates.left << std::endl;
		std::cout << "Monitor Y: " << desc.DesktopCoordinates.bottom - desc.DesktopCoordinates.top << std::endl;

		DEVMODE displayMode{};
		displayMode.dmSize = sizeof(DEVMODE);

		EnumDisplaySettings(desc.DeviceName, ENUM_CURRENT_SETTINGS, &displayMode);

		float proc = (float)displayMode.dmPelsHeight / (desc.DesktopCoordinates.bottom - desc.DesktopCoordinates.top);
		std::cout << "DPI percentage: " << proc << "\n";
		std::cout << "Screen Start position: " << displayMode.dmPosition.x << " x " << displayMode.dmPosition.y << std::endl;

this is that simple, now you will know is it scaled or not and make proper code changes :) hope it helps

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!