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

Function PopulateDisplayModes

trinityal/dx12/Tr2VideoAdapterInfoALDx12.cpp:63–110  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

61}
62
63ALResult PopulateDisplayModes( AdapterInfo& output, DXGI_FORMAT backBufferFormat )
64{
65 auto inserted = output.m_displayModes.insert( std::make_pair( backBufferFormat, std::vector<DXGI_MODE_DESC>() ) );
66 auto& displayModes = inserted.first->second;
67 if( !inserted.second )
68 {
69 return S_OK;
70 }
71
72 uint32_t count = 0;
73 HRESULT hr = output.m_output->GetDisplayModeList(
74 backBufferFormat,
75 0,
76 &count,
77 nullptr );
78 if( hr == E_FAIL && backBufferFormat == DXGI_FORMAT_B8G8R8A8_UNORM && output.m_deviceInfoIndex == 0 )
79 {
80 CCP_LOGWARN( "Failed to get available display modes. Consider updating video driver." );
81 displayModes.resize( 1 );
82 return GetFallbackMode( displayModes[0] );
83 }
84 if( hr == DXGI_ERROR_NOT_CURRENTLY_AVAILABLE && backBufferFormat == DXGI_FORMAT_B8G8R8A8_UNORM )
85 {
86 CCP_LOGWARN( "Tr2VideoAdapterInfo: failed to enumerate display modes (running in remote desktop?)" );
87 count = 1;
88 }
89 else if( FAILED( hr ) || ( count == 0 ) )
90 {
91 return hr;
92 }
93
94 CCP_ASSERT( count > 0 );
95
96 displayModes.resize( count );
97 hr = output.m_output->GetDisplayModeList( static_cast<DXGI_FORMAT>( backBufferFormat ),
98 0,
99 &count,
100 &displayModes[0] );
101 if( hr == DXGI_ERROR_NOT_CURRENTLY_AVAILABLE && backBufferFormat == DXGI_FORMAT_B8G8R8A8_UNORM && !displayModes.empty() )
102 {
103 return GetFallbackMode( displayModes[0] );
104 }
105 else if( FAILED( hr ) )
106 {
107 return hr;
108 }
109 return S_OK;
110}
111
112ALResult InitializeDirect3D()
113{

Callers 3

InitializeDirect3DFunction · 0.70
GetAdapterModeCountMethod · 0.70
GetAdapterModeMethod · 0.70

Calls 2

emptyMethod · 0.80
GetFallbackModeFunction · 0.70

Tested by

no test coverage detected