diff --git a/frontend/drivers/platform_ctr.c b/frontend/drivers/platform_ctr.c index 0fecca5768..6db1865dbb 100644 --- a/frontend/drivers/platform_ctr.c +++ b/frontend/drivers/platform_ctr.c @@ -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", }; diff --git a/frontend/drivers/platform_darwin.m b/frontend/drivers/platform_darwin.m index 4cf563717c..bdf33d5cde 100644 --- a/frontend/drivers/platform_darwin.m +++ b/frontend/drivers/platform_darwin.m @@ -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", }; diff --git a/frontend/drivers/platform_dos.c b/frontend/drivers/platform_dos.c index 661a68737b..daac64064f 100644 --- a/frontend/drivers/platform_dos.c +++ b/frontend/drivers/platform_dos.c @@ -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", }; diff --git a/frontend/drivers/platform_emscripten.c b/frontend/drivers/platform_emscripten.c index 946f9e97d8..4aaf6a7d13 100644 --- a/frontend/drivers/platform_emscripten.c +++ b/frontend/drivers/platform_emscripten.c @@ -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" }; diff --git a/frontend/drivers/platform_gx.c b/frontend/drivers/platform_gx.c index ff0c1e77d5..47e983cf6d 100644 --- a/frontend/drivers/platform_gx.c +++ b/frontend/drivers/platform_gx.c @@ -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", }; diff --git a/frontend/drivers/platform_null.c b/frontend/drivers/platform_null.c index dacb0d2c2f..7d4ec37558 100644 --- a/frontend/drivers/platform_null.c +++ b/frontend/drivers/platform_null.c @@ -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", }; diff --git a/frontend/drivers/platform_orbis.c b/frontend/drivers/platform_orbis.c index 2d55ce8a31..b46d11f4e9 100644 --- a/frontend/drivers/platform_orbis.c +++ b/frontend/drivers/platform_orbis.c @@ -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", }; diff --git a/frontend/drivers/platform_ps2.c b/frontend/drivers/platform_ps2.c index 7315d9578d..61fc72bb5a 100644 --- a/frontend/drivers/platform_ps2.c +++ b/frontend/drivers/platform_ps2.c @@ -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", }; diff --git a/frontend/drivers/platform_ps3.c b/frontend/drivers/platform_ps3.c index e74a10c969..656d1e604b 100644 --- a/frontend/drivers/platform_ps3.c +++ b/frontend/drivers/platform_ps3.c @@ -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", }; diff --git a/frontend/drivers/platform_psp.c b/frontend/drivers/platform_psp.c index 60c0080c55..fa8e86e472 100644 --- a/frontend/drivers/platform_psp.c +++ b/frontend/drivers/platform_psp.c @@ -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 diff --git a/frontend/drivers/platform_qnx.c b/frontend/drivers/platform_qnx.c index 05feaae20e..168a7462ca 100644 --- a/frontend/drivers/platform_qnx.c +++ b/frontend/drivers/platform_qnx.c @@ -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", }; diff --git a/frontend/drivers/platform_switch.c b/frontend/drivers/platform_switch.c index fb88dd097b..d3927eff84 100644 --- a/frontend/drivers/platform_switch.c +++ b/frontend/drivers/platform_switch.c @@ -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", }; diff --git a/frontend/drivers/platform_unix.c b/frontend/drivers/platform_unix.c index 4d46d34f4a..cd08bc9c83 100644 --- a/frontend/drivers/platform_unix.c +++ b/frontend/drivers/platform_unix.c @@ -68,6 +68,7 @@ #include #include #include +#include #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 diff --git a/frontend/drivers/platform_uwp.c b/frontend/drivers/platform_uwp.c index fb053b00e8..7859f8ac5b 100644 --- a/frontend/drivers/platform_uwp.c +++ b/frontend/drivers/platform_uwp.c @@ -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" }; diff --git a/frontend/drivers/platform_wiiu.c b/frontend/drivers/platform_wiiu.c index 36097fdabf..f3a6831019 100644 --- a/frontend/drivers/platform_wiiu.c +++ b/frontend/drivers/platform_wiiu.c @@ -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 */ }; diff --git a/frontend/drivers/platform_win32.c b/frontend/drivers/platform_win32.c index 0fd2c4adc1..da5142956d 100644 --- a/frontend/drivers/platform_win32.c +++ b/frontend/drivers/platform_win32.c @@ -27,6 +27,7 @@ #include #include #include +#include #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" }; diff --git a/frontend/drivers/platform_xdk.c b/frontend/drivers/platform_xdk.c index bba69bed75..73b1e978eb 100644 --- a/frontend/drivers/platform_xdk.c +++ b/frontend/drivers/platform_xdk.c @@ -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", }; diff --git a/frontend/drivers/platform_xenon.c b/frontend/drivers/platform_xenon.c index c10f1d7f13..0e9988f0a4 100644 --- a/frontend/drivers/platform_xenon.c +++ b/frontend/drivers/platform_xenon.c @@ -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", }; diff --git a/frontend/frontend_driver.c b/frontend/frontend_driver.c index 0a9d3fc5d2..cfb0ce8955 100644 --- a/frontend/frontend_driver.c +++ b/frontend/frontend_driver.c @@ -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 diff --git a/frontend/frontend_driver.h b/frontend/frontend_driver.h index 3920a660f4..76119f660e 100644 --- a/frontend/frontend_driver.h +++ b/frontend/frontend_driver.h @@ -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 diff --git a/libretro-common/features/features_cpu.c b/libretro-common/features/features_cpu.c index 09138819c2..2e13084462 100644 --- a/libretro-common/features/features_cpu.c +++ b/libretro-common/features/features_cpu.c @@ -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 +} diff --git a/libretro-common/include/features/features_cpu.h b/libretro-common/include/features/features_cpu.h index 0aa043dad0..139d9b2d0a 100644 --- a/libretro-common/include/features/features_cpu.h +++ b/libretro-common/include/features/features_cpu.h @@ -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 diff --git a/retroarch.c b/retroarch.c index 0a39cdf98f..152b4d071e 100644 --- a/retroarch.c +++ b/retroarch.c @@ -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__);