I'm not familiar with D3D11 but for my C++ AMP application I need to query the available devices, choose one that is not connected to a display to use it as a dedicated accelerator, and to turn off the TDR for that device.

This blog post discusses how to create a D3D11 device with TDR turned off. My problem is that I don't know how to choose the correct pAdapter parameter (an adapter without a display).

I tried to find the solution on MSDN, I think I should enumerate IDXGIAdapter2 and store the available adapters on an std::vector<IDXGIAdapter2*>, then use GetDesc2 on each element in the vector to get a DXGI_ADAPTER_DESC2 structure, then read its Description data member.

The problem is that there is no example or guidelines on how to enumerate IDXGIAdapter2. Two examples with descriptions exist but they are for IDXGIAdapter and IDXGIAdapter1.

So I would like to ask you guys to kindly help me or give me some hints on how to query the available devices and check their description.

The way I do this for DXGI 1.1 is I create an IDXGIFactory1 with CreateDXGIFactory1, and then I call EnumAdapters. The docs for IDXGIFactory2 suggest that the same approach will work, you just need to pass __uuidof(IDXGIFactory2) when calling CreateDXGIFactory.

The way I do this for DXGI 1.1 is I create an IDXGIFactory1 with CreateDXGIFactory1, and then I call EnumAdapters. The docs for IDXGIFactory2 suggest that the same approach will work, you just need to pass __uuidof(IDXGIFactory2) when calling CreateDXGIFactory.

Hi MJP,

Thank you for your help.

The documentation on IDXGIFactory2 is not clear because if I use 1.1 approach to get the devices then I won't have GetDesc2() method available, and another problem is that if I use IDXGI 1 or 1.1 I can't get any descriptions using GetDesc() and GetDesc1(). I wrote the following code to test IDXGI 1.1 and 2 and in both cases the pointers that I get from enumerating adapters point to nothing:

I checked the while loop where the enumeration is being done, it appears that the pointer to the device (adapter_ptr) contains an address and it does have the GetDesc1() method, the method receives a DXGI_ADAPTER_DESC1 pointer and it is supposed to fill the pointer with an address, but when the method returns the DXGI_ADAPTER_DESC1 pointer, it is NULL so something is wrong with the GetDesc1() method but I'm not sure what.

Here is a screenshot from debugging:

I have also changed nullptr to NULL the problem still exists. I don't think nullptr needs /clr, I thought /clr is only needed when Microsoft's C++ managed extensions are being used, nullptr is standard C++. Honestly I'm not a fan of managed C++ so I prefer not using /clr... unless I have to. Even then it will cause other problems since I have to turn off quite a number of other compiler options.

I think you're a bit confused about /clr option. It works even for an application which doesn't have managed data. You may want to read more about both nullptr and /clr. But anyhow, that isn't the problem at hand.

I think you're already quite close to the solution.

Unfortunately, I am unable to try out your code on my setup and check this issue firsthand.

You should check that EnumAdapters1 returns S_OK.
Also you should check that GetDesc1 return S_OK.
If they don't return S_OK, then their error return code should hint where the problem lies - Get Desc1 expects pointer to existing structure, not NULL. It write to the object passed, but if you pass NULL there's nowhere to write adapter properties.

You should check that EnumAdapters1 returns S_OK.
Also you should check that GetDesc1 return S_OK.
If they don't return S_OK, then their error return code should hint where the problem lies - Get Desc1 expects pointer to existing structure, not NULL. It write to the object passed, but if you pass NULL there's nowhere to write adapter properties.