diff options
author | Patrick Mours <pmours@nvidia.com> | 2021-04-29 16:51:29 +0300 |
---|---|---|
committer | Brecht Van Lommel <brecht@blender.org> | 2021-04-29 16:58:51 +0300 |
commit | ffa70e769010a3b7e6b80be6f80b21dfb8713f13 (patch) | |
tree | a89ab146b3cca09f931b3d83d633e03b81b75346 | |
parent | cd05a05bca02e9fa7dfcb59f7fa8533015889ff4 (diff) |
Fix missing Cycles CPU name for Arm processors
-rw-r--r-- | intern/cycles/util/util_system.cpp | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/intern/cycles/util/util_system.cpp b/intern/cycles/util/util_system.cpp index 2c1716ce515..6500a59e42c 100644 --- a/intern/cycles/util/util_system.cpp +++ b/intern/cycles/util/util_system.cpp @@ -166,12 +166,33 @@ static void __cpuid(int data[4], int selector) string system_cpu_brand_string() { +#if !defined(WIN32) && !defined(__x86_64__) && !defined(__i386__) + FILE *cpuinfo = fopen("/proc/cpuinfo", "r"); + if (cpuinfo != nullptr) { + char cpuinfo_buf[513] = ""; + fread(cpuinfo_buf, sizeof(cpuinfo_buf) - 1, 1, cpuinfo); + fclose(cpuinfo); + + char *modelname = strstr(cpuinfo_buf, "model name"); + if (modelname != nullptr) { + modelname = strchr(modelname, ':'); + if (modelname != nullptr) { + modelname += 2; + char *modelname_end = strchr(modelname, '\n'); + if (modelname_end != nullptr) { + *modelname_end = '\0'; + return modelname; + } + } + } + } +#else char buf[49] = {0}; int result[4] = {0}; __cpuid(result, 0x80000000); - if (result[0] >= (int)0x80000004) { + if (result[0] != 0 && result[0] >= (int)0x80000004) { __cpuid((int *)(buf + 0), 0x80000002); __cpuid((int *)(buf + 16), 0x80000003); __cpuid((int *)(buf + 32), 0x80000004); @@ -183,7 +204,7 @@ string system_cpu_brand_string() return brand; } - +#endif return "Unknown CPU"; } |