Overte C++ Documentation
GPUIdent.h
1 //
2 // GPUIdent.h
3 // libraries/shared/src
4 //
5 // Provides information about the GPU
6 //
7 // Created by Howard Stearns on 4/16/16.
8 // Copyright 2016 High Fidelity, Inc.
9 //
10 // Distributed under the Apache License, Version 2.0.
11 // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
12 //
13 
14 #ifndef hifi_GPUIdent_h
15 #define hifi_GPUIdent_h
16 
17 #include <cstdint>
18 #include <QString>
19 #include <memory>
20 #include <nlohmann/json.hpp>
21 #include <vector>
22 
23 class GPUIdent
24 {
25 
26 public:
27  uint64_t getMemory() { return _dedicatedMemoryMB; }
28  QString getName() { return _name; }
29  QString getDriver() { return _driver; }
30  bool isValid() { return _isValid; }
31  const std::vector<nlohmann::json>& getOutput() { return _output; }
32 
33  // E.g., GPUIdent::getInstance()->getMemory();
34  static GPUIdent* getInstance(const QString& vendor = "", const QString& renderer = "") { return _instance.ensureQuery(vendor, renderer); }
35 private:
36  std::vector<nlohmann::json> _output;
37  uint64_t _dedicatedMemoryMB { 0 };
38  QString _name { "" };
39  QString _driver { "" };
40  bool _isQueried { false };
41  bool _isValid { false };
42  static GPUIdent _instance;
43  GPUIdent* ensureQuery(const QString& vendor, const QString& renderer);
44 };
45 
46 #endif // hifi_GPUIdent_h