MCPcopy Create free account
hub / github.com/carbonengine/trinity / InitializeDirect3D

Function InitializeDirect3D

trinityal/dx11/Tr2VideoAdapterInfoALDx11.cpp:112–198  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

110}
111
112ALResult InitializeDirect3D()
113{
114 s_adapters.resize( 0 );
115 s_deviceInfo.resize( 0 );
116
117 s_factory = nullptr;
118
119 CR_RETURN_HR( CreateDXGIFactory1(
120 __uuidof( IDXGIFactory1 ),
121 (void**)( &s_factory ) ) );
122
123 const D3D_FEATURE_LEVEL levelWanted = D3D_FEATURE_LEVEL_11_0;
124 D3D_FEATURE_LEVEL levelSupported;
125 uint32_t dwFlags = 0;
126
127 if( !s_factory )
128 {
129 return E_FAIL;
130 }
131
132 CComPtr<IDXGIAdapter1> adapterPtr;
133
134 uint32_t adapterIndex = 0;
135 while( SUCCEEDED( s_factory->EnumAdapters1( adapterIndex++, &adapterPtr ) ) )
136 {
137 CComPtr<ID3D11Device> device;
138 CComPtr<ID3D11DeviceContext> context;
139
140 if( FAILED( D3D11CreateDevice( adapterPtr,
141 D3D_DRIVER_TYPE_UNKNOWN,
142 0,
143 dwFlags,
144 &levelWanted,
145 1,
146 D3D11_SDK_VERSION,
147 &device,
148 &levelSupported,
149 &context ) ) )
150 {
151 continue;
152 }
153
154 DXGI_ADAPTER_DESC1 adapterDesc;
155 CR_RETURN_HR( adapterPtr->GetDesc1( &adapterDesc ) );
156
157 CCP_LOG( "Found video adapter \"%S\"", adapterDesc.Description );
158
159 DeviceInfo deviceInfo;
160 memset( deviceInfo.m_formatSupport, 0, sizeof( deviceInfo.m_formatSupport ) );
161 for( unsigned i = 0; i < DeviceInfo::FORMAT_COUNT; ++i )
162 {
163 device->CheckFormatSupport( static_cast<DXGI_FORMAT>( i ), deviceInfo.m_formatSupport + i );
164 }
165
166 CComPtr<IDXGIOutput> outputPtr;
167 uint32_t outputIndex = 0;
168 bool hasValidOutputs = false;
169 while( SUCCEEDED( adapterPtr->EnumOutputs( outputIndex++, &outputPtr ) ) )

Callers 2

RefreshDataMethod · 0.70
GetVideoAdapterDX11Method · 0.70

Calls 4

sizeMethod · 0.80
emptyMethod · 0.80
ReleaseMethod · 0.80
PopulateDisplayModesFunction · 0.70

Tested by

no test coverage detected