summaryrefslogtreecommitdiff
path: root/src/common
diff options
context:
space:
mode:
authorGravatar Lioncash2018-08-14 18:48:28 -0400
committerGravatar Lioncash2018-08-14 18:57:46 -0400
commit60f476cd8f3aa4cf0c9c0091e53559d7e3d30116 (patch)
tree6581d46de9b751341990935cb604d9e29c1ff6a7 /src/common
parentMerge pull request #1055 from lioncash/init (diff)
downloadyuzu-60f476cd8f3aa4cf0c9c0091e53559d7e3d30116.tar.gz
yuzu-60f476cd8f3aa4cf0c9c0091e53559d7e3d30116.tar.xz
yuzu-60f476cd8f3aa4cf0c9c0091e53559d7e3d30116.zip
common/telemetry: Migrate core-independent info gathering to common
Previously core itself was the library containing the code to gather common information (build info, CPU info, and OS info), however all of this isn't core-dependent and can be moved to the common code and use the common interfaces. We can then just call those functions from the core instead. This will allow replacing our CPU detection with Xbyak's which has better detection facilities than ours. It also keeps more architecture-dependent code in common instead of core.
Diffstat (limited to 'src/common')
-rw-r--r--src/common/telemetry.cpp65
-rw-r--r--src/common/telemetry.h12
2 files changed, 77 insertions, 0 deletions
diff --git a/src/common/telemetry.cpp b/src/common/telemetry.cpp
index bf1f54886..f53a8d193 100644
--- a/src/common/telemetry.cpp
+++ b/src/common/telemetry.cpp
@@ -3,8 +3,15 @@
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5#include <algorithm> 5#include <algorithm>
6#include <cstring>
7#include "common/assert.h"
8#include "common/scm_rev.h"
6#include "common/telemetry.h" 9#include "common/telemetry.h"
7 10
11#ifdef ARCHITECTURE_x86_64
12#include "common/x64/cpu_detect.h"
13#endif
14
8namespace Telemetry { 15namespace Telemetry {
9 16
10void FieldCollection::Accept(VisitorInterface& visitor) const { 17void FieldCollection::Accept(VisitorInterface& visitor) const {
@@ -37,4 +44,62 @@ template class Field<std::string>;
37template class Field<const char*>; 44template class Field<const char*>;
38template class Field<std::chrono::microseconds>; 45template class Field<std::chrono::microseconds>;
39 46
47#ifdef ARCHITECTURE_x86_64
48static const char* CpuVendorToStr(Common::CPUVendor vendor) {
49 switch (vendor) {
50 case Common::CPUVendor::INTEL:
51 return "Intel";
52 case Common::CPUVendor::AMD:
53 return "Amd";
54 case Common::CPUVendor::OTHER:
55 return "Other";
56 }
57 UNREACHABLE();
58}
59#endif
60
61void AppendBuildInfo(FieldCollection& fc) {
62 const bool is_git_dirty{std::strstr(Common::g_scm_desc, "dirty") != nullptr};
63 fc.AddField(FieldType::App, "Git_IsDirty", is_git_dirty);
64 fc.AddField(FieldType::App, "Git_Branch", Common::g_scm_branch);
65 fc.AddField(FieldType::App, "Git_Revision", Common::g_scm_rev);
66 fc.AddField(FieldType::App, "BuildDate", Common::g_build_date);
67 fc.AddField(FieldType::App, "BuildName", Common::g_build_name);
68}
69
70void AppendCPUInfo(FieldCollection& fc) {
71#ifdef ARCHITECTURE_x86_64
72 fc.AddField(FieldType::UserSystem, "CPU_Model", Common::GetCPUCaps().cpu_string);
73 fc.AddField(FieldType::UserSystem, "CPU_BrandString", Common::GetCPUCaps().brand_string);
74 fc.AddField(FieldType::UserSystem, "CPU_Vendor", CpuVendorToStr(Common::GetCPUCaps().vendor));
75 fc.AddField(FieldType::UserSystem, "CPU_Extension_x64_AES", Common::GetCPUCaps().aes);
76 fc.AddField(FieldType::UserSystem, "CPU_Extension_x64_AVX", Common::GetCPUCaps().avx);
77 fc.AddField(FieldType::UserSystem, "CPU_Extension_x64_AVX2", Common::GetCPUCaps().avx2);
78 fc.AddField(FieldType::UserSystem, "CPU_Extension_x64_BMI1", Common::GetCPUCaps().bmi1);
79 fc.AddField(FieldType::UserSystem, "CPU_Extension_x64_BMI2", Common::GetCPUCaps().bmi2);
80 fc.AddField(FieldType::UserSystem, "CPU_Extension_x64_FMA", Common::GetCPUCaps().fma);
81 fc.AddField(FieldType::UserSystem, "CPU_Extension_x64_FMA4", Common::GetCPUCaps().fma4);
82 fc.AddField(FieldType::UserSystem, "CPU_Extension_x64_SSE", Common::GetCPUCaps().sse);
83 fc.AddField(FieldType::UserSystem, "CPU_Extension_x64_SSE2", Common::GetCPUCaps().sse2);
84 fc.AddField(FieldType::UserSystem, "CPU_Extension_x64_SSE3", Common::GetCPUCaps().sse3);
85 fc.AddField(FieldType::UserSystem, "CPU_Extension_x64_SSSE3", Common::GetCPUCaps().ssse3);
86 fc.AddField(FieldType::UserSystem, "CPU_Extension_x64_SSE41", Common::GetCPUCaps().sse4_1);
87 fc.AddField(FieldType::UserSystem, "CPU_Extension_x64_SSE42", Common::GetCPUCaps().sse4_2);
88#else
89 fc.AddField(FieldType::UserSystem, "CPU_Model", "Other");
90#endif
91}
92
93void AppendOSInfo(FieldCollection& fc) {
94#ifdef __APPLE__
95 fc.AddField(FieldType::UserSystem, "OsPlatform", "Apple");
96#elif defined(_WIN32)
97 fc.AddField(FieldType::UserSystem, "OsPlatform", "Windows");
98#elif defined(__linux__) || defined(linux) || defined(__linux)
99 fc.AddField(FieldType::UserSystem, "OsPlatform", "Linux");
100#else
101 fc.AddField(FieldType::UserSystem, "OsPlatform", "Unknown");
102#endif
103}
104
40} // namespace Telemetry 105} // namespace Telemetry
diff --git a/src/common/telemetry.h b/src/common/telemetry.h
index 3bab75b59..8d6ab986b 100644
--- a/src/common/telemetry.h
+++ b/src/common/telemetry.h
@@ -180,4 +180,16 @@ struct NullVisitor : public VisitorInterface {
180 void Complete() override {} 180 void Complete() override {}
181}; 181};
182 182
183/// Appends build-specific information to the given FieldCollection,
184/// such as branch name, revision hash, etc.
185void AppendBuildInfo(FieldCollection& fc);
186
187/// Appends CPU-specific information to the given FieldCollection,
188/// such as instruction set extensions, etc.
189void AppendCPUInfo(FieldCollection& fc);
190
191/// Appends OS-specific information to the given FieldCollection,
192/// such as platform name, etc.
193void AppendOSInfo(FieldCollection& fc);
194
183} // namespace Telemetry 195} // namespace Telemetry