public static IDXGIFactory3 *GetLatestDxgiFactory(IDXGIFactory3 *dxgiFactory, out uint dxgiFactoryVersion) { IDXGIFactory3 *result; if (dxgiFactory->QueryInterface(__uuidof <IDXGIFactory7>(), (void **)&result).SUCCEEDED) { dxgiFactoryVersion = 7; _ = dxgiFactory->Release(); } else if (dxgiFactory->QueryInterface(__uuidof <IDXGIFactory6>(), (void **)&result).SUCCEEDED) { dxgiFactoryVersion = 6; _ = dxgiFactory->Release(); } else if (dxgiFactory->QueryInterface(__uuidof <IDXGIFactory5>(), (void **)&result).SUCCEEDED) { dxgiFactoryVersion = 5; _ = dxgiFactory->Release(); } else if (dxgiFactory->QueryInterface(__uuidof <IDXGIFactory4>(), (void **)&result).SUCCEEDED) { dxgiFactoryVersion = 4; _ = dxgiFactory->Release(); } else { dxgiFactoryVersion = 3; result = dxgiFactory; } return(result); }
ValueList <GraphicsAdapter> GetAdapters(IDXGIFactory3 *dxgiFactory) { IDXGIAdapter1 *dxgiAdapter1 = null; var adapters = new ValueList <GraphicsAdapter>(); var index = 0u; do { var result = dxgiFactory->EnumAdapters1(index, &dxgiAdapter1); if (result.FAILED) { if (result != DXGI_ERROR_NOT_FOUND) { ReleaseIfNotNull(dxgiAdapter1); ExceptionUtilities.ThrowExternalException(nameof(IDXGIFactory1.EnumAdapters1), result); } index = 0; } else { var adapter = new GraphicsAdapter(this, dxgiAdapter1); adapters.Add(adapter); index++; dxgiAdapter1 = null; } }while (index != 0); return(adapters); }