show cpu model name in log, implemented for x86/64 on windows/linux so far

This commit is contained in:
Brad Parker 2019-02-23 16:50:36 -05:00
parent f0d51596d1
commit e22148fed4
23 changed files with 119 additions and 1 deletions

View File

@ -602,5 +602,6 @@ frontend_ctx_driver_t frontend_ctx_ctr =
NULL, /* watch_path_for_changes */
NULL, /* check_for_path_changes */
NULL, /* set_sustained_performance_mode */
NULL, /* get_cpu_model_name */
"ctr",
};

View File

@ -763,5 +763,6 @@ frontend_ctx_driver_t frontend_ctx_darwin = {
NULL, /* watch_path_for_changes */
NULL, /* check_for_path_changes */
NULL, /* set_sustained_performance_mode */
NULL, /* get_cpu_model_name */
"darwin",
};

View File

@ -71,5 +71,6 @@ frontend_ctx_driver_t frontend_ctx_dos = {
NULL, /* watch_path_for_changes */
NULL, /* check_for_path_changes */
NULL, /* set_sustained_performance_mode */
NULL, /* get_cpu_model_name */
"dos",
};

View File

@ -264,5 +264,6 @@ frontend_ctx_driver_t frontend_ctx_emscripten = {
NULL, /* watch_path_for_changes */
NULL, /* check_for_path_changes */
NULL, /* set_sustained_performance_mode */
NULL, /* get_cpu_model_name */
"emscripten"
};

View File

@ -574,5 +574,6 @@ frontend_ctx_driver_t frontend_ctx_gx = {
NULL, /* watch_path_for_changes */
NULL, /* check_for_path_changes */
NULL, /* set_sustained_performance_mode */
NULL, /* get_cpu_model_name */
"gx",
};

View File

@ -47,5 +47,6 @@ frontend_ctx_driver_t frontend_ctx_null = {
NULL, /* watch_path_for_changes */
NULL, /* check_for_path_changes */
NULL, /* set_sustained_performance_mode */
NULL, /* get_cpu_model_name */
"null",
};

View File

@ -366,5 +366,6 @@ frontend_ctx_driver_t frontend_ctx_orbis = {
NULL, /* watch_path_for_changes */
NULL, /* check_for_path_changes */
NULL, /* set_sustained_performance_mode */
NULL, /* get_cpu_model_name */
"orbis",
};

View File

@ -563,5 +563,6 @@ frontend_ctx_driver_t frontend_ctx_ps2 = {
NULL, /* watch_path_for_changes */
NULL, /* check_for_path_changes */
NULL, /* set_sustained_performance_mode */
NULL, /* get_cpu_model_name */
"null",
};

View File

@ -635,5 +635,6 @@ frontend_ctx_driver_t frontend_ctx_ps3 = {
NULL, /* watch_path_for_changes */
NULL, /* check_for_path_changes */
NULL, /* set_sustained_performance_mode */
NULL, /* get_cpu_model_name */
"ps3",
};

View File

@ -529,6 +529,7 @@ frontend_ctx_driver_t frontend_ctx_psp = {
NULL, /* watch_path_for_changes */
NULL, /* check_for_path_changes */
NULL, /* set_sustained_performance_mode */
NULL, /* get_cpu_model_name */
#ifdef VITA
"vita",
#else

View File

@ -205,5 +205,6 @@ frontend_ctx_driver_t frontend_ctx_qnx = {
NULL, /* watch_path_for_changes */
NULL, /* check_for_path_changes */
NULL, /* set_sustained_performance_mode */
NULL, /* get_cpu_model_name */
"qnx",
};

View File

@ -941,5 +941,6 @@ frontend_ctx_driver_t frontend_ctx_switch =
NULL, /* watch_path_for_changes */
NULL, /* check_for_path_changes */
NULL, /* set_sustained_performance_mode */
NULL, /* get_cpu_model_name */
"switch",
};

View File

@ -68,6 +68,7 @@
#include <string/stdstring.h>
#include <queues/task_queue.h>
#include <retro_timers.h>
#include <features/features_cpu.h>
#include "../frontend.h"
#include "../frontend_driver.h"
@ -113,6 +114,7 @@ static const char *proc_acpi_battery_path = "/proc/acpi/battery";
static const char *proc_acpi_sysfs_ac_adapter_path = "/sys/class/power_supply/ACAD";
static const char *proc_acpi_sysfs_battery_path = "/sys/class/power_supply";
static const char *proc_acpi_ac_adapter_path = "/proc/acpi/ac_adapter";
static char unix_cpu_model_name[64] = {0};
#endif
static volatile sig_atomic_t unix_sighandler_quit;
@ -2466,6 +2468,16 @@ static void frontend_unix_set_sustained_performance_mode(bool on)
#endif
}
static const char* frontend_unix_get_cpu_model_name(void)
{
#ifdef ANDROID
return NULL;
#else
cpu_features_get_model_name(unix_cpu_model_name, sizeof(unix_cpu_model_name));
return unix_cpu_model_name;
#endif
}
frontend_ctx_driver_t frontend_ctx_unix = {
frontend_unix_get_env, /* environment_get */
frontend_unix_init, /* init */
@ -2510,6 +2522,7 @@ frontend_ctx_driver_t frontend_ctx_unix = {
frontend_unix_watch_path_for_changes,
frontend_unix_check_for_path_changes,
frontend_unix_set_sustained_performance_mode,
frontend_unix_get_cpu_model_name,
#ifdef ANDROID
"android"
#else

View File

@ -444,5 +444,6 @@ frontend_ctx_driver_t frontend_ctx_uwp = {
NULL, /* watch_path_for_changes */
NULL, /* check_for_path_changes */
NULL, /* set_sustained_performance_mode */
NULL, /* get_cpu_model_name */
"uwp"
};

View File

@ -299,6 +299,7 @@ frontend_ctx_driver_t frontend_ctx_wiiu =
NULL, /* watch_path_for_changes */
NULL, /* check_for_path_changes */
NULL, /* set_sustained_performance_mode */
NULL, /* get_cpu_model_name */
"wiiu",
NULL, /* get_video_driver */
};

View File

@ -27,6 +27,7 @@
#include <lists/file_list.h>
#include <file/file_path.h>
#include <string/stdstring.h>
#include <features/features_cpu.h>
#ifdef HAVE_CONFIG_H
#include "../../config.h"
@ -57,6 +58,8 @@ static dylib_t dwmlib;
static dylib_t shell32lib;
#endif
static char win32_cpu_model_name[64] = {0};
VOID (WINAPI *DragAcceptFiles_func)(HWND, BOOL);
static bool dwm_composition_disabled;
@ -561,6 +564,16 @@ static void frontend_win32_detach_console(void)
#endif
}
static const char* frontend_win32_get_cpu_model_name(void)
{
#ifdef ANDROID
return NULL;
#else
cpu_features_get_model_name(win32_cpu_model_name, sizeof(win32_cpu_model_name));
return win32_cpu_model_name;
#endif
}
frontend_ctx_driver_t frontend_ctx_win32 = {
frontend_win32_environment_get,
frontend_win32_init,
@ -588,5 +601,6 @@ frontend_ctx_driver_t frontend_ctx_win32 = {
NULL, /* watch_path_for_changes */
NULL, /* check_for_path_changes */
NULL, /* set_sustained_performance_mode */
frontend_win32_get_cpu_model_name,
"win32"
};

View File

@ -427,5 +427,6 @@ frontend_ctx_driver_t frontend_ctx_xdk = {
NULL, /* watch_path_for_changes */
NULL, /* check_for_path_changes */
NULL, /* set_sustained_performance_mode */
NULL, /* get_cpu_model_name */
"xdk",
};

View File

@ -94,5 +94,6 @@ frontend_ctx_driver_t frontend_ctx_qnx = {
NULL, /* watch_path_for_changes */
NULL, /* check_for_path_changes */
NULL, /* set_sustained_performance_mode */
NULL, /* get_cpu_model_name */
"xenon",
};

View File

@ -457,4 +457,11 @@ void frontend_driver_set_sustained_performance_mode(bool on)
frontend->set_sustained_performance_mode(on);
}
const char* frontend_driver_get_cpu_model_name(void)
{
frontend_ctx_driver_t *frontend = frontend_get_ptr();
if (!frontend || !frontend->get_cpu_model_name)
return NULL;
return frontend->get_cpu_model_name();
}
#endif

View File

@ -106,6 +106,7 @@ typedef struct frontend_ctx_driver
void (*watch_path_for_changes)(struct string_list *list, int flags, path_change_data_t **change_data);
bool (*check_for_path_changes)(path_change_data_t *change_data);
void (*set_sustained_performance_mode)(bool on);
const char* (*get_cpu_model_name)(void);
const char *ident;
@ -211,6 +212,8 @@ bool frontend_driver_check_for_path_changes(path_change_data_t *change_data);
void frontend_driver_set_sustained_performance_mode(bool on);
const char* frontend_driver_get_cpu_model_name(void);
RETRO_END_DECLS
#endif

View File

@ -255,7 +255,7 @@ retro_time_t cpu_features_get_time_usec(void)
#endif
}
#if defined(__x86_64__) || defined(__i386__) || defined(__i486__) || defined(__i686__) || (defined(_M_X64) && _MSC_VER > 1310) || (defined(_M_IX86) && _MSC_VER > 1310)
#if defined(__x86_64__) || defined(__i386__) || defined(__i486__) || defined(__i686__) || (defined(_M_X64) && _MSC_VER > 1310) || (defined(_M_IX86) && _MSC_VER > 1310)
#define CPU_X86
#endif
@ -827,3 +827,55 @@ uint64_t cpu_features_get(void)
return cpu;
}
void cpu_features_get_model_name(char *name, int len)
{
#ifdef CPU_X86
union {
int i[4];
unsigned char s[16];
} flags;
int i, j;
size_t pos = 0;
bool start = false;
if (!name)
return;
x86_cpuid(0x80000000, flags.i);
if (flags.i[0] < 0x80000004)
return;
for (i = 0; i < 3; i++)
{
memset(flags.i, 0, sizeof(flags.i));
x86_cpuid(0x80000002 + i, flags.i);
for (j = 0; j < sizeof(flags.s); j++)
{
if (!start && flags.s[j] == ' ')
continue;
else
start = true;
if (pos == len - 1)
{
/* truncate if we ran out of room */
name[pos] = '\0';
goto end;
}
name[pos++] = flags.s[j];
}
}
end:
/* terminate our string */
if (pos < len)
name[pos] = '\0';
#else
if (!name)
return;
return;
#endif
}

View File

@ -68,6 +68,8 @@ uint64_t cpu_features_get(void);
**/
unsigned cpu_features_get_core_amount(void);
void cpu_features_get_model_name(char *name, int len);
RETRO_END_DECLS
#endif

View File

@ -1262,6 +1262,10 @@ static void retroarch_validate_cpu_features(void)
uint64_t cpu = cpu_features_get();
(void)cpu;
#ifdef __MMX__
if (!(cpu & RETRO_SIMD_MMX))
FAIL_CPU("MMX");
#endif
#ifdef __SSE__
if (!(cpu & RETRO_SIMD_SSE))
FAIL_CPU("SSE");
@ -1367,9 +1371,16 @@ bool retroarch_main_init(int argc, char *argv[])
if (verbosity_is_enabled())
{
char str[128];
const char *cpu_model = NULL;
str[0] = '\0';
cpu_model = frontend_driver_get_cpu_model_name();
RARCH_LOG_OUTPUT("=== Build =======================================\n");
if (!string_is_empty(cpu_model))
RARCH_LOG_OUTPUT("CPU Model Name: %s\n", cpu_model);
retroarch_get_capabilities(RARCH_CAPABILITIES_CPU, str, sizeof(str));
fprintf(stderr, "%s: %s\n", msg_hash_to_str(MSG_CAPABILITIES), str);
fprintf(stderr, "Built: %s\n", __DATE__);