0

I try to run a demo of d3d9 in a windows 10 virtual machine only with a NVIDIA RTX 3090 card. This windows vm is connected via windows remote desktop. Here is my demo:

#include <Windows.h>
#include <d3d9.h>
#include <stdio.h>

int main() {
    // sleep 5 seconds and manually minimize the remote desktop window immediately after the sleep operation
    Sleep(5000);

    IDirect3D9* pD3d9 = nullptr;
    
    pD3d9 = Direct3DCreate9(D3D9b_SDK_VERSION);
    
    UINT adapters = pD3d9->GetAdapterCount();

    for (UINT i = 0; i < adapters; i++) {
        D3DCAPS9 caps = {};
        HRESULT res = pD3d9->GetDeviceCaps(i, D3DDEVTYPE_HAL, &caps);
        if (FAILED(res)) {
            printf("Call GetDeviceCaps Failed:%x\n", res);
            break;
        }
    }

    pD3d9->Release();
    return 0;
}

GetDeviceCaps return S_OK when the remote desktop is a window or fullscreen mode. But, when running this demo in a minimized remote desktop, GetDeviceCaps return a error code: D3DERR_NOTAVAILABLE.

Does anyone know what is causing this call to fail?

Thanks!

Chen Chen
  • 27
  • 4
  • You already figured it out: Because the remote desktop window is minimized. – Raymond Chen Aug 15 '22 at 13:57
  • Thanks Raymond! But I don't know why this call will be failed. How does minimizing the remote desktop affect the execution result of this call? Do you know the deep reason? – Chen Chen Aug 16 '22 at 01:38
  • Naturally, when the remote desktop window is minimized, the session has no graphics to show the user. – Raymond Chen Aug 16 '22 at 03:25
  • However,other d3d9 methods can run successfully, such as `GetAdapterIdentifier` and `GetAdapterDisplayMode`. Is there any other reason why `GetDeviceCaps` call fails? OS or Driver? I guess. – Chen Chen Aug 16 '22 at 03:46
  • I don't know. I'm just saying that you seem to have figured out what causes `GetDeviceCaps` to return `D3DERR_NOTAVAILABLE`. It doesn't seem unreasonable. – Raymond Chen Aug 16 '22 at 04:04
  • OK, thanks! There should be something special, we don't know for now. – Chen Chen Aug 16 '22 at 06:23

1 Answers1

2

When 'minimized' legacy Direct3D 9 does NOT have access to the GPU. This is part of the emulation of legacy behavior. Direct3D9Ex or later are WDDM aware APIs, and support accessing the GPU when 'screen locked' or 'minimized' in cases where legacy Direct3D does not.

Chuck Walbourn
  • 38,259
  • 2
  • 58
  • 81
  • Thanks! Yes, Direct3D 11 can runs successfully when minimizing screen. Can you provide a link to some relevant description? I appreciate your help. – Chen Chen Aug 18 '22 at 06:45