Hash :
7b4e00d2
Author :
Date :
2017-02-08T10:43:47
gpu_info_util: Implement GetSystemInfo on Linux BUG=angleproject:1874 Change-Id: Id39c26b806e6a7937517235afe0ca60f5087df5b Reviewed-on: https://chromium-review.googlesource.com/438940 Reviewed-by: Zhenyao Mo <zmo@chromium.org> Reviewed-by: Geoff Lang <geofflang@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Corentin Wallez <cwallez@chromium.org>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78
//
// Copyright (c) 2013-2017 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// SystemInfo.cpp: implementation of the system-agnostic parts of SystemInfo.h
#include "gpu_info_util/SystemInfo.h"
#include <cstring>
#include <sstream>
namespace angle
{
bool IsAMD(uint32_t vendorId)
{
return vendorId == VENDOR_ID_AMD;
}
bool IsIntel(uint32_t vendorId)
{
return vendorId == VENDOR_ID_INTEL;
}
bool IsNvidia(uint32_t vendorId)
{
return vendorId == VENDOR_ID_NVIDIA;
}
bool IsQualcomm(uint32_t vendorId)
{
return vendorId == VENDOR_ID_QUALCOMM;
}
bool ParseAMDBrahmaDriverVersion(const std::string &content, std::string *version)
{
const size_t begin = content.find_first_of("0123456789");
if (begin == std::string::npos)
{
return false;
}
const size_t end = content.find_first_not_of("0123456789.", begin);
if (end == std::string::npos)
{
*version = content.substr(begin);
}
else
{
*version = content.substr(begin, end - begin);
}
return true;
}
bool ParseAMDCatalystDriverVersion(const std::string &content, std::string *version)
{
std::istringstream stream(content);
std::string line;
while (std::getline(stream, line))
{
static const char kReleaseVersion[] = "ReleaseVersion=";
if (line.compare(0, std::strlen(kReleaseVersion), kReleaseVersion) != 0)
{
continue;
}
if (ParseAMDBrahmaDriverVersion(line, version))
{
return true;
}
}
return false;
}
} // namespace angle