Hi, all
Firstly , I enumrate all adapter in pc.I choose the one with one ranking score.
IDXGIAdapter* LOBBYWINDOW::GetMostSuitableAdapter() {
IDXGIAdapter* pBestAdapter = NULL;
size_t BestAdapterVMem = 0;
IDXGIAdapter* pAdapter = NULL;
for ( uint32_t i = 0; DXGIFactory->EnumAdapters( i, &pAdapter ) != DXGI_ERROR_NOT_FOUND; i++ ) {
DXGI_ADAPTER_DESC AdapterDesc;
pAdapter->GetDesc( &AdapterDesc );
if ( AdapterDesc.DedicatedVideoMemory > BestAdapterVMem ) {
BestAdapterVMem = AdapterDesc.DedicatedVideoMemory;
pBestAdapter = pAdapter;
}
}
return pBestAdapter;
}
As msdn tells us ,
EnumAdapters first returns the adapter with the output on which the desktop primary is displayed. This adapter corresponds with an index of zero.
Then , I use the best adapter to createdevice.
res = D3D11CreateDevice(
pBestAdapter, // DXGI Adapter
D3D_DRIVER_TYPE_UNKNOWN, // DriverType needs to be UNKNOWN when passing pAdapter != NULL
NULL, // Software Rasterizer Pointer (if DriverType is Software)
FeatureFlags, // Flags
featureLevels, // Supported features levels
ARRAYSIZE( featureLevels ), // number of supported features
D3D11_SDK_VERSION, // SDK Version
&D3DDevice, // out Device
&selectedFeatureLevel, // out The feature level that the adapter chose
&D3DDeviceContext // out DeviceContext
);
But I found that the dapter with high score isn't the first one in the enumrating list. In some guys's pc, the first adapter is integrated video card, How can I solve this situation?
I have two ideas, one is that I show a message box to tip the player to change the independent card for displaying , and the other way is just
using the integrate vido card to createdevice (this way sometimes may failed to createdevice).
Can anyone have some experience on this problem ? Please help me.