Path: blob/main_old/src/gpu_info_util/SystemInfo_x11.cpp
1693 views
//1// Copyright 2013 The ANGLE Project Authors. All rights reserved.2// Use of this source code is governed by a BSD-style license that can be3// found in the LICENSE file.4//56// SystemInfo_x11.cpp: implementation of the X11-specific parts of SystemInfo.h78#include "gpu_info_util/SystemInfo_internal.h"910#include <X11/Xlib.h>1112#include "common/debug.h"13#include "third_party/libXNVCtrl/NVCtrl.h"14#include "third_party/libXNVCtrl/NVCtrlLib.h"1516#if !defined(GPU_INFO_USE_X11)17# error SystemInfo_x11.cpp compiled without GPU_INFO_USE_X1118#endif1920namespace angle21{2223bool GetNvidiaDriverVersionWithXNVCtrl(std::string *version)24{25*version = "";2627int eventBase = 0;28int errorBase = 0;2930Display *display = XOpenDisplay(nullptr);3132if (display && XNVCTRLQueryExtension(display, &eventBase, &errorBase))33{34int screenCount = ScreenCount(display);35for (int screen = 0; screen < screenCount; ++screen)36{37char *buffer = nullptr;38if (XNVCTRLIsNvScreen(display, screen) &&39XNVCTRLQueryStringAttribute(display, screen, 0,40NV_CTRL_STRING_NVIDIA_DRIVER_VERSION, &buffer))41{42ASSERT(buffer != nullptr);43*version = buffer;44XFree(buffer);45return true;46}47}48}4950return false;51}52} // namespace angle535455