File tree Expand file tree Collapse file tree 1 file changed +5
-1
lines changed Expand file tree Collapse file tree 1 file changed +5
-1
lines changed Original file line number Diff line number Diff line change 2424using System . Collections . Generic ;
2525using System . Globalization ;
2626using System . Diagnostics ;
27+ using SharpDX . DXGI ;
2728
2829namespace ORTS . Common
2930{
@@ -87,13 +88,16 @@ static SystemInfo()
8788 Trace . WriteLine ( error ) ;
8889 }
8990
91+ // The WMI data for AdapterRAM is unreliable, so we have to use DXGI to get the real numbers.
92+ // Alas, DXGI doesn't give us the manufacturer name for the adapter, so we combine it with WMI.
93+ var descriptions = new Factory1 ( ) . Adapters . Select ( adapter => adapter . Description ) . ToArray ( ) ;
9094 try
9195 {
9296 GPUs = new ManagementClass ( "Win32_VideoController" ) . GetInstances ( ) . Cast < ManagementObject > ( ) . Select ( adapter => new GPU
9397 {
9498 Name = ( string ) adapter [ "Name" ] ,
9599 Manufacturer = ( string ) adapter [ "AdapterCompatibility" ] ,
96- MemoryMB = ( uint ? ) adapter [ "AdapterRAM" ] / 1024 / 1024 ?? 0 ,
100+ MemoryMB = ( uint ) ( ( long ) descriptions . FirstOrDefault ( desc => desc . Description == ( string ) adapter [ "Name" ] ) . DedicatedVideoMemory / 1024 / 1024 ) ,
97101 } ) . ToList ( ) ;
98102 }
99103 catch ( ManagementException error )
You can’t perform that action at this time.
0 commit comments