Prefer high performance GPUs in laptops with DX12 #746

This commit is contained in:
Robert Beckebans 2023-04-02 12:31:22 +02:00
parent 8c9f79b28f
commit 75e6fe2a27
2 changed files with 13 additions and 1 deletions

View file

@ -28,6 +28,7 @@
#if USE_DX11 || USE_DX12
#include <DXGI.h>
#include <dxgi1_6.h>
#endif
#if USE_DX11

View file

@ -121,11 +121,22 @@ static RefCountPtr<IDXGIAdapter> FindAdapter( const std::wstring& targetName )
return targetAdapter;
}
RefCountPtr<IDXGIFactory6> DXGIFactory6;
unsigned int adapterNo = 0;
while( SUCCEEDED( hres ) )
{
RefCountPtr<IDXGIAdapter> pAdapter;
hres = DXGIFactory->EnumAdapters( adapterNo, &pAdapter );
// Try to use EnumAdapterByGpuPreference method to get the better performing GPU.
if( S_OK == DXGIFactory->QueryInterface( IID_PPV_ARGS( &DXGIFactory6 ) ) )
{
hres = DXGIFactory6->EnumAdapterByGpuPreference( adapterNo, DXGI_GPU_PREFERENCE_HIGH_PERFORMANCE, IID_PPV_ARGS( &pAdapter ) );
}
else
{
hres = DXGIFactory->EnumAdapters( adapterNo, &pAdapter );
}
if( SUCCEEDED( hres ) )
{