#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "gpu/config/gpu_info_collector.h"
#include <stddef.h>
#include <stdint.h>
#include <optional>
#include <string>
#include <utility>
#include <vector>
#include "base/base_paths.h"
#include "base/command_line.h"
#include "base/files/file_path.h"
#include "base/logging.h"
#include "base/metrics/histogram_functions.h"
#include "base/metrics/histogram_macros.h"
#include "base/path_service.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_split.h"
#include "base/strings/string_util.h"
#include "base/trace_event/trace_event.h"
#include "build/build_config.h"
#include "gpu/config/gpu_switches.h"
#include "gpu/config/webgpu_blocklist.h"
#include "skia/buildflags.h"
#include "third_party/abseil-cpp/absl/cleanup/cleanup.h"
#include "third_party/angle/src/gpu_info_util/SystemInfo.h"
#include "third_party/skia/include/core/SkGraphics.h"
#include "ui/gl/buildflags.h"
#include "ui/gl/gl_bindings.h"
#include "ui/gl/gl_context.h"
#include "ui/gl/gl_implementation.h"
#include "ui/gl/gl_surface.h"
#include "ui/gl/gl_surface_egl.h"
#include "ui/gl/gl_switches.h"
#include "ui/gl/gl_utils.h"
#include "ui/gl/gl_version_info.h"
#include "ui/gl/init/create_gr_gl_interface.h"
#include "ui/gl/init/gl_factory.h"
#if BUILDFLAG(IS_MAC)
#include "base/apple/bundle_locations.h"
#include "base/apple/foundation_util.h"
#endif
#if BUILDFLAG(IS_OZONE)
#include "ui/ozone/public/ozone_platform.h"
#include "ui/ozone/public/platform_gl_egl_utility.h"
#endif
#if !BUILDFLAG(USE_DAWN) && BUILDFLAG(SKIA_USE_DAWN)
#error "SKIA_USE_DAWN used without USE_DAWN is not supposed to work."
#endif
#if BUILDFLAG(USE_DAWN)
#include "third_party/dawn/include/dawn/dawn_proc.h"
#include "third_party/dawn/include/dawn/native/DawnNative.h"
#include "third_party/dawn/include/dawn/native/OpenGLBackend.h"
#include "third_party/dawn/include/dawn/webgpu.h"
#include "third_party/dawn/include/dawn/webgpu_cpp.h"
#endif
namespace {
#ifndef EGL_ANGLE_feature_control
#define EGL_ANGLE_feature_control …
#define EGL_FEATURE_NAME_ANGLE …
#define EGL_FEATURE_CATEGORY_ANGLE …
#define EGL_FEATURE_DESCRIPTION_ANGLE …
#define EGL_FEATURE_BUG_ANGLE …
#define EGL_FEATURE_STATUS_ANGLE …
#define EGL_FEATURE_COUNT_ANGLE …
#define EGL_FEATURE_OVERRIDES_ENABLED_ANGLE …
#define EGL_FEATURE_OVERRIDES_DISABLED_ANGLE …
#define EGL_FEATURE_CONDITION_ANGLE …
#endif
scoped_refptr<gl::GLSurface> InitializeGLSurface(gl::GLDisplay* display) { … }
scoped_refptr<gl::GLContext> InitializeGLContext(gl::GLSurface* surface) { … }
std::string GetGLString(unsigned int pname) { … }
std::string QueryEGLStringi(EGLDisplay display,
unsigned int name,
unsigned int index) { … }
std::string GetVersionFromString(const std::string& version_string) { … }
int StringContainsName(const std::string& str,
const std::string* names,
size_t num_names) { … }
std::string GetDisplayTypeString(gl::DisplayType type) { … }
#if BUILDFLAG(USE_DAWN)
std::string GetDawnAdapterTypeString(wgpu::AdapterType type) { … }
std::string GetDawnBackendTypeString(wgpu::BackendType type) { … }
void AddTogglesToDawnInfoList(dawn::native::Instance* instance,
const std::vector<const char*>& toggle_names,
std::vector<std::string>* dawn_info_list) { … }
void GetDawnTogglesForWebGPU(
bool enable_unsafe_webgpu,
bool enable_webgpu_developer_features,
const std::vector<std::string>& enabled_preference,
const std::vector<std::string>& disabled_preference,
std::vector<const char*>* force_enabled_toggles,
std::vector<const char*>* force_disabled_toggles) { … }
#if BUILDFLAG(SKIA_USE_DAWN)
void GetDawnTogglesForSkiaGraphite(
std::vector<const char*>* force_enabled_toggles,
std::vector<const char*>* force_disabled_toggles) { … }
#endif
void ReportWebGPUAdapterMetrics(dawn::native::Instance* instance) { … }
void ReportWebGPUSupportMetrics(dawn::native::Instance* instance) { … }
#endif
}
namespace gpu {
bool CollectGraphicsDeviceInfoFromCommandLine(
const base::CommandLine* command_line,
GPUInfo* gpu_info) { … }
bool CollectBasicGraphicsInfo(const base::CommandLine* command_line,
GPUInfo* gpu_info) { … }
bool CollectGraphicsInfoGL(GPUInfo* gpu_info, gl::GLDisplay* display) { … }
void IdentifyActiveGPU(GPUInfo* gpu_info) { … }
void FillGPUInfoFromSystemInfo(GPUInfo* gpu_info,
angle::SystemInfo* system_info) { … }
void CollectGraphicsInfoForTesting(GPUInfo* gpu_info) { … }
bool CollectGpuExtraInfo(gfx::GpuExtraInfo* gpu_extra_info,
const GpuPreferences& prefs) { … }
void CollectDawnInfo(const gpu::GpuPreferences& gpu_preferences,
bool collect_metrics,
std::vector<std::string>* dawn_info_list) { … }
}