DirectX11 SDK June (2010) Initialization on VC ++ 2010

Hope I posted a suitable forum on this!

I recently started programming with DirectX on June 11 (2010) SDK on VC ++ 2010, on Dell LapTop with an NVIDIA GeForce GT 630M GPU and Intel HD 4000 chip.

One of the things you do is try to list the available adapters and outputs, etc. Here is an example:

IDXGIFactory1 *factory; CreateDXGIFactory1(__uuidof(IDXGIFactory1), (LPVOID *)&factory); IDXGIAdapter *adapter; factory->EnumAdapters(0, &adapter); DXGI_ADAPTER_DESC desc; adapter->GetDesc(&desc); 

When I run this, the desc structure contains information for my Intel HD chip, NOT information for my GPU!

Now, when I open the NVidia control panel and select the GPU as the preferred processor and restart the sample, I get the information for my GPU in desc - which is right! And also, when I then try to list the outputs for this adapter, I find that there is at least one.

My question is: is there a way to accomplish this programmatically, as in the DirectX 11 SDK, so that I do not need to set this parameter in my NVidia control panel?

I went through the SDK code (for EmptyProject11), and somehow they “captured” the GPU instead of the Intel chip. I commented out all the code in the WinMain function and inserted the above code, and it still grabbed the GPU! Does this have anything to do with project setup, environment variables, command line arguments, or ...? I mean how do they do it!?!?!?

I would be grateful for your understanding of this issue.

thanks

+4
source share
1 answer

You can run all the presented adapters and get information about them by going through all possible adapters using the same function that you are already using:

 HRESULT r = S_OK; unsigned int adapterindex = 0; std::unique_ptr<IDXGIAdapter, ReleaseDirectX> dxgiadapter = null; // Save the result of EnumAdapters to r, and then check if it S_OK while ( ( r = factory->EnumAdapters( adapterindex, &dxgiadapter ) ) == S_OK ) { ++adapterindex; /* Work with your adapter here, particularly DXGI_ADAPTER_DESC */ } 

Usually you will have to automatically select the default or list them all in some kind of settings panel that the user can select. Another way to do this is to use the “Adapter Description” , which has the most video memory. This is not a reliable heuristic, but I use it to get the "best" (used in different ways) video cards for the system. However, the default reason is most often used by default.

Good luck

0
source

Source: https://habr.com/ru/post/1478940/


All Articles