1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #include "gpu/config/gpu_info.h" 6 7 namespace { 8 9 void EnumerateGPUDevice(gpu::GPUInfo::Enumerator* enumerator, 10 const gpu::GPUInfo::GPUDevice& device) { 11 enumerator->BeginGPUDevice(); 12 enumerator->AddInt("vendorId", device.vendor_id); 13 enumerator->AddInt("deviceId", device.device_id); 14 enumerator->AddBool("active", device.active); 15 enumerator->AddString("vendorString", device.vendor_string); 16 enumerator->AddString("deviceString", device.device_string); 17 enumerator->EndGPUDevice(); 18 } 19 20 } // namespace 21 22 namespace gpu { 23 24 GPUInfo::GPUDevice::GPUDevice() 25 : vendor_id(0), 26 device_id(0), 27 active(false) { 28 } 29 30 GPUInfo::GPUDevice::~GPUDevice() { } 31 32 GPUInfo::GPUInfo() 33 : finalized(false), 34 optimus(false), 35 amd_switchable(false), 36 lenovo_dcute(false), 37 adapter_luid(0), 38 gl_reset_notification_strategy(0), 39 can_lose_context(false), 40 software_rendering(false), 41 direct_rendering(true), 42 sandboxed(false) { 43 } 44 45 GPUInfo::~GPUInfo() { } 46 47 void GPUInfo::EnumerateFields(Enumerator* enumerator) const { 48 struct GPUInfoKnownFields { 49 bool finalized; 50 base::TimeDelta initialization_time; 51 bool optimus; 52 bool amd_switchable; 53 bool lenovo_dcute; 54 Version display_link_version; 55 GPUDevice gpu; 56 std::vector<GPUDevice> secondary_gpus; 57 uint64 adapter_luid; 58 std::string driver_vendor; 59 std::string driver_version; 60 std::string driver_date; 61 std::string pixel_shader_version; 62 std::string vertex_shader_version; 63 std::string machine_model_name; 64 std::string machine_model_version; 65 std::string gl_version_string; 66 std::string gl_vendor; 67 std::string gl_renderer; 68 std::string gl_extensions; 69 std::string gl_ws_vendor; 70 std::string gl_ws_version; 71 std::string gl_ws_extensions; 72 uint32 gl_reset_notification_strategy; 73 bool can_lose_context; 74 GpuPerformanceStats performance_stats; 75 bool software_rendering; 76 bool direct_rendering; 77 bool sandboxed; 78 #if defined(OS_WIN) 79 DxDiagNode dx_diagnostics; 80 #endif 81 }; 82 83 // If this assert fails then most likely something below needs to be updated. 84 // Note that this assert is only approximate. If a new field is added to 85 // GPUInfo which fits within the current padding then it will not be caught. 86 COMPILE_ASSERT( 87 sizeof(GPUInfo) == sizeof(GPUInfoKnownFields), 88 Fields_Have_Changed_In_GPUInfo_So_Update_Below); 89 90 // Required fields (according to DevTools protocol) first. 91 enumerator->AddString("machineModelName", machine_model_name); 92 enumerator->AddString("machineModelVersion", machine_model_version); 93 EnumerateGPUDevice(enumerator, gpu); 94 for (size_t ii = 0; ii < secondary_gpus.size(); ++ii) { 95 EnumerateGPUDevice(enumerator, secondary_gpus[ii]); 96 } 97 98 enumerator->BeginAuxAttributes(); 99 enumerator->AddBool("finalized", finalized); 100 enumerator->AddTimeDeltaInSecondsF("initializationTime", 101 initialization_time); 102 enumerator->AddBool("optimus", optimus); 103 enumerator->AddBool("amdSwitchable", amd_switchable); 104 enumerator->AddBool("lenovoDcute", lenovo_dcute); 105 if (display_link_version.IsValid()) { 106 enumerator->AddString("displayLinkVersion", 107 display_link_version.GetString()); 108 } 109 enumerator->AddInt64("adapterLuid", adapter_luid); 110 enumerator->AddString("driverVendor", driver_vendor); 111 enumerator->AddString("driverVersion", driver_version); 112 enumerator->AddString("driverDate", driver_date); 113 enumerator->AddString("pixelShaderVersion", pixel_shader_version); 114 enumerator->AddString("vertexShaderVersion", vertex_shader_version); 115 enumerator->AddString("glVersion", gl_version); 116 enumerator->AddString("glVendor", gl_vendor); 117 enumerator->AddString("glRenderer", gl_renderer); 118 enumerator->AddString("glExtensions", gl_extensions); 119 enumerator->AddString("glWsVendor", gl_ws_vendor); 120 enumerator->AddString("glWsVersion", gl_ws_version); 121 enumerator->AddString("glWsExtensions", gl_ws_extensions); 122 enumerator->AddInt( 123 "glResetNotificationStrategy", 124 static_cast<int>(gl_reset_notification_strategy)); 125 enumerator->AddBool("can_lose_context", can_lose_context); 126 // TODO(kbr): add performance_stats. 127 enumerator->AddBool("softwareRendering", software_rendering); 128 enumerator->AddBool("directRendering", direct_rendering); 129 enumerator->AddBool("sandboxed", sandboxed); 130 // TODO(kbr): add dx_diagnostics on Windows. 131 enumerator->EndAuxAttributes(); 132 } 133 134 } // namespace gpu 135