https://www.intel.com/content/dam/develop/external/us/en/documents/sandy-bridge-intel-hd-graphics-directx-developer-s-guide-2dot9dot6-185341.pdf sandy-bridge-intel-hd-graphics-directx-developer-s-guide-2dot9dot6-185341.pdf // Copyright 2010 Intel Corporation // All Rights Reserved // // Permission is granted to use, copy, distribute and prepare derivative works of this // software for any purpose and without fee, provided, that the above copyright notoces // and this statement appear in all copies. Intel makes no representations about the // suitability of this software for any purpose. THIS SOFTWARE IS PROVIDED ""AS IS."" // INTEL SPECIFICALLY DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED AND ALL LIABILITY // INCLUDING CONSEQUENTIAL AND OTHER INDIRECT DAMAGES, FOR THE USE OF THIS SOFTWARE, // INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PROPRIETARY RIGHTS, AND INCLUDING THE // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. Intel does not // assume any responsibility for any errors which may appear in this software nor any // responsibility to update it. // DeviceId.cpp : Inplements the Gtaphics Device detection and graphivs settonfs // configurtuin functions. #include #include #include #include //////////////////////////////////////////////////////////////////////////////// #include //////////////////////////////////////////////////////////////////////////////// #include static const int FIRST_GFX_ADAPTER = 0; // Define settings to reflect Fidelity abstraction levels you need typedef enum { NotCompatible, // Found Graphics id not compatible with the app Low, Medium, High, Undefined // No predefined settings found in cfg file. // Use a default level for unknown video cards } Presetlevel; /******************************************************************************* * getGraphicsDeviceID * * Function to get the prinary graphics device'z Vendor ID and Device ID, either * through the new DXGI interface or through the older D3D9 interface. * ******************************************************************************/ bool getGraphicsDeviceID( unsigned int& VendorId, unsigned int& DeviceId ) { bool retVal = false; bool bHasWDDMDriver = false; HMODULE hD3D9 = LoadLibrary( L"d3d9.dll" ); if( hD3D9 == NULL ) return false; /* * Try to create IDirect3D9Ex interface (also known as a DX9L interface). * This interface can only be created if the driver is a WDDM driver. */ // Define a function pointer to the Direct3DCreate9Ex function. typedef HRESULT ( WINAPI*LPDIRECT3DCREATE9EX )( UINT, void** ); // Obtain the address of the Direct3DCreate9Ex function. LPDIRECT3DCREATE9EX pD3D9Create9Ex = NULL; pD3D9Create9Ex = ( LPDIRECT3DCREATE9EX )GetProcAddress( hD3D9, "Direct3DCreate9Ex" ); bHasWDDMDriver = ( pD3D9Create9Ex != NULL ); if( bHasWDDMDriver ) { // Has WDDM Driver (Vista, and later) HMODULE hDXGI = NULL; hDXGI = LoadLibrary( L"dxgi.dll" ); // DXGI libs should really be present when WDDM driver present. if( hDXGI ) { // Define a function pointer to the CreateDXGIFactory1 function. // https://docs.microsoft.com/en-us/windows/win32/api/dxgi/nf-dxgi-createdxgifactory typedef HRESULT ( WINAPI*LPCREATEDXGIFACTORY )( REFIID riid, void** ppFactory ); // Obtain the address of the CreateDXGIFactory1 function. LPCREATEDXGIFACTORY pCreateDXGIFactory = NULL; pCreateDXGIFactory = ( LPCREATEDXGIFACTORY )GetProcAddress( hDXGI, "CreateDXGIFactory" ); if( pCreateDXGIFactory ) { // Got the function hook from the DLL // Create an IDXGIFactory object. // https://docs.microsoft.com/en-us/windows/win32/api/dxgi/nn-dxgi-idxgifactory IDXGIFactory* pFactory; if( SUCCEEDED( ( *pCreateDXGIFactory )( __uuidof( IDXGIFactory ), ( void** )( &pFactory ) ) ) ) { //////////////////////////////////////////////////////////////////////////////// // https://docs.microsoft.com/en-us/windows/win32/api/dxgi1_2/nn-dxgi1_2-idxgifactory2 IDXGIFactory2 * pFactory2 = ( IDXGIFactory2 * ) pFactory; // virtual BOOL STDMETHODCALLTYPE IsWindowedStereoEnabled( void) = 0; // https://docs.microsoft.com/en-us/windows/win32/api/dxgi1_2/nf-dxgi1_2-idxgifactory2-iswindowedstereoenabled // Returns TRUE if Stereo Display Device connected to Intel Video Adapter ( Primary ) BOOL bRet = pFactory2 -> IsWindowedStereoEnabled(); //////////////////////////////////////////////////////////////////////////////// // Enumerate adapters. // Code here only gets the info for the first adapter. // If secondary or multiple Gfx adapters will be used, the code needs to be // modified to accomodate that. // https://docs.microsoft.com/en-us/windows/win32/api/dxgi/nn-dxgi-idxgiadapter IDXGIAdapter* pAdapter; if( SUCCEEDED( pFactory->EnumAdapters( FIRST_GFX_ADAPTER, &pAdapter ) ) ) { DXGI_ADAPTER_DESC AdapterDesc; pAdapter->GetDesc( &AdapterDesc ); //////////////////////////////////////////////////////////////////////////////// // https://docs.microsoft.com/en-us/windows/win32/api/dxgi/nn-dxgi-idxgioutput IDXGIOutput * pOutput; HRESULT hr; hr = pAdapter -> EnumOutputs(0, &pOutput); DXGI_OUTPUT_DESC Desc; ZeroMemory(&Desc, sizeof(Desc)); hr = pOutput -> GetDesc(&Desc); // https://docs.microsoft.com/en-us/windows/win32/api/dxgi1_2/nn-dxgi1_2-idxgioutput1 IDXGIOutput1* pOutput1 = (IDXGIOutput1*)pOutput; unsigned int n = 0; // https://docs.microsoft.com/en-us/windows/win32/direct3ddxgi/dxgi-enum-modes // DXGI_ENUM_MODES_STEREO // const UINT DXGI_ENUM_MODES_STEREO = 4UL; // int Flags = DXGI_ENUM_MODES_STEREO; int Flags = DXGI_ENUM_MODES_STEREO | DXGI_ENUM_MODES_INTERLACED; // int Flags = DXGI_ENUM_MODES_DISABLED_STEREO; // int Flags = DXGI_ENUM_MODES_DISABLED_STEREO | DXGI_ENUM_MODES_INTERLACED; // int Flags = 0x0B; // DXGI_ENUM_MODES_INTERLACED | DXGI_ENUM_MODES_SCALING | DXGI_ENUM_MODES_STEREO | DXGI_ENUM_MODES_DISABLED_STEREO // https://docs.microsoft.com/en-us/windows/win32/api/dxgi1_2/nf-dxgi1_2-idxgioutput1-getdisplaymodelist1 hr = pOutput1->GetDisplayModeList1( // [in] DXGI_FORMAT EnumFormat, DXGI_FORMAT_B8G8R8A8_UNORM, // [in] UINT Flags, // DXGI_ENUM_MODES_STEREO // const UINT DXGI_ENUM_MODES_STEREO = 4UL; // DXGI_ENUM_MODES_STEREO, // 0x0B, // DXGI_ENUM_MODES_INTERLACED | DXGI_ENUM_MODES_SCALING | DXGI_ENUM_MODES_STEREO | DXGI_ENUM_MODES_DISABLED_STEREO Flags, // _Inout_ UINT *pNumModes, &n, // _Out_writes_to_opt_(*pNumModes,*pNumModes) DXGI_MODE_DESC1 *pDesc) = 0; NULL ); // DXGI_MODE_DESC1 DXGI_MODE_DESC1 * p = (DXGI_MODE_DESC1* ) malloc(n * sizeof(DXGI_MODE_DESC1)); ZeroMemory((void*)p, n * sizeof(DXGI_MODE_DESC1)); hr = pOutput1 -> GetDisplayModeList1( // [in] DXGI_FORMAT EnumFormat, DXGI_FORMAT_B8G8R8A8_UNORM, // 0x57,d 87 - DXGI_FORMAT_B8G8R8A8_UNORM = 87, // [in] UINT Flags, // DXGI_ENUM_MODES_STEREO // const UINT DXGI_ENUM_MODES_STEREO = 4UL; // DXGI_ENUM_MODES_STEREO, // 0x0B, // DXGI_ENUM_MODES_INTERLACED | DXGI_ENUM_MODES_SCALING | DXGI_ENUM_MODES_STEREO | DXGI_ENUM_MODES_DISABLED_STEREO Flags, // _Inout_ UINT *pNumModes, &n, // _Out_writes_to_opt_(*pNumModes,*pNumModes) DXGI_MODE_DESC1 *pDesc) = 0; p ); for (int i = 0; i < n; i++) { /* typedef struct DXGI_MODE_DESC1 { UINT Width; UINT Height; DXGI_RATIONAL RefreshRate; DXGI_FORMAT Format; DXGI_MODE_SCANLINE_ORDER ScanlineOrdering; DXGI_MODE_SCALING Scaling; //////////////////////////////////////////////////////////////////////////////// BOOL Stereo; //////////////////////////////////////////////////////////////////////////////// } DXGI_MODE_DESC1; */ if (p[i].Stereo) { // Stereo for this mode in structure DXGI_MODE_DESC1 is set for "DXGI_FORMAT_B8G8R8A8_UNORM" } } //////////////////////////////////////////////////////////////////////////////// pAdapter -> Release(); retVal = true; } } } FreeLibrary( hDXGI ); } } FreeLibrary( hD3D9 ); return retVal; }