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 #ifndef GPU_CONFIG_GPU_INFO_COLLECTOR_H_ 6 #define GPU_CONFIG_GPU_INFO_COLLECTOR_H_ 7 8 #include "base/basictypes.h" 9 #include "build/build_config.h" 10 #include "gpu/config/gpu_info.h" 11 #include "gpu/gpu_export.h" 12 13 namespace gpu { 14 15 enum GpuIDResult { 16 kGpuIDFailure, 17 kGpuIDSuccess, 18 kGpuIDNotSupported 19 }; 20 21 // Collect GPU vendor_id and device ID. 22 GPU_EXPORT GpuIDResult CollectGpuID(uint32* vendor_id, uint32* device_id); 23 24 // Collects basic GPU info without creating a GL/DirectX context (and without 25 // the danger of crashing), including vendor_id and device_id. 26 // This is called at browser process startup time. 27 // The subset each platform collects may be different. 28 GPU_EXPORT bool CollectBasicGraphicsInfo(GPUInfo* gpu_info); 29 30 // Create a GL/DirectX context and collect related info. 31 // This is called at GPU process startup time. 32 // Returns true on success. 33 GPU_EXPORT bool CollectContextGraphicsInfo(GPUInfo* gpu_info); 34 35 #if defined(OS_WIN) 36 // Collect the DirectX Disagnostics information about the attached displays. 37 GPU_EXPORT bool GetDxDiagnostics(DxDiagNode* output); 38 #endif // OS_WIN 39 40 // Create a GL context and collect GL strings and versions. 41 GPU_EXPORT bool CollectGraphicsInfoGL(GPUInfo* gpu_info); 42 43 // Each platform stores the driver version on the GL_VERSION string differently 44 GPU_EXPORT bool CollectDriverInfoGL(GPUInfo* gpu_info); 45 46 // Merge GPUInfo from CollectContextGraphicsInfo into basic GPUInfo. 47 // This is platform specific, depending on which info are collected at which 48 // stage. 49 GPU_EXPORT void MergeGPUInfo(GPUInfo* basic_gpu_info, 50 const GPUInfo& context_gpu_info); 51 52 // MergeGPUInfo() when GL driver is used. 53 GPU_EXPORT void MergeGPUInfoGL(GPUInfo* basic_gpu_info, 54 const GPUInfo& context_gpu_info); 55 56 // If multiple GPUs are detected, use GL_VENDOR string to determine which GPU 57 // is currently active. 58 // |gpu_info| is expected to be the merged GPUInfo after full info collection. 59 // Upon return, |gpu_info->gpu| will contain the active GPU, assuming the 60 // platform supports it. Return false if it's not supported. 61 GPU_EXPORT bool DetermineActiveGPU(GPUInfo* gpu_info); 62 63 // Advanced Micro Devices has interesting configurations on laptops were 64 // there are two videocards that can alternatively a given process output. 65 enum AMDVideoCardType { 66 UNKNOWN, 67 STANDALONE, 68 INTEGRATED, 69 SWITCHABLE 70 }; 71 72 } // namespace gpu 73 74 #endif // GPU_CONFIG_GPU_INFO_COLLECTOR_H_ 75