DirectX 11 GetDisplayModeList() fails in Remote Desktop Connection

1

Good afternoon,

I have a barebone Direct3D App that works on a host PC, but fails to initialize DirectX while running via remote desktop.

I traced the failure to this call, where it fails with

    result = adapterOutput->GetDisplayModeList(DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_ENUM_MODES_INTERLACED, &numModes, NULL);
    if(FAILED(result))
    {
        return false;
    }

It fails with:

result = 0x887a0022 : A resource is not available at the time of the call, but may become available later.

The full initialization code is from Rastertek tutorials, found here: http://www.rastertek.com/dx11tut03.html

Does anyone know a workaround for this problem?

c++
windows
directx
directx-11
direct3d
asked on Stack Overflow Jun 14, 2019 by Mich

2 Answers

2

Remote Desktop involves some corner-cases, and keep in mind it's sometimes using the 'Microsoft Basic Renderer' (a.k.a. the software WARP driver). See this blog post.

You can also guard your use of GetDisplayModeList in the remote scenario by detecting it in the first place. For example, the legacy DXUT sample framework did this in it's enumeration code:

// mode for the current screen resolution for the remote session.
if( 0 != GetSystemMetrics( SM_REMOTESESSION) )
{
    DEVMODE DevMode;
    DevMode.dmSize = sizeof( DEVMODE );
    if( EnumDisplaySettings( nullptr, ENUM_CURRENT_SETTINGS, &DevMode ) )
    {
        NumModes = 1;
        pDesc[0].Width = DevMode.dmPelsWidth;
        pDesc[0].Height = DevMode.dmPelsHeight;
        pDesc[0].Format = DXGI_FORMAT_R8G8B8A8_UNORM;
        pDesc[0].RefreshRate.Numerator = 0;
        pDesc[0].RefreshRate.Denominator = 0;
        pDesc[0].ScanlineOrdering = DXGI_MODE_SCANLINE_ORDER_PROGRESSIVE;
        pDesc[0].Scaling = DXGI_MODE_SCALING_CENTERED;
    }
}

You also can't use 'full-screen exclusive' mode in remote desktop:

if( GetSystemMetrics(SM_REMOTESESSION) != 0 )
{
    sd.Windowed = TRUE;
}   

You don't really need to use GetDisplayModeList at all. Just pick a reasonable starting size or start your window 'maximized'. See the directx-vs-templates for an approach that just uses the 'native resolution' of the desktop for both windowed and 'fake full screen'. It also all works well for remote desktop.

Another 'corner-case' with remote desktop is "raw input" for mouse. See the implementation of Mouse from the DirectX Tool Kit.

answered on Stack Overflow Jun 15, 2019 by Chuck Walbourn
0

Not technically a solution, but the problem was in refresh rate initialization, bypassing this with a try{}-catch{} block allowed me to run with a default refresh rate via remote desktop. Everything else initialized without issues

answered on Stack Overflow Jun 14, 2019 by Mich

User contributions licensed under CC BY-SA 3.0