From 7a0ff5911dab7796580f669ca92030e338eaf35c Mon Sep 17 00:00:00 2001 From: Alcaro Date: Tue, 10 May 2016 18:34:46 +0200 Subject: [PATCH 01/61] Fix #2897 --- deps/spir2cross | 1 - 1 file changed, 1 deletion(-) delete mode 160000 deps/spir2cross diff --git a/deps/spir2cross b/deps/spir2cross deleted file mode 160000 index 0ae2bcc3d0..0000000000 --- a/deps/spir2cross +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 0ae2bcc3d0edc60e03180f6080a168f78edc82ca From f49dcd07391c1ec6227964f00ea9e654d96500d8 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 10 May 2016 18:43:23 +0200 Subject: [PATCH 02/61] (performance.c ) Cleanups --- performance.c | 118 +++++++++++++++++++++++--------------------------- performance.h | 22 ---------- 2 files changed, 55 insertions(+), 85 deletions(-) diff --git a/performance.c b/performance.c index b165192103..15eac5fdfb 100644 --- a/performance.c +++ b/performance.c @@ -16,16 +16,6 @@ #include #include "libretro.h" -#include "performance.h" -#include "general.h" -#include "compat/strl.h" -#include "verbosity.h" - -#ifdef _WIN32 -#define PERF_LOG_FMT "[PERF]: Avg (%s): %I64u ticks, %I64u runs.\n" -#else -#define PERF_LOG_FMT "[PERF]: Avg (%s): %llu ticks, %llu runs.\n" -#endif #if defined(_WIN32) #include @@ -33,6 +23,8 @@ #include #endif +#include + #if defined(_WIN32) && !defined(_XBOX) #include #include @@ -387,53 +379,53 @@ uint64_t cpu_features_get(void) len = sizeof(size_t); if (sysctlbyname("hw.optional.mmx", NULL, &len, NULL, 0) == 0) { - cpu |= CPU_FEATURE_MMX; - cpu |= CPU_FEATURE_MMXEXT; + cpu |= RETRO_SIMD_MMX; + cpu |= RETRO_SIMD_MMXEXT; } len = sizeof(size_t); if (sysctlbyname("hw.optional.sse", NULL, &len, NULL, 0) == 0) - cpu |= CPU_FEATURE_SSE; + cpu |= RETRO_SIMD_SSE; len = sizeof(size_t); if (sysctlbyname("hw.optional.sse2", NULL, &len, NULL, 0) == 0) - cpu |= CPU_FEATURE_SSE2; + cpu |= RETRO_SIMD_SSE2; len = sizeof(size_t); if (sysctlbyname("hw.optional.sse3", NULL, &len, NULL, 0) == 0) - cpu |= CPU_FEATURE_SSE3; + cpu |= RETRO_SIMD_SSE3; len = sizeof(size_t); if (sysctlbyname("hw.optional.supplementalsse3", NULL, &len, NULL, 0) == 0) - cpu |= CPU_FEATURE_SSSE3; + cpu |= RETRO_SIMD_SSSE3; len = sizeof(size_t); if (sysctlbyname("hw.optional.sse4_1", NULL, &len, NULL, 0) == 0) - cpu |= CPU_FEATURE_SSE4; + cpu |= RETRO_SIMD_SSE4; len = sizeof(size_t); if (sysctlbyname("hw.optional.sse4_2", NULL, &len, NULL, 0) == 0) - cpu |= CPU_FEATURE_SSE42; + cpu |= RETRO_SIMD_SSE42; len = sizeof(size_t); if (sysctlbyname("hw.optional.aes", NULL, &len, NULL, 0) == 0) - cpu |= CPU_FEATURE_AES; + cpu |= RETRO_SIMD_AES; len = sizeof(size_t); if (sysctlbyname("hw.optional.avx1_0", NULL, &len, NULL, 0) == 0) - cpu |= CPU_FEATURE_AVX; + cpu |= RETRO_SIMD_AVX; len = sizeof(size_t); if (sysctlbyname("hw.optional.avx2_0", NULL, &len, NULL, 0) == 0) - cpu |= CPU_FEATURE_AVX2; + cpu |= RETRO_SIMD_AVX2; len = sizeof(size_t); if (sysctlbyname("hw.optional.altivec", NULL, &len, NULL, 0) == 0) - cpu |= CPU_FEATURE_VMX; + cpu |= RETRO_SIMD_VMX; len = sizeof(size_t); if (sysctlbyname("hw.optional.neon", NULL, &len, NULL, 0) == 0) - cpu |= CPU_FEATURE_NEON; + cpu |= RETRO_SIMD_NEON; #elif defined(CPU_X86) (void)avx_flags; @@ -458,52 +450,52 @@ uint64_t cpu_features_get(void) x86_cpuid(1, flags); if (flags[3] & (1 << 23)) - cpu |= CPU_FEATURE_MMX; + cpu |= RETRO_SIMD_MMX; if (flags[3] & (1 << 25)) { /* SSE also implies MMXEXT (according to FFmpeg source). */ - cpu |= CPU_FEATURE_SSE; - cpu |= CPU_FEATURE_MMXEXT; + cpu |= RETRO_SIMD_SSE; + cpu |= RETRO_SIMD_MMXEXT; } if (flags[3] & (1 << 26)) - cpu |= CPU_FEATURE_SSE2; + cpu |= RETRO_SIMD_SSE2; if (flags[2] & (1 << 0)) - cpu |= CPU_FEATURE_SSE3; + cpu |= RETRO_SIMD_SSE3; if (flags[2] & (1 << 9)) - cpu |= CPU_FEATURE_SSSE3; + cpu |= RETRO_SIMD_SSSE3; if (flags[2] & (1 << 19)) - cpu |= CPU_FEATURE_SSE4; + cpu |= RETRO_SIMD_SSE4; if (flags[2] & (1 << 20)) - cpu |= CPU_FEATURE_SSE42; + cpu |= RETRO_SIMD_SSE42; if ((flags[2] & (1 << 23))) - cpu |= CPU_FEATURE_POPCNT; + cpu |= RETRO_SIMD_POPCNT; if (vendor_is_intel && (flags[2] & (1 << 22))) - cpu |= CPU_FEATURE_MOVBE; + cpu |= RETRO_SIMD_MOVBE; if (flags[2] & (1 << 25)) - cpu |= CPU_FEATURE_AES; + cpu |= RETRO_SIMD_AES; /* Must only perform xgetbv check if we have * AVX CPU support (guaranteed to have at least i686). */ if (((flags[2] & avx_flags) == avx_flags) && ((xgetbv_x86(0) & 0x6) == 0x6)) - cpu |= CPU_FEATURE_AVX; + cpu |= RETRO_SIMD_AVX; if (max_flag >= 7) { x86_cpuid(7, flags); if (flags[1] & (1 << 5)) - cpu |= CPU_FEATURE_AVX2; + cpu |= RETRO_SIMD_AVX2; } x86_cpuid(0x80000000, flags); @@ -512,55 +504,55 @@ uint64_t cpu_features_get(void) { x86_cpuid(0x80000001, flags); if (flags[3] & (1 << 23)) - cpu |= CPU_FEATURE_MMX; + cpu |= RETRO_SIMD_MMX; if (flags[3] & (1 << 22)) - cpu |= CPU_FEATURE_MMXEXT; + cpu |= RETRO_SIMD_MMXEXT; } #elif defined(__linux__) cpu_flags = linux_get_cpu_features(); if (cpu_flags & CPU_ARM_FEATURE_NEON) { - cpu |= CPU_FEATURE_NEON; + cpu |= RETRO_SIMD_NEON; #ifdef __ARM_NEON__ arm_enable_runfast_mode(); #endif } if (cpu_flags & CPU_ARM_FEATURE_VFPv3) - cpu |= CPU_FEATURE_VFPV3; + cpu |= RETRO_SIMD_VFPV3; #elif defined(__ARM_NEON__) - cpu |= CPU_FEATURE_NEON; + cpu |= RETRO_SIMD_NEON; arm_enable_runfast_mode(); #elif defined(__ALTIVEC__) - cpu |= CPU_FEATURE_VMX; + cpu |= RETRO_SIMD_VMX; #elif defined(XBOX360) - cpu |= CPU_FEATURE_VMX128; + cpu |= RETRO_SIMD_VMX128; #elif defined(PSP) - cpu |= CPU_FEATURE_VFPU; + cpu |= RETRO_SIMD_VFPU; #elif defined(GEKKO) - cpu |= CPU_FEATURE_PS; + cpu |= RETRO_SIMD_PS; #endif - if (cpu & CPU_FEATURE_MMX) strlcat(buf, " MMX", sizeof(buf)); - if (cpu & CPU_FEATURE_MMXEXT) strlcat(buf, " MMXEXT", sizeof(buf)); - if (cpu & CPU_FEATURE_SSE) strlcat(buf, " SSE", sizeof(buf)); - if (cpu & CPU_FEATURE_SSE2) strlcat(buf, " SSE2", sizeof(buf)); - if (cpu & CPU_FEATURE_SSE3) strlcat(buf, " SSE3", sizeof(buf)); - if (cpu & CPU_FEATURE_SSSE3) strlcat(buf, " SSSE3", sizeof(buf)); - if (cpu & CPU_FEATURE_SSE4) strlcat(buf, " SSE4", sizeof(buf)); - if (cpu & CPU_FEATURE_SSE42) strlcat(buf, " SSE4.2", sizeof(buf)); - if (cpu & CPU_FEATURE_AES) strlcat(buf, " AES", sizeof(buf)); - if (cpu & CPU_FEATURE_AVX) strlcat(buf, " AVX", sizeof(buf)); - if (cpu & CPU_FEATURE_AVX2) strlcat(buf, " AVX2", sizeof(buf)); - if (cpu & CPU_FEATURE_NEON) strlcat(buf, " NEON", sizeof(buf)); - if (cpu & CPU_FEATURE_VFPV3) strlcat(buf, " VFPv3", sizeof(buf)); - if (cpu & CPU_FEATURE_VFPV4) strlcat(buf, " VFPv4", sizeof(buf)); - if (cpu & CPU_FEATURE_VMX) strlcat(buf, " VMX", sizeof(buf)); - if (cpu & CPU_FEATURE_VMX128) strlcat(buf, " VMX128", sizeof(buf)); - if (cpu & CPU_FEATURE_VFPU) strlcat(buf, " VFPU", sizeof(buf)); - if (cpu & CPU_FEATURE_PS) strlcat(buf, " PS", sizeof(buf)); + if (cpu & RETRO_SIMD_MMX) strlcat(buf, " MMX", sizeof(buf)); + if (cpu & RETRO_SIMD_MMXEXT) strlcat(buf, " MMXEXT", sizeof(buf)); + if (cpu & RETRO_SIMD_SSE) strlcat(buf, " SSE", sizeof(buf)); + if (cpu & RETRO_SIMD_SSE2) strlcat(buf, " SSE2", sizeof(buf)); + if (cpu & RETRO_SIMD_SSE3) strlcat(buf, " SSE3", sizeof(buf)); + if (cpu & RETRO_SIMD_SSSE3) strlcat(buf, " SSSE3", sizeof(buf)); + if (cpu & RETRO_SIMD_SSE4) strlcat(buf, " SSE4", sizeof(buf)); + if (cpu & RETRO_SIMD_SSE42) strlcat(buf, " SSE4.2", sizeof(buf)); + if (cpu & RETRO_SIMD_AES) strlcat(buf, " AES", sizeof(buf)); + if (cpu & RETRO_SIMD_AVX) strlcat(buf, " AVX", sizeof(buf)); + if (cpu & RETRO_SIMD_AVX2) strlcat(buf, " AVX2", sizeof(buf)); + if (cpu & RETRO_SIMD_NEON) strlcat(buf, " NEON", sizeof(buf)); + if (cpu & RETRO_SIMD_VFPV3) strlcat(buf, " VFPv3", sizeof(buf)); + if (cpu & RETRO_SIMD_VFPV4) strlcat(buf, " VFPv4", sizeof(buf)); + if (cpu & RETRO_SIMD_VMX) strlcat(buf, " VMX", sizeof(buf)); + if (cpu & RETRO_SIMD_VMX128) strlcat(buf, " VMX128", sizeof(buf)); + if (cpu & RETRO_SIMD_VFPU) strlcat(buf, " VFPU", sizeof(buf)); + if (cpu & RETRO_SIMD_PS) strlcat(buf, " PS", sizeof(buf)); return cpu; } diff --git a/performance.h b/performance.h index dac242511d..c3ea91d859 100644 --- a/performance.h +++ b/performance.h @@ -26,28 +26,6 @@ typedef uint64_t retro_perf_tick_t; typedef uint64_t retro_time_t; #endif -/* ID values for CPU features */ -#define CPU_FEATURE_SSE (1 << 0) -#define CPU_FEATURE_SSE2 (1 << 1) -#define CPU_FEATURE_VMX (1 << 2) -#define CPU_FEATURE_VMX128 (1 << 3) -#define CPU_FEATURE_AVX (1 << 4) -#define CPU_FEATURE_NEON (1 << 5) -#define CPU_FEATURE_SSE3 (1 << 6) -#define CPU_FEATURE_SSSE3 (1 << 7) -#define CPU_FEATURE_MMX (1 << 8) -#define CPU_FEATURE_MMXEXT (1 << 9) -#define CPU_FEATURE_SSE4 (1 << 10) -#define CPU_FEATURE_SSE42 (1 << 11) -#define CPU_FEATURE_AVX2 (1 << 12) -#define CPU_FEATURE_VFPU (1 << 13) -#define CPU_FEATURE_PS (1 << 14) -#define CPU_FEATURE_AES (1 << 15) -#define CPU_FEATURE_VFPV3 (1 << 16) -#define CPU_FEATURE_VFPV4 (1 << 17) -#define CPU_FEATURE_POPCNT (1 << 18) -#define CPU_FEATURE_MOVBE (1 << 19) - #ifdef __cplusplus extern "C" { #endif From 4a7ab8366b631ff5e167f8037469806df66050bb Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 10 May 2016 19:03:53 +0200 Subject: [PATCH 03/61] Move libretro.h headers to libretro-common/include --- audio/audio_resampler_driver.h | 9 +++---- camera/camera_driver.h | 3 ++- cheevos.c | 2 +- core.h | 2 +- core_impl.c | 2 +- cores/dynamic_dummy.c | 3 ++- cores/internal_cores.h | 2 +- cores/libretro-ffmpeg/ffmpeg_core.c | 2 +- cores/libretro-ffmpeg/libretro.h | 1 - cores/libretro-imageviewer/image_core.c | 4 +-- .../libretro-test-gl-ff/libretro_gl_ff_test.c | 2 +- cores/libretro-test-gl/libretro_gl_test.c | 2 +- cores/libretro-test/libretro-test.c | 2 +- cores/retropad/retropad.c | 2 +- dynamic.h | 2 +- gfx/common/vulkan_common.h | 5 ++-- gfx/d3d/render_chain_driver.h | 3 ++- gfx/drivers/gl.c | 2 +- gfx/drivers/vg.c | 2 +- gfx/drivers/vulkan.c | 27 ++++++++++--------- gfx/video_driver.h | 2 +- gfx/video_filter.h | 3 ++- gfx/video_state_python.c | 6 +++-- input/common/input_x11_common.c | 3 ++- input/connect/joypad_connection.h | 2 +- input/drivers/ctr_input.c | 3 ++- input/drivers/gx_input.c | 3 ++- input/drivers/ps3_input.c | 6 ++--- input/drivers/psp_input.c | 6 ++--- input/drivers/sdl_input.c | 2 +- input/drivers/xdk_xinput_input.c | 6 ++--- input/drivers/xenon360_input.c | 7 ++--- input/input_hid_driver.h | 2 +- input/input_joypad_driver.h | 3 +-- input/input_keyboard.h | 3 +-- input/input_keymaps.h | 2 +- .../include/libretro.h | 0 .../include/libretro_vulkan.h | 2 +- managers/core_option_manager.c | 2 +- network/net_http_special.h | 2 +- network/netplay.h | 2 +- performance.c | 3 ++- performance.h | 7 +---- performance_counters.h | 2 +- system.h | 2 +- 45 files changed, 81 insertions(+), 79 deletions(-) delete mode 100644 cores/libretro-ffmpeg/libretro.h rename libretro.h => libretro-common/include/libretro.h (100%) rename libretro_vulkan.h => libretro-common/include/libretro_vulkan.h (99%) diff --git a/audio/audio_resampler_driver.h b/audio/audio_resampler_driver.h index 0b1224a795..ca89c42fec 100644 --- a/audio/audio_resampler_driver.h +++ b/audio/audio_resampler_driver.h @@ -22,12 +22,13 @@ extern "C" { #endif -#include #include +#include #include -#include #include +#include +#include #define RESAMPLER_SIMD_SSE (1 << 0) #define RESAMPLER_SIMD_SSE2 (1 << 1) @@ -200,10 +201,6 @@ bool rarch_resampler_realloc(void **re, const rarch_resampler_t **backend, (backend)->process(handle, data); \ } while(0) -#ifndef RARCH_INTERNAL -#include "libretro.h" -extern retro_get_cpu_features_t perf_get_cpu_features_cb; -#endif #ifdef __cplusplus } diff --git a/camera/camera_driver.h b/camera/camera_driver.h index 5a767df5a6..bfd6f6bf18 100644 --- a/camera/camera_driver.h +++ b/camera/camera_driver.h @@ -18,8 +18,9 @@ #define __CAMERA_DRIVER__H #include + #include -#include "../libretro.h" +#include #ifdef __cplusplus extern "C" { diff --git a/cheevos.c b/cheevos.c index 9eba3219d2..ff3f473944 100644 --- a/cheevos.c +++ b/cheevos.c @@ -20,10 +20,10 @@ #include #include #include +#include #include "cheevos.h" #include "dynamic.h" -#include "libretro.h" #include "network/net_http_special.h" #include "configuration.h" #include "performance_counters.h" diff --git a/core.h b/core.h index 2866e3abcc..d969e82138 100644 --- a/core.h +++ b/core.h @@ -23,9 +23,9 @@ extern "C" { #endif #include +#include #include "core_type.h" -#include "libretro.h" enum { diff --git a/core_impl.c b/core_impl.c index 163ed55396..2c3d365418 100644 --- a/core_impl.c +++ b/core_impl.c @@ -24,9 +24,9 @@ #include #include #include +#include #include "dynamic.h" -#include "libretro.h" #include "core.h" #include "general.h" #include "msg_hash.h" diff --git a/cores/dynamic_dummy.c b/cores/dynamic_dummy.c index ffcdf493a0..53efa0b90a 100644 --- a/cores/dynamic_dummy.c +++ b/cores/dynamic_dummy.c @@ -19,8 +19,9 @@ #include #include +#include + #include "internal_cores.h" -#include "../libretro.h" static uint16_t *frame_buf; diff --git a/cores/internal_cores.h b/cores/internal_cores.h index 60fbb49417..22d25e18aa 100644 --- a/cores/internal_cores.h +++ b/cores/internal_cores.h @@ -19,7 +19,7 @@ #define INTERNAL_CORES_H__ #include -#include "../libretro.h" +#include void libretro_dummy_retro_init(void); diff --git a/cores/libretro-ffmpeg/ffmpeg_core.c b/cores/libretro-ffmpeg/ffmpeg_core.c index 799f54c016..9e56232ae9 100644 --- a/cores/libretro-ffmpeg/ffmpeg_core.c +++ b/cores/libretro-ffmpeg/ffmpeg_core.c @@ -42,7 +42,7 @@ extern "C" { #include #include -#include "libretro.h" +#include #ifdef RARCH_INTERNAL #include "internal_cores.h" #define CORE_PREFIX(s) libretro_ffmpeg_##s diff --git a/cores/libretro-ffmpeg/libretro.h b/cores/libretro-ffmpeg/libretro.h deleted file mode 100644 index 5ed9e5c181..0000000000 --- a/cores/libretro-ffmpeg/libretro.h +++ /dev/null @@ -1 +0,0 @@ -#include "../../libretro.h" diff --git a/cores/libretro-imageviewer/image_core.c b/cores/libretro-imageviewer/image_core.c index 771776e0f5..2a4d168fe0 100644 --- a/cores/libretro-imageviewer/image_core.c +++ b/cores/libretro-imageviewer/image_core.c @@ -22,12 +22,12 @@ #include "../../deps/stb/stb_image.h" +#include + #ifdef RARCH_INTERNAL #include "internal_cores.h" -#include "../../libretro.h" #define IMAGE_CORE_PREFIX(s) libretro_imageviewer_##s #else -#include "libretro.h" #define IMAGE_CORE_PREFIX(s) s #endif diff --git a/cores/libretro-test-gl-ff/libretro_gl_ff_test.c b/cores/libretro-test-gl-ff/libretro_gl_ff_test.c index f9e6d4ce6d..a0f1ee215f 100644 --- a/cores/libretro-test-gl-ff/libretro_gl_ff_test.c +++ b/cores/libretro-test-gl-ff/libretro_gl_ff_test.c @@ -6,7 +6,7 @@ #include -#include "../../libretro.h" +#include #define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0])) static struct retro_hw_render_callback hw_render; diff --git a/cores/libretro-test-gl/libretro_gl_test.c b/cores/libretro-test-gl/libretro_gl_test.c index 139d87ae14..b995d691d9 100644 --- a/cores/libretro-test-gl/libretro_gl_test.c +++ b/cores/libretro-test-gl/libretro_gl_test.c @@ -6,7 +6,7 @@ #include -#include "../../libretro.h" +#include #define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0])) static struct retro_hw_render_callback hw_render; diff --git a/cores/libretro-test/libretro-test.c b/cores/libretro-test/libretro-test.c index bc7e592399..3eccfc83c6 100644 --- a/cores/libretro-test/libretro-test.c +++ b/cores/libretro-test/libretro-test.c @@ -7,7 +7,7 @@ #include -#include "../../libretro.h" +#include static uint32_t *frame_buf; static struct retro_log_callback logging; diff --git a/cores/retropad/retropad.c b/cores/retropad/retropad.c index 608866b57d..6edc342820 100644 --- a/cores/retropad/retropad.c +++ b/cores/retropad/retropad.c @@ -40,7 +40,7 @@ #include -#include "../../libretro.h" +#include #ifndef SOCKET_ERROR #define SOCKET_ERROR -1 diff --git a/dynamic.h b/dynamic.h index f072f78a7a..4fe1152614 100644 --- a/dynamic.h +++ b/dynamic.h @@ -18,9 +18,9 @@ #define __DYNAMIC_H #include +#include #include "core_type.h" -#include "libretro.h" #ifdef HAVE_CONFIG_H #include "config.h" diff --git a/gfx/common/vulkan_common.h b/gfx/common/vulkan_common.h index 6afaa53178..13d0f0b6d9 100644 --- a/gfx/common/vulkan_common.h +++ b/gfx/common/vulkan_common.h @@ -38,13 +38,14 @@ #include #include +#include +#include + #include "../../driver.h" -#include "../../libretro.h" #include "../../general.h" #include "../../retroarch.h" #include "../font_driver.h" #include "../video_context_driver.h" -#include "../../libretro_vulkan.h" #include "../drivers_shader/shader_vulkan.h" typedef struct vulkan_filter_chain vulkan_filter_chain_t; diff --git a/gfx/d3d/render_chain_driver.h b/gfx/d3d/render_chain_driver.h index 498f0000b4..7ccb55be87 100644 --- a/gfx/d3d/render_chain_driver.h +++ b/gfx/d3d/render_chain_driver.h @@ -17,10 +17,11 @@ #ifndef __D3D_RENDER_CHAIN_H #define __D3D_RENDER_CHAIN_H +#include + #include "../video_driver.h" #include "../video_shader_parse.h" #include "../video_state_tracker.h" -#include "../../libretro.h" #include "../../defines/d3d_defines.h" #ifdef __cplusplus diff --git a/gfx/drivers/gl.c b/gfx/drivers/gl.c index f3d240fa52..7f0fe2f7c2 100644 --- a/gfx/drivers/gl.c +++ b/gfx/drivers/gl.c @@ -31,12 +31,12 @@ #include #include #include +#include #include "../../driver.h" #include "../../record/record_driver.h" #include "../../performance_counters.h" -#include "../../libretro.h" #include "../../general.h" #include "../../retroarch.h" #include "../../verbosity.h" diff --git a/gfx/drivers/vg.c b/gfx/drivers/vg.c index 73527ff83c..f7413a50ac 100644 --- a/gfx/drivers/vg.c +++ b/gfx/drivers/vg.c @@ -24,9 +24,9 @@ #include #include #include +#include #include "../video_context_driver.h" -#include "../../libretro.h" #include "../../general.h" #include "../../retroarch.h" #include "../../driver.h" diff --git a/gfx/drivers/vulkan.c b/gfx/drivers/vulkan.c index 1147badfa2..7975eddfcb 100644 --- a/gfx/drivers/vulkan.c +++ b/gfx/drivers/vulkan.c @@ -13,6 +13,20 @@ * If not, see . */ +#include +#include +#include +#include + + +#include +#include +#include +#include +#include +#include +#include + #include "../common/vulkan_common.h" #include "vulkan_shaders/alpha_blend.vert.inc" #include "vulkan_shaders/alpha_blend.frag.inc" @@ -22,23 +36,10 @@ #include "vulkan_shaders/ribbon_simple.vert.inc" #include "vulkan_shaders/ribbon_simple.frag.inc" -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include - #include "../../driver.h" #include "../../record/record_driver.h" #include "../../performance_counters.h" -#include "../../libretro.h" #include "../../general.h" #include "../../retroarch.h" diff --git a/gfx/video_driver.h b/gfx/video_driver.h index 450f3b2782..93b5a13c68 100644 --- a/gfx/video_driver.h +++ b/gfx/video_driver.h @@ -22,12 +22,12 @@ #include #include +#include #include "font_driver.h" #include "video_filter.h" #include "video_shader_parse.h" -#include "../libretro.h" #include "../input/input_driver.h" diff --git a/gfx/video_filter.h b/gfx/video_filter.h index 7f12f92b55..d8af27ad47 100644 --- a/gfx/video_filter.h +++ b/gfx/video_filter.h @@ -17,9 +17,10 @@ #ifndef RARCH_FILTER_H__ #define RARCH_FILTER_H__ -#include "../libretro.h" #include +#include + #define RARCH_SOFTFILTER_THREADS_AUTO 0 typedef struct rarch_softfilter rarch_softfilter_t; diff --git a/gfx/video_state_python.c b/gfx/video_state_python.c index 2ad9fd1dd7..08c2d0dc67 100644 --- a/gfx/video_state_python.c +++ b/gfx/video_state_python.c @@ -14,18 +14,20 @@ * If not, see . */ -#include #include #include #include +#include + #include #include #include +#include + #include "video_state_python.h" #include "../dynamic.h" -#include "../libretro.h" #include "../core.h" #include "../general.h" #include "../verbosity.h" diff --git a/input/common/input_x11_common.c b/input/common/input_x11_common.c index 087bc3a8aa..1e028ad8bb 100644 --- a/input/common/input_x11_common.c +++ b/input/common/input_x11_common.c @@ -14,8 +14,9 @@ * If not, see . */ +#include + #include "input_x11_common.h" -#include "../../libretro.h" static bool x11_mouse_wu; static bool x11_mouse_wd; diff --git a/input/connect/joypad_connection.h b/input/connect/joypad_connection.h index 1e0e270505..1b5c70d768 100644 --- a/input/connect/joypad_connection.h +++ b/input/connect/joypad_connection.h @@ -20,7 +20,7 @@ #include #include -#include "../../libretro.h" +#include typedef void (*send_control_t)(void *data, uint8_t *buf, size_t size); diff --git a/input/drivers/ctr_input.c b/input/drivers/ctr_input.c index b44b1906a2..cc37474e85 100644 --- a/input/drivers/ctr_input.c +++ b/input/drivers/ctr_input.c @@ -15,10 +15,11 @@ #include #include + #include +#include #include "../../driver.h" -#include "../../libretro.h" #include "../../general.h" #include "../input_config.h" #include "../input_joypad_driver.h" diff --git a/input/drivers/gx_input.c b/input/drivers/gx_input.c index c280873b33..6962795464 100644 --- a/input/drivers/gx_input.c +++ b/input/drivers/gx_input.c @@ -23,8 +23,9 @@ #include #include +#include + #include "../../driver.h" -#include "../../libretro.h" #ifndef MAX_PADS #define MAX_PADS 4 diff --git a/input/drivers/ps3_input.c b/input/drivers/ps3_input.c index 58a0325b93..2cfba27289 100644 --- a/input/drivers/ps3_input.c +++ b/input/drivers/ps3_input.c @@ -17,14 +17,14 @@ #include #include -#include - #include +#include +#include + #include "../../defines/ps3_defines.h" #include "../../driver.h" -#include "../../libretro.h" #include "../../general.h" #ifdef HAVE_MOUSE diff --git a/input/drivers/psp_input.c b/input/drivers/psp_input.c index a832cb80e7..d9fcccfc55 100644 --- a/input/drivers/psp_input.c +++ b/input/drivers/psp_input.c @@ -17,8 +17,6 @@ #include #include -#include - #if defined(SN_TARGET_PSP2) #include #include @@ -29,10 +27,12 @@ #include #endif +#include +#include + #include "../../defines/psp_defines.h" #include "../../driver.h" -#include "../../libretro.h" #include "../../general.h" #include "../input_config.h" #ifdef HAVE_KERNEL_PRX diff --git a/input/drivers/sdl_input.c b/input/drivers/sdl_input.c index c07ac18470..3ad5bfa4c8 100644 --- a/input/drivers/sdl_input.c +++ b/input/drivers/sdl_input.c @@ -19,6 +19,7 @@ #include #include +#include #include "../../driver.h" @@ -26,7 +27,6 @@ #include "../../gfx/video_context_driver.h" #include "../../general.h" #include "../../verbosity.h" -#include "../../libretro.h" #include "../input_autodetect.h" #include "../input_config.h" #include "../input_joypad_driver.h" diff --git a/input/drivers/xdk_xinput_input.c b/input/drivers/xdk_xinput_input.c index 7ae411debb..aa7f7d1ae4 100644 --- a/input/drivers/xdk_xinput_input.c +++ b/input/drivers/xdk_xinput_input.c @@ -17,15 +17,15 @@ #include #include -#include - #ifdef _XBOX #include #endif +#include +#include + #include "../../driver.h" #include "../../general.h" -#include "../../libretro.h" #define MAX_PADS 4 diff --git a/input/drivers/xenon360_input.c b/input/drivers/xenon360_input.c index 438d6e1e48..cce53c6c68 100644 --- a/input/drivers/xenon360_input.c +++ b/input/drivers/xenon360_input.c @@ -18,12 +18,13 @@ #include #include -#include "../../driver.h" -#include "../../libretro.h" - #include #include +#include + +#include "../../driver.h" + #define MAX_PADS 4 static uint64_t state[MAX_PADS]; diff --git a/input/input_hid_driver.h b/input/input_hid_driver.h index cc77346afd..2a48c67816 100644 --- a/input/input_hid_driver.h +++ b/input/input_hid_driver.h @@ -24,7 +24,7 @@ extern "C" { #include #include -#include "../libretro.h" +#include typedef struct hid_driver hid_driver_t; diff --git a/input/input_joypad_driver.h b/input/input_joypad_driver.h index 1e1a5edca6..ef6d949dbf 100644 --- a/input/input_joypad_driver.h +++ b/input/input_joypad_driver.h @@ -23,8 +23,7 @@ extern "C" { #include #include - -#include "../libretro.h" +#include typedef struct rarch_joypad_driver input_device_driver_t; diff --git a/input/input_keyboard.h b/input/input_keyboard.h index 50bf53f602..d662ef3042 100644 --- a/input/input_keyboard.h +++ b/input/input_keyboard.h @@ -24,8 +24,7 @@ extern "C" { #include #include - -#include "../libretro.h" +#include enum rarch_input_keyboard_ctl_state { diff --git a/input/input_keymaps.h b/input/input_keymaps.h index 967f444bde..6a99c17ed1 100644 --- a/input/input_keymaps.h +++ b/input/input_keymaps.h @@ -19,7 +19,7 @@ #include -#include "../libretro.h" +#include #ifdef __cplusplus extern "C" { diff --git a/libretro.h b/libretro-common/include/libretro.h similarity index 100% rename from libretro.h rename to libretro-common/include/libretro.h diff --git a/libretro_vulkan.h b/libretro-common/include/libretro_vulkan.h similarity index 99% rename from libretro_vulkan.h rename to libretro-common/include/libretro_vulkan.h index 01e310bc7b..55375e1399 100644 --- a/libretro_vulkan.h +++ b/libretro-common/include/libretro_vulkan.h @@ -23,7 +23,7 @@ #ifndef LIBRETRO_VULKAN_H__ #define LIBRETRO_VULKAN_H__ -#include "libretro.h" +#include #include #define RETRO_HW_RENDER_INTERFACE_VULKAN_VERSION 2 diff --git a/managers/core_option_manager.c b/managers/core_option_manager.c index 466f10352d..f5075a9365 100644 --- a/managers/core_option_manager.c +++ b/managers/core_option_manager.c @@ -24,7 +24,7 @@ #include #include -#include "../libretro.h" +#include #include "core_option_manager.h" diff --git a/network/net_http_special.h b/network/net_http_special.h index de8c305153..6fa1af0fa8 100644 --- a/network/net_http_special.h +++ b/network/net_http_special.h @@ -17,7 +17,7 @@ #ifndef __NET_HTTP_SPECIAL_H #define __NET_HTTP_SPECIAL_H -#include "../libretro.h" +#include enum { diff --git a/network/netplay.h b/network/netplay.h index 8015c4c428..8f22abc60a 100644 --- a/network/netplay.h +++ b/network/netplay.h @@ -22,8 +22,8 @@ #include #include +#include -#include "../libretro.h" #include "../core.h" typedef struct netplay netplay_t; diff --git a/performance.c b/performance.c index 15eac5fdfb..923ca11d85 100644 --- a/performance.c +++ b/performance.c @@ -15,7 +15,7 @@ */ #include -#include "libretro.h" + #if defined(_WIN32) #include @@ -24,6 +24,7 @@ #endif #include +#include #if defined(_WIN32) && !defined(_XBOX) #include diff --git a/performance.h b/performance.h index c3ea91d859..ce04550938 100644 --- a/performance.h +++ b/performance.h @@ -19,12 +19,7 @@ #include -#ifdef RARCH_INTERNAL -#include "libretro.h" -#else -typedef uint64_t retro_perf_tick_t; -typedef uint64_t retro_time_t; -#endif +#include #ifdef __cplusplus extern "C" { diff --git a/performance_counters.h b/performance_counters.h index c15cc7881a..a992a4baa4 100644 --- a/performance_counters.h +++ b/performance_counters.h @@ -19,7 +19,7 @@ #include -#include "libretro.h" +#include #ifdef __cplusplus extern "C" { diff --git a/system.h b/system.h index a878b1d624..774b079724 100644 --- a/system.h +++ b/system.h @@ -17,9 +17,9 @@ #define __RARCH_SYSTEM_H #include +#include #include "driver.h" -#include "libretro.h" #ifndef MAX_USERS #define MAX_USERS 16 From fe4ef69aafaa031744177a47d5cd59600730fd4b Mon Sep 17 00:00:00 2001 From: Alcaro Date: Tue, 10 May 2016 18:51:39 +0200 Subject: [PATCH 04/61] Better check this one too. (Vulkan is the only user of that, right?) --- qb/config.libs.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/qb/config.libs.sh b/qb/config.libs.sh index 04cdff7566..a58f88f77b 100644 --- a/qb/config.libs.sh +++ b/qb/config.libs.sh @@ -403,6 +403,12 @@ if [ "$HAVE_VULKAN" != 'no' ] && [ ! -e deps/glslang/glslang/README.md ]; then HAVE_VULKAN=no fi +if [ "$HAVE_VULKAN" != 'no' ] && [ ! -e deps/SPIRV-Cross/README.md ]; then + echo "Warning: SPIRV-Cross submodule not loaded, can't use Vulkan." + echo "To fix, use: git submodule init && git submodule update" + HAVE_VULKAN=no +fi + check_pkgconf PYTHON python3 if [ "$HAVE_MATERIALUI" != 'no' ] || [ "$HAVE_XMB" != 'no' ] || [ "$HAVE_ZARCH" != 'no' ]; then From 2235aad7310971b0b5be6b70ead7b7ecf9b9c5fe Mon Sep 17 00:00:00 2001 From: Alcaro Date: Tue, 10 May 2016 19:43:15 +0200 Subject: [PATCH 05/61] Need these even without networking --- tasks/tasks_internal.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tasks/tasks_internal.h b/tasks/tasks_internal.h index 897ce2fc2f..1427740abb 100644 --- a/tasks/tasks_internal.h +++ b/tasks/tasks_internal.h @@ -51,6 +51,7 @@ typedef struct http_transfer_info char url[PATH_MAX_LENGTH]; int progress; } http_transfer_info_t; +#endif typedef struct nbio_image_handle { @@ -79,6 +80,7 @@ typedef struct nbio_handle unsigned status; } nbio_handle_t; +#ifdef HAVE_NETWORKING void *rarch_task_push_http_transfer(const char *url, const char *type, retro_task_callback_t cb, void *userdata); From 1bef3665e2080384092e32c2a94915b1e884616a Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 10 May 2016 20:06:38 +0200 Subject: [PATCH 06/61] Cleanups --- frontend/drivers/platform_linux.c | 214 +++++++++++++----------------- 1 file changed, 95 insertions(+), 119 deletions(-) diff --git a/frontend/drivers/platform_linux.c b/frontend/drivers/platform_linux.c index 634f60c05a..8e6de08f55 100644 --- a/frontend/drivers/platform_linux.c +++ b/frontend/drivers/platform_linux.c @@ -65,9 +65,7 @@ typedef struct } CpuList; static bool cpu_inited_once; -static enum cpu_family g_cpuFamily; static uint64_t g_cpuFeatures; -static int g_cpuCount; #ifndef HAVE_DYNAMIC static enum frontend_fork linux_fork_mode = FRONTEND_FORK_NONE; @@ -207,126 +205,22 @@ static const char *parse_decimal(const char* input, return p; } - -/* Parse a textual list of cpus and store the result inside a CpuList object. - * Input format is the following: - * - comma-separated list of items (no spaces) - * - each item is either a single decimal number (cpu index), or a range made - * of two numbers separated by a single dash (-). Ranges are inclusive. - * - * Examples: 0 - * 2,4-127,128-143 - * 0-1 - */ -static void cpulist_parse(CpuList* list, char **buf, ssize_t length) -{ - const char* p = (const char*)buf; - const char* end = p + length; - - /* NOTE: the input line coming from sysfs typically contains a - * trailing newline, so take care of it in the code below - */ - while (p < end && *p != '\n') - { - int val, start_value, end_value; - /* Find the end of current item, and put it into 'q' */ - const char *q = (const char*)memchr(p, ',', end-p); - - if (!q) - q = end; - - /* Get first value */ - p = parse_decimal(p, q, &start_value); - if (p == NULL) - return; - - end_value = start_value; - - /* If we're not at the end of the item, expect a dash and - * and integer; extract end value. - */ - if (p < q && *p == '-') - { - p = parse_decimal(p+1, q, &end_value); - if (p == NULL) - return; - } - - /* Set bits CPU list bits */ - for (val = start_value; val <= end_value; val++) - { - if ((unsigned)val < 32) - list->mask |= (uint32_t)(1U << val); - } - - /* Jump to next item */ - p = q; - if (p < end) - p++; - } -} - -/* Read a CPU list from one sysfs file */ -static void cpulist_read_from(CpuList* list, const char* filename) -{ - ssize_t length; - char *buf = NULL; - - list->mask = 0; - - if (filestream_read_file(filename, (void**)&buf, &length) != 1) - { - RARCH_ERR("Could not read %s: %s\n", filename, strerror(errno)); - return; - } - - cpulist_parse(list, &buf, length); - if (buf) - free(buf); - buf = NULL; -} - -/* Return the number of cpus present on a given device. +/* Return the number of cores present on a given CPU. * * To handle all weird kernel configurations, we need to compute the * intersection of the 'present' and 'possible' CPU lists and count * the result. */ -static int get_cpu_count(void) -{ - CpuList cpus_present[1]; - CpuList cpus_possible[1]; - - cpulist_read_from(cpus_present, "/sys/devices/system/cpu/present"); - cpulist_read_from(cpus_possible, "/sys/devices/system/cpu/possible"); - - /* Compute the intersection of both sets to get the actual number of - * CPU cores that can be used on this device by the kernel. - */ - cpus_present->mask &= cpus_possible->mask; - - return __builtin_popcount(cpus_present->mask); -} - static void linux_cpu_init(void) { ssize_t length; void *buf = NULL; - g_cpuFamily = DEFAULT_CPU_FAMILY; g_cpuFeatures = 0; - g_cpuCount = 1; if (filestream_read_file("/proc/cpuinfo", &buf, &length) != 1) return; - /* Count the CPU cores, the value may be 0 for single-core CPUs */ - g_cpuCount = get_cpu_count(); - if (g_cpuCount == 0) - g_cpuCount = 1; - - RARCH_LOG("found cpuCount = %d\n", g_cpuCount); - #ifdef __ARM_ARCH__ /* Extract architecture from the "CPU Architecture" field. * The list is well-known, unlike the the output of @@ -415,30 +309,112 @@ static void linux_cpu_init(void) } #endif /* __ARM_ARCH__ */ -#ifdef __i386__ - g_cpuFamily = CPU_FAMILY_X86; -#elif defined(_MIPS_ARCH) - g_cpuFamily = CPU_FAMILY_MIPS; -#endif - if (buf) free(buf); buf = NULL; } -enum cpu_family linux_get_cpu_platform(void) -{ - return g_cpuFamily; -} - uint64_t linux_get_cpu_features(void) { return g_cpuFeatures; } +/* Parse a textual list of cpus and store the result inside a CpuList object. + * Input format is the following: + * - comma-separated list of items (no spaces) + * - each item is either a single decimal number (cpu index), or a range made + * of two numbers separated by a single dash (-). Ranges are inclusive. + * + * Examples: 0 + * 2,4-127,128-143 + * 0-1 + */ +static void cpulist_parse(CpuList* list, char **buf, ssize_t length) +{ + const char* p = (const char*)buf; + const char* end = p + length; + + /* NOTE: the input line coming from sysfs typically contains a + * trailing newline, so take care of it in the code below + */ + while (p < end && *p != '\n') + { + int val, start_value, end_value; + /* Find the end of current item, and put it into 'q' */ + const char *q = (const char*)memchr(p, ',', end-p); + + if (!q) + q = end; + + /* Get first value */ + p = parse_decimal(p, q, &start_value); + if (p == NULL) + return; + + end_value = start_value; + + /* If we're not at the end of the item, expect a dash and + * and integer; extract end value. + */ + if (p < q && *p == '-') + { + p = parse_decimal(p+1, q, &end_value); + if (p == NULL) + return; + } + + /* Set bits CPU list bits */ + for (val = start_value; val <= end_value; val++) + { + if ((unsigned)val < 32) + list->mask |= (uint32_t)(1U << val); + } + + /* Jump to next item */ + p = q; + if (p < end) + p++; + } +} + +/* Read a CPU list from one sysfs file */ +static void cpulist_read_from(CpuList* list, const char* filename) +{ + ssize_t length; + char *buf = NULL; + + list->mask = 0; + + if (filestream_read_file(filename, (void**)&buf, &length) != 1) + { + RARCH_ERR("Could not read %s: %s\n", filename, strerror(errno)); + return; + } + + cpulist_parse(list, &buf, length); + if (buf) + free(buf); + buf = NULL; +} + int linux_get_cpu_count(void) { - return g_cpuCount; + int amount = 0; + CpuList cpus_present[1]; + CpuList cpus_possible[1]; + + cpulist_read_from(cpus_present, "/sys/devices/system/cpu/present"); + cpulist_read_from(cpus_possible, "/sys/devices/system/cpu/possible"); + + /* Compute the intersection of both sets to get the actual number of + * CPU cores that can be used on this device by the kernel. + */ + cpus_present->mask &= cpus_possible->mask; + amount = __builtin_popcount(cpus_present->mask); + + if (amount == 0) + return 1; + return amount; } int system_property_get(const char *command, From 1fdc547a97351262cec0c0300aaf7c229f11f393 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 10 May 2016 20:20:44 +0200 Subject: [PATCH 07/61] Refactor performance.c - merge Android performance code --- frontend/drivers/platform_linux.c | 368 ------------------------------ frontend/drivers/platform_linux.h | 31 --- performance.c | 350 +++++++++++++++++++++++++++- 3 files changed, 343 insertions(+), 406 deletions(-) diff --git a/frontend/drivers/platform_linux.c b/frontend/drivers/platform_linux.c index 8e6de08f55..7b65e20b94 100644 --- a/frontend/drivers/platform_linux.c +++ b/frontend/drivers/platform_linux.c @@ -41,7 +41,6 @@ #include #include #include -#include #include #include "../frontend.h" @@ -51,372 +50,10 @@ #include "../../verbosity.h" #include "platform_linux.h" -/* This small data type is used to represent a CPU list / mask, - * as read from sysfs on Linux. - * - * See http://www.kernel.org/doc/Documentation/cputopology.txt - * - * For now, we don't expect more than 32 cores on mobile devices, - * so keep everything simple. - */ -typedef struct -{ - uint32_t mask; -} CpuList; - -static bool cpu_inited_once; -static uint64_t g_cpuFeatures; - #ifndef HAVE_DYNAMIC static enum frontend_fork linux_fork_mode = FRONTEND_FORK_NONE; #endif -#ifdef __arm__ -# define DEFAULT_CPU_FAMILY CPU_FAMILY_ARM -#elif defined __i386__ -# define DEFAULT_CPU_FAMILY CPU_FAMILY_X86 -#else -# define DEFAULT_CPU_FAMILY CPU_FAMILY_UNKNOWN -#endif - -#ifdef __i386__ -void x86_cpuid(int func, int flags[4]); -#endif - -#ifdef __ARM_ARCH__ -/* Extract the content of a the first occurrence of a given field in - * the content of /proc/cpuinfo and return it as a heap-allocated - * string that must be freed by the caller. - * - * Return NULL if not found - */ -static char *extract_cpuinfo_field(char* buffer, - ssize_t length, const char* field) -{ - int len; - const char *q; - int fieldlen = strlen(field); - char* bufend = buffer + length; - char* result = NULL; - /* Look for first field occurrence, - * and ensures it starts the line. */ - const char *p = buffer; - - for (;;) - { - p = memmem(p, bufend-p, field, fieldlen); - if (p == NULL) - return result; - - if (p == buffer || p[-1] == '\n') - break; - - p += fieldlen; - } - - /* Skip to the first column followed by a space */ - p += fieldlen; - p = memchr(p, ':', bufend-p); - if (p == NULL || p[1] != ' ') - return result; - - /* Find the end of the line */ - p += 2; - q = memchr(p, '\n', bufend-p); - if (q == NULL) - q = bufend; - - /* Copy the line into a heap-allocated buffer */ - len = q-p; - result = malloc(len+1); - if (result == NULL) - return result; - - memcpy(result, p, len); - result[len] = '\0'; - - return result; -} - -/* Checks that a space-separated list of items - * contains one given 'item'. - * Returns 1 if found, 0 otherwise. - */ -static int has_list_item(const char* list, const char* item) -{ - const char* p = list; - int itemlen = strlen(item); - - if (list == NULL) - return 0; - - while (*p) - { - const char* q; - - /* skip spaces */ - while (*p == ' ' || *p == '\t') - p++; - - /* find end of current list item */ - q = p; - while (*q && *q != ' ' && *q != '\t') - q++; - - if (itemlen == q-p && !memcmp(p, item, itemlen)) - return 1; - - /* skip to next item */ - p = q; - } - return 0; -} -#endif - - -/* Parse an decimal integer starting from 'input', but not going further - * than 'limit'. Return the value into '*result'. - * - * NOTE: Does not skip over leading spaces, or deal with sign characters. - * NOTE: Ignores overflows. - * - * The function returns NULL in case of error (bad format), or the new - * position after the decimal number in case of success (which will always - * be <= 'limit'). - */ -static const char *parse_decimal(const char* input, - const char* limit, int* result) -{ - const char* p = input; - int val = 0; - - while (p < limit) - { - int d = (*p - '0'); - if ((unsigned)d >= 10U) - break; - val = val*10 + d; - p++; - } - if (p == input) - return NULL; - - *result = val; - return p; -} - -/* Return the number of cores present on a given CPU. - * - * To handle all weird kernel configurations, we need to compute the - * intersection of the 'present' and 'possible' CPU lists and count - * the result. - */ -static void linux_cpu_init(void) -{ - ssize_t length; - void *buf = NULL; - - g_cpuFeatures = 0; - - if (filestream_read_file("/proc/cpuinfo", &buf, &length) != 1) - return; - -#ifdef __ARM_ARCH__ - /* Extract architecture from the "CPU Architecture" field. - * The list is well-known, unlike the the output of - * the 'Processor' field which can vary greatly. - * - * See the definition of the 'proc_arch' array in - * $KERNEL/arch/arm/kernel/setup.c and the 'c_show' function in - * same file. - */ - char* cpu_arch = extract_cpuinfo_field(buf, length, "CPU architecture"); - - if (cpu_arch) - { - char* end; - int has_armv7 = 0; - /* read the initial decimal number, ignore the rest */ - long arch_number = strtol(cpu_arch, &end, 10); - - RARCH_LOG("Found CPU architecture = '%s'\n", cpu_arch); - - /* Here we assume that ARMv8 will be upwards compatible with v7 - * in the future. Unfortunately, there is no 'Features' field to - * indicate that Thumb-2 is supported. - */ - if (end > cpu_arch && arch_number >= 7) - has_armv7 = 1; - - /* Unfortunately, it seems that certain ARMv6-based CPUs - * report an incorrect architecture number of 7! - * - * See http://code.google.com/p/android/issues/detail?id=10812 - * - * We try to correct this by looking at the 'elf_format' - * field reported by the 'Processor' field, which is of the - * form of "(v7l)" for an ARMv7-based CPU, and "(v6l)" for - * an ARMv6-one. - */ - if (has_armv7) - { - char *cpu_proc = extract_cpuinfo_field(buf, length, - "Processor"); - - if (cpu_proc != NULL) - { - RARCH_LOG("found cpu_proc = '%s'\n", cpu_proc); - if (has_list_item(cpu_proc, "(v6l)")) - { - RARCH_ERR("CPU processor and architecture mismatch!!\n"); - has_armv7 = 0; - } - free(cpu_proc); - } - } - - if (has_armv7) - g_cpuFeatures |= CPU_ARM_FEATURE_ARMv7; - - /* The LDREX / STREX instructions are available from ARMv6 */ - if (arch_number >= 6) - g_cpuFeatures |= CPU_ARM_FEATURE_LDREX_STREX; - - free(cpu_arch); - } - - /* Extract the list of CPU features from 'Features' field */ - char* cpu_features = extract_cpuinfo_field(buf, length, "Features"); - - if (cpu_features) - { - RARCH_LOG("found cpu_features = '%s'\n", cpu_features); - - if (has_list_item(cpu_features, "vfpv3")) - g_cpuFeatures |= CPU_ARM_FEATURE_VFPv3; - - else if (has_list_item(cpu_features, "vfpv3d16")) - g_cpuFeatures |= CPU_ARM_FEATURE_VFPv3; - - /* Note: Certain kernels only report NEON but not VFPv3 - * in their features list. However, ARM mandates - * that if NEON is implemented, so must be VFPv3 - * so always set the flag. - */ - if (has_list_item(cpu_features, "neon")) - g_cpuFeatures |= CPU_ARM_FEATURE_NEON | CPU_ARM_FEATURE_VFPv3; - free(cpu_features); - } -#endif /* __ARM_ARCH__ */ - - if (buf) - free(buf); - buf = NULL; -} - -uint64_t linux_get_cpu_features(void) -{ - return g_cpuFeatures; -} - -/* Parse a textual list of cpus and store the result inside a CpuList object. - * Input format is the following: - * - comma-separated list of items (no spaces) - * - each item is either a single decimal number (cpu index), or a range made - * of two numbers separated by a single dash (-). Ranges are inclusive. - * - * Examples: 0 - * 2,4-127,128-143 - * 0-1 - */ -static void cpulist_parse(CpuList* list, char **buf, ssize_t length) -{ - const char* p = (const char*)buf; - const char* end = p + length; - - /* NOTE: the input line coming from sysfs typically contains a - * trailing newline, so take care of it in the code below - */ - while (p < end && *p != '\n') - { - int val, start_value, end_value; - /* Find the end of current item, and put it into 'q' */ - const char *q = (const char*)memchr(p, ',', end-p); - - if (!q) - q = end; - - /* Get first value */ - p = parse_decimal(p, q, &start_value); - if (p == NULL) - return; - - end_value = start_value; - - /* If we're not at the end of the item, expect a dash and - * and integer; extract end value. - */ - if (p < q && *p == '-') - { - p = parse_decimal(p+1, q, &end_value); - if (p == NULL) - return; - } - - /* Set bits CPU list bits */ - for (val = start_value; val <= end_value; val++) - { - if ((unsigned)val < 32) - list->mask |= (uint32_t)(1U << val); - } - - /* Jump to next item */ - p = q; - if (p < end) - p++; - } -} - -/* Read a CPU list from one sysfs file */ -static void cpulist_read_from(CpuList* list, const char* filename) -{ - ssize_t length; - char *buf = NULL; - - list->mask = 0; - - if (filestream_read_file(filename, (void**)&buf, &length) != 1) - { - RARCH_ERR("Could not read %s: %s\n", filename, strerror(errno)); - return; - } - - cpulist_parse(list, &buf, length); - if (buf) - free(buf); - buf = NULL; -} - -int linux_get_cpu_count(void) -{ - int amount = 0; - CpuList cpus_present[1]; - CpuList cpus_possible[1]; - - cpulist_read_from(cpus_present, "/sys/devices/system/cpu/present"); - cpulist_read_from(cpus_possible, "/sys/devices/system/cpu/possible"); - - /* Compute the intersection of both sets to get the actual number of - * CPU cores that can be used on this device by the kernel. - */ - cpus_present->mask &= cpus_possible->mask; - amount = __builtin_popcount(cpus_present->mask); - - if (amount == 0) - return 1; - return amount; -} - int system_property_get(const char *command, const char *args, char *value) { @@ -2141,11 +1778,6 @@ static void frontend_linux_init(void *data) "getStringExtra", "(Ljava/lang/String;)Ljava/lang/String;"); #endif - if (!cpu_inited_once) - { - linux_cpu_init(); - cpu_inited_once = true; - } } #ifdef ANDROID diff --git a/frontend/drivers/platform_linux.h b/frontend/drivers/platform_linux.h index 9ccdf069b5..345bae2907 100644 --- a/frontend/drivers/platform_linux.h +++ b/frontend/drivers/platform_linux.h @@ -23,31 +23,6 @@ #include -enum cpu_family -{ - CPU_FAMILY_UNKNOWN = 0, - CPU_FAMILY_ARM, - CPU_FAMILY_X86, - CPU_FAMILY_MIPS, - - CPU_FAMILY_MAX /* do not remove */ -}; - -enum -{ - CPU_ARM_FEATURE_ARMv7 = (1 << 0), - CPU_ARM_FEATURE_VFPv3 = (1 << 1), - CPU_ARM_FEATURE_NEON = (1 << 2), - CPU_ARM_FEATURE_LDREX_STREX = (1 << 3) -}; - -enum -{ - CPU_X86_FEATURE_SSSE3 = (1 << 0), - CPU_X86_FEATURE_POPCNT = (1 << 1), - CPU_X86_FEATURE_MOVBE = (1 << 2) -}; - #ifndef MAX_PADS #define MAX_PADS 8 #endif @@ -56,12 +31,6 @@ enum #define MAX_AXIS 10 #endif -enum cpu_family linux_get_cpu_family(void); - -uint64_t linux_get_cpu_features(void); - -int linux_get_cpu_count(void); - #ifdef ANDROID #include #include diff --git a/performance.c b/performance.c index 923ca11d85..7f7da8f31f 100644 --- a/performance.c +++ b/performance.c @@ -15,7 +15,7 @@ */ #include - +#include #if defined(_WIN32) #include @@ -24,6 +24,7 @@ #endif #include +#include #include #if defined(_WIN32) && !defined(_XBOX) @@ -100,10 +101,6 @@ static int clock_gettime(int clk_ik, struct timespec *t) #include -#if defined(__linux__) -#include "frontend/drivers/platform_linux.h" -#endif - /** * cpu_features_get_perf_counter: * @@ -283,6 +280,214 @@ static void arm_enable_runfast_mode(void) } #endif +#if defined(__linux__) + +#ifdef __ARM_ARCH__ +/* Extract the content of a the first occurrence of a given field in + * the content of /proc/cpuinfo and return it as a heap-allocated + * string that must be freed by the caller. + * + * Return NULL if not found + */ +static char *extract_cpuinfo_field(char* buffer, + ssize_t length, const char* field) +{ + int len; + const char *q; + int fieldlen = strlen(field); + char* bufend = buffer + length; + char* result = NULL; + /* Look for first field occurrence, + * and ensures it starts the line. */ + const char *p = buffer; + + for (;;) + { + p = memmem(p, bufend-p, field, fieldlen); + if (p == NULL) + return result; + + if (p == buffer || p[-1] == '\n') + break; + + p += fieldlen; + } + + /* Skip to the first column followed by a space */ + p += fieldlen; + p = memchr(p, ':', bufend-p); + if (p == NULL || p[1] != ' ') + return result; + + /* Find the end of the line */ + p += 2; + q = memchr(p, '\n', bufend-p); + if (q == NULL) + q = bufend; + + /* Copy the line into a heap-allocated buffer */ + len = q-p; + result = malloc(len+1); + if (result == NULL) + return result; + + memcpy(result, p, len); + result[len] = '\0'; + + return result; +} + +/* Checks that a space-separated list of items + * contains one given 'item'. + * Returns 1 if found, 0 otherwise. + */ +static int has_list_item(const char* list, const char* item) +{ + const char* p = list; + int itemlen = strlen(item); + + if (list == NULL) + return 0; + + while (*p) + { + const char* q; + + /* skip spaces */ + while (*p == ' ' || *p == '\t') + p++; + + /* find end of current list item */ + q = p; + while (*q && *q != ' ' && *q != '\t') + q++; + + if (itemlen == q-p && !memcmp(p, item, itemlen)) + return 1; + + /* skip to next item */ + p = q; + } + return 0; +} +#endif + +typedef struct +{ + uint32_t mask; +} CpuList; + + +#if !defined(_SC_NPROCESSORS_ONLN) +/* Parse an decimal integer starting from 'input', but not going further + * than 'limit'. Return the value into '*result'. + * + * NOTE: Does not skip over leading spaces, or deal with sign characters. + * NOTE: Ignores overflows. + * + * The function returns NULL in case of error (bad format), or the new + * position after the decimal number in case of success (which will always + * be <= 'limit'). + */ +static const char *parse_decimal(const char* input, + const char* limit, int* result) +{ + const char* p = input; + int val = 0; + + while (p < limit) + { + int d = (*p - '0'); + if ((unsigned)d >= 10U) + break; + val = val*10 + d; + p++; + } + if (p == input) + return NULL; + + *result = val; + return p; +} + +/* Parse a textual list of cpus and store the result inside a CpuList object. + * Input format is the following: + * - comma-separated list of items (no spaces) + * - each item is either a single decimal number (cpu index), or a range made + * of two numbers separated by a single dash (-). Ranges are inclusive. + * + * Examples: 0 + * 2,4-127,128-143 + * 0-1 + */ +static void cpulist_parse(CpuList* list, char **buf, ssize_t length) +{ + const char* p = (const char*)buf; + const char* end = p + length; + + /* NOTE: the input line coming from sysfs typically contains a + * trailing newline, so take care of it in the code below + */ + while (p < end && *p != '\n') + { + int val, start_value, end_value; + /* Find the end of current item, and put it into 'q' */ + const char *q = (const char*)memchr(p, ',', end-p); + + if (!q) + q = end; + + /* Get first value */ + p = parse_decimal(p, q, &start_value); + if (p == NULL) + return; + + end_value = start_value; + + /* If we're not at the end of the item, expect a dash and + * and integer; extract end value. + */ + if (p < q && *p == '-') + { + p = parse_decimal(p+1, q, &end_value); + if (p == NULL) + return; + } + + /* Set bits CPU list bits */ + for (val = start_value; val <= end_value; val++) + { + if ((unsigned)val < 32) + list->mask |= (uint32_t)(1U << val); + } + + /* Jump to next item */ + p = q; + if (p < end) + p++; + } +} + +/* Read a CPU list from one sysfs file */ +static void cpulist_read_from(CpuList* list, const char* filename) +{ + ssize_t length; + char *buf = NULL; + + list->mask = 0; + + if (filestream_read_file(filename, (void**)&buf, &length) != 1) + return; + + cpulist_parse(list, &buf, length); + if (buf) + free(buf); + buf = NULL; +} +#endif + +#endif + /** * cpu_features_get_core_amount: * @@ -330,7 +535,22 @@ unsigned cpu_features_get_core_amount(void) } return num_cpu; #elif defined(__linux__) - return linux_get_cpu_count(); + CpuList cpus_present[1]; + CpuList cpus_possible[1]; + int amount = 0; + + cpulist_read_from(cpus_present, "/sys/devices/system/cpu/present"); + cpulist_read_from(cpus_possible, "/sys/devices/system/cpu/possible"); + + /* Compute the intersection of both sets to get the actual number of + * CPU cores that can be used on this device by the kernel. + */ + cpus_present->mask &= cpus_possible->mask; + amount = __builtin_popcount(cpus_present->mask); + + if (amount == 0) + return 1; + return amount; #elif defined(_XBOX360) return 3; #else @@ -510,7 +730,123 @@ uint64_t cpu_features_get(void) cpu |= RETRO_SIMD_MMXEXT; } #elif defined(__linux__) - cpu_flags = linux_get_cpu_features(); + + static bool cpu_inited_once = false; + static uint64_t g_cpuFeatures; + + enum + { + CPU_ARM_FEATURE_ARMv7 = (1 << 0), + CPU_ARM_FEATURE_VFPv3 = (1 << 1), + CPU_ARM_FEATURE_NEON = (1 << 2), + CPU_ARM_FEATURE_LDREX_STREX = (1 << 3) + }; + + if (!cpu_inited_once) + { + ssize_t length; + void *buf = NULL; + + g_cpuFeatures = 0; + + if (filestream_read_file("/proc/cpuinfo", &buf, &length) == 1) + { +#ifdef __ARM_ARCH__ + /* Extract architecture from the "CPU Architecture" field. + * The list is well-known, unlike the the output of + * the 'Processor' field which can vary greatly. + * + * See the definition of the 'proc_arch' array in + * $KERNEL/arch/arm/kernel/setup.c and the 'c_show' function in + * same file. + */ + char* cpu_arch = extract_cpuinfo_field(buf, length, "CPU architecture"); + + if (cpu_arch) + { + char* end; + int has_armv7 = 0; + /* read the initial decimal number, ignore the rest */ + long arch_number = strtol(cpu_arch, &end, 10); + + RARCH_LOG("Found CPU architecture = '%s'\n", cpu_arch); + + /* Here we assume that ARMv8 will be upwards compatible with v7 + * in the future. Unfortunately, there is no 'Features' field to + * indicate that Thumb-2 is supported. + */ + if (end > cpu_arch && arch_number >= 7) + has_armv7 = 1; + + /* Unfortunately, it seems that certain ARMv6-based CPUs + * report an incorrect architecture number of 7! + * + * See http://code.google.com/p/android/issues/detail?id=10812 + * + * We try to correct this by looking at the 'elf_format' + * field reported by the 'Processor' field, which is of the + * form of "(v7l)" for an ARMv7-based CPU, and "(v6l)" for + * an ARMv6-one. + */ + if (has_armv7) + { + char *cpu_proc = extract_cpuinfo_field(buf, length, + "Processor"); + + if (cpu_proc != NULL) + { + RARCH_LOG("found cpu_proc = '%s'\n", cpu_proc); + if (has_list_item(cpu_proc, "(v6l)")) + { + /* CPU processor and architecture mismatch. */ + has_armv7 = 0; + } + free(cpu_proc); + } + } + + if (has_armv7) + g_cpuFeatures |= CPU_ARM_FEATURE_ARMv7; + + /* The LDREX / STREX instructions are available from ARMv6 */ + if (arch_number >= 6) + g_cpuFeatures |= CPU_ARM_FEATURE_LDREX_STREX; + + free(cpu_arch); + } + + /* Extract the list of CPU features from 'Features' field */ + char* cpu_features = extract_cpuinfo_field(buf, length, "Features"); + + if (cpu_features) + { + RARCH_LOG("found cpu_features = '%s'\n", cpu_features); + + if (has_list_item(cpu_features, "vfpv3")) + g_cpuFeatures |= CPU_ARM_FEATURE_VFPv3; + + else if (has_list_item(cpu_features, "vfpv3d16")) + g_cpuFeatures |= CPU_ARM_FEATURE_VFPv3; + + /* Note: Certain kernels only report NEON but not VFPv3 + * in their features list. However, ARM mandates + * that if NEON is implemented, so must be VFPv3 + * so always set the flag. + */ + if (has_list_item(cpu_features, "neon")) + g_cpuFeatures |= CPU_ARM_FEATURE_NEON | CPU_ARM_FEATURE_VFPv3; + free(cpu_features); + } +#endif /* __ARM_ARCH__ */ + + if (buf) + free(buf); + buf = NULL; + } + cpu_inited_once = true; + } + + cpu_flags = g_cpuFeatures; if (cpu_flags & CPU_ARM_FEATURE_NEON) { From 9aed52ac650de08c9e20764fd8d3d7b5d8373d64 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 10 May 2016 20:31:27 +0200 Subject: [PATCH 08/61] Move performance.c to libretro-common/features/features_cpu.c --- Makefile.common | 2 +- audio/audio_dsp_filter.c | 2 +- audio/audio_resampler_driver.c | 6 +- audio/audio_utils.c | 10 +-- dynamic.c | 3 +- frontend/drivers/platform_linux.c | 1 + gfx/video_driver.c | 2 +- gfx/video_filter.c | 2 +- gfx/video_thread_wrapper.c | 2 +- griffin/griffin.c | 2 +- .../features/features_cpu.c | 33 ++++---- .../include/features/features_cpu.h | 75 +++++++++++++++++++ menu/drivers/menu_generic.c | 2 +- menu/menu_animation.c | 3 +- menu/menu_input.c | 3 +- network/net_http_special.c | 2 +- performance.h | 69 ----------------- performance_counters.c | 3 +- retroarch.c | 3 +- runloop.c | 2 +- 20 files changed, 118 insertions(+), 109 deletions(-) rename performance.c => libretro-common/features/features_cpu.c (94%) create mode 100644 libretro-common/include/features/features_cpu.h delete mode 100644 performance.h diff --git a/Makefile.common b/Makefile.common index 9a55a67774..b36ec42be9 100644 --- a/Makefile.common +++ b/Makefile.common @@ -204,7 +204,7 @@ OBJ += frontend/frontend.o \ movie.o \ record/record_driver.o \ record/drivers/record_null.o \ - performance.o \ + libretro-common/features/features_cpu.o \ performance_counters.o \ verbosity.o diff --git a/audio/audio_dsp_filter.c b/audio/audio_dsp_filter.c index e781683918..6f49734f2e 100644 --- a/audio/audio_dsp_filter.c +++ b/audio/audio_dsp_filter.c @@ -23,13 +23,13 @@ #include #include +#include #include "audio_dsp_filter.h" #include "audio_filters/dspfilter.h" #include "../config_file_userdata.h" #include "../frontend/frontend_driver.h" -#include "../performance.h" #include "../performance_counters.h" #include "../dynamic.h" diff --git a/audio/audio_resampler_driver.c b/audio/audio_resampler_driver.c index a50d70fece..6e1f5cebb0 100644 --- a/audio/audio_resampler_driver.c +++ b/audio/audio_resampler_driver.c @@ -17,11 +17,11 @@ #include #include +#include #include "audio_resampler_driver.h" #include "../config_file_userdata.h" #ifdef RARCH_INTERNAL -#include "../performance.h" #include "../performance_counters.h" #endif #ifndef DONT_HAVE_STRING_LIST @@ -142,11 +142,7 @@ retro_get_cpu_features_t perf_get_cpu_features_cb; static resampler_simd_mask_t resampler_get_cpu_features(void) { -#ifdef RARCH_INTERNAL return cpu_features_get(); -#else - return perf_get_cpu_features_cb(); -#endif } /** diff --git a/audio/audio_utils.c b/audio/audio_utils.c index 51b5f9b9a1..b7cab9463a 100644 --- a/audio/audio_utils.c +++ b/audio/audio_utils.c @@ -13,18 +13,18 @@ * You should have received a copy of the GNU General Public License along with RetroArch. * If not, see . */ - -#include -#include "audio_utils.h" - #if defined(__SSE2__) #include #elif defined(__ALTIVEC__) #include #endif +#include +#include + +#include "audio_utils.h" + #ifdef RARCH_INTERNAL -#include "../performance.h" #include "../performance_counters.h" #endif diff --git a/dynamic.c b/dynamic.c index e89bdfa18d..e02798fb8f 100644 --- a/dynamic.c +++ b/dynamic.c @@ -25,6 +25,8 @@ #include #include +#include + #ifdef HAVE_CONFIG_H #include "config.h" #endif @@ -38,7 +40,6 @@ #include "record/record_driver.h" #include "core.h" #include "performance_counters.h" -#include "performance.h" #include "system.h" #include "gfx/video_context_driver.h" diff --git a/frontend/drivers/platform_linux.c b/frontend/drivers/platform_linux.c index 7b65e20b94..592ed1e242 100644 --- a/frontend/drivers/platform_linux.c +++ b/frontend/drivers/platform_linux.c @@ -41,6 +41,7 @@ #include #include #include +#include #include #include "../frontend.h" diff --git a/gfx/video_driver.c b/gfx/video_driver.c index 8b380a7dc4..7af875e3e4 100644 --- a/gfx/video_driver.c +++ b/gfx/video_driver.c @@ -25,6 +25,7 @@ #endif #include +#include #include "video_thread_wrapper.h" #include "../frontend/frontend_driver.h" @@ -33,7 +34,6 @@ #include "../config.def.h" #include "../retroarch.h" #include "../runloop.h" -#include "../performance.h" #include "../performance_counters.h" #include "../list_special.h" #include "../core.h" diff --git a/gfx/video_filter.c b/gfx/video_filter.c index fe46697bce..1f59be39ad 100644 --- a/gfx/video_filter.c +++ b/gfx/video_filter.c @@ -19,12 +19,12 @@ #include #include #include +#include #include "../frontend/frontend_driver.h" #include "../config_file_userdata.h" #include "../dynamic.h" #include "../general.h" -#include "../performance.h" #include "../performance_counters.h" #include "../verbosity.h" #include "video_filter.h" diff --git a/gfx/video_thread_wrapper.c b/gfx/video_thread_wrapper.c index b4b8ca1155..3f7b058e53 100644 --- a/gfx/video_thread_wrapper.c +++ b/gfx/video_thread_wrapper.c @@ -18,12 +18,12 @@ #include #include +#include #include #include "video_thread_wrapper.h" #include "font_driver.h" #include "video_shader_driver.h" -#include "../performance.h" #include "../performance_counters.h" #include "../runloop.h" #include "../verbosity.h" diff --git a/griffin/griffin.c b/griffin/griffin.c index 6fe88a87b8..edf45c5fad 100644 --- a/griffin/griffin.c +++ b/griffin/griffin.c @@ -62,7 +62,7 @@ ENCODINGS /*============================================================ PERFORMANCE ============================================================ */ -#include "../performance.c" +#include "../libretro-common/features/features_cpu.c" #include "../performance_counters.c" /*============================================================ diff --git a/performance.c b/libretro-common/features/features_cpu.c similarity index 94% rename from performance.c rename to libretro-common/features/features_cpu.c index 7f7da8f31f..185de2932c 100644 --- a/performance.c +++ b/libretro-common/features/features_cpu.c @@ -1,17 +1,23 @@ -/* RetroArch - A frontend for libretro. - * Copyright (C) 2010-2014 - Hans-Kristian Arntzen - * Copyright (C) 2011-2016 - Daniel De Matteis +/* Copyright (C) 2010-2016 The RetroArch team * - * RetroArch is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Found- - * ation, either version 3 of the License, or (at your option) any later version. + * --------------------------------------------------------------------------------------- + * The following license statement only applies to this file (features_cpu.c). + * --------------------------------------------------------------------------------------- * - * RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. + * Permission is hereby granted, free of charge, + * to any person obtaining a copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, + * and to permit persons to whom the Software is furnished to do so, subject to the following conditions: * - * You should have received a copy of the GNU General Public License along with RetroArch. - * If not, see . + * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #include @@ -769,8 +775,6 @@ uint64_t cpu_features_get(void) /* read the initial decimal number, ignore the rest */ long arch_number = strtol(cpu_arch, &end, 10); - RARCH_LOG("Found CPU architecture = '%s'\n", cpu_arch); - /* Here we assume that ARMv8 will be upwards compatible with v7 * in the future. Unfortunately, there is no 'Features' field to * indicate that Thumb-2 is supported. @@ -795,7 +799,6 @@ uint64_t cpu_features_get(void) if (cpu_proc != NULL) { - RARCH_LOG("found cpu_proc = '%s'\n", cpu_proc); if (has_list_item(cpu_proc, "(v6l)")) { /* CPU processor and architecture mismatch. */ @@ -820,8 +823,6 @@ uint64_t cpu_features_get(void) if (cpu_features) { - RARCH_LOG("found cpu_features = '%s'\n", cpu_features); - if (has_list_item(cpu_features, "vfpv3")) g_cpuFeatures |= CPU_ARM_FEATURE_VFPv3; diff --git a/libretro-common/include/features/features_cpu.h b/libretro-common/include/features/features_cpu.h new file mode 100644 index 0000000000..f5da7c1424 --- /dev/null +++ b/libretro-common/include/features/features_cpu.h @@ -0,0 +1,75 @@ +/* Copyright (C) 2010-2016 The RetroArch team + * + * --------------------------------------------------------------------------------------- + * The following license statement only applies to this file (features_cpu.h). + * --------------------------------------------------------------------------------------- + * + * Permission is hereby granted, free of charge, + * to any person obtaining a copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, + * and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#ifndef _LIBRETRO_SDK_CPU_INFO_H +#define _LIBRETRO_SDK_CPU_INFO_H + +#include + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * cpu_features_get_perf_counter: + * + * Gets performance counter. + * + * Returns: performance counter. + **/ +retro_perf_tick_t cpu_features_get_perf_counter(void); + +/** + * cpu_features_get_time_usec: + * + * Gets time in microseconds. * + * Returns: time in microseconds. + **/ +retro_time_t cpu_features_get_time_usec(void); + +/** + * cpu_features_get: + * + * Gets CPU features.. + * + * Returns: bitmask of all CPU features available. + **/ +uint64_t cpu_features_get(void); + +/** + * cpu_features_get_core_amount: + * + * Gets the amount of available CPU cores. + * + * Returns: amount of CPU cores available. + **/ +unsigned cpu_features_get_core_amount(void); + + +#ifdef __cplusplus +} +#endif + +#endif + diff --git a/menu/drivers/menu_generic.c b/menu/drivers/menu_generic.c index c1bd67114d..95140707b9 100644 --- a/menu/drivers/menu_generic.c +++ b/menu/drivers/menu_generic.c @@ -17,6 +17,7 @@ #include #include +#include #include "menu_generic.h" @@ -28,7 +29,6 @@ #include "../menu_entries.h" #include "../../configuration.h" -#include "../../performance.h" #include "../../performance_counters.h" #include "../../input/input_autodetect.h" #include "../../input/input_config.h" diff --git a/menu/menu_animation.c b/menu/menu_animation.c index db267ec8fb..1f58a26ede 100644 --- a/menu/menu_animation.c +++ b/menu/menu_animation.c @@ -16,13 +16,14 @@ #include #include + #include #include #include +#include #include "menu_animation.h" #include "../configuration.h" -#include "../performance.h" #include "../performance_counters.h" #define IDEAL_DELTA_TIME (1.0 / 60.0 * 1000000.0) diff --git a/menu/menu_input.c b/menu/menu_input.c index 0025dd668d..64a5c65eea 100644 --- a/menu/menu_input.c +++ b/menu/menu_input.c @@ -27,6 +27,8 @@ #include #include +#include + #include "menu_driver.h" #include "menu_input.h" #include "menu_animation.h" @@ -39,7 +41,6 @@ #include "../general.h" #include "../managers/cheat_manager.h" -#include "../performance.h" #include "../performance_counters.h" #include "../core.h" #include "../input/input_joypad_driver.h" diff --git a/network/net_http_special.c b/network/net_http_special.c index 2c488c614c..f074510ca4 100644 --- a/network/net_http_special.c +++ b/network/net_http_special.c @@ -17,8 +17,8 @@ #include #include +#include -#include "../performance.h" #include "../performance_counters.h" #include "net_http_special.h" diff --git a/performance.h b/performance.h deleted file mode 100644 index ce04550938..0000000000 --- a/performance.h +++ /dev/null @@ -1,69 +0,0 @@ -/* RetroArch - A frontend for libretro. - * Copyright (C) 2010-2014 - Hans-Kristian Arntzen - * Copyright (C) 2011-2016 - Daniel De Matteis - * - * RetroArch is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Found- - * ation, either version 3 of the License, or (at your option) any later version. - * - * RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along with RetroArch. - * If not, see . - */ - -#ifndef _LIBRETRO_SDK_CPU_INFO_H -#define _LIBRETRO_SDK_CPU_INFO_H - -#include - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * cpu_features_get_perf_counter: - * - * Gets performance counter. - * - * Returns: performance counter. - **/ -retro_perf_tick_t cpu_features_get_perf_counter(void); - -/** - * cpu_features_get_time_usec: - * - * Gets time in microseconds. * - * Returns: time in microseconds. - **/ -retro_time_t cpu_features_get_time_usec(void); - -/** - * cpu_features_get: - * - * Gets CPU features.. - * - * Returns: bitmask of all CPU features available. - **/ -uint64_t cpu_features_get(void); - -/** - * cpu_features_get_core_amount: - * - * Gets the amount of available CPU cores. - * - * Returns: amount of CPU cores available. - **/ -unsigned cpu_features_get_core_amount(void); - - -#ifdef __cplusplus -} -#endif - -#endif - diff --git a/performance_counters.c b/performance_counters.c index 209e6fb824..97e9ec9366 100644 --- a/performance_counters.c +++ b/performance_counters.c @@ -17,7 +17,8 @@ #include #include -#include "performance.h" +#include + #include "performance_counters.h" #include "general.h" diff --git a/retroarch.c b/retroarch.c index e0f1cff51f..dd6801fc3d 100644 --- a/retroarch.c +++ b/retroarch.c @@ -43,6 +43,8 @@ #include #include +#include + #include "content.h" #include "core_type.h" #include "core_info.h" @@ -58,7 +60,6 @@ #include "configuration.h" #include "general.h" #include "runloop.h" -#include "performance.h" #include "managers/cheat_manager.h" #include "system.h" diff --git a/runloop.c b/runloop.c index 63e4e2d889..fcd1e6bfab 100644 --- a/runloop.c +++ b/runloop.c @@ -29,6 +29,7 @@ #endif #include #include +#include #include @@ -38,7 +39,6 @@ #include "autosave.h" #include "core_info.h" #include "configuration.h" -#include "performance.h" #include "movie.h" #include "retroarch.h" #include "runloop.h" From eec4218ebbc98d66ed021f32b7da9f1bef53db63 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 10 May 2016 20:36:05 +0200 Subject: [PATCH 09/61] (RJPEG) Use features_cpu --- libretro-common/formats/jpeg/rjpeg.c | 49 +++++----------------------- 1 file changed, 9 insertions(+), 40 deletions(-) diff --git a/libretro-common/formats/jpeg/rjpeg.c b/libretro-common/formats/jpeg/rjpeg.c index 4d43a66c76..7e384ad7fa 100644 --- a/libretro-common/formats/jpeg/rjpeg.c +++ b/libretro-common/formats/jpeg/rjpeg.c @@ -11,6 +11,7 @@ #include #include #include +#include enum { @@ -88,51 +89,19 @@ typedef struct #include #ifdef _MSC_VER - -#if _MSC_VER >= 1400 /* not VC6 */ -#include /* __cpuid */ -static int rjpeg__cpuid3(void) -{ - int info[4]; - __cpuid(info,1); - return info[3]; -} -#else -static int rjpeg__cpuid3(void) -{ - int res; - __asm { - mov eax,1 - cpuid - mov res,edx - } - return res; -} -#endif - #define RJPEG_SIMD_ALIGN(type, name) __declspec(align(16)) type name - -static int rjpeg__sse2_available(void) -{ - int info3 = rjpeg__cpuid3(); - return ((info3 >> 26) & 1) != 0; -} -#else /* assume GCC-style if not VC++ */ -#define RJPEG_SIMD_ALIGN(type, name) type name __attribute__((aligned(16))) - -static int rjpeg__sse2_available(void) -{ -#if defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__) >= 408 /* GCC 4.8 or later */ - /* GCC 4.8+ has a nice way to do this */ - return __builtin_cpu_supports("sse2"); #else - /* portable way to do this, preferably without using GCC inline ASM? - * just bail for now. */ +#define RJPEG_SIMD_ALIGN(type, name) type name __attribute__((aligned(16))) +#endif + +static int rjpeg__sse2_available(void) +{ + uint64_t mask = cpu_features_get(); + if (mask & RETRO_SIMD_SSE2) + return 1; return 0; -#endif } #endif -#endif /* ARM NEON */ #if defined(RJPEG_NO_SIMD) && defined(RJPEG_NEON) From 19afc807efa242ef503f184de71469b50e662b6c Mon Sep 17 00:00:00 2001 From: Twinaphex Date: Tue, 10 May 2016 23:33:51 +0200 Subject: [PATCH 10/61] (iOS) Not sure why we are calling rarch_main() twice for iOS --- menu/menu_driver.c | 2 +- ui/drivers/ui_cocoatouch.m | 3 --- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/menu/menu_driver.c b/menu/menu_driver.c index a7ebcfac2a..006820a9c6 100644 --- a/menu/menu_driver.c +++ b/menu/menu_driver.c @@ -761,7 +761,7 @@ bool menu_driver_ctl(enum rarch_menu_ctl_state state, void *data) if (!latch) return false; - if (menu_driver_ctx->toggle) + if (menu_driver_ctx && menu_driver_ctx->toggle) menu_driver_ctx->toggle(menu_userdata, *latch); } break; diff --git a/ui/drivers/ui_cocoatouch.m b/ui/drivers/ui_cocoatouch.m index 586dada58a..aae07ab0e0 100644 --- a/ui/drivers/ui_cocoatouch.m +++ b/ui/drivers/ui_cocoatouch.m @@ -337,9 +337,6 @@ enum apple_platform = self; [self setDelegate:self]; - - if (rarch_main(argc, argv, NULL)) - apple_rarch_exited(); #ifdef HAVE_AVFOUNDATION /* Other background audio check */ From 2c6cf33dec6477ccd9270040b5e07dd912ef1c11 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 May 2016 00:26:31 +0200 Subject: [PATCH 11/61] Take out RARCH_CONSOLE ifdef --- performance_counters.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/performance_counters.c b/performance_counters.c index 97e9ec9366..002222ef5c 100644 --- a/performance_counters.c +++ b/performance_counters.c @@ -17,6 +17,12 @@ #include #include +#ifdef _WIN32 +#include +#else +#include +#endif + #include #include "performance_counters.h" @@ -31,10 +37,6 @@ #define PERF_LOG_FMT "[PERF]: Avg (%s): %llu ticks, %llu runs.\n" #endif -#if !defined(_WIN32) && !defined(RARCH_CONSOLE) -#include -#endif - static struct retro_perf_counter *perf_counters_rarch[MAX_COUNTERS]; static struct retro_perf_counter *perf_counters_libretro[MAX_COUNTERS]; static unsigned perf_ptr_rarch; From 4ad23c927ae4d2db3663b48574c8566f87faa3d7 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 May 2016 00:40:34 +0200 Subject: [PATCH 12/61] Take out RARCH_CONSOLE ifdefs --- menu/menu_setting.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/menu/menu_setting.c b/menu/menu_setting.c index d6e20db97a..427aca79d9 100644 --- a/menu/menu_setting.c +++ b/menu/menu_setting.c @@ -4594,7 +4594,7 @@ static bool setting_append_list( &subgroup_info, parent_group); -#if defined(HAVE_THREADS) && !defined(RARCH_CONSOLE) +#if defined(HAVE_THREADS) CONFIG_BOOL( list, list_info, &settings->video.threaded, @@ -5454,7 +5454,6 @@ static bool setting_append_list( &subgroup_info, parent_group); -#ifndef RARCH_CONSOLE CONFIG_BOOL( list, list_info, &settings->video.font_enable, @@ -5468,7 +5467,6 @@ static bool setting_append_list( parent_group, general_write_handler, general_read_handler); -#endif CONFIG_PATH( list, list_info, From 1ac30884c438b9b70a645589bb04620c46e4e719 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 May 2016 03:40:25 +0200 Subject: [PATCH 13/61] (RJPEG) Prevent warnings --- libretro-common/formats/jpeg/rjpeg.c | 26 ++++++++++++++++++++++- libretro-common/include/formats/image.h | 2 +- libretro-common/include/formats/jsonsax.h | 2 +- libretro-common/include/formats/rjpeg.h | 2 +- libretro-common/include/formats/rxml.h | 2 +- 5 files changed, 29 insertions(+), 5 deletions(-) diff --git a/libretro-common/formats/jpeg/rjpeg.c b/libretro-common/formats/jpeg/rjpeg.c index 7e384ad7fa..a9ca0b753f 100644 --- a/libretro-common/formats/jpeg/rjpeg.c +++ b/libretro-common/formats/jpeg/rjpeg.c @@ -1,3 +1,25 @@ +/* Copyright (C) 2010-2016 The RetroArch team + * + * --------------------------------------------------------------------------------------- + * The following license statement only applies to this file (rjpeg.c). + * --------------------------------------------------------------------------------------- + * + * Permission is hereby granted, free of charge, + * to any person obtaining a copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, + * and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + /* Modified version of stb_image's JPEG sources. */ @@ -2422,7 +2444,9 @@ bool rjpeg_image_load(uint8_t *_buf, void *data, size_t size, unsigned a_shift, unsigned r_shift, unsigned g_shift, unsigned b_shift) { - int x, y, comp; + int comp; + int x = 0; + int y = 0; struct texture_image *out_img = (struct texture_image*)data; out_img->pixels = (uint32_t*)rjpeg_load_from_memory(_buf, size, &x, &y, &comp, 4); diff --git a/libretro-common/include/formats/image.h b/libretro-common/include/formats/image.h index 1f96b81efd..3c98761b3e 100644 --- a/libretro-common/include/formats/image.h +++ b/libretro-common/include/formats/image.h @@ -1,6 +1,6 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen - * Copyright (C) 2011-2015 - Daniel De Matteis + * Copyright (C) 2011-2016 - Daniel De Matteis * * RetroArch is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Found- diff --git a/libretro-common/include/formats/jsonsax.h b/libretro-common/include/formats/jsonsax.h index 76860fe5f5..86d6d6b207 100644 --- a/libretro-common/include/formats/jsonsax.h +++ b/libretro-common/include/formats/jsonsax.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2015 The RetroArch team +/* Copyright (C) 2010-2016 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (jsonsax.h). diff --git a/libretro-common/include/formats/rjpeg.h b/libretro-common/include/formats/rjpeg.h index 539fd058df..81f61b92af 100644 --- a/libretro-common/include/formats/rjpeg.h +++ b/libretro-common/include/formats/rjpeg.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2015 The RetroArch team +/* Copyright (C) 2010-2016 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (rjpeg.h). diff --git a/libretro-common/include/formats/rxml.h b/libretro-common/include/formats/rxml.h index 3ee1109601..c3f3335c19 100644 --- a/libretro-common/include/formats/rxml.h +++ b/libretro-common/include/formats/rxml.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2015 The RetroArch team +/* Copyright (C) 2010-2016 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (rxml.h). From 1b4d744dcdf476758ffbef1d5f21d76f29e5db4e Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 May 2016 03:51:26 +0200 Subject: [PATCH 14/61] (task_image.c) Cleanups --- tasks/task_image.c | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/tasks/task_image.c b/tasks/task_image.c index 7ae06bfa25..0944079394 100644 --- a/tasks/task_image.c +++ b/tasks/task_image.c @@ -154,18 +154,6 @@ static int cb_image_menu_generic_rpng(nbio_handle_t *nbio) return 0; } -static int cb_image_menu_wallpaper_rpng(void *data, size_t len) -{ - nbio_handle_t *nbio = (nbio_handle_t*)data; - - if (cb_image_menu_generic_rpng(nbio) != 0) - return -1; - - nbio->image.cb = &cb_image_menu_upload_generic; - - return 0; -} - static int cb_image_menu_thumbnail(void *data, size_t len) { nbio_handle_t *nbio = (nbio_handle_t*)data; @@ -190,9 +178,11 @@ static int rarch_main_data_image_iterate_transfer(nbio_handle_t *nbio) for (i = 0; i < nbio->image.pos_increment; i++) { +#ifdef HAVE_RPNG /* TODO/FIXME - add JPEG equivalents as well */ if (!rpng_nbio_load_image_argb_iterate((rpng_t*)nbio->image.handle)) goto error; +#endif } nbio->image.frame_count++; @@ -251,12 +241,17 @@ static int cb_nbio_generic_rpng(nbio_handle_t *nbio, size_t *len) if (!ptr) goto error; +#ifdef HAVE_RPNG rpng_set_buf_ptr((rpng_t*)nbio->image.handle, (uint8_t*)ptr); +#endif + nbio->image.pos_increment = (*len / 2) ? (*len / 2) : 1; nbio->image.processing_pos_increment = (*len / 4) ? (*len / 4) : 1; +#ifdef HAVE_RPNG if (!rpng_nbio_load_image_argb_start((rpng_t*)nbio->image.handle)) goto error; +#endif nbio->image.is_blocking = false; nbio->image.is_finished = false; @@ -276,8 +271,11 @@ static int cb_nbio_image_menu_wallpaper_rpng(void *data, size_t len) if (!nbio || !data) return -1; +#ifdef HAVE_RPNG nbio->image.handle = rpng_alloc(); - nbio->image.cb = &cb_image_menu_wallpaper_rpng; +#endif + + nbio->image.cb = &cb_image_menu_thumbnail; return cb_nbio_generic_rpng(nbio, &len); } @@ -289,7 +287,10 @@ static int cb_nbio_image_menu_thumbnail_rpng(void *data, size_t len) if (!nbio || !data) return -1; +#ifdef HAVE_RPNG nbio->image.handle = rpng_alloc(); +#endif + nbio->image.cb = &cb_image_menu_thumbnail; return cb_nbio_generic_rpng(nbio, &len); From e6f55814a9eae3da0c59245337ae1bd43a000cab Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 May 2016 03:55:09 +0200 Subject: [PATCH 15/61] (task_image.c) Cleanups --- tasks/task_image.c | 49 ++++++++++++---------------------------------- 1 file changed, 13 insertions(+), 36 deletions(-) diff --git a/tasks/task_image.c b/tasks/task_image.c index 0944079394..55aaf49f61 100644 --- a/tasks/task_image.c +++ b/tasks/task_image.c @@ -71,18 +71,6 @@ static int cb_image_menu_upload_generic(void *data, size_t len) return 0; } -static int rarch_main_data_image_iterate_process_transfer_parse( - nbio_handle_t *nbio) -{ - if (nbio->image.handle && nbio->image.cb) - { - size_t len = 0; - nbio->image.cb(nbio, len); - } - - return 0; -} - static int rarch_main_data_image_iterate_transfer_parse(nbio_handle_t *nbio) { if (nbio->image.handle && nbio->image.cb) @@ -130,8 +118,7 @@ static int rarch_main_data_image_process( return *retval; } -#ifdef HAVE_RPNG -static int cb_image_menu_generic_rpng(nbio_handle_t *nbio) +static int cb_image_menu_generic(nbio_handle_t *nbio) { int retval = 0; unsigned width = 0, height = 0; @@ -158,7 +145,7 @@ static int cb_image_menu_thumbnail(void *data, size_t len) { nbio_handle_t *nbio = (nbio_handle_t*)data; - if (cb_image_menu_generic_rpng(nbio) != 0) + if (cb_image_menu_generic(nbio) != 0) return -1; nbio->image.cb = &cb_image_menu_upload_generic; @@ -166,6 +153,7 @@ static int cb_image_menu_thumbnail(void *data, size_t len) return 0; } +#ifdef HAVE_RPNG static int rarch_main_data_image_iterate_transfer(nbio_handle_t *nbio) { unsigned i; @@ -264,22 +252,6 @@ error: return -1; } -static int cb_nbio_image_menu_wallpaper_rpng(void *data, size_t len) -{ - nbio_handle_t *nbio = (nbio_handle_t*)data; - - if (!nbio || !data) - return -1; - -#ifdef HAVE_RPNG - nbio->image.handle = rpng_alloc(); -#endif - - nbio->image.cb = &cb_image_menu_thumbnail; - - return cb_nbio_generic_rpng(nbio, &len); -} - static int cb_nbio_image_menu_thumbnail_rpng(void *data, size_t len) { nbio_handle_t *nbio = (nbio_handle_t*)data; @@ -319,7 +291,7 @@ bool rarch_task_image_load_handler(retro_task_t *task) image->status = IMAGE_STATUS_TRANSFER_PARSE; break; case IMAGE_STATUS_PROCESS_TRANSFER_PARSE: - rarch_main_data_image_iterate_process_transfer_parse(nbio); + rarch_main_data_image_iterate_transfer_parse(nbio); if (!image->is_finished) break; case IMAGE_STATUS_TRANSFER_PARSE_FREE: @@ -368,10 +340,15 @@ bool rarch_task_push_image_load(const char *fullpath, if (strstr(fullpath, ".png")) { #ifdef HAVE_RPNG - if (cb_type_hash == CB_MENU_WALLPAPER) - nbio->cb = &cb_nbio_image_menu_wallpaper_rpng; - else if (cb_type_hash == CB_MENU_THUMBNAIL) - nbio->cb = &cb_nbio_image_menu_thumbnail_rpng; + switch (cb_type_hash) + { + case CB_MENU_WALLPAPER: + case CB_MENU_THUMBNAIL: + nbio->cb = &cb_nbio_image_menu_thumbnail_rpng; + break; + default: + break; + } #endif } else if (strstr(fullpath, ".jpeg") || strstr(fullpath, ".jpg")) From 556017f23d043cc07714c581b2e381a96ed00fb3 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 May 2016 03:56:31 +0200 Subject: [PATCH 16/61] Cleanup --- tasks/task_image.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tasks/task_image.c b/tasks/task_image.c index 55aaf49f61..07da9dcd62 100644 --- a/tasks/task_image.c +++ b/tasks/task_image.c @@ -252,7 +252,7 @@ error: return -1; } -static int cb_nbio_image_menu_thumbnail_rpng(void *data, size_t len) +static int cb_nbio_image_menu_thumbnail(void *data, size_t len) { nbio_handle_t *nbio = (nbio_handle_t*)data; @@ -344,7 +344,7 @@ bool rarch_task_push_image_load(const char *fullpath, { case CB_MENU_WALLPAPER: case CB_MENU_THUMBNAIL: - nbio->cb = &cb_nbio_image_menu_thumbnail_rpng; + nbio->cb = &cb_nbio_image_menu_thumbnail; break; default: break; From e6969f7ceda3784bffda1652aa3e984c165ff892 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 May 2016 04:03:21 +0200 Subject: [PATCH 17/61] Cleanups --- tasks/task_image.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tasks/task_image.c b/tasks/task_image.c index 07da9dcd62..be15b3e1e2 100644 --- a/tasks/task_image.c +++ b/tasks/task_image.c @@ -217,7 +217,7 @@ static void rarch_task_image_load_free_internal(nbio_handle_t *nbio) image->frame_count = 0; } -static int cb_nbio_generic_rpng(nbio_handle_t *nbio, size_t *len) +static int cb_nbio_generic(nbio_handle_t *nbio, size_t *len) { void *ptr = NULL; @@ -265,7 +265,7 @@ static int cb_nbio_image_menu_thumbnail(void *data, size_t len) nbio->image.cb = &cb_image_menu_thumbnail; - return cb_nbio_generic_rpng(nbio, &len); + return cb_nbio_generic(nbio, &len); } #endif From 5ad45ea17f49c4735d3f0d71d1849e4209651bf5 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 May 2016 04:10:42 +0200 Subject: [PATCH 18/61] task_image.c - Refactors to prepare it for JPEG support --- tasks/task_image.c | 94 +++++++++++++++++++++++++++++------------- tasks/tasks_internal.h | 10 ++++- 2 files changed, 74 insertions(+), 30 deletions(-) diff --git a/tasks/task_image.c b/tasks/task_image.c index be15b3e1e2..bcc25af17e 100644 --- a/tasks/task_image.c +++ b/tasks/task_image.c @@ -102,15 +102,22 @@ static int rarch_main_data_image_process( unsigned *height, int *retval) { + switch (nbio->image_type) + { + case IMAGE_TYPE_PNG: #ifdef HAVE_RPNG - if (!rpng_is_valid((rpng_t*)nbio->image.handle)) - return IMAGE_PROCESS_ERROR; + if (!rpng_is_valid((rpng_t*)nbio->image.handle)) + return IMAGE_PROCESS_ERROR; - *retval = rpng_nbio_load_image_argb_process( - (rpng_t*)nbio->image.handle, - &nbio->image.ti.pixels, - width, height); + *retval = rpng_nbio_load_image_argb_process( + (rpng_t*)nbio->image.handle, + &nbio->image.ti.pixels, + width, height); #endif + break; + case IMAGE_TYPE_JPEG: + break; + } nbio->image.ti.width = *width; nbio->image.ti.height = *height; @@ -166,11 +173,17 @@ static int rarch_main_data_image_iterate_transfer(nbio_handle_t *nbio) for (i = 0; i < nbio->image.pos_increment; i++) { + switch (nbio->image_type) + { + case IMAGE_TYPE_PNG: #ifdef HAVE_RPNG - /* TODO/FIXME - add JPEG equivalents as well */ - if (!rpng_nbio_load_image_argb_iterate((rpng_t*)nbio->image.handle)) - goto error; + if (!rpng_nbio_load_image_argb_iterate((rpng_t*)nbio->image.handle)) + goto error; #endif + break; + case IMAGE_TYPE_JPEG: + break; + } } nbio->image.frame_count++; @@ -207,10 +220,16 @@ static void rarch_task_image_load_free_internal(nbio_handle_t *nbio) { nbio_image_handle_t *image = nbio ? &nbio->image : NULL; + switch (nbio->image_type) + { + case IMAGE_TYPE_PNG: #ifdef HAVE_RPNG - /* TODO/FIXME - add JPEG equivalents as well */ - rpng_nbio_load_image_free((rpng_t*)image->handle); + rpng_nbio_load_image_free((rpng_t*)image->handle); #endif + break; + case IMAGE_TYPE_JPEG: + break; + } image->handle = NULL; image->cb = NULL; @@ -229,17 +248,31 @@ static int cb_nbio_generic(nbio_handle_t *nbio, size_t *len) if (!ptr) goto error; + switch (nbio->image_type) + { + case IMAGE_TYPE_PNG: #ifdef HAVE_RPNG - rpng_set_buf_ptr((rpng_t*)nbio->image.handle, (uint8_t*)ptr); + rpng_set_buf_ptr((rpng_t*)nbio->image.handle, (uint8_t*)ptr); #endif + break; + case IMAGE_TYPE_JPEG: + break; + } nbio->image.pos_increment = (*len / 2) ? (*len / 2) : 1; nbio->image.processing_pos_increment = (*len / 4) ? (*len / 4) : 1; + switch (nbio->image_type) + { + case IMAGE_TYPE_PNG: #ifdef HAVE_RPNG - if (!rpng_nbio_load_image_argb_start((rpng_t*)nbio->image.handle)) - goto error; + if (!rpng_nbio_load_image_argb_start((rpng_t*)nbio->image.handle)) + goto error; #endif + break; + case IMAGE_TYPE_JPEG: + break; + } nbio->image.is_blocking = false; nbio->image.is_finished = false; @@ -259,9 +292,16 @@ static int cb_nbio_image_menu_thumbnail(void *data, size_t len) if (!nbio || !data) return -1; + switch (nbio->image_type) + { + case IMAGE_TYPE_PNG: #ifdef HAVE_RPNG - nbio->image.handle = rpng_alloc(); + nbio->image.handle = rpng_alloc(); #endif + break; + case IMAGE_TYPE_JPEG: + break; + } nbio->image.cb = &cb_image_menu_thumbnail; @@ -338,22 +378,18 @@ bool rarch_task_push_image_load(const char *fullpath, nbio->image.status = IMAGE_STATUS_TRANSFER; if (strstr(fullpath, ".png")) - { -#ifdef HAVE_RPNG - switch (cb_type_hash) - { - case CB_MENU_WALLPAPER: - case CB_MENU_THUMBNAIL: - nbio->cb = &cb_nbio_image_menu_thumbnail; - break; - default: - break; - } -#endif - } + nbio->image_type = IMAGE_TYPE_PNG; else if (strstr(fullpath, ".jpeg") || strstr(fullpath, ".jpg")) + nbio->image_type = IMAGE_TYPE_JPEG; + + switch (cb_type_hash) { - /* TODO/FIXME */ + case CB_MENU_WALLPAPER: + case CB_MENU_THUMBNAIL: + nbio->cb = &cb_nbio_image_menu_thumbnail; + break; + default: + break; } nbio_begin_read(handle); diff --git a/tasks/tasks_internal.h b/tasks/tasks_internal.h index 1427740abb..737261fe74 100644 --- a/tasks/tasks_internal.h +++ b/tasks/tasks_internal.h @@ -40,8 +40,15 @@ enum nbio_status_enum NBIO_STATUS_TRANSFER_PARSE_FREE }; +enum image_type_enum +{ + IMAGE_TYPE_PNG = 0, + IMAGE_TYPE_JPEG +}; + #ifdef HAVE_NETWORKING -typedef struct { +typedef struct +{ char *data; size_t len; } http_transfer_data_t; @@ -70,6 +77,7 @@ typedef struct nbio_image_handle typedef struct nbio_handle { + enum image_type_enum image_type; nbio_image_handle_t image; bool is_finished; transfer_cb_t cb; From b9df6f52f53343d1c0be0aa6865ce21fbefee4cc Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 May 2016 04:22:22 +0200 Subject: [PATCH 19/61] Kill off a bunch of RARCH_CTL_LOAD_CONTENT enums --- command.c | 23 +++++++++++++++-------- retroarch.c | 12 ------------ retroarch.h | 6 ------ runloop.c | 9 ++++++++- 4 files changed, 23 insertions(+), 27 deletions(-) diff --git a/command.c b/command.c index 4259459032..beabb1c5d5 100644 --- a/command.c +++ b/command.c @@ -70,6 +70,7 @@ #ifdef HAVE_MENU #include "menu/menu_driver.h" +#include "menu/menu_content.h" #include "menu/menu_display.h" #include "menu/menu_shader.h" #endif @@ -1559,8 +1560,13 @@ static bool command_event_cmd_exec(void *data) } #if defined(HAVE_DYNAMIC) - if (!rarch_ctl(RARCH_CTL_LOAD_CONTENT, NULL)) +#ifdef HAVE_MENU + if (!menu_content_ctl(MENU_CONTENT_CTL_LOAD, NULL)) + { + rarch_ctl(RARCH_CTL_MENU_RUNNING, NULL); return false; + } +#endif #else frontend_driver_set_fork(FRONTEND_FORK_CORE_WITH_ARGS); #endif @@ -1620,15 +1626,16 @@ bool command_event(enum event_command cmd, void *data) #ifdef HAVE_DYNAMIC command_event(CMD_EVENT_LOAD_CORE, NULL); #endif - rarch_ctl(RARCH_CTL_LOAD_CONTENT, NULL); - break; -#ifdef HAVE_FFMPEG + /* fall-through */ case CMD_EVENT_LOAD_CONTENT_FFMPEG: - rarch_ctl(RARCH_CTL_LOAD_CONTENT_FFMPEG, NULL); - break; -#endif case CMD_EVENT_LOAD_CONTENT_IMAGEVIEWER: - rarch_ctl(RARCH_CTL_LOAD_CONTENT_IMAGEVIEWER, NULL); +#ifdef HAVE_MENU + if (!menu_content_ctl(MENU_CONTENT_CTL_LOAD, NULL)) + { + rarch_ctl(RARCH_CTL_MENU_RUNNING, NULL); + return false; + } +#endif break; case CMD_EVENT_LOAD_CONTENT: { diff --git a/retroarch.c b/retroarch.c index dd6801fc3d..85f46f4072 100644 --- a/retroarch.c +++ b/retroarch.c @@ -1513,18 +1513,6 @@ bool rarch_ctl(enum rarch_ctl_state state, void *data) #ifdef HAVE_OVERLAY if (settings->input.overlay_hide_in_menu) command_event(CMD_EVENT_OVERLAY_DEINIT, NULL); -#endif - break; - case RARCH_CTL_LOAD_CONTENT: - case RARCH_CTL_LOAD_CONTENT_FFMPEG: - case RARCH_CTL_LOAD_CONTENT_IMAGEVIEWER: -#ifdef HAVE_MENU - /* If content loading fails, we go back to menu. */ - if (!menu_content_ctl(MENU_CONTENT_CTL_LOAD, NULL)) - { - rarch_ctl(RARCH_CTL_MENU_RUNNING, NULL); - return false; - } #endif break; case RARCH_CTL_MENU_RUNNING_FINISHED: diff --git a/retroarch.h b/retroarch.h index 253c659105..7b5e9bb023 100644 --- a/retroarch.h +++ b/retroarch.h @@ -80,12 +80,6 @@ enum rarch_ctl_state RARCH_CTL_DESTROY, - RARCH_CTL_LOAD_CONTENT, - - RARCH_CTL_LOAD_CONTENT_FFMPEG, - - RARCH_CTL_LOAD_CONTENT_IMAGEVIEWER, - RARCH_CTL_MENU_RUNNING, RARCH_CTL_MENU_RUNNING_FINISHED, diff --git a/runloop.c b/runloop.c index 2bd9e449eb..dd257f8460 100644 --- a/runloop.c +++ b/runloop.c @@ -60,6 +60,7 @@ #ifdef HAVE_MENU #include "menu/menu_driver.h" +#include "menu/menu_content.h" #endif #ifdef HAVE_NETPLAY @@ -1052,7 +1053,13 @@ bool runloop_ctl(enum runloop_ctl_state state, void *data) runloop_ctl(RUNLOOP_CTL_TASK_INIT, NULL); runloop_ctl(RUNLOOP_CTL_CLEAR_CONTENT_PATH, NULL); - rarch_ctl(RARCH_CTL_LOAD_CONTENT, NULL); +#ifdef HAVE_MENU + if (!menu_content_ctl(MENU_CONTENT_CTL_LOAD, NULL)) + { + rarch_ctl(RARCH_CTL_MENU_RUNNING, NULL); + return false; + } +#endif break; case RUNLOOP_CTL_SET_CORE_SHUTDOWN: runloop_core_shutdown_initiated = true; From 95a6428915b182251cb74acaaac48f0dc936b684 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 May 2016 04:24:27 +0200 Subject: [PATCH 20/61] RARCH_CTL_FORCE_QUIT is the same as RARCH_CTL_QUIT --- command.c | 6 +++--- frontend/drivers/platform_gx.c | 2 +- frontend/drivers/platform_linux.c | 2 +- retroarch.c | 3 --- retroarch.h | 2 -- 5 files changed, 5 insertions(+), 10 deletions(-) diff --git a/command.c b/command.c index beabb1c5d5..40d4dc1075 100644 --- a/command.c +++ b/command.c @@ -2032,19 +2032,19 @@ bool command_event(enum event_command cmd, void *data) } break; case CMD_EVENT_QUIT_RETROARCH: - rarch_ctl(RARCH_CTL_FORCE_QUIT, NULL); + rarch_ctl(RARCH_CTL_QUIT, NULL); break; case CMD_EVENT_SHUTDOWN: #if defined(__linux__) && !defined(ANDROID) runloop_msg_queue_push("Shutting down...", 1, 180, true); - rarch_ctl(RARCH_CTL_FORCE_QUIT, NULL); + rarch_ctl(RARCH_CTL_QUIT, NULL); system("shutdown -P now"); #endif break; case CMD_EVENT_REBOOT: #if defined(__linux__) && !defined(ANDROID) runloop_msg_queue_push("Rebooting...", 1, 180, true); - rarch_ctl(RARCH_CTL_FORCE_QUIT, NULL); + rarch_ctl(RARCH_CTL_QUIT, NULL); system("shutdown -r now"); #endif break; diff --git a/frontend/drivers/platform_gx.c b/frontend/drivers/platform_gx.c index 6e5d43edee..a4e070e30b 100644 --- a/frontend/drivers/platform_gx.c +++ b/frontend/drivers/platform_gx.c @@ -426,7 +426,7 @@ static bool frontend_gx_set_fork(enum frontend_fork fork_mode) case FRONTEND_FORK_RESTART: RARCH_LOG("FRONTEND_FORK_RESTART\n"); gx_fork_mode = fork_mode; - rarch_ctl(RARCH_CTL_FORCE_QUIT, NULL); + command_event(CMD_EVENT_QUIT_RETROARCH, NULL); break; case FRONTEND_FORK_NONE: default: diff --git a/frontend/drivers/platform_linux.c b/frontend/drivers/platform_linux.c index 592ed1e242..9f0ea43639 100644 --- a/frontend/drivers/platform_linux.c +++ b/frontend/drivers/platform_linux.c @@ -1827,7 +1827,7 @@ static bool frontend_linux_set_fork(enum frontend_fork fork_mode) fill_pathname_application_path(executable_path, sizeof(executable_path)); strlcpy(settings->path.libretro, executable_path, sizeof(settings->path.libretro)); } - rarch_ctl(RARCH_CTL_FORCE_QUIT, NULL); + command_event(CMD_EVENT_QUIT_RETROARCH, NULL); break; case FRONTEND_FORK_NONE: default: diff --git a/retroarch.c b/retroarch.c index 85f46f4072..dbf803e32b 100644 --- a/retroarch.c +++ b/retroarch.c @@ -1529,9 +1529,6 @@ bool rarch_ctl(enum rarch_ctl_state state, void *data) runloop_ctl(RUNLOOP_CTL_SET_SHUTDOWN, NULL); rarch_ctl(RARCH_CTL_MENU_RUNNING_FINISHED, NULL); break; - case RARCH_CTL_FORCE_QUIT: - rarch_ctl(RARCH_CTL_QUIT, NULL); - break; case RARCH_CTL_VALIDATE_CPU_FEATURES: { uint64_t cpu = cpu_features_get(); diff --git a/retroarch.h b/retroarch.h index 7b5e9bb023..f7f4196350 100644 --- a/retroarch.h +++ b/retroarch.h @@ -91,8 +91,6 @@ enum rarch_ctl_state RARCH_CTL_QUIT, - RARCH_CTL_FORCE_QUIT, - /* Validates CPU features for given processor architecture. * Make sure we haven't compiled for something we cannot run. * Ideally, code would get swapped out depending on CPU support, From 030513bceea594e906e95695fb2db73f47a47240 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 May 2016 04:29:01 +0200 Subject: [PATCH 21/61] Create retroarch_fill_pathnames --- command.c | 4 ++-- retroarch.c | 38 +++++++++++++++++++++----------------- retroarch.h | 4 ++-- 3 files changed, 25 insertions(+), 21 deletions(-) diff --git a/command.c b/command.c index 40d4dc1075..91e9ff2217 100644 --- a/command.c +++ b/command.c @@ -871,7 +871,7 @@ static bool command_event_disk_control_append_image(const char *path) * started out in a single disk case, and that this way * of doing it makes the most sense. */ rarch_ctl(RARCH_CTL_SET_PATHS, (void*)path); - rarch_ctl(RARCH_CTL_FILL_PATHNAMES, NULL); + retroarch_fill_pathnames(); } command_event(CMD_EVENT_AUTOSAVE_INIT, NULL); @@ -1205,7 +1205,7 @@ static bool event_init_content(void) return true; if (!content_does_not_need_content()) - rarch_ctl(RARCH_CTL_FILL_PATHNAMES, NULL); + retroarch_fill_pathnames(); if (!content_init()) return false; diff --git a/retroarch.c b/retroarch.c index dbf803e32b..b2b6b4ace9 100644 --- a/retroarch.c +++ b/retroarch.c @@ -1548,23 +1548,6 @@ bool rarch_ctl(enum rarch_ctl_state state, void *data) #endif } break; - case RARCH_CTL_FILL_PATHNAMES: - retroarch_init_savefile_paths(); - bsv_movie_set_path(global->name.savefile); - - if (!*global->name.base) - return false; - - if (!*global->name.ups) - fill_pathname_noext(global->name.ups, global->name.base, ".ups", - sizeof(global->name.ups)); - if (!*global->name.bps) - fill_pathname_noext(global->name.bps, global->name.base, ".bps", - sizeof(global->name.bps)); - if (!*global->name.ips) - fill_pathname_noext(global->name.ips, global->name.base, ".ips", - sizeof(global->name.ips)); - break; case RARCH_CTL_NONE: default: return false; @@ -1573,6 +1556,27 @@ bool rarch_ctl(enum rarch_ctl_state state, void *data) return true; } +void retroarch_fill_pathnames(void) +{ + global_t *global = global_get_ptr(); + + retroarch_init_savefile_paths(); + bsv_movie_set_path(global->name.savefile); + + if (!*global->name.base) + return; + + if (!*global->name.ups) + fill_pathname_noext(global->name.ups, global->name.base, ".ups", + sizeof(global->name.ups)); + if (!*global->name.bps) + fill_pathname_noext(global->name.bps, global->name.base, ".bps", + sizeof(global->name.bps)); + if (!*global->name.ips) + fill_pathname_noext(global->name.ips, global->name.base, ".ips", + sizeof(global->name.ips)); +} + int retroarch_get_capabilities(enum rarch_capabilities type, char *s, size_t len) { diff --git a/retroarch.h b/retroarch.h index f7f4196350..36dd53cc03 100644 --- a/retroarch.h +++ b/retroarch.h @@ -97,8 +97,6 @@ enum rarch_ctl_state * but this will do for now. */ RARCH_CTL_VALIDATE_CPU_FEATURES, - RARCH_CTL_FILL_PATHNAMES, - RARCH_CTL_SET_PATHS_REDIRECT, RARCH_CTL_SET_SRAM_ENABLE, @@ -171,6 +169,8 @@ const char *retroarch_get_current_savefile_dir(void); bool retroarch_validate_game_options(char *s, size_t len, bool mkdir); +void retroarch_fill_pathnames(void); + /** * retroarch_fail: * @error_code : Error code. From 7ebfe1b66d3b217ecd701b2ea371c742e9071817 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 May 2016 04:32:29 +0200 Subject: [PATCH 22/61] Create retroarch_set_pathnames --- command.c | 2 +- retroarch.c | 34 +++++++++++++++++++--------------- retroarch.h | 4 ++-- 3 files changed, 22 insertions(+), 18 deletions(-) diff --git a/command.c b/command.c index 91e9ff2217..f3b4ba0378 100644 --- a/command.c +++ b/command.c @@ -870,7 +870,7 @@ static bool command_event_disk_control_append_image(const char *path) * If we actually use append_image, we assume that we * started out in a single disk case, and that this way * of doing it makes the most sense. */ - rarch_ctl(RARCH_CTL_SET_PATHS, (void*)path); + retroarch_set_pathnames(path); retroarch_fill_pathnames(); } diff --git a/retroarch.c b/retroarch.c index b2b6b4ace9..aedcb24b83 100644 --- a/retroarch.c +++ b/retroarch.c @@ -1040,7 +1040,7 @@ static void retroarch_parse_input(int argc, char *argv[]) { /* We requested explicit ROM, so use PLAIN core type. */ current_core_type = CORE_TYPE_PLAIN; - rarch_ctl(RARCH_CTL_SET_PATHS, (void*)argv[optind]); + retroarch_set_pathnames((const char*)argv[optind]); } else if (*global->subsystem && optind < argc) { @@ -1340,20 +1340,6 @@ bool rarch_ctl(enum rarch_ctl_state state, void *data) switch(state) { - case RARCH_CTL_SET_PATHS: - retroarch_set_basename((const char*)data); - - if (!global->has_set.save_path) - fill_pathname_noext(global->name.savefile, global->name.base, - ".srm", sizeof(global->name.savefile)); - if (!global->has_set.state_path) - fill_pathname_noext(global->name.savestate, global->name.base, - ".state", sizeof(global->name.savestate)); - fill_pathname_noext(global->name.cheatfile, global->name.base, - ".cht", sizeof(global->name.cheatfile)); - - retroarch_set_paths_redirect((const char*)data); - break; case RARCH_CTL_IS_PLAIN_CORE: return (current_core_type == CORE_TYPE_PLAIN); case RARCH_CTL_IS_DUMMY_CORE: @@ -1556,6 +1542,24 @@ bool rarch_ctl(enum rarch_ctl_state state, void *data) return true; } +void retroarch_set_pathnames(const char *path) +{ + global_t *global = global_get_ptr(); + + retroarch_set_basename(path); + + if (!global->has_set.save_path) + fill_pathname_noext(global->name.savefile, global->name.base, + ".srm", sizeof(global->name.savefile)); + if (!global->has_set.state_path) + fill_pathname_noext(global->name.savestate, global->name.base, + ".state", sizeof(global->name.savestate)); + fill_pathname_noext(global->name.cheatfile, global->name.base, + ".cht", sizeof(global->name.cheatfile)); + + retroarch_set_paths_redirect(path); +} + void retroarch_fill_pathnames(void) { global_t *global = global_get_ptr(); diff --git a/retroarch.h b/retroarch.h index 36dd53cc03..d4e13ab3c4 100644 --- a/retroarch.h +++ b/retroarch.h @@ -101,8 +101,6 @@ enum rarch_ctl_state RARCH_CTL_SET_SRAM_ENABLE, - RARCH_CTL_SET_PATHS, - RARCH_CTL_SET_FORCE_FULLSCREEN, RARCH_CTL_UNSET_FORCE_FULLSCREEN, @@ -169,6 +167,8 @@ const char *retroarch_get_current_savefile_dir(void); bool retroarch_validate_game_options(char *s, size_t len, bool mkdir); +void retroarch_set_pathnames(const char *path); + void retroarch_fill_pathnames(void); /** From b0342ebe44f43eeaf8b32d543553bd91b3d610fb Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 May 2016 09:52:06 +0200 Subject: [PATCH 23/61] Buildfix for compiling without ffmpeg --- command.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/command.h b/command.h index 92dd882916..b10279a548 100644 --- a/command.h +++ b/command.h @@ -44,9 +44,7 @@ enum event_command /* Loads content file. */ CMD_EVENT_LOAD_CONTENT, CMD_EVENT_LOAD_CONTENT_PERSIST, -#ifdef HAVE_FFMPEG CMD_EVENT_LOAD_CONTENT_FFMPEG, -#endif CMD_EVENT_LOAD_CONTENT_IMAGEVIEWER, CMD_EVENT_SET_PER_GAME_RESOLUTION, CMD_EVENT_SET_FRAME_LIMIT, From 78783cc2aa55ad1809b44f4c0b7f09400369b716 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 May 2016 10:06:15 +0200 Subject: [PATCH 24/61] Buildfixes for compiling without HAVE_MENU --- cheevos.c | 1 + driver.c | 1 + gfx/drivers/vulkan.c | 2 ++ 3 files changed, 4 insertions(+) diff --git a/cheevos.c b/cheevos.c index ff3f473944..67c8600804 100644 --- a/cheevos.c +++ b/cheevos.c @@ -23,6 +23,7 @@ #include #include "cheevos.h" +#include "command.h" #include "dynamic.h" #include "network/net_http_special.h" #include "configuration.h" diff --git a/driver.c b/driver.c index 5e6c076363..9bebc2a2a8 100644 --- a/driver.c +++ b/driver.c @@ -17,6 +17,7 @@ #include #include +#include "command.h" #include "general.h" #include "msg_hash.h" #include "system.h" diff --git a/gfx/drivers/vulkan.c b/gfx/drivers/vulkan.c index 7975eddfcb..aab91ebcc3 100644 --- a/gfx/drivers/vulkan.c +++ b/gfx/drivers/vulkan.c @@ -2008,7 +2008,9 @@ static const video_poke_interface_t vulkan_poke_interface = { NULL, NULL, #endif +#ifdef HAVE_MENU vulkan_set_osd_msg, +#endif vulkan_show_mouse, NULL, vulkan_get_current_shader, From fc56f6ebdb0a9a5e1b296de6ce3c3602c9f70426 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 May 2016 10:10:30 +0200 Subject: [PATCH 25/61] Add some HAVE_THREADS ifdefs --- gfx/common/vulkan_common.c | 10 ++++++++++ gfx/drivers/gl.c | 2 ++ gfx/drivers/vulkan.c | 12 ++++++++++++ 3 files changed, 24 insertions(+) diff --git a/gfx/common/vulkan_common.c b/gfx/common/vulkan_common.c index 7f232211b1..6a205c6638 100644 --- a/gfx/common/vulkan_common.c +++ b/gfx/common/vulkan_common.c @@ -481,7 +481,9 @@ struct vk_texture vulkan_create_texture(vk_t *vk, submit_info.commandBufferCount = 1; submit_info.pCommandBuffers = &staging; +#ifdef HAVE_THREADS slock_lock(vk->context->queue_lock); +#endif VKFUNC(vkQueueSubmit)(vk->context->queue, 1, &submit_info, VK_NULL_HANDLE); @@ -489,7 +491,9 @@ struct vk_texture vulkan_create_texture(vk_t *vk, * during init, so waiting for GPU to complete transfer * and blocking isn't a big deal. */ VKFUNC(vkQueueWaitIdle)(vk->context->queue); +#ifdef HAVE_THREADS slock_unlock(vk->context->queue_lock); +#endif VKFUNC(vkFreeCommandBuffers)(vk->context->device, vk->staging_pool, 1, &staging); vulkan_destroy_texture( @@ -1423,9 +1427,11 @@ bool vulkan_context_init(gfx_ctx_vulkan_data_t *vk, break; } +#ifdef HAVE_THREADS vk->context.queue_lock = slock_new(); if (!vk->context.queue_lock) return false; +#endif return true; } @@ -1577,7 +1583,9 @@ void vulkan_present(gfx_ctx_vulkan_data_t *vk, unsigned index) present.pWaitSemaphores = &vk->context.swapchain_semaphores[index]; /* Better hope QueuePresent doesn't block D: */ +#ifdef HAVE_THREADS slock_lock(vk->context.queue_lock); +#endif err = VKFUNC(vkQueuePresentKHR)(vk->context.queue, &present); if (err != VK_SUCCESS || result != VK_SUCCESS) @@ -1586,7 +1594,9 @@ void vulkan_present(gfx_ctx_vulkan_data_t *vk, unsigned index) vk->context.invalid_swapchain = true; } +#ifdef HAVE_THREADS slock_unlock(vk->context.queue_lock); +#endif } void vulkan_context_destroy(gfx_ctx_vulkan_data_t *vk, diff --git a/gfx/drivers/gl.c b/gfx/drivers/gl.c index 7f0fe2f7c2..cfaff3e26f 100644 --- a/gfx/drivers/gl.c +++ b/gfx/drivers/gl.c @@ -3786,6 +3786,7 @@ static void video_texture_load_gl( ); } +#ifdef HAVE_THREADS static int video_texture_load_wrap_gl_mipmap(void *data) { uintptr_t id = 0; @@ -3807,6 +3808,7 @@ static int video_texture_load_wrap_gl(void *data) TEXTURE_FILTER_LINEAR, &id); return id; } +#endif static uintptr_t gl_load_texture(void *video_data, void *data, bool threaded, enum texture_filter_type filter_type) diff --git a/gfx/drivers/vulkan.c b/gfx/drivers/vulkan.c index aab91ebcc3..c46ea440e5 100644 --- a/gfx/drivers/vulkan.c +++ b/gfx/drivers/vulkan.c @@ -885,13 +885,17 @@ static void vulkan_set_command_buffers(void *handle, uint32_t num_cmd, static void vulkan_lock_queue(void *handle) { vk_t *vk = (vk_t*)handle; +#ifdef HAVE_THREADS slock_lock(vk->context->queue_lock); +#endif } static void vulkan_unlock_queue(void *handle) { vk_t *vk = (vk_t*)handle; +#ifdef HAVE_THREADS slock_unlock(vk->context->queue_lock); +#endif } static void vulkan_init_hw_render(vk_t *vk) @@ -1741,10 +1745,14 @@ static bool vulkan_frame(void *data, const void *frame, retro_perf_start(&queue_submit); +#ifdef HAVE_THREADS slock_lock(vk->context->queue_lock); +#endif VKFUNC(vkQueueSubmit)(vk->context->queue, 1, &submit_info, vk->context->swapchain_fences[frame_index]); +#ifdef HAVE_THREADS slock_unlock(vk->context->queue_lock); +#endif retro_perf_stop(&queue_submit); retro_perf_start(&swapbuffers); @@ -2263,9 +2271,13 @@ static bool vulkan_overlay_load(void *data, if (!vk) return false; +#ifdef HAVE_THREADS slock_lock(vk->context->queue_lock); +#endif VKFUNC(vkQueueWaitIdle)(vk->context->queue); +#ifdef HAVE_THREADS slock_unlock(vk->context->queue_lock); +#endif vulkan_overlay_free(vk); vk->overlay.images = (struct vk_texture*) From 377f09f12a51a6a50e31decf68f54bd0cf9eab39 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 May 2016 18:54:22 +0200 Subject: [PATCH 26/61] Change back retro_dirent_is_dir to hopefully avoid sshfs issues - more rigorous testing should be applied before changing these functions --- libretro-common/file/retro_dirent.c | 5 +---- libretro-common/include/retro_dirent.h | 2 +- libretro-common/lists/dir_list.c | 2 +- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/libretro-common/file/retro_dirent.c b/libretro-common/file/retro_dirent.c index bdb50094a9..15046be14c 100644 --- a/libretro-common/file/retro_dirent.c +++ b/libretro-common/file/retro_dirent.c @@ -158,7 +158,7 @@ const char *retro_dirent_get_name(struct RDIR *rdir) * Returns: true if directory listing entry is * a directory, false if not. */ -bool retro_dirent_is_dir(struct RDIR *rdir) +bool retro_dirent_is_dir(struct RDIR *rdir, const char *path) { #if defined(_WIN32) const WIN32_FIND_DATA *entry = (const WIN32_FIND_DATA*)&rdir->entry; @@ -174,18 +174,15 @@ bool retro_dirent_is_dir(struct RDIR *rdir) CellFsDirent *entry = (CellFsDirent*)&rdir->entry; return (entry->d_type == CELL_FS_TYPE_DIRECTORY); #elif defined(DT_DIR) - const char *path = NULL; const struct dirent *entry = (const struct dirent*)rdir->entry; if (entry->d_type == DT_DIR) return true; /* This can happen on certain file systems. */ - path = retro_dirent_get_name(rdir); if (entry->d_type == DT_UNKNOWN || entry->d_type == DT_LNK) return path_is_directory(path); return false; #else /* dirent struct doesn't have d_type, do it the slow way ... */ - const char *path = retro_dirent_get_name(rdir); return path_is_directory(path); #endif } diff --git a/libretro-common/include/retro_dirent.h b/libretro-common/include/retro_dirent.h index 65af28d11d..9b4f53b1d2 100644 --- a/libretro-common/include/retro_dirent.h +++ b/libretro-common/include/retro_dirent.h @@ -49,7 +49,7 @@ const char *retro_dirent_get_name(struct RDIR *rdir); * Returns: true if directory listing entry is * a directory, false if not. */ -bool retro_dirent_is_dir(struct RDIR *rdir); +bool retro_dirent_is_dir(struct RDIR *rdir, const char *path); void retro_closedir(struct RDIR *rdir); diff --git a/libretro-common/lists/dir_list.c b/libretro-common/lists/dir_list.c index 5fb2b373e3..8bcb3f3fbe 100644 --- a/libretro-common/lists/dir_list.c +++ b/libretro-common/lists/dir_list.c @@ -188,7 +188,7 @@ struct string_list *dir_list_new(const char *dir, const char *file_ext = path_get_extension(name); fill_pathname_join(file_path, dir, name, sizeof(file_path)); - is_dir = retro_dirent_is_dir(entry); + is_dir = retro_dirent_is_dir(entry, file_path); ret = parse_dir_entry(name, file_path, is_dir, include_dirs, include_compressed, list, ext_list, file_ext); From 5845a9944d2c2e7c4532c5d739793dee4ac3ae77 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 May 2016 19:02:43 +0200 Subject: [PATCH 27/61] Add more HAVE_THREADS ifdefs --- Makefile.common | 9 +++++++-- audio/audio_driver.c | 2 +- audio/drivers/jack.c | 14 ++++++++++++++ audio/drivers/sdl_audio.c | 10 ++++++++++ gfx/drivers_context/wayland_ctx.c | 2 +- gfx/drivers_context/x_ctx.c | 2 +- griffin/griffin.c | 2 +- input/input_hid_driver.c | 2 +- 8 files changed, 36 insertions(+), 7 deletions(-) diff --git a/Makefile.common b/Makefile.common index b36ec42be9..4d909c217a 100644 --- a/Makefile.common +++ b/Makefile.common @@ -291,8 +291,11 @@ ifeq ($(HAVE_OSS_BSD), 1) endif ifeq ($(HAVE_ALSA), 1) - OBJ += audio/drivers/alsa.o \ - audio/drivers/alsathread.o + OBJ += audio/drivers/alsa.o + +ifeq ($(HAVE_THREADS), 1) + OBJ += audio/drivers/alsathread.o +endif LIBS += $(ALSA_LIBS) DEFINES += $(ALSA_CFLAGS) endif @@ -575,11 +578,13 @@ ifeq ($(HAVE_UDEV), 1) endif ifeq ($(HAVE_LIBUSB), 1) +ifeq ($(HAVE_THREADS), 1) DEFINES += -DHAVE_LIBUSB OBJ += input/drivers_hid/libusb_hid.o LIBS += -lusb-1.0 HAVE_HID = 1 endif +endif ifeq ($(HAVE_IOHIDMANAGER), 1) DEFINES += -DHAVE_IOHIDMANAGER diff --git a/audio/audio_driver.c b/audio/audio_driver.c index b9cd3fed4c..c875df40f1 100644 --- a/audio/audio_driver.c +++ b/audio/audio_driver.c @@ -93,7 +93,7 @@ typedef struct audio_driver_input_data static const audio_driver_t *audio_drivers[] = { #ifdef HAVE_ALSA &audio_alsa, -#ifndef __QNX__ +#if !defined(__QNX__) && defined(HAVE_THREADS) &audio_alsathread, #endif #endif diff --git a/audio/drivers/jack.c b/audio/drivers/jack.c index f9f3abfaf6..80b2ee34e3 100644 --- a/audio/drivers/jack.c +++ b/audio/drivers/jack.c @@ -41,8 +41,10 @@ typedef struct jack bool nonblock; bool is_paused; +#ifdef HAVE_THREADS scond_t *cond; slock_t *cond_lock; +#endif size_t buffer_size; } jack_t; @@ -54,7 +56,9 @@ static int process_cb(jack_nframes_t nframes, void *data) if (nframes <= 0) { +#ifdef HAVE_THREADS scond_signal(jd->cond); +#endif return 0; } @@ -74,7 +78,9 @@ static int process_cb(jack_nframes_t nframes, void *data) for (f = min_avail; f < nframes; f++) out[f] = 0.0f; } +#ifdef HAVE_THREADS scond_signal(jd->cond); +#endif return 0; } @@ -86,7 +92,9 @@ static void shutdown_cb(void *data) return; jd->shutdown = true; +#ifdef HAVE_THREADS scond_signal(jd->cond); +#endif } static int parse_ports(char **dest_ports, const char **jports) @@ -149,8 +157,10 @@ static void *ja_init(const char *device, unsigned rate, unsigned latency) if (!jd) return NULL; +#ifdef HAVE_THREADS jd->cond = scond_new(); jd->cond_lock = slock_new(); +#endif jd->client = jack_client_open("RetroArch", JackNullOption, NULL); if (jd->client == NULL) @@ -258,12 +268,14 @@ static size_t write_buffer(jack_t *jd, const float *buf, size_t size) } written += write_frames; } +#ifdef HAVE_THREADS else { slock_lock(jd->cond_lock); scond_wait(jd->cond, jd->cond_lock); slock_unlock(jd->cond_lock); } +#endif if (jd->nonblock) break; @@ -327,10 +339,12 @@ static void ja_free(void *data) if (jd->buffer[i] != NULL) jack_ringbuffer_free(jd->buffer[i]); +#ifdef HAVE_THREADS if (jd->cond_lock) slock_free(jd->cond_lock); if (jd->cond) scond_free(jd->cond); +#endif free(jd); } diff --git a/audio/drivers/sdl_audio.c b/audio/drivers/sdl_audio.c index dc6f16eb34..181d60f105 100644 --- a/audio/drivers/sdl_audio.c +++ b/audio/drivers/sdl_audio.c @@ -35,8 +35,10 @@ typedef struct sdl_audio bool nonblock; bool is_paused; +#ifdef HAVE_THREADS slock_t *lock; scond_t *cond; +#endif fifo_buffer_t *buffer; } sdl_audio_t; @@ -47,7 +49,9 @@ static void sdl_audio_cb(void *data, Uint8 *stream, int len) size_t write_size = len > (int)avail ? avail : len; fifo_read(sdl->buffer, stream, write_size); +#ifdef HAVE_THREADS scond_signal(sdl->cond); +#endif /* If underrun, fill rest with silence. */ memset(stream + write_size, 0, len - write_size); @@ -109,8 +113,10 @@ static void *sdl_audio_init(const char *device, settings->audio.out_rate = out.freq; +#ifdef HAVE_THREADS sdl->lock = slock_new(); sdl->cond = scond_new(); +#endif RARCH_LOG("SDL audio: Requested %u ms latency, got %d ms\n", latency, (int)(out.samples * 4 * 1000 / settings->audio.out_rate)); @@ -160,9 +166,11 @@ static ssize_t sdl_audio_write(void *data, const void *buf, size_t size) if (avail == 0) { SDL_UnlockAudio(); +#ifdef HAVE_THREADS slock_lock(sdl->lock); scond_wait(sdl->cond, sdl->lock); slock_unlock(sdl->lock); +#endif } else { @@ -220,8 +228,10 @@ static void sdl_audio_free(void *data) if (sdl) { fifo_free(sdl->buffer); +#ifdef HAVE_THREADS slock_free(sdl->lock); scond_free(sdl->cond); +#endif } free(sdl); } diff --git a/gfx/drivers_context/wayland_ctx.c b/gfx/drivers_context/wayland_ctx.c index 7098916b39..66b7dbbdc9 100644 --- a/gfx/drivers_context/wayland_ctx.c +++ b/gfx/drivers_context/wayland_ctx.c @@ -706,7 +706,7 @@ static void gfx_ctx_wl_destroy(void *data) switch (wl_api) { case GFX_CTX_VULKAN_API: -#ifdef HAVE_VULKAN +#if defined(HAVE_VULKAN) && defined(HAVE_THREADS) if (wl->vk.context.queue_lock) slock_free(wl->vk.context.queue_lock); #endif diff --git a/gfx/drivers_context/x_ctx.c b/gfx/drivers_context/x_ctx.c index 1e6c41101b..1f7aec4f85 100644 --- a/gfx/drivers_context/x_ctx.c +++ b/gfx/drivers_context/x_ctx.c @@ -167,7 +167,7 @@ static void gfx_ctx_x_destroy(void *data) switch (x_api) { case GFX_CTX_VULKAN_API: -#ifdef HAVE_VULKAN +#if defined(HAVE_VULKAN) && defined(HAVE_THREADS) if (x->vk.context.queue_lock) slock_free(x->vk.context.queue_lock); #endif diff --git a/griffin/griffin.c b/griffin/griffin.c index edf45c5fad..da142c7151 100644 --- a/griffin/griffin.c +++ b/griffin/griffin.c @@ -430,7 +430,7 @@ INPUT (HID) #include "../input/drivers_hid/null_hid.c" -#if defined(HAVE_LIBUSB) +#if defined(HAVE_LIBUSB) && defined(HAVE_THREADS) #include "../input/drivers_hid/libusb_hid.c" #endif diff --git a/input/input_hid_driver.c b/input/input_hid_driver.c index ce37c24f22..a7b9bdc732 100644 --- a/input/input_hid_driver.c +++ b/input/input_hid_driver.c @@ -29,7 +29,7 @@ static hid_driver_t *hid_drivers[] = { #if defined(__APPLE__) && defined(HAVE_IOHIDMANAGER) &iohidmanager_hid, #endif -#ifdef HAVE_LIBUSB +#if defined(HAVE_LIBUSB) && defined(HAVE_THREADS) &libusb_hid, #endif #ifdef HW_RVL From 123025665d324bbf5345c5942ae3ca175ecb540b Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 May 2016 19:11:09 +0200 Subject: [PATCH 28/61] (Qb) When threads are disabled, disable cheevos and/or libusb too --- qb/config.libs.sh | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/qb/config.libs.sh b/qb/config.libs.sh index a58f88f77b..1bf9ec0816 100644 --- a/qb/config.libs.sh +++ b/qb/config.libs.sh @@ -416,12 +416,12 @@ if [ "$HAVE_MATERIALUI" != 'no' ] || [ "$HAVE_XMB" != 'no' ] || [ "$HAVE_ZARCH" HAVE_MATERIALUI=no HAVE_XMB=no HAVE_ZARCH=no - echo "Notice: RGUI not available, MaterialUI, XMB and ZARCH will be disabled." + echo "Notice: RGUI not available, MaterialUI, XMB and ZARCH will also be disabled." elif [ "$HAVE_OPENGL" = 'no' ] && [ "$HAVE_GLES" = 'no' ] && [ "$HAVE_VULKAN" = 'no' ]; then HAVE_MATERIALUI=no HAVE_XMB=no HAVE_ZARCH=no - echo "Notice: Hardware rendering context not available, XMB, MaterialUI and ZARCH will be disabled." + echo "Notice: Hardware rendering context not available, XMB, MaterialUI and ZARCH will also be disabled." fi fi @@ -429,6 +429,16 @@ check_macro NEON __ARM_NEON__ add_define_make OS "$OS" +if [ "$HAVE_THREADS" = 'no' ] && [ "HAVE_CHEEVOS" != 'no' ]; then + HAVE_CHEEVOS=no + echo "Notice: Threads are not available, Cheevos will also be disabled." +fi + +if [ "$HAVE_THREADS" = 'no' ] && [ "HAVE_LIBUSB" != 'no' ]; then + HAVE_LIBUSB=no + echo "Notice: Threads are not available, libusb will also be disabled." +fi + # Creates config.mk and config.h. add_define_make GLOBAL_CONFIG_DIR "$GLOBAL_CONFIG_DIR" VARS=$(eval set | grep ^HAVE_ | sed s/=.*// | sed s/^HAVE_//) From daf031173f5990a11374215daaae26d21488e526 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 May 2016 19:25:15 +0200 Subject: [PATCH 29/61] Remove unused variable --- runloop.c | 6 ++++++ runloop.h | 7 +------ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/runloop.c b/runloop.c index dd257f8460..1daa414811 100644 --- a/runloop.c +++ b/runloop.c @@ -93,6 +93,12 @@ cmd->state[1], cmd->state[2])) #endif +struct rarch_dir_list +{ + struct string_list *list; + size_t ptr; +}; + typedef struct event_cmd_state { retro_input_t state[3]; diff --git a/runloop.h b/runloop.h index 46a74d6e9f..5315099600 100644 --- a/runloop.h +++ b/runloop.h @@ -112,11 +112,7 @@ enum runloop_ctl_state typedef int (*transfer_cb_t)(void *data, size_t len); -typedef struct rarch_dir_list -{ - struct string_list *list; - size_t ptr; -} rarch_dir_list_t; +typedef struct rarch_dir_list rarch_dir_list_t; typedef struct rarch_dir { @@ -127,7 +123,6 @@ typedef struct rarch_dir #ifdef HAVE_OVERLAY char osk_overlay[PATH_MAX_LENGTH]; #endif - rarch_dir_list_t filter_dir; } rarch_dir_t; typedef struct rarch_path From 22bea3a50b62651492b55e118135f4a97723b186 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 May 2016 19:28:22 +0200 Subject: [PATCH 30/61] Remove some RUNLOOP_CTL_ enums --- runloop.c | 104 +++++++++++++++++++++++++++++------------------------- runloop.h | 4 --- 2 files changed, 55 insertions(+), 53 deletions(-) diff --git a/runloop.c b/runloop.c index 1daa414811..92a85b4d81 100644 --- a/runloop.c +++ b/runloop.c @@ -233,6 +233,60 @@ static bool runloop_check_movie_record(void) return true; } +static bool runloop_check_movie_init(void) +{ + char msg[128], path[PATH_MAX_LENGTH]; + settings_t *settings = config_get_ptr(); + if (bsv_movie_ctl(BSV_MOVIE_CTL_IS_INITED, NULL)) + return false; + + settings->rewind_granularity = 1; + + if (settings->state_slot > 0) + snprintf(path, sizeof(path), "%s%d", + bsv_movie_get_path(), settings->state_slot); + else + strlcpy(path, bsv_movie_get_path(), sizeof(path)); + + strlcat(path, ".bsv", sizeof(path)); + + snprintf(msg, sizeof(msg), "%s \"%s\".", + msg_hash_to_str(MSG_STARTING_MOVIE_RECORD_TO), + path); + + bsv_movie_init_handle(path, RARCH_MOVIE_RECORD); + + if (!bsv_movie_ctl(BSV_MOVIE_CTL_IS_INITED, NULL)) + return false; + + if (bsv_movie_ctl(BSV_MOVIE_CTL_IS_INITED, NULL)) + { + runloop_msg_queue_push(msg, 1, 180, true); + RARCH_LOG("%s \"%s\".\n", + msg_hash_to_str(MSG_STARTING_MOVIE_RECORD_TO), + path); + } + else + { + runloop_msg_queue_push( + msg_hash_to_str(MSG_FAILED_TO_START_MOVIE_RECORD), + 1, 180, true); + RARCH_ERR("%s\n", + msg_hash_to_str(MSG_FAILED_TO_START_MOVIE_RECORD)); + } + + return true; +} + +static bool runloop_check_movie(void) +{ + if (bsv_movie_ctl(BSV_MOVIE_CTL_PLAYBACK_ON, NULL)) + return runloop_check_movie_playback(); + if (!bsv_movie_ctl(BSV_MOVIE_CTL_IS_INITED, NULL)) + return runloop_check_movie_init(); + return runloop_check_movie_record(); +} + /* Checks if slowmotion toggle/hold was being pressed and/or held. */ static bool runloop_check_slowmotion(bool *ptr) { @@ -595,7 +649,7 @@ static bool runloop_check_state(event_cmd_state_t *cmd, rarch_dir_list_t *shader runloop_check_slowmotion(&tmp); if (runloop_cmd_triggered(cmd, RARCH_MOVIE_RECORD_TOGGLE)) - runloop_ctl(RUNLOOP_CTL_CHECK_MOVIE, NULL); + runloop_check_movie(); runloop_check_shader_dir(shader_dir, runloop_cmd_triggered(cmd, RARCH_SHADER_NEXT), @@ -875,54 +929,6 @@ bool runloop_ctl(enum runloop_ctl_state state, void *data) return false; } break; - case RUNLOOP_CTL_CHECK_MOVIE: - if (bsv_movie_ctl(BSV_MOVIE_CTL_PLAYBACK_ON, NULL)) - return runloop_check_movie_playback(); - if (!bsv_movie_ctl(BSV_MOVIE_CTL_IS_INITED, NULL)) - return runloop_ctl(RUNLOOP_CTL_CHECK_MOVIE_INIT, NULL); - return runloop_check_movie_record(); - case RUNLOOP_CTL_CHECK_MOVIE_INIT: - if (bsv_movie_ctl(BSV_MOVIE_CTL_IS_INITED, NULL)) - return false; - { - char msg[128]; - char path[PATH_MAX_LENGTH]; - - settings->rewind_granularity = 1; - - if (settings->state_slot > 0) - snprintf(path, sizeof(path), "%s%d", - bsv_movie_get_path(), settings->state_slot); - else - strlcpy(path, bsv_movie_get_path(), sizeof(path)); - - strlcat(path, ".bsv", sizeof(path)); - - snprintf(msg, sizeof(msg), "%s \"%s\".", - msg_hash_to_str(MSG_STARTING_MOVIE_RECORD_TO), - path); - - bsv_movie_init_handle(path, RARCH_MOVIE_RECORD); - - if (!bsv_movie_ctl(BSV_MOVIE_CTL_IS_INITED, NULL)) - return false; - else if (bsv_movie_ctl(BSV_MOVIE_CTL_IS_INITED, NULL)) - { - runloop_msg_queue_push(msg, 1, 180, true); - RARCH_LOG("%s \"%s\".\n", - msg_hash_to_str(MSG_STARTING_MOVIE_RECORD_TO), - path); - } - else - { - runloop_msg_queue_push( - msg_hash_to_str(MSG_FAILED_TO_START_MOVIE_RECORD), - 1, 180, true); - RARCH_ERR("%s\n", - msg_hash_to_str(MSG_FAILED_TO_START_MOVIE_RECORD)); - } - } - break; case RUNLOOP_CTL_FRAME_TIME_FREE: memset(&runloop_frame_time, 0, sizeof(struct retro_frame_time_callback)); runloop_frame_time_last = 0; diff --git a/runloop.h b/runloop.h index 5315099600..ce7cc6f03d 100644 --- a/runloop.h +++ b/runloop.h @@ -79,10 +79,6 @@ enum runloop_ctl_state RUNLOOP_CTL_KEY_EVENT_GET, RUNLOOP_CTL_DATA_DEINIT, - RUNLOOP_CTL_CHECK_MOVIE, - - RUNLOOP_CTL_CHECK_MOVIE_INIT, - /* Initializes message queue. */ RUNLOOP_CTL_MSG_QUEUE_INIT, From 322d11e3879074b09325402ff0618ee22b9dee55 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 May 2016 19:37:56 +0200 Subject: [PATCH 31/61] Avoid some warnings when compiling with --disable-netplay --- command.c | 136 +++++++++++++++++++++++++++--------------------------- 1 file changed, 69 insertions(+), 67 deletions(-) diff --git a/command.c b/command.c index f3b4ba0378..98ae2e3fec 100644 --- a/command.c +++ b/command.c @@ -201,40 +201,6 @@ static const struct cmd_map map[] = { { "MENU_B", RETRO_DEVICE_ID_JOYPAD_B }, }; -#if defined(HAVE_NETWORK_CMD) && defined(HAVE_NETPLAY) -static bool command_network_init(command_t *handle, uint16_t port) -{ - int fd; - struct addrinfo *res = NULL; - - RARCH_LOG("Bringing up command interface on port %hu.\n", - (unsigned short)port); - - fd = socket_init((void**)&res, port, NULL, SOCKET_TYPE_DATAGRAM); - - if (fd < 0) - goto error; - - handle->net_fd = fd; - - if (!socket_nonblock(handle->net_fd)) - goto error; - - if (!socket_bind(handle->net_fd, (void*)res)) - { - RARCH_ERR("Failed to bind socket.\n"); - goto error; - } - - freeaddrinfo_retro(res); - return true; - -error: - if (res) - freeaddrinfo_retro(res); - return false; -} - static bool command_get_arg(const char *tok, const char **arg, unsigned *index) { @@ -276,6 +242,75 @@ static bool command_get_arg(const char *tok, return false; } +static void command_parse_sub_msg(command_t *handle, const char *tok) +{ + const char *arg = NULL; + unsigned index = 0; + + if (command_get_arg(tok, &arg, &index)) + { + if (arg) + { + if (!action_map[index].action(arg)) + RARCH_ERR("Command \"%s\" failed.\n", arg); + } + else + handle->state[map[index].id] = true; + } + else + RARCH_WARN("%s \"%s\" %s.\n", + msg_hash_to_str(MSG_UNRECOGNIZED_COMMAND), + tok, + msg_hash_to_str(MSG_RECEIVED)); +} + +static void command_parse_msg(command_t *handle, char *buf) +{ + char *save = NULL; + const char *tok = strtok_r(buf, "\n", &save); + + while (tok) + { + command_parse_sub_msg(handle, tok); + tok = strtok_r(NULL, "\n", &save); + } +} + +#if defined(HAVE_NETWORK_CMD) && defined(HAVE_NETPLAY) +static bool command_network_init(command_t *handle, uint16_t port) +{ + int fd; + struct addrinfo *res = NULL; + + RARCH_LOG("Bringing up command interface on port %hu.\n", + (unsigned short)port); + + fd = socket_init((void**)&res, port, NULL, SOCKET_TYPE_DATAGRAM); + + if (fd < 0) + goto error; + + handle->net_fd = fd; + + if (!socket_nonblock(handle->net_fd)) + goto error; + + if (!socket_bind(handle->net_fd, (void*)res)) + { + RARCH_ERR("Failed to bind socket.\n"); + goto error; + } + + freeaddrinfo_retro(res); + return true; + +error: + if (res) + freeaddrinfo_retro(res); + return false; +} + + static bool send_udp_packet(const char *host, uint16_t port, const char *msg) @@ -390,39 +425,6 @@ bool command_network_send(const char *cmd_) return ret; } -static void command_parse_sub_msg(command_t *handle, const char *tok) -{ - const char *arg = NULL; - unsigned index = 0; - - if (command_get_arg(tok, &arg, &index)) - { - if (arg) - { - if (!action_map[index].action(arg)) - RARCH_ERR("Command \"%s\" failed.\n", arg); - } - else - handle->state[map[index].id] = true; - } - else - RARCH_WARN("%s \"%s\" %s.\n", - msg_hash_to_str(MSG_UNRECOGNIZED_COMMAND), - tok, - msg_hash_to_str(MSG_RECEIVED)); -} - -static void command_parse_msg(command_t *handle, char *buf) -{ - char *save = NULL; - const char *tok = strtok_r(buf, "\n", &save); - - while (tok) - { - command_parse_sub_msg(handle, tok); - tok = strtok_r(NULL, "\n", &save); - } -} static void command_network_poll(command_t *handle) { From dc46c0d0124ac76ab4c7f4380b28b616dc62c0ee Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 May 2016 19:38:46 +0200 Subject: [PATCH 32/61] C89 build-fix --- tasks/tasks_internal.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tasks/tasks_internal.h b/tasks/tasks_internal.h index 737261fe74..f880dbe156 100644 --- a/tasks/tasks_internal.h +++ b/tasks/tasks_internal.h @@ -141,7 +141,7 @@ bool rarch_task_push_content_load_default( void rarch_task_image_load_free(retro_task_t *task); -void rarch_task_file_load_handler(retro_task_t *task);; +void rarch_task_file_load_handler(retro_task_t *task); #ifdef __cplusplus } From 5cc86384b813d397d003c9f25562cb4278a18229 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 May 2016 20:38:09 +0200 Subject: [PATCH 33/61] (task_image.c) Cleanups --- tasks/task_image.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/tasks/task_image.c b/tasks/task_image.c index bcc25af17e..446a3f4dca 100644 --- a/tasks/task_image.c +++ b/tasks/task_image.c @@ -99,9 +99,10 @@ static int cb_nbio_default(void *data, size_t len) static int rarch_main_data_image_process( nbio_handle_t *nbio, unsigned *width, - unsigned *height, - int *retval) + unsigned *height) { + int retval = 0; + switch (nbio->image_type) { case IMAGE_TYPE_PNG: @@ -109,7 +110,7 @@ static int rarch_main_data_image_process( if (!rpng_is_valid((rpng_t*)nbio->image.handle)) return IMAGE_PROCESS_ERROR; - *retval = rpng_nbio_load_image_argb_process( + retval = rpng_nbio_load_image_argb_process( (rpng_t*)nbio->image.handle, &nbio->image.ti.pixels, width, height); @@ -122,7 +123,7 @@ static int rarch_main_data_image_process( nbio->image.ti.width = *width; nbio->image.ti.height = *height; - return *retval; + return retval; } static int cb_image_menu_generic(nbio_handle_t *nbio) @@ -132,8 +133,10 @@ static int cb_image_menu_generic(nbio_handle_t *nbio) if (!nbio) return -1; - switch (rarch_main_data_image_process(nbio, - &width, &height, &retval)) + retval = rarch_main_data_image_process(nbio, + &width, &height); + + switch (retval) { case IMAGE_PROCESS_ERROR: case IMAGE_PROCESS_ERROR_END: @@ -204,8 +207,9 @@ static int rarch_main_data_image_iterate_process_transfer(nbio_handle_t *nbio) for (i = 0; i < nbio->image.processing_pos_increment; i++) { - if (rarch_main_data_image_process(nbio, - &width, &height, &retval) != IMAGE_PROCESS_NEXT) + retval = rarch_main_data_image_process(nbio, + &width, &height); + if (retval != IMAGE_PROCESS_NEXT) break; } From 0e972b98047fb2ae61dbdb841df16688c887ae0a Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 May 2016 20:44:24 +0200 Subject: [PATCH 34/61] Rename rarch_git_version to retroarch_git_version --- git_version.c | 2 +- git_version.h | 2 +- menu/menu_displaylist.c | 2 +- retroarch.c | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/git_version.c b/git_version.c index 12835695e4..3d7a62109e 100644 --- a/git_version.c +++ b/git_version.c @@ -17,5 +17,5 @@ #include "git_version.h" #define STR_(x) #x #define STR(x) STR_(x) -const char rarch_git_version[] = STR(GIT_VERSION); +const char retroarch_git_version[] = STR(GIT_VERSION); diff --git a/git_version.h b/git_version.h index 843d5d1f1c..2217898ee7 100644 --- a/git_version.h +++ b/git_version.h @@ -23,7 +23,7 @@ extern "C" { /* Put this in a separate file so we don't have to rebuilt * retroarch.c every single build. */ -extern const char rarch_git_version[]; +extern const char retroarch_git_version[]; #ifdef __cplusplus } diff --git a/menu/menu_displaylist.c b/menu/menu_displaylist.c index eb902a4c99..66fdcd1c7f 100644 --- a/menu/menu_displaylist.c +++ b/menu/menu_displaylist.c @@ -619,7 +619,7 @@ static int menu_displaylist_parse_system_info(menu_displaylist_info_t *info) strlcpy(tmp, menu_hash_to_str(MENU_LABEL_VALUE_SYSTEM_INFO_GIT_VERSION), sizeof(tmp)); strlcat(tmp, ": ", sizeof(tmp)); - strlcat(tmp, rarch_git_version, sizeof(tmp)); + strlcat(tmp, retroarch_git_version, sizeof(tmp)); menu_entries_add(info->list, tmp, "", MENU_SETTINGS_CORE_INFO_NONE, 0, 0); #endif diff --git a/retroarch.c b/retroarch.c index aedcb24b83..b62edb6f54 100644 --- a/retroarch.c +++ b/retroarch.c @@ -176,7 +176,7 @@ static void retroarch_print_version(void) fprintf(stderr, "%s: Frontend for libretro -- v%s", msg_hash_to_str(MSG_PROGRAM), PACKAGE_VERSION); #ifdef HAVE_GIT_VERSION - printf(" -- %s --\n", rarch_git_version); + printf(" -- %s --\n", retroarch_git_version); #endif retroarch_get_capabilities(RARCH_CAPABILITIES_COMPILER, str, sizeof(str)); fprintf(stdout, "%s", str); @@ -1249,7 +1249,7 @@ static int retroarch_main_init(int argc, char *argv[]) fprintf(stderr, "Built: %s\n", __DATE__); RARCH_LOG_OUTPUT("Version: %s\n", PACKAGE_VERSION); #ifdef HAVE_GIT_VERSION - RARCH_LOG_OUTPUT("Git: %s\n", rarch_git_version); + RARCH_LOG_OUTPUT("Git: %s\n", retroarch_git_version); #endif RARCH_LOG_OUTPUT("=================================================\n"); } From a082198d4b506076c66dbe90a7f6718ef0cd5a6f Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 May 2016 20:50:34 +0200 Subject: [PATCH 35/61] Change retroarch_main_init --- content.c | 2 +- retroarch.c | 16 +++++----------- retroarch.h | 14 +++++++++++--- 3 files changed, 17 insertions(+), 15 deletions(-) diff --git a/content.c b/content.c index 73c0f6ba94..2873230cef 100644 --- a/content.c +++ b/content.c @@ -892,7 +892,7 @@ bool content_load(content_ctx_info_t *info) wrap_args->argc = *rarch_argc_ptr; wrap_args->argv = rarch_argv_ptr; - if (!rarch_ctl(RARCH_CTL_MAIN_INIT, wrap_args)) + if (!retroarch_main_init(wrap_args->argc, wrap_args->argv)) { retval = false; goto error; diff --git a/retroarch.c b/retroarch.c index b62edb6f54..9fe07f1327 100644 --- a/retroarch.c +++ b/retroarch.c @@ -1220,7 +1220,7 @@ bool retroarch_validate_game_options(char *s, size_t len, bool mkdir) * * Returns: 0 on success, otherwise 1 if there was an error. **/ -static int retroarch_main_init(int argc, char *argv[]) +bool retroarch_main_init(int argc, char *argv[]) { int sjlj_ret; bool *verbosity = NULL; @@ -1230,7 +1230,7 @@ static int retroarch_main_init(int argc, char *argv[]) if ((sjlj_ret = setjmp(error_sjlj_context)) > 0) { RARCH_ERR("Fatal error received in: \"%s\"\n", error_string); - return sjlj_ret; + return false; } rarch_ctl(RARCH_CTL_SET_ERROR_ON_INIT, NULL); @@ -1315,12 +1315,13 @@ static int retroarch_main_init(int argc, char *argv[]) rarch_ctl(RARCH_CTL_UNSET_ERROR_ON_INIT, NULL); rarch_ctl(RARCH_CTL_SET_INITED, NULL); - return 0; + + return true; error: command_event(CMD_EVENT_CORE_DEINIT, NULL); rarch_ctl(RARCH_CTL_UNSET_INITED, NULL); - return 1; + return false; } #define FAIL_CPU(simd_type) do { \ @@ -1416,13 +1417,6 @@ bool rarch_ctl(enum rarch_ctl_state state, void *data) rarch_ctl(RARCH_CTL_UNSET_INITED, NULL); break; - case RARCH_CTL_MAIN_INIT: - { - struct rarch_main_wrap *wrap = (struct rarch_main_wrap*)data; - if (retroarch_main_init(wrap->argc, wrap->argv)) - return false; - } - break; case RARCH_CTL_INIT: rarch_ctl(RARCH_CTL_DEINIT, NULL); retroarch_init_state(); diff --git a/retroarch.h b/retroarch.h index d4e13ab3c4..77759ad38f 100644 --- a/retroarch.h +++ b/retroarch.h @@ -60,9 +60,6 @@ enum rarch_ctl_state /* Initialize all drivers. */ RARCH_CTL_INIT, - /* Initializes RetroArch. */ - RARCH_CTL_MAIN_INIT, - /* Deinitializes RetroArch. */ RARCH_CTL_MAIN_DEINIT, @@ -180,6 +177,17 @@ void retroarch_fill_pathnames(void); **/ void retroarch_fail(int error_code, const char *error); +/** + * retroarch_main_init: + * @argc : Count of (commandline) arguments. + * @argv : (Commandline) arguments. + * + * Initializes the program. + * + * Returns: 1 (true) on success, otherwise false (0) if there was an error. + **/ +bool retroarch_main_init(int argc, char *argv[]); + #ifdef __cplusplus } #endif From cf3f8d587cd5333f900044c7693cc7f84fbcc85a Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 May 2016 20:53:28 +0200 Subject: [PATCH 36/61] Cleanup --- command.c | 8 ++++---- retroarch.c | 10 ++++++---- retroarch.h | 4 ++-- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/command.c b/command.c index 98ae2e3fec..55728c2845 100644 --- a/command.c +++ b/command.c @@ -1779,7 +1779,7 @@ bool command_event(enum event_command cmd, void *data) command_event(CMD_EVENT_LOAD_CORE_DEINIT, NULL); break; case CMD_EVENT_QUIT: - rarch_ctl(RARCH_CTL_QUIT, NULL); + retroarch_main_quit(); break; case CMD_EVENT_CHEEVOS_HARDCORE_MODE_TOGGLE: #ifdef HAVE_CHEEVOS @@ -2034,19 +2034,19 @@ bool command_event(enum event_command cmd, void *data) } break; case CMD_EVENT_QUIT_RETROARCH: - rarch_ctl(RARCH_CTL_QUIT, NULL); + command_event(CMD_EVENT_QUIT, NULL); break; case CMD_EVENT_SHUTDOWN: #if defined(__linux__) && !defined(ANDROID) runloop_msg_queue_push("Shutting down...", 1, 180, true); - rarch_ctl(RARCH_CTL_QUIT, NULL); + command_event(CMD_EVENT_QUIT, NULL); system("shutdown -P now"); #endif break; case CMD_EVENT_REBOOT: #if defined(__linux__) && !defined(ANDROID) runloop_msg_queue_push("Rebooting...", 1, 180, true); - rarch_ctl(RARCH_CTL_QUIT, NULL); + command_event(CMD_EVENT_QUIT, NULL); system("shutdown -r now"); #endif break; diff --git a/retroarch.c b/retroarch.c index 9fe07f1327..73d24c472c 100644 --- a/retroarch.c +++ b/retroarch.c @@ -1505,10 +1505,6 @@ bool rarch_ctl(enum rarch_ctl_state state, void *data) command_event(CMD_EVENT_OVERLAY_INIT, NULL); #endif break; - case RARCH_CTL_QUIT: - runloop_ctl(RUNLOOP_CTL_SET_SHUTDOWN, NULL); - rarch_ctl(RARCH_CTL_MENU_RUNNING_FINISHED, NULL); - break; case RARCH_CTL_VALIDATE_CPU_FEATURES: { uint64_t cpu = cpu_features_get(); @@ -1666,3 +1662,9 @@ void retroarch_fail(int error_code, const char *error) strlcpy(error_string, error, sizeof(error_string)); longjmp(error_sjlj_context, error_code); } + +void retroarch_main_quit(void) +{ + runloop_ctl(RUNLOOP_CTL_SET_SHUTDOWN, NULL); + rarch_ctl(RARCH_CTL_MENU_RUNNING_FINISHED, NULL); +} diff --git a/retroarch.h b/retroarch.h index 77759ad38f..24b3c78a1f 100644 --- a/retroarch.h +++ b/retroarch.h @@ -86,8 +86,6 @@ enum rarch_ctl_state * properly. */ RARCH_CTL_REPLACE_CONFIG, - RARCH_CTL_QUIT, - /* Validates CPU features for given processor architecture. * Make sure we haven't compiled for something we cannot run. * Ideally, code would get swapped out depending on CPU support, @@ -188,6 +186,8 @@ void retroarch_fail(int error_code, const char *error); **/ bool retroarch_main_init(int argc, char *argv[]); +void retroarch_main_quit(void); + #ifdef __cplusplus } #endif From 90d7722125b22dff32acebaf3e635057c95f0ff3 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 May 2016 20:56:02 +0200 Subject: [PATCH 37/61] Remove CMD_EVENT_QUIT_RETROARCH --- command.c | 3 --- command.h | 2 -- frontend/drivers/platform_gx.c | 2 +- frontend/drivers/platform_linux.c | 2 +- menu/menu_setting.c | 2 +- 5 files changed, 3 insertions(+), 8 deletions(-) diff --git a/command.c b/command.c index 55728c2845..d7c99c8eb9 100644 --- a/command.c +++ b/command.c @@ -2033,9 +2033,6 @@ bool command_event(enum event_command cmd, void *data) driver_ctl(RARCH_DRIVER_CTL_INIT, &flags); } break; - case CMD_EVENT_QUIT_RETROARCH: - command_event(CMD_EVENT_QUIT, NULL); - break; case CMD_EVENT_SHUTDOWN: #if defined(__linux__) && !defined(ANDROID) runloop_msg_queue_push("Shutting down...", 1, 180, true); diff --git a/command.h b/command.h index b10279a548..c1db7db1a9 100644 --- a/command.h +++ b/command.h @@ -129,8 +129,6 @@ enum event_command CMD_EVENT_RESET_CONTEXT, /* Restarts RetroArch. */ CMD_EVENT_RESTART_RETROARCH, - /* Force-quit RetroArch. */ - CMD_EVENT_QUIT_RETROARCH, /* Shutdown the OS */ CMD_EVENT_SHUTDOWN, /* Reboot the OS */ diff --git a/frontend/drivers/platform_gx.c b/frontend/drivers/platform_gx.c index a4e070e30b..7478b21148 100644 --- a/frontend/drivers/platform_gx.c +++ b/frontend/drivers/platform_gx.c @@ -426,7 +426,7 @@ static bool frontend_gx_set_fork(enum frontend_fork fork_mode) case FRONTEND_FORK_RESTART: RARCH_LOG("FRONTEND_FORK_RESTART\n"); gx_fork_mode = fork_mode; - command_event(CMD_EVENT_QUIT_RETROARCH, NULL); + command_event(CMD_EVENT_QUIT, NULL); break; case FRONTEND_FORK_NONE: default: diff --git a/frontend/drivers/platform_linux.c b/frontend/drivers/platform_linux.c index 9f0ea43639..3f48e38a7d 100644 --- a/frontend/drivers/platform_linux.c +++ b/frontend/drivers/platform_linux.c @@ -1827,7 +1827,7 @@ static bool frontend_linux_set_fork(enum frontend_fork fork_mode) fill_pathname_application_path(executable_path, sizeof(executable_path)); strlcpy(settings->path.libretro, executable_path, sizeof(settings->path.libretro)); } - command_event(CMD_EVENT_QUIT_RETROARCH, NULL); + command_event(CMD_EVENT_QUIT, NULL); break; case FRONTEND_FORK_NONE: default: diff --git a/menu/menu_setting.c b/menu/menu_setting.c index 427aca79d9..0959b2ccc7 100644 --- a/menu/menu_setting.c +++ b/menu/menu_setting.c @@ -3638,7 +3638,7 @@ static bool setting_append_list( &group_info, &subgroup_info, parent_group); - menu_settings_list_current_add_cmd(list, list_info, CMD_EVENT_QUIT_RETROARCH); + menu_settings_list_current_add_cmd(list, list_info, CMD_EVENT_QUIT); #endif #if defined(HAVE_LAKKA) From 4100bf95b425bb12c61926a4e5a56feb39fdd028 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 May 2016 21:22:45 +0200 Subject: [PATCH 38/61] Able to compile without RPNG support --- Makefile.common | 6 +---- menu/cbs/menu_cbs_ok.c | 2 ++ qb/config.libs.sh | 6 +++++ qb/config.params.sh | 1 + tasks/task_image.c | 51 +++++++++++++++++++++--------------------- 5 files changed, 35 insertions(+), 31 deletions(-) diff --git a/Makefile.common b/Makefile.common index 4d909c217a..dfe3772c1e 100644 --- a/Makefile.common +++ b/Makefile.common @@ -890,7 +890,6 @@ ifeq ($(HAVE_ZLIB), 1) tasks/task_decompress.o OBJ += $(ZLIB_OBJS) DEFINES += -DHAVE_ZLIB - HAVE_RPNG = 1 HAVE_COMPRESSION = 1 ifeq ($(WANT_ZLIB), 1) DEFINES += -DWANT_ZLIB @@ -900,11 +899,8 @@ ifeq ($(HAVE_ZLIB), 1) endif endif -ifdef HAVE_RPNG - DEFINES += -DHAVE_RPNG -endif - ifeq ($(HAVE_RPNG), 1) + DEFINES += -DHAVE_RPNG OBJ += libretro-common/formats/png/rpng.o \ libretro-common/formats/png/rpng_encode.o endif diff --git a/menu/cbs/menu_cbs_ok.c b/menu/cbs/menu_cbs_ok.c index c129b1d76c..818266fe99 100644 --- a/menu/cbs/menu_cbs_ok.c +++ b/menu/cbs/menu_cbs_ok.c @@ -1259,6 +1259,7 @@ static int action_ok_save_state(const char *path, } #ifdef HAVE_NETWORKING +#ifdef HAVE_ZLIB static void cb_decompressed(void *task_data, void *user_data, const char *err) { decompress_task_data_t *dec = (decompress_task_data_t*)task_data; @@ -1289,6 +1290,7 @@ static void cb_decompressed(void *task_data, void *user_data, const char *err) free(dec); } } +#endif /* expects http_transfer_t*, menu_file_transfer_t* */ static void cb_generic_download(void *task_data, diff --git a/qb/config.libs.sh b/qb/config.libs.sh index 1bf9ec0816..01859e8ede 100644 --- a/qb/config.libs.sh +++ b/qb/config.libs.sh @@ -425,10 +425,16 @@ if [ "$HAVE_MATERIALUI" != 'no' ] || [ "$HAVE_XMB" != 'no' ] || [ "$HAVE_ZARCH" fi fi + check_macro NEON __ARM_NEON__ add_define_make OS "$OS" +if [ "$HAVE_ZLIB" = 'no' ] && [ "HAVE_RPNG" != 'no' ]; then + HAVE_RPNG=no + echo "Notice: zlib is not available, RPNG will also be disabled." +fi + if [ "$HAVE_THREADS" = 'no' ] && [ "HAVE_CHEEVOS" != 'no' ]; then HAVE_CHEEVOS=no echo "Notice: Threads are not available, Cheevos will also be disabled." diff --git a/qb/config.params.sh b/qb/config.params.sh index 16c576a2a6..e69da313e8 100644 --- a/qb/config.params.sh +++ b/qb/config.params.sh @@ -77,3 +77,4 @@ HAVE_XSHM=no # XShm video driver support (disabled because it's ju HAVE_CHEEVOS=yes # Retro Achievements HAVE_VULKAN=auto # Vulkan support C89_VULKAN=no +HAVE_RPNG=yes # RPNG support diff --git a/tasks/task_image.c b/tasks/task_image.c index 446a3f4dca..ea6e504279 100644 --- a/tasks/task_image.c +++ b/tasks/task_image.c @@ -163,7 +163,29 @@ static int cb_image_menu_thumbnail(void *data, size_t len) return 0; } -#ifdef HAVE_RPNG +static int rarch_main_data_image_iterate_process_transfer(nbio_handle_t *nbio) +{ + unsigned i, width = 0, height = 0; + int retval = 0; + + if (!nbio) + return -1; + + for (i = 0; i < nbio->image.processing_pos_increment; i++) + { + retval = rarch_main_data_image_process(nbio, + &width, &height); + if (retval != IMAGE_PROCESS_NEXT) + break; + } + + if (retval == IMAGE_PROCESS_NEXT) + return 0; + + nbio->image.processing_final_state = retval; + return -1; +} + static int rarch_main_data_image_iterate_transfer(nbio_handle_t *nbio) { unsigned i; @@ -192,32 +214,10 @@ static int rarch_main_data_image_iterate_transfer(nbio_handle_t *nbio) nbio->image.frame_count++; return 0; +#ifdef HAVE_RPNG error: return -1; -} - - -static int rarch_main_data_image_iterate_process_transfer(nbio_handle_t *nbio) -{ - unsigned i, width = 0, height = 0; - int retval = 0; - - if (!nbio) - return -1; - - for (i = 0; i < nbio->image.processing_pos_increment; i++) - { - retval = rarch_main_data_image_process(nbio, - &width, &height); - if (retval != IMAGE_PROCESS_NEXT) - break; - } - - if (retval == IMAGE_PROCESS_NEXT) - return 0; - - nbio->image.processing_final_state = retval; - return -1; +#endif } static void rarch_task_image_load_free_internal(nbio_handle_t *nbio) @@ -311,7 +311,6 @@ static int cb_nbio_image_menu_thumbnail(void *data, size_t len) return cb_nbio_generic(nbio, &len); } -#endif bool rarch_task_image_load_handler(retro_task_t *task) { From 28dd2c2545d1ccb4110fe1cf62909cc29a85b0b7 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 May 2016 21:27:17 +0200 Subject: [PATCH 39/61] Add HAVE_RJPEG ifdefs --- Makefile.common | 9 +++++++-- griffin/griffin.c | 2 ++ qb/config.params.sh | 1 + tasks/task_image.c | 12 ++++++++++++ 4 files changed, 22 insertions(+), 2 deletions(-) diff --git a/Makefile.common b/Makefile.common index dfe3772c1e..b869261baa 100644 --- a/Makefile.common +++ b/Makefile.common @@ -904,8 +904,13 @@ ifeq ($(HAVE_RPNG), 1) OBJ += libretro-common/formats/png/rpng.o \ libretro-common/formats/png/rpng_encode.o endif -OBJ += libretro-common/formats/jpeg/rjpeg.o \ - libretro-common/formats/bmp/rbmp_encode.o \ + +ifeq ($(HAVE_RJPEG), 1) + DEFINES += -DHAVE_RJPEG + OBJ += libretro-common/formats/jpeg/rjpeg.o +endif + +OBJ += libretro-common/formats/bmp/rbmp_encode.o \ libretro-common/formats/tga/rtga.o \ libretro-common/formats/json/jsonsax.o diff --git a/griffin/griffin.c b/griffin/griffin.c index da142c7151..13c99f3c2c 100644 --- a/griffin/griffin.c +++ b/griffin/griffin.c @@ -232,7 +232,9 @@ VIDEO IMAGE #include "../libretro-common/formats/png/rpng.c" #include "../libretro-common/formats/png/rpng_encode.c" #endif +#ifdef HAVE_RJPEG #include "../libretro-common/formats/jpeg/rjpeg.c" +#endif #include "../libretro-common/formats/bmp/rbmp_encode.c" /*============================================================ diff --git a/qb/config.params.sh b/qb/config.params.sh index e69da313e8..6c4ca9414a 100644 --- a/qb/config.params.sh +++ b/qb/config.params.sh @@ -78,3 +78,4 @@ HAVE_CHEEVOS=yes # Retro Achievements HAVE_VULKAN=auto # Vulkan support C89_VULKAN=no HAVE_RPNG=yes # RPNG support +HAVE_RJPEG=yes # RJPEG support diff --git a/tasks/task_image.c b/tasks/task_image.c index ea6e504279..f3c442219f 100644 --- a/tasks/task_image.c +++ b/tasks/task_image.c @@ -117,6 +117,8 @@ static int rarch_main_data_image_process( #endif break; case IMAGE_TYPE_JPEG: +#ifdef HAVE_RJPEG +#endif break; } @@ -207,6 +209,8 @@ static int rarch_main_data_image_iterate_transfer(nbio_handle_t *nbio) #endif break; case IMAGE_TYPE_JPEG: +#ifdef HAVE_RJPEG +#endif break; } } @@ -232,6 +236,8 @@ static void rarch_task_image_load_free_internal(nbio_handle_t *nbio) #endif break; case IMAGE_TYPE_JPEG: +#ifdef HAVE_RJPEG +#endif break; } @@ -260,6 +266,8 @@ static int cb_nbio_generic(nbio_handle_t *nbio, size_t *len) #endif break; case IMAGE_TYPE_JPEG: +#ifdef HAVE_RJPEG +#endif break; } @@ -275,6 +283,8 @@ static int cb_nbio_generic(nbio_handle_t *nbio, size_t *len) #endif break; case IMAGE_TYPE_JPEG: +#ifdef HAVE_RJPEG +#endif break; } @@ -304,6 +314,8 @@ static int cb_nbio_image_menu_thumbnail(void *data, size_t len) #endif break; case IMAGE_TYPE_JPEG: +#ifdef HAVE_RJPEG +#endif break; } From e3802c499f06481dddf9b42560cb7b3b7886020b Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 May 2016 21:38:33 +0200 Subject: [PATCH 40/61] Add RJPEG header include --- tasks/task_image.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tasks/task_image.c b/tasks/task_image.c index f3c442219f..63fdaf6461 100644 --- a/tasks/task_image.c +++ b/tasks/task_image.c @@ -27,6 +27,9 @@ #ifdef HAVE_RPNG #include #endif +#ifdef HAVE_RJPEG +#include +#endif #ifdef HAVE_MENU #include "../menu/menu_driver.h" From 07101f48d32f6b3286af4e00ceebaa5b40512f90 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 May 2016 21:41:19 +0200 Subject: [PATCH 41/61] Move struct to content.c --- content.c | 8 ++++++++ content.h | 8 -------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/content.c b/content.c index 2873230cef..7804333047 100644 --- a/content.c +++ b/content.c @@ -90,6 +90,14 @@ struct sram_block size_t size; }; +typedef struct content_stream +{ + uint32_t a; + const uint8_t *b; + size_t c; + uint32_t crc; +} content_stream_t; + static const struct file_archive_file_backend *stream_backend = NULL; static struct string_list *temporary_content = NULL; static bool _content_is_inited = false; diff --git a/content.h b/content.h index e02ee8f692..13118f67f9 100644 --- a/content.h +++ b/content.h @@ -36,14 +36,6 @@ typedef struct ram_type int type; } ram_type_t; -typedef struct content_stream -{ - uint32_t a; - const uint8_t *b; - size_t c; - uint32_t crc; -} content_stream_t; - typedef struct content_ctx_info { int argc; /* Argument count. */ From 1abe81b2224e332ef0f95b4afdf1ec991eaa1de2 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 May 2016 21:44:52 +0200 Subject: [PATCH 42/61] Create retroarch_replace_config --- menu/cbs/menu_cbs_ok.c | 2 +- retroarch.c | 53 ++++++++++++++++++++++++------------------ retroarch.h | 9 +++---- 3 files changed, 36 insertions(+), 28 deletions(-) diff --git a/menu/cbs/menu_cbs_ok.c b/menu/cbs/menu_cbs_ok.c index 818266fe99..c9d9a25328 100644 --- a/menu/cbs/menu_cbs_ok.c +++ b/menu/cbs/menu_cbs_ok.c @@ -772,7 +772,7 @@ static int generic_action_ok(const char *path, flush_type = MENU_SETTINGS; menu_display_set_msg_force(true); - if (rarch_ctl(RARCH_CTL_REPLACE_CONFIG, action_path)) + if (retroarch_replace_config(action_path)) { bool pending_push = false; menu_navigation_ctl(MENU_NAVIGATION_CTL_CLEAR, &pending_push); diff --git a/retroarch.c b/retroarch.c index 73d24c472c..725582914a 100644 --- a/retroarch.c +++ b/retroarch.c @@ -1463,29 +1463,6 @@ bool rarch_ctl(enum rarch_ctl_state state, void *data) break; case RARCH_CTL_IS_BLOCK_CONFIG_READ: return rarch_block_config_read; - case RARCH_CTL_REPLACE_CONFIG: - { - char *path = (char*)data; - - if (!path) - return false; - - /* If config file to be replaced is the same as the - * current config file, exit. */ - if (string_is_equal(path, global->path.config)) - return false; - - if (settings->config_save_on_exit && *global->path.config) - config_save_file(global->path.config); - - strlcpy(global->path.config, path, sizeof(global->path.config)); - - rarch_ctl(RARCH_CTL_UNSET_BLOCK_CONFIG_READ, NULL); - - *settings->path.libretro = '\0'; /* Load core in new config. */ - } - runloop_ctl(RUNLOOP_CTL_PREPARE_DUMMY, NULL); - break; case RARCH_CTL_MENU_RUNNING: #ifdef HAVE_MENU menu_driver_ctl(RARCH_MENU_CTL_SET_TOGGLE, NULL); @@ -1532,6 +1509,36 @@ bool rarch_ctl(enum rarch_ctl_state state, void *data) return true; } +/* Replaces currently loaded configuration file with + * another one. Will load a dummy core to flush state + * properly. */ +bool retroarch_replace_config(char *path) +{ + settings_t *settings = config_get_ptr(); + global_t *global = global_get_ptr(); + + if (!path) + return false; + + /* If config file to be replaced is the same as the + * current config file, exit. */ + if (string_is_equal(path, global->path.config)) + return false; + + if (settings->config_save_on_exit && *global->path.config) + config_save_file(global->path.config); + + strlcpy(global->path.config, path, sizeof(global->path.config)); + + rarch_ctl(RARCH_CTL_UNSET_BLOCK_CONFIG_READ, NULL); + + *settings->path.libretro = '\0'; /* Load core in new config. */ + + runloop_ctl(RUNLOOP_CTL_PREPARE_DUMMY, NULL); + + return true; +} + void retroarch_set_pathnames(const char *path) { global_t *global = global_get_ptr(); diff --git a/retroarch.h b/retroarch.h index 24b3c78a1f..f1678210f7 100644 --- a/retroarch.h +++ b/retroarch.h @@ -81,10 +81,6 @@ enum rarch_ctl_state RARCH_CTL_MENU_RUNNING_FINISHED, - /* Replaces currently loaded configuration file with - * another one. Will load a dummy core to flush state - * properly. */ - RARCH_CTL_REPLACE_CONFIG, /* Validates CPU features for given processor architecture. * Make sure we haven't compiled for something we cannot run. @@ -166,6 +162,11 @@ void retroarch_set_pathnames(const char *path); void retroarch_fill_pathnames(void); +/* Replaces currently loaded configuration file with + * another one. Will load a dummy core to flush state + * properly. */ +bool retroarch_replace_config(char *path); + /** * retroarch_fail: * @error_code : Error code. From 367150b487b4675c900023f09ec0dd081dc84400 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 May 2016 21:48:30 +0200 Subject: [PATCH 43/61] Cleanups --- gfx/video_texture_image.c | 4 +++ retroarch.c | 53 +++++++++++++++++++++------------------ retroarch.h | 7 ------ 3 files changed, 33 insertions(+), 31 deletions(-) diff --git a/gfx/video_texture_image.c b/gfx/video_texture_image.c index 349a4332f7..19bcdd00aa 100644 --- a/gfx/video_texture_image.c +++ b/gfx/video_texture_image.c @@ -29,7 +29,9 @@ #ifdef HAVE_RPNG #include #endif +#ifdef HAVE_RJPEG #include +#endif #include #include "../general.h" @@ -276,9 +278,11 @@ bool video_texture_image_load(struct texture_image *out_img, #endif break; case IMAGE_FORMAT_JPEG: +#ifdef HAVE_RJPEG if (rjpeg_image_load((uint8_t*)ptr, out_img, file_len, a_shift, r_shift, g_shift, b_shift)) goto success; +#endif break; default: case IMAGE_FORMAT_NONE: diff --git a/retroarch.c b/retroarch.c index 725582914a..59e862602c 100644 --- a/retroarch.c +++ b/retroarch.c @@ -1211,6 +1211,34 @@ bool retroarch_validate_game_options(char *s, size_t len, bool mkdir) return true; } +#define FAIL_CPU(simd_type) do { \ + RARCH_ERR(simd_type " code is compiled in, but CPU does not support this feature. Cannot continue.\n"); \ + retroarch_fail(1, "validate_cpu_features()"); \ +} while(0) + +/* Validates CPU features for given processor architecture. + * Make sure we haven't compiled for something we cannot run. + * Ideally, code would get swapped out depending on CPU support, + * but this will do for now. */ +static void retroarch_validate_cpu_features(void) +{ + uint64_t cpu = cpu_features_get(); + (void)cpu; + +#ifdef __SSE__ + if (!(cpu & RETRO_SIMD_SSE)) + FAIL_CPU("SSE"); +#endif +#ifdef __SSE2__ + if (!(cpu & RETRO_SIMD_SSE2)) + FAIL_CPU("SSE2"); +#endif +#ifdef __AVX__ + if (!(cpu & RETRO_SIMD_AVX)) + FAIL_CPU("AVX"); +#endif +} + /** * retroarch_main_init: * @argc : Count of (commandline) arguments. @@ -1254,7 +1282,7 @@ bool retroarch_main_init(int argc, char *argv[]) RARCH_LOG_OUTPUT("=================================================\n"); } - rarch_ctl(RARCH_CTL_VALIDATE_CPU_FEATURES, NULL); + retroarch_validate_cpu_features(); config_load(); runloop_ctl(RUNLOOP_CTL_TASK_INIT, NULL); @@ -1324,10 +1352,6 @@ error: return false; } -#define FAIL_CPU(simd_type) do { \ - RARCH_ERR(simd_type " code is compiled in, but CPU does not support this feature. Cannot continue.\n"); \ - retroarch_fail(1, "validate_cpu_features()"); \ -} while(0) bool rarch_ctl(enum rarch_ctl_state state, void *data) { @@ -1482,25 +1506,6 @@ bool rarch_ctl(enum rarch_ctl_state state, void *data) command_event(CMD_EVENT_OVERLAY_INIT, NULL); #endif break; - case RARCH_CTL_VALIDATE_CPU_FEATURES: - { - uint64_t cpu = cpu_features_get(); - (void)cpu; - -#ifdef __SSE__ - if (!(cpu & RETRO_SIMD_SSE)) - FAIL_CPU("SSE"); -#endif -#ifdef __SSE2__ - if (!(cpu & RETRO_SIMD_SSE2)) - FAIL_CPU("SSE2"); -#endif -#ifdef __AVX__ - if (!(cpu & RETRO_SIMD_AVX)) - FAIL_CPU("AVX"); -#endif - } - break; case RARCH_CTL_NONE: default: return false; diff --git a/retroarch.h b/retroarch.h index f1678210f7..0ce529bd78 100644 --- a/retroarch.h +++ b/retroarch.h @@ -81,13 +81,6 @@ enum rarch_ctl_state RARCH_CTL_MENU_RUNNING_FINISHED, - - /* Validates CPU features for given processor architecture. - * Make sure we haven't compiled for something we cannot run. - * Ideally, code would get swapped out depending on CPU support, - * but this will do for now. */ - RARCH_CTL_VALIDATE_CPU_FEATURES, - RARCH_CTL_SET_PATHS_REDIRECT, RARCH_CTL_SET_SRAM_ENABLE, From 670b564f135ef00f88df79b73f1f8e829a4ae0ec Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 May 2016 21:57:41 +0200 Subject: [PATCH 44/61] Add HAVE_RTGA switch --- Makefile.common | 5 ++++- gfx/video_texture_image.c | 4 ++++ griffin/griffin.c | 2 ++ qb/config.params.sh | 1 + 4 files changed, 11 insertions(+), 1 deletion(-) diff --git a/Makefile.common b/Makefile.common index b869261baa..b5e54fbec6 100644 --- a/Makefile.common +++ b/Makefile.common @@ -911,9 +911,12 @@ ifeq ($(HAVE_RJPEG), 1) endif OBJ += libretro-common/formats/bmp/rbmp_encode.o \ - libretro-common/formats/tga/rtga.o \ libretro-common/formats/json/jsonsax.o +ifeq ($(HAVE_RTGA), 1) +OBJ += libretro-common/formats/tga/rtga.o +endif + ifdef HAVE_COMPRESSION DEFINES += -DHAVE_COMPRESSION endif diff --git a/gfx/video_texture_image.c b/gfx/video_texture_image.c index 19bcdd00aa..8949781813 100644 --- a/gfx/video_texture_image.c +++ b/gfx/video_texture_image.c @@ -32,7 +32,9 @@ #ifdef HAVE_RJPEG #include #endif +#ifdef HAVE_RTGA #include +#endif #include "../general.h" @@ -266,9 +268,11 @@ bool video_texture_image_load(struct texture_image *out_img, switch (fmt) { case IMAGE_FORMAT_TGA: +#ifdef HAVE_RTGA if (rtga_image_load_shift((uint8_t*)ptr, out_img, a_shift, r_shift, g_shift, b_shift)) goto success; +#endif break; case IMAGE_FORMAT_PNG: #ifdef HAVE_RPNG diff --git a/griffin/griffin.c b/griffin/griffin.c index 13c99f3c2c..ba626ee9fe 100644 --- a/griffin/griffin.c +++ b/griffin/griffin.c @@ -222,7 +222,9 @@ VIDEO IMAGE #include "../gfx/video_texture_image.c" +#ifdef HAVE_RTGA #include "../libretro-common/formats/tga/rtga.c" +#endif #ifdef HAVE_IMAGEVIEWER #include "../cores/libretro-imageviewer/image_core.c" diff --git a/qb/config.params.sh b/qb/config.params.sh index 6c4ca9414a..7f89043a61 100644 --- a/qb/config.params.sh +++ b/qb/config.params.sh @@ -79,3 +79,4 @@ HAVE_VULKAN=auto # Vulkan support C89_VULKAN=no HAVE_RPNG=yes # RPNG support HAVE_RJPEG=yes # RJPEG support +HAVE_RTGA=yes # RTGA support From c9d3936ee53cc123bafd72b05e8ec70e12efbb10 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 May 2016 22:49:41 +0200 Subject: [PATCH 45/61] Check for GL_EXT_framebuffer_object too --- gfx/drivers/gl.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/gfx/drivers/gl.c b/gfx/drivers/gl.c index cfaff3e26f..93b9a46972 100644 --- a/gfx/drivers/gl.c +++ b/gfx/drivers/gl.c @@ -190,7 +190,8 @@ static bool gl_check_mipmap(void) if (!extension_queried) { gl_t *gl = (gl_t*)video_driver_get_ptr(false); - extension = gl_query_extension(gl, "ARB_framebuffer_object"); + extension = gl_query_extension(gl, "ARB_framebuffer_object") || + gl_query_extension(gl, "EXT_framebuffer_object"); extension_queried = true; } @@ -230,7 +231,8 @@ static bool gl_init_vao(gl_t *gl) #elif !defined(HAVE_OPENGLES2) static bool gl_check_fbo_proc(gl_t *gl) { - if (!gl->core_context && !gl_query_extension(gl, "ARB_framebuffer_object")) + if (!gl->core_context && !gl_query_extension(gl, "ARB_framebuffer_object") + && !gl_query_extension(gl, "EXT_framebuffer_object")) return false; return glGenFramebuffers From 67e64f4ca6e33453daf6f6250e48c08edab0a425 Mon Sep 17 00:00:00 2001 From: neville Date: Wed, 11 May 2016 23:04:48 +0200 Subject: [PATCH 46/61] gl_check_mipmap - don't look for GL_EXT_framebuffer_object here - breaks OSX PPC --- gfx/drivers/gl.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/gfx/drivers/gl.c b/gfx/drivers/gl.c index 93b9a46972..6426a0b0b3 100644 --- a/gfx/drivers/gl.c +++ b/gfx/drivers/gl.c @@ -190,8 +190,7 @@ static bool gl_check_mipmap(void) if (!extension_queried) { gl_t *gl = (gl_t*)video_driver_get_ptr(false); - extension = gl_query_extension(gl, "ARB_framebuffer_object") || - gl_query_extension(gl, "EXT_framebuffer_object"); + extension = gl_query_extension(gl, "ARB_framebuffer_object"); extension_queried = true; } From 2321ee829ff978c5361ad391250d6415335cedf5 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 May 2016 23:17:42 +0200 Subject: [PATCH 47/61] Add glsym_es3 --- libretro-common/glsym/glsym_es3.c | 10 +++++++ libretro-common/include/glsym/glsym_es3.h | 35 +++++++++++++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 libretro-common/glsym/glsym_es3.c create mode 100644 libretro-common/include/glsym/glsym_es3.h diff --git a/libretro-common/glsym/glsym_es3.c b/libretro-common/glsym/glsym_es3.c new file mode 100644 index 0000000000..a8c0657824 --- /dev/null +++ b/libretro-common/glsym/glsym_es3.c @@ -0,0 +1,10 @@ +#include "glsym.h" +#include +#define SYM(x) { "gl" #x, &(gl##x) } +const struct rglgen_sym_map rglgen_symbol_map[] = { + + + { NULL, NULL }, +}; + + diff --git a/libretro-common/include/glsym/glsym_es3.h b/libretro-common/include/glsym/glsym_es3.h new file mode 100644 index 0000000000..996b9d2760 --- /dev/null +++ b/libretro-common/include/glsym/glsym_es3.h @@ -0,0 +1,35 @@ +#ifndef RGLGEN_DECL_H__ +#define RGLGEN_DECL_H__ +#ifdef __cplusplus +extern "C" { +#endif +#ifdef GL_APIENTRY +typedef void (GL_APIENTRY *RGLGENGLDEBUGPROC)(GLenum, GLenum, GLuint, GLenum, GLsizei, const GLchar*, GLvoid*); +#else +#ifndef APIENTRY +#define APIENTRY +#endif +#ifndef APIENTRYP +#define APIENTRYP APIENTRY * +#endif +typedef void (APIENTRY *RGLGENGLDEBUGPROCARB)(GLenum, GLenum, GLuint, GLenum, GLsizei, const GLchar*, GLvoid*); +typedef void (APIENTRY *RGLGENGLDEBUGPROC)(GLenum, GLenum, GLuint, GLenum, GLsizei, const GLchar*, GLvoid*); +#endif +#ifndef GL_OES_EGL_image +typedef void *GLeglImageOES; +#endif +#if !defined(GL_OES_fixed_point) && !defined(HAVE_OPENGLES2) +typedef GLint GLfixed; +#endif + + + + + + +struct rglgen_sym_map { const char *sym; void *ptr; }; +extern const struct rglgen_sym_map rglgen_symbol_map[]; +#ifdef __cplusplus +} +#endif +#endif From 21438fc0af11fa87ac7e7b38b69ef54fa8599241 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 12 May 2016 02:58:09 +0200 Subject: [PATCH 48/61] Some buildfixes for GL_DEBUG --- gfx/drivers/gl.c | 2 +- gfx/drivers_context/xegl_ctx.c | 9 +++------ 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/gfx/drivers/gl.c b/gfx/drivers/gl.c index 6426a0b0b3..ae9ea181fc 100644 --- a/gfx/drivers/gl.c +++ b/gfx/drivers/gl.c @@ -2494,7 +2494,7 @@ static void DEBUG_CALLBACK_TYPE gl_debug_cb(GLenum source, GLenum type, const GLchar *message, void *userParam) { const char *src = NULL; - const char **typestr = NULL; + const char *typestr = NULL; gl_t *gl = (gl_t*)userParam; /* Useful for debugger. */ (void)gl; diff --git a/gfx/drivers_context/xegl_ctx.c b/gfx/drivers_context/xegl_ctx.c index 6fa1a2f33b..5d21b9c250 100644 --- a/gfx/drivers_context/xegl_ctx.c +++ b/gfx/drivers_context/xegl_ctx.c @@ -189,16 +189,13 @@ static EGLint *xegl_fill_attribs(xegl_ctx_data_t *xegl, EGLint *attr) #ifdef EGL_KHR_create_context case GFX_CTX_OPENGL_API: { - bool debug = false; unsigned version = xegl->egl.major * 1000 + xegl->egl.minor; bool core = version >= 3001; - struct retro_hw_render_callback *hwr = NULL; - - hwr = video_driver_get_hw_context(); #ifdef GL_DEBUG - debug = true; + bool debug = true; #else - debug = hwr->debug_context; + struct retro_hw_render_callback *hwr = video_driver_get_hw_context(); + bool debug = hwr->debug_context; #endif if (core) From f0b99edafcfc05a58012f649570a29aaebbfb3f0 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 12 May 2016 04:29:36 +0200 Subject: [PATCH 49/61] Prevent some warnings/errors from occurring with MESA_DEBUG --- gfx/drivers_shader/shader_glsl.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/gfx/drivers_shader/shader_glsl.c b/gfx/drivers_shader/shader_glsl.c index 38f6b81f1a..e7b3ac687e 100644 --- a/gfx/drivers_shader/shader_glsl.c +++ b/gfx/drivers_shader/shader_glsl.c @@ -1153,7 +1153,10 @@ static void gl_glsl_set_params(void *data, void *shader_data, orig_uniforms[1].enabled = true; for (j = 0; j < 2; j++) - gl_glsl_set_uniform_parameter(glsl, &orig_uniforms[j], NULL); + { + if (orig_uniforms[j].enabled) + gl_glsl_set_uniform_parameter(glsl, &orig_uniforms[j], NULL); + } /* Pass texture coordinates. */ if (uni->orig.tex_coord >= 0) @@ -1204,7 +1207,10 @@ static void gl_glsl_set_params(void *data, void *shader_data, feedback_uniforms[1].enabled = true; for (j = 0; j < 2; j++) - gl_glsl_set_uniform_parameter(glsl, &feedback_uniforms[j], NULL); + { + if (feedback_uniforms[j].enabled) + gl_glsl_set_uniform_parameter(glsl, &feedback_uniforms[j], NULL); + } /* Pass texture coordinates. */ if (uni->feedback.tex_coord >= 0) @@ -1255,7 +1261,10 @@ static void gl_glsl_set_params(void *data, void *shader_data, fbo_tex_params[2].enabled = true; for (j = 0; j < 3; j++) - gl_glsl_set_uniform_parameter(glsl, &fbo_tex_params[j], NULL); + { + if (fbo_tex_params[j].enabled) + gl_glsl_set_uniform_parameter(glsl, &fbo_tex_params[j], NULL); + } if (uni->pass[i].tex_coord >= 0) { @@ -1307,7 +1316,10 @@ static void gl_glsl_set_params(void *data, void *shader_data, prev_tex_params[2].enabled = true; for (j = 0; j < 3; j++) - gl_glsl_set_uniform_parameter(glsl, &prev_tex_params[j], NULL); + { + if (prev_tex_params[j].enabled) + gl_glsl_set_uniform_parameter(glsl, &prev_tex_params[j], NULL); + } /* Pass texture coordinates. */ if (uni->prev[i].tex_coord >= 0) From e1d9e3418328bb9becc518d2d5cadaf35314176c Mon Sep 17 00:00:00 2001 From: Ezio-PS Date: Thu, 12 May 2016 08:14:10 +0200 Subject: [PATCH 50/61] Updated Italian Translation --- menu/intl/menu_hash_it.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/menu/intl/menu_hash_it.c b/menu/intl/menu_hash_it.c index 88e58073a3..b19195cba1 100644 --- a/menu/intl/menu_hash_it.c +++ b/menu/intl/menu_hash_it.c @@ -352,7 +352,9 @@ const char *menu_hash_to_str_it(uint32_t hash) case MENU_LABEL_VALUE_PAUSE_NONACTIVE: return "Non caricare in background"; case MENU_LABEL_VALUE_UI_COMPANION_START_ON_BOOT: - return "Avvia UI Companion all'avvio"; + return "Abilita UI Companion all'avvio"; + case MENU_LABEL_VALUE_UI_COMPANION_ENABLE: + return "Abilita UI Companion"; case MENU_LABEL_VALUE_UI_MENUBAR_ENABLE: return "Barra dei menù"; case MENU_LABEL_VALUE_ARCHIVE_MODE: @@ -587,8 +589,10 @@ const char *menu_hash_to_str_it(uint32_t hash) return "Settaggi"; case MENU_LABEL_VALUE_QUIT_RETROARCH: return "Esci da RetroArch"; - case MENU_LABEL_VALUE_SHUTDOWN: + case MENU_LABEL_VALUE_SHUTDOWN: return "Spegni"; + case MENU_LABEL_VALUE_REBOOT: + return "Riavvia"; case MENU_LABEL_VALUE_HELP: return "Aiuto"; case MENU_LABEL_VALUE_SAVE_NEW_CONFIG: @@ -924,7 +928,7 @@ const char *menu_hash_to_str_it(uint32_t hash) case MENU_LABEL_VALUE_DIRECTORY_SETTINGS: return "Directory"; case MENU_LABEL_VALUE_RECORDING_SETTINGS: - return "Registrando"; + return "Registrazione"; case MENU_LABEL_VALUE_NO_INFORMATION_AVAILABLE: return "Nessuna informazione disponibile."; case MENU_LABEL_VALUE_INPUT_USER_BINDS: @@ -967,6 +971,12 @@ const char *menu_hash_to_str_it(uint32_t hash) return "Cerca:"; case MENU_LABEL_VALUE_USE_BUILTIN_IMAGE_VIEWER: return "Usa visualizzatore di immagini interno"; + case MENU_LABEL_VALUE_ENABLE: + return "Attivare"; + case MENU_LABEL_VALUE_START_CORE: + return "Avvia Core"; + case MENU_LABEL_VALUE_INPUT_POLL_TYPE_BEHAVIOR: + return "Tipo di ritardo"; default: break; } From c1bfe795f8dee8453f77b5ec0b71821676f13ef0 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 12 May 2016 09:04:31 +0200 Subject: [PATCH 51/61] Create runloop_prepare_dummy --- command.c | 2 +- retroarch.c | 2 +- runloop.c | 39 +++++++++++++++++++++------------------ runloop.h | 5 +++-- 4 files changed, 26 insertions(+), 22 deletions(-) diff --git a/command.c b/command.c index d7c99c8eb9..57762309db 100644 --- a/command.c +++ b/command.c @@ -1775,7 +1775,7 @@ bool command_event(enum event_command cmd, void *data) return false; break; case CMD_EVENT_UNLOAD_CORE: - runloop_ctl(RUNLOOP_CTL_PREPARE_DUMMY, NULL); + runloop_prepare_dummy(); command_event(CMD_EVENT_LOAD_CORE_DEINIT, NULL); break; case CMD_EVENT_QUIT: diff --git a/retroarch.c b/retroarch.c index 59e862602c..f4c5fb3ba5 100644 --- a/retroarch.c +++ b/retroarch.c @@ -1539,7 +1539,7 @@ bool retroarch_replace_config(char *path) *settings->path.libretro = '\0'; /* Load core in new config. */ - runloop_ctl(RUNLOOP_CTL_PREPARE_DUMMY, NULL); + runloop_prepare_dummy(); return true; } diff --git a/runloop.c b/runloop.c index 92a85b4d81..ce0f8f18a4 100644 --- a/runloop.c +++ b/runloop.c @@ -720,6 +720,26 @@ static bool runloop_is_frame_count_end(void) } +bool runloop_prepare_dummy(void) +{ + memset(&runloop_frame_time, 0, sizeof(struct retro_frame_time_callback)); +#ifdef HAVE_MENU + menu_driver_ctl(RARCH_MENU_CTL_UNSET_LOAD_NO_CONTENT, NULL); +#endif + runloop_ctl(RUNLOOP_CTL_DATA_DEINIT, NULL); + runloop_ctl(RUNLOOP_CTL_TASK_INIT, NULL); + runloop_ctl(RUNLOOP_CTL_CLEAR_CONTENT_PATH, NULL); + +#ifdef HAVE_MENU + if (!menu_content_ctl(MENU_CONTENT_CTL_LOAD, NULL)) + { + rarch_ctl(RARCH_CTL_MENU_RUNNING, NULL); + return false; + } +#endif + return true; +} + bool runloop_ctl(enum runloop_ctl_state state, void *data) { settings_t *settings = config_get_ptr(); @@ -1056,23 +1076,6 @@ bool runloop_ctl(enum runloop_ctl_state state, void *data) task_queue_ctl(TASK_QUEUE_CTL_INIT, &threaded_enable); } break; - case RUNLOOP_CTL_PREPARE_DUMMY: - memset(&runloop_frame_time, 0, sizeof(struct retro_frame_time_callback)); -#ifdef HAVE_MENU - menu_driver_ctl(RARCH_MENU_CTL_UNSET_LOAD_NO_CONTENT, NULL); -#endif - runloop_ctl(RUNLOOP_CTL_DATA_DEINIT, NULL); - runloop_ctl(RUNLOOP_CTL_TASK_INIT, NULL); - runloop_ctl(RUNLOOP_CTL_CLEAR_CONTENT_PATH, NULL); - -#ifdef HAVE_MENU - if (!menu_content_ctl(MENU_CONTENT_CTL_LOAD, NULL)) - { - rarch_ctl(RARCH_CTL_MENU_RUNNING, NULL); - return false; - } -#endif - break; case RUNLOOP_CTL_SET_CORE_SHUTDOWN: runloop_core_shutdown_initiated = true; break; @@ -1262,7 +1265,7 @@ static void runloop_iterate_linefeed_overlay(settings_t *settings) * Aborts core shutdown if invoked. */ static int runloop_iterate_time_to_exit_load_dummy(void) { - if (!runloop_ctl(RUNLOOP_CTL_PREPARE_DUMMY, NULL)) + if (!runloop_prepare_dummy()) return -1; runloop_ctl(RUNLOOP_CTL_UNSET_SHUTDOWN, NULL); diff --git a/runloop.h b/runloop.h index ce7cc6f03d..3c7f5ad9b6 100644 --- a/runloop.h +++ b/runloop.h @@ -102,8 +102,7 @@ enum runloop_ctl_state RUNLOOP_CTL_SHADER_DIR_INIT, RUNLOOP_CTL_SYSTEM_INFO_GET, RUNLOOP_CTL_SYSTEM_INFO_INIT, - RUNLOOP_CTL_SYSTEM_INFO_FREE, - RUNLOOP_CTL_PREPARE_DUMMY + RUNLOOP_CTL_SYSTEM_INFO_FREE }; typedef int (*transfer_cb_t)(void *data, size_t len); @@ -295,6 +294,8 @@ void runloop_msg_queue_push(const char *msg, unsigned prio, char* runloop_msg_queue_pull(void); +bool runloop_prepare_dummy(void); + bool runloop_ctl(enum runloop_ctl_state state, void *data); From 35bf38e05cfbaa3ed4efbfdfd2afdcedc2c57b8a Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 12 May 2016 09:25:52 +0200 Subject: [PATCH 52/61] Create runloop_get_system_info/runloop_free_system_info/runloop_init_system_info --- command.c | 12 ++-- configuration.c | 4 +- content.c | 4 +- dynamic.c | 6 +- frontend/frontend.c | 2 +- gfx/video_driver.c | 2 +- location/location_driver.c | 4 +- menu/cbs/menu_cbs_deferred_push.c | 3 +- menu/cbs/menu_cbs_get_value.c | 6 +- menu/cbs/menu_cbs_ok.c | 2 +- menu/drivers/materialui.c | 2 +- menu/menu_displaylist.c | 6 +- menu/menu_entries.c | 2 +- menu/menu_setting.c | 12 ++-- network/netplay_common.c | 2 +- retroarch.c | 28 +++++---- runloop.c | 98 ++++++++++++++++--------------- runloop.h | 12 ++-- 18 files changed, 110 insertions(+), 97 deletions(-) diff --git a/command.c b/command.c index 57762309db..d19de50906 100644 --- a/command.c +++ b/command.c @@ -733,7 +733,7 @@ static void command_event_disk_control_set_eject(bool new_state, bool print_log) rarch_system_info_t *info = NULL; const struct retro_disk_control_callback *control = NULL; - runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &info); + runloop_get_system_info((void**)&info); if (info) control = (const struct retro_disk_control_callback*)&info->disk_control_cb; @@ -781,7 +781,7 @@ static void command_event_disk_control_set_index(unsigned idx) rarch_system_info_t *info = NULL; const struct retro_disk_control_callback *control = NULL; - runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &info); + runloop_get_system_info((void**)&info); if (info) control = (const struct retro_disk_control_callback*)&info->disk_control_cb; @@ -838,7 +838,7 @@ static bool command_event_disk_control_append_image(const char *path) const struct retro_disk_control_callback *control = NULL; rarch_system_info_t *sysinfo = NULL; - runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &sysinfo); + runloop_get_system_info((void**)&info); if (sysinfo) control = (const struct retro_disk_control_callback*) @@ -983,7 +983,7 @@ static void command_event_init_controllers(void) settings_t *settings = config_get_ptr(); rarch_system_info_t *info = NULL; - runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &info); + runloop_get_system_info((void**)&info); for (i = 0; i < MAX_USERS; i++) { @@ -1236,7 +1236,7 @@ static bool command_event_init_core(enum rarch_core_type *data) if (!core_init_symbols(data)) return false; - runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_INIT, NULL); + runloop_get_system_info((void**)&info); /* auto overrides: apply overrides */ if(settings->auto_overrides_enable) @@ -1591,7 +1591,7 @@ bool command_event(enum event_command cmd, void *data) settings_t *settings = config_get_ptr(); rarch_system_info_t *info = NULL; - runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &info); + runloop_get_system_info((void**)&info); (void)i; diff --git a/configuration.c b/configuration.c index 2adf63d908..3767670826 100644 --- a/configuration.c +++ b/configuration.c @@ -1965,7 +1965,7 @@ bool config_load_override(void) settings_t *settings = config_get_ptr(); rarch_system_info_t *system = NULL; - runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system); + runloop_get_system_info((void**)&system); if (system) core_name = system->info.library_name; @@ -2143,7 +2143,7 @@ bool config_load_remap(void) settings_t *settings = config_get_ptr(); rarch_system_info_t *system = NULL; - runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system); + runloop_get_system_info((void**)&system); if (system) core_name = system->info.library_name; diff --git a/content.c b/content.c index 7804333047..026d25415c 100644 --- a/content.c +++ b/content.c @@ -1329,7 +1329,7 @@ static bool load_content_from_compressed_archive( settings_t *settings = config_get_ptr(); rarch_system_info_t *sys_info= NULL; - runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &sys_info); + runloop_get_system_info((void**)sys_info); if (sys_info && sys_info->info.block_extract) return true; @@ -1648,7 +1648,7 @@ static bool content_file_init(struct string_list *temporary_content) rarch_system_info_t *system = NULL; global_t *global = global_get_ptr(); - runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system); + runloop_get_system_info((void**)system); if (*global->subsystem) { diff --git a/dynamic.c b/dynamic.c index edefb1fd1c..e2297bcd4b 100644 --- a/dynamic.c +++ b/dynamic.c @@ -578,7 +578,9 @@ void uninit_libretro_sym(struct retro_core_t *current_core) memset(current_core, 0, sizeof(struct retro_core_t)); runloop_ctl(RUNLOOP_CTL_CORE_OPTIONS_DEINIT, NULL); - runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_FREE, NULL); + + runloop_free_system_info(); + runloop_ctl(RUNLOOP_CTL_FRAME_TIME_FREE, NULL); camera_driver_ctl(RARCH_CAMERA_CTL_UNSET_ACTIVE, NULL); location_driver_ctl(RARCH_LOCATION_CTL_UNSET_ACTIVE, NULL); @@ -740,7 +742,7 @@ bool rarch_environment_cb(unsigned cmd, void *data) global_t *global = global_get_ptr(); rarch_system_info_t *system = NULL; - runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system); + runloop_get_system_info((void**)&system); if (ignore_environment_cb) return false; diff --git a/frontend/frontend.c b/frontend/frontend.c index 3708bb64d9..24f5ae7c3c 100644 --- a/frontend/frontend.c +++ b/frontend/frontend.c @@ -130,7 +130,7 @@ int rarch_main(int argc, char *argv[], void *data) return 0; } - runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system); + runloop_get_system_info((void**)&system); runloop_ctl(RUNLOOP_CTL_GET_CONTENT_PATH, &fullpath); if (content_is_inited() || content_does_not_need_content()) diff --git a/gfx/video_driver.c b/gfx/video_driver.c index 7af875e3e4..3c380cd5e4 100644 --- a/gfx/video_driver.c +++ b/gfx/video_driver.c @@ -598,7 +598,7 @@ static bool init_video(void) struct retro_system_av_info *av_info = video_viewport_get_system_av_info(); - runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system); + runloop_get_system_info((void**)&system); init_video_filter(video_driver_state.pix_fmt); command_event(CMD_EVENT_SHADER_DIR_INIT, NULL); diff --git a/location/location_driver.c b/location/location_driver.c index 4921fb1a92..e8cec5b048 100644 --- a/location/location_driver.c +++ b/location/location_driver.c @@ -203,7 +203,7 @@ void init_location(void) { rarch_system_info_t *system = NULL; - runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system); + runloop_get_system_info((void**)&system); /* Resource leaks will follow if location interface is initialized twice. */ if (location_data) @@ -227,7 +227,7 @@ static void uninit_location(void) { rarch_system_info_t *system = NULL; - runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system); + runloop_get_system_info((void**)&system); if (location_data && location_driver) { diff --git a/menu/cbs/menu_cbs_deferred_push.c b/menu/cbs/menu_cbs_deferred_push.c index afa343df23..8c7dd23034 100644 --- a/menu/cbs/menu_cbs_deferred_push.c +++ b/menu/cbs/menu_cbs_deferred_push.c @@ -345,7 +345,8 @@ static int general_push(menu_displaylist_info_t *info, core_info_get_list(&list); menu_driver_ctl(RARCH_MENU_CTL_SYSTEM_INFO_GET, &system_menu); - runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system); + + runloop_get_system_info((void**)&system); switch (id) { diff --git a/menu/cbs/menu_cbs_get_value.c b/menu/cbs/menu_cbs_get_value.c index 6ab52e6106..8e6a569801 100644 --- a/menu/cbs/menu_cbs_get_value.c +++ b/menu/cbs/menu_cbs_get_value.c @@ -778,7 +778,8 @@ static void menu_action_setting_disp_set_label_menu_disk_index( rarch_system_info_t *system = NULL; struct retro_disk_control_callback *control = NULL; - runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system); + runloop_get_system_info((void**)&system); + if (!system) return; @@ -1164,7 +1165,8 @@ static void menu_action_setting_disp_set_label_core_option_create( rarch_system_info_t *system = NULL; global_t *global = global_get_ptr(); - runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system); + runloop_get_system_info((void**)&system); + if (!system) return; diff --git a/menu/cbs/menu_cbs_ok.c b/menu/cbs/menu_cbs_ok.c index c9d9a25328..5f61e41dc8 100644 --- a/menu/cbs/menu_cbs_ok.c +++ b/menu/cbs/menu_cbs_ok.c @@ -1013,7 +1013,7 @@ static int generic_action_ok_remap_file_save(const char *path, const char *game_name = NULL; const char *core_name = NULL; - runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &info); + runloop_get_system_info((void**)&info); if (info) core_name = info->info.library_name; diff --git a/menu/drivers/materialui.c b/menu/drivers/materialui.c index 49c88ed897..0290b56631 100644 --- a/menu/drivers/materialui.c +++ b/menu/drivers/materialui.c @@ -685,7 +685,7 @@ static int mui_get_core_title(char *s, size_t len) core_name = system->library_name; core_version = system->library_version; - runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &info); + runloop_get_system_info((void**)&info); if (!settings->menu.core_enable) return -1; diff --git a/menu/menu_displaylist.c b/menu/menu_displaylist.c index 66fdcd1c7f..5b8aa3bc3d 100644 --- a/menu/menu_displaylist.c +++ b/menu/menu_displaylist.c @@ -2157,7 +2157,7 @@ static int menu_displaylist_parse_load_content_settings( { rarch_system_info_t *system = NULL; - runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system); + runloop_get_system_info((void**)&system); menu_entries_add(info->list, menu_hash_to_str(MENU_LABEL_VALUE_RESUME_CONTENT), @@ -2518,7 +2518,7 @@ static int menu_displaylist_parse_options_remappings( if (!menu_driver_ctl(RARCH_MENU_CTL_DRIVER_DATA_GET, &menu)) return -1; - runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system); + runloop_get_system_info((void**)&system); for (p = 0; p < settings->input.max_users; p++) { @@ -3326,7 +3326,7 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, void *data) case DISPLAYLIST_MAIN_MENU: { rarch_system_info_t *system = NULL; - runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system); + runloop_get_system_info((void**)&system); if (!rarch_ctl(RARCH_CTL_IS_DUMMY_CORE, NULL)) menu_displaylist_parse_settings(menu, info, diff --git a/menu/menu_entries.c b/menu/menu_entries.c index 9b430e2c26..f79da5fb0e 100644 --- a/menu/menu_entries.c +++ b/menu/menu_entries.c @@ -448,7 +448,7 @@ int menu_entries_get_core_title(char *s, size_t len) core_name = system->library_name; core_version = system->library_version; - runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &info); + runloop_get_system_info((void**)&info); if (!settings->menu.core_enable) return -1; diff --git a/menu/menu_setting.c b/menu/menu_setting.c index 0959b2ccc7..d6b69d3307 100644 --- a/menu/menu_setting.c +++ b/menu/menu_setting.c @@ -1068,7 +1068,7 @@ static void setting_get_string_representation_uint_libretro_device(void *data, settings_t *settings = config_get_ptr(); rarch_system_info_t *system = NULL; - runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system); + runloop_get_system_info((void**)&system); if (!setting) return; @@ -2290,7 +2290,7 @@ static int setting_action_start_libretro_device_type(void *data) settings_t *settings = config_get_ptr(); rarch_system_info_t *system = NULL; - runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system); + runloop_get_system_info((void**)&system); if (setting_generic_action_start_default(setting) != 0) return -1; @@ -2440,7 +2440,7 @@ static int setting_action_left_libretro_device_type( settings_t *settings = config_get_ptr(); rarch_system_info_t *system = NULL; - runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system); + runloop_get_system_info((void**)&system); if (!setting) return -1; @@ -2505,7 +2505,7 @@ static int setting_action_right_libretro_device_type( settings_t *settings = config_get_ptr(); rarch_system_info_t *system = NULL; - runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system); + runloop_get_system_info((void**)&system); if (!setting) return -1; @@ -2888,7 +2888,7 @@ void general_write_handler(void *data) uint32_t hash = setting ? menu_hash_calculate(setting->name) : 0; uint64_t flags = menu_setting_get_flags(setting); - runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system); + runloop_get_system_info((void**)&system); if (!setting) return; @@ -3238,7 +3238,7 @@ static bool setting_append_list_input_player_options( (user == 0) ? retro_keybinds_1 : retro_keybinds_rest; rarch_system_info_t *system = NULL; - runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system); + runloop_get_system_info((void**)&system); snprintf(buffer[user], sizeof(buffer[user]), "%s %u", menu_hash_to_str(MENU_VALUE_USER), user + 1); diff --git a/network/netplay_common.c b/network/netplay_common.c index f6bc3deb0b..40b2e3b853 100644 --- a/network/netplay_common.c +++ b/network/netplay_common.c @@ -169,7 +169,7 @@ uint32_t np_impl_magic(void) api = api_info.version; - runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &info); + runloop_get_system_info((void**)&info); if (info) lib = info->info.library_name; diff --git a/retroarch.c b/retroarch.c index f4c5fb3ba5..4fcdae0caf 100644 --- a/retroarch.c +++ b/retroarch.c @@ -412,7 +412,8 @@ static void retroarch_set_paths_redirect(const char *path) settings_t *settings = config_get_ptr(); rarch_system_info_t *info = NULL; - runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &info); + runloop_get_system_info((void**)&info); + if (!global) { RARCH_WARN("retroarch_set_paths_redirect was sent a NULL \"global\" pointer."); @@ -1066,9 +1067,9 @@ static void retroarch_parse_input(int argc, char *argv[]) static void retroarch_init_savefile_paths(void) { global_t *global = global_get_ptr(); - rarch_system_info_t *system = NULL; + rarch_system_info_t *info = NULL; - runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system); + runloop_get_system_info((void**)&info); command_event(CMD_EVENT_SAVEFILES_DEINIT, NULL); @@ -1080,14 +1081,15 @@ static void retroarch_init_savefile_paths(void) /* For subsystems, we know exactly which RAM types are supported. */ unsigned i, j; - const struct retro_subsystem_info *info = + const struct retro_subsystem_info *subsystem_info = libretro_find_subsystem_info( - system->subsystem.data, - system->subsystem.size, + info->subsystem.data, + info->subsystem.size, global->subsystem); /* We'll handle this error gracefully later. */ - unsigned num_content = MIN(info ? info->num_roms : 0, + unsigned num_content = MIN(info + ? subsystem_info->num_roms : 0, global->subsystem_fullpaths ? global->subsystem_fullpaths->size : 0); @@ -1095,14 +1097,14 @@ static void retroarch_init_savefile_paths(void) for (i = 0; i < num_content; i++) { - for (j = 0; j < info->roms[i].num_memory; j++) + for (j = 0; j < subsystem_info->roms[i].num_memory; j++) { union string_list_elem_attr attr; char path[PATH_MAX_LENGTH] = {0}; char ext[32] = {0}; const struct retro_subsystem_memory_info *mem = (const struct retro_subsystem_memory_info*) - &info->roms[i].memory[j]; + &subsystem_info->roms[i].memory[j]; snprintf(ext, sizeof(ext), ".%s", mem->extension); @@ -1172,12 +1174,12 @@ bool retroarch_validate_game_options(char *s, size_t len, bool mkdir) const char *game_name = NULL; global_t *global = global_get_ptr(); settings_t *settings = config_get_ptr(); - rarch_system_info_t *system = NULL; + rarch_system_info_t *info = NULL; - runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system); + runloop_get_system_info((void**)&info); - if (system) - core_name = system->info.library_name; + if (info) + core_name = info->info.library_name; if (global) game_name = path_basename(global->name.base); diff --git a/runloop.c b/runloop.c index ce0f8f18a4..4d75054087 100644 --- a/runloop.c +++ b/runloop.c @@ -740,6 +740,57 @@ bool runloop_prepare_dummy(void) return true; } +bool runloop_get_system_info(void **data) +{ + rarch_system_info_t **system = (rarch_system_info_t**)data; + if (!system) + return false; + *system = &runloop_system; + return true; +} + +void runloop_init_system_info(void) +{ + core_get_system_info(&runloop_system.info); + + if (!runloop_system.info.library_name) + runloop_system.info.library_name = msg_hash_to_str(MSG_UNKNOWN); + if (!runloop_system.info.library_version) + runloop_system.info.library_version = "v0"; + + video_driver_set_title_buf(); + + strlcpy(runloop_system.valid_extensions, + runloop_system.info.valid_extensions ? + runloop_system.info.valid_extensions : DEFAULT_EXT, + sizeof(runloop_system.valid_extensions)); +} + +void runloop_free_system_info(void) +{ + /* No longer valid. */ + if (runloop_system.subsystem.data) + free(runloop_system.subsystem.data); + runloop_system.subsystem.data = NULL; + runloop_system.subsystem.size = 0; + + if (runloop_system.ports.data) + free(runloop_system.ports.data); + runloop_system.ports.data = NULL; + runloop_system.ports.size = 0; + + if (runloop_system.mmaps.descriptors) + free((void *)runloop_system.mmaps.descriptors); + runloop_system.mmaps.descriptors = NULL; + runloop_system.mmaps.num_descriptors = 0; + + runloop_key_event = NULL; + runloop_frontend_key_event = NULL; + + audio_driver_unset_callback(); + memset(&runloop_system, 0, sizeof(rarch_system_info_t)); +} + bool runloop_ctl(enum runloop_ctl_state state, void *data) { settings_t *settings = config_get_ptr(); @@ -751,21 +802,6 @@ bool runloop_ctl(enum runloop_ctl_state state, void *data) break; case RUNLOOP_CTL_SHADER_DIR_INIT: return shader_dir_init(&runloop_shader_dir); - case RUNLOOP_CTL_SYSTEM_INFO_INIT: - core_get_system_info(&runloop_system.info); - - if (!runloop_system.info.library_name) - runloop_system.info.library_name = msg_hash_to_str(MSG_UNKNOWN); - if (!runloop_system.info.library_version) - runloop_system.info.library_version = "v0"; - - video_driver_set_title_buf(); - - strlcpy(runloop_system.valid_extensions, - runloop_system.info.valid_extensions ? - runloop_system.info.valid_extensions : DEFAULT_EXT, - sizeof(runloop_system.valid_extensions)); - break; case RUNLOOP_CTL_GET_CORE_OPTION_SIZE: { unsigned *idx = (unsigned*)data; @@ -784,38 +820,6 @@ bool runloop_ctl(enum runloop_ctl_state state, void *data) *coreopts = runloop_core_options; } break; - case RUNLOOP_CTL_SYSTEM_INFO_GET: - { - rarch_system_info_t **system = (rarch_system_info_t**)data; - if (!system) - return false; - *system = &runloop_system; - } - break; - case RUNLOOP_CTL_SYSTEM_INFO_FREE: - - /* No longer valid. */ - if (runloop_system.subsystem.data) - free(runloop_system.subsystem.data); - runloop_system.subsystem.data = NULL; - runloop_system.subsystem.size = 0; - - if (runloop_system.ports.data) - free(runloop_system.ports.data); - runloop_system.ports.data = NULL; - runloop_system.ports.size = 0; - - if (runloop_system.mmaps.descriptors) - free((void *)runloop_system.mmaps.descriptors); - runloop_system.mmaps.descriptors = NULL; - runloop_system.mmaps.num_descriptors = 0; - - runloop_key_event = NULL; - runloop_frontend_key_event = NULL; - - audio_driver_unset_callback(); - memset(&runloop_system, 0, sizeof(rarch_system_info_t)); - break; case RUNLOOP_CTL_SET_FRAME_TIME_LAST: runloop_frame_time_last_enable = true; break; diff --git a/runloop.h b/runloop.h index 3c7f5ad9b6..d92643b929 100644 --- a/runloop.h +++ b/runloop.h @@ -99,10 +99,7 @@ enum runloop_ctl_state RUNLOOP_CTL_CORE_OPTIONS_DEINIT, RUNLOOP_CTL_CORE_OPTIONS_FREE, RUNLOOP_CTL_SHADER_DIR_DEINIT, - RUNLOOP_CTL_SHADER_DIR_INIT, - RUNLOOP_CTL_SYSTEM_INFO_GET, - RUNLOOP_CTL_SYSTEM_INFO_INIT, - RUNLOOP_CTL_SYSTEM_INFO_FREE + RUNLOOP_CTL_SHADER_DIR_INIT }; typedef int (*transfer_cb_t)(void *data, size_t len); @@ -296,8 +293,13 @@ char* runloop_msg_queue_pull(void); bool runloop_prepare_dummy(void); -bool runloop_ctl(enum runloop_ctl_state state, void *data); +void runloop_init_system_info(void); +void runloop_free_system_info(void); + +bool runloop_get_system_info(void **data); + +bool runloop_ctl(enum runloop_ctl_state state, void *data); #ifdef __cplusplus } From 6b33c19802cc2804ad4802ececd0de9b82197e41 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 12 May 2016 09:31:25 +0200 Subject: [PATCH 53/61] Fix CXX_BUILD --- libretro-common/include/features/features_cpu.h | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/libretro-common/include/features/features_cpu.h b/libretro-common/include/features/features_cpu.h index f5da7c1424..019c7f76a4 100644 --- a/libretro-common/include/features/features_cpu.h +++ b/libretro-common/include/features/features_cpu.h @@ -23,13 +23,13 @@ #ifndef _LIBRETRO_SDK_CPU_INFO_H #define _LIBRETRO_SDK_CPU_INFO_H +#include + #include #include -#ifdef __cplusplus -extern "C" { -#endif +RETRO_BEGIN_DECLS /** * cpu_features_get_perf_counter: @@ -66,10 +66,7 @@ uint64_t cpu_features_get(void); **/ unsigned cpu_features_get_core_amount(void); - -#ifdef __cplusplus -} -#endif +RETRO_END_DECLS #endif From df3b090d7a6e7a546d2e3d59f80890c60e631567 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 12 May 2016 09:37:21 +0200 Subject: [PATCH 54/61] Revert "Create runloop_get_system_info/runloop_free_system_info/runloop_init_system_info" This reverts commit 35bf38e05cfbaa3ed4efbfdfd2afdcedc2c57b8a. --- command.c | 12 ++-- configuration.c | 4 +- content.c | 4 +- dynamic.c | 6 +- frontend/frontend.c | 2 +- gfx/video_driver.c | 2 +- location/location_driver.c | 4 +- menu/cbs/menu_cbs_deferred_push.c | 3 +- menu/cbs/menu_cbs_get_value.c | 6 +- menu/cbs/menu_cbs_ok.c | 2 +- menu/drivers/materialui.c | 2 +- menu/menu_displaylist.c | 6 +- menu/menu_entries.c | 2 +- menu/menu_setting.c | 12 ++-- network/netplay_common.c | 2 +- retroarch.c | 28 ++++----- runloop.c | 98 +++++++++++++++---------------- runloop.h | 12 ++-- 18 files changed, 97 insertions(+), 110 deletions(-) diff --git a/command.c b/command.c index d19de50906..57762309db 100644 --- a/command.c +++ b/command.c @@ -733,7 +733,7 @@ static void command_event_disk_control_set_eject(bool new_state, bool print_log) rarch_system_info_t *info = NULL; const struct retro_disk_control_callback *control = NULL; - runloop_get_system_info((void**)&info); + runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &info); if (info) control = (const struct retro_disk_control_callback*)&info->disk_control_cb; @@ -781,7 +781,7 @@ static void command_event_disk_control_set_index(unsigned idx) rarch_system_info_t *info = NULL; const struct retro_disk_control_callback *control = NULL; - runloop_get_system_info((void**)&info); + runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &info); if (info) control = (const struct retro_disk_control_callback*)&info->disk_control_cb; @@ -838,7 +838,7 @@ static bool command_event_disk_control_append_image(const char *path) const struct retro_disk_control_callback *control = NULL; rarch_system_info_t *sysinfo = NULL; - runloop_get_system_info((void**)&info); + runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &sysinfo); if (sysinfo) control = (const struct retro_disk_control_callback*) @@ -983,7 +983,7 @@ static void command_event_init_controllers(void) settings_t *settings = config_get_ptr(); rarch_system_info_t *info = NULL; - runloop_get_system_info((void**)&info); + runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &info); for (i = 0; i < MAX_USERS; i++) { @@ -1236,7 +1236,7 @@ static bool command_event_init_core(enum rarch_core_type *data) if (!core_init_symbols(data)) return false; - runloop_get_system_info((void**)&info); + runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_INIT, NULL); /* auto overrides: apply overrides */ if(settings->auto_overrides_enable) @@ -1591,7 +1591,7 @@ bool command_event(enum event_command cmd, void *data) settings_t *settings = config_get_ptr(); rarch_system_info_t *info = NULL; - runloop_get_system_info((void**)&info); + runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &info); (void)i; diff --git a/configuration.c b/configuration.c index 3767670826..2adf63d908 100644 --- a/configuration.c +++ b/configuration.c @@ -1965,7 +1965,7 @@ bool config_load_override(void) settings_t *settings = config_get_ptr(); rarch_system_info_t *system = NULL; - runloop_get_system_info((void**)&system); + runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system); if (system) core_name = system->info.library_name; @@ -2143,7 +2143,7 @@ bool config_load_remap(void) settings_t *settings = config_get_ptr(); rarch_system_info_t *system = NULL; - runloop_get_system_info((void**)&system); + runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system); if (system) core_name = system->info.library_name; diff --git a/content.c b/content.c index 026d25415c..7804333047 100644 --- a/content.c +++ b/content.c @@ -1329,7 +1329,7 @@ static bool load_content_from_compressed_archive( settings_t *settings = config_get_ptr(); rarch_system_info_t *sys_info= NULL; - runloop_get_system_info((void**)sys_info); + runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &sys_info); if (sys_info && sys_info->info.block_extract) return true; @@ -1648,7 +1648,7 @@ static bool content_file_init(struct string_list *temporary_content) rarch_system_info_t *system = NULL; global_t *global = global_get_ptr(); - runloop_get_system_info((void**)system); + runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system); if (*global->subsystem) { diff --git a/dynamic.c b/dynamic.c index e2297bcd4b..edefb1fd1c 100644 --- a/dynamic.c +++ b/dynamic.c @@ -578,9 +578,7 @@ void uninit_libretro_sym(struct retro_core_t *current_core) memset(current_core, 0, sizeof(struct retro_core_t)); runloop_ctl(RUNLOOP_CTL_CORE_OPTIONS_DEINIT, NULL); - - runloop_free_system_info(); - + runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_FREE, NULL); runloop_ctl(RUNLOOP_CTL_FRAME_TIME_FREE, NULL); camera_driver_ctl(RARCH_CAMERA_CTL_UNSET_ACTIVE, NULL); location_driver_ctl(RARCH_LOCATION_CTL_UNSET_ACTIVE, NULL); @@ -742,7 +740,7 @@ bool rarch_environment_cb(unsigned cmd, void *data) global_t *global = global_get_ptr(); rarch_system_info_t *system = NULL; - runloop_get_system_info((void**)&system); + runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system); if (ignore_environment_cb) return false; diff --git a/frontend/frontend.c b/frontend/frontend.c index 24f5ae7c3c..3708bb64d9 100644 --- a/frontend/frontend.c +++ b/frontend/frontend.c @@ -130,7 +130,7 @@ int rarch_main(int argc, char *argv[], void *data) return 0; } - runloop_get_system_info((void**)&system); + runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system); runloop_ctl(RUNLOOP_CTL_GET_CONTENT_PATH, &fullpath); if (content_is_inited() || content_does_not_need_content()) diff --git a/gfx/video_driver.c b/gfx/video_driver.c index 3c380cd5e4..7af875e3e4 100644 --- a/gfx/video_driver.c +++ b/gfx/video_driver.c @@ -598,7 +598,7 @@ static bool init_video(void) struct retro_system_av_info *av_info = video_viewport_get_system_av_info(); - runloop_get_system_info((void**)&system); + runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system); init_video_filter(video_driver_state.pix_fmt); command_event(CMD_EVENT_SHADER_DIR_INIT, NULL); diff --git a/location/location_driver.c b/location/location_driver.c index e8cec5b048..4921fb1a92 100644 --- a/location/location_driver.c +++ b/location/location_driver.c @@ -203,7 +203,7 @@ void init_location(void) { rarch_system_info_t *system = NULL; - runloop_get_system_info((void**)&system); + runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system); /* Resource leaks will follow if location interface is initialized twice. */ if (location_data) @@ -227,7 +227,7 @@ static void uninit_location(void) { rarch_system_info_t *system = NULL; - runloop_get_system_info((void**)&system); + runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system); if (location_data && location_driver) { diff --git a/menu/cbs/menu_cbs_deferred_push.c b/menu/cbs/menu_cbs_deferred_push.c index 8c7dd23034..afa343df23 100644 --- a/menu/cbs/menu_cbs_deferred_push.c +++ b/menu/cbs/menu_cbs_deferred_push.c @@ -345,8 +345,7 @@ static int general_push(menu_displaylist_info_t *info, core_info_get_list(&list); menu_driver_ctl(RARCH_MENU_CTL_SYSTEM_INFO_GET, &system_menu); - - runloop_get_system_info((void**)&system); + runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system); switch (id) { diff --git a/menu/cbs/menu_cbs_get_value.c b/menu/cbs/menu_cbs_get_value.c index 8e6a569801..6ab52e6106 100644 --- a/menu/cbs/menu_cbs_get_value.c +++ b/menu/cbs/menu_cbs_get_value.c @@ -778,8 +778,7 @@ static void menu_action_setting_disp_set_label_menu_disk_index( rarch_system_info_t *system = NULL; struct retro_disk_control_callback *control = NULL; - runloop_get_system_info((void**)&system); - + runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system); if (!system) return; @@ -1165,8 +1164,7 @@ static void menu_action_setting_disp_set_label_core_option_create( rarch_system_info_t *system = NULL; global_t *global = global_get_ptr(); - runloop_get_system_info((void**)&system); - + runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system); if (!system) return; diff --git a/menu/cbs/menu_cbs_ok.c b/menu/cbs/menu_cbs_ok.c index 5f61e41dc8..c9d9a25328 100644 --- a/menu/cbs/menu_cbs_ok.c +++ b/menu/cbs/menu_cbs_ok.c @@ -1013,7 +1013,7 @@ static int generic_action_ok_remap_file_save(const char *path, const char *game_name = NULL; const char *core_name = NULL; - runloop_get_system_info((void**)&info); + runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &info); if (info) core_name = info->info.library_name; diff --git a/menu/drivers/materialui.c b/menu/drivers/materialui.c index 0290b56631..49c88ed897 100644 --- a/menu/drivers/materialui.c +++ b/menu/drivers/materialui.c @@ -685,7 +685,7 @@ static int mui_get_core_title(char *s, size_t len) core_name = system->library_name; core_version = system->library_version; - runloop_get_system_info((void**)&info); + runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &info); if (!settings->menu.core_enable) return -1; diff --git a/menu/menu_displaylist.c b/menu/menu_displaylist.c index 5b8aa3bc3d..66fdcd1c7f 100644 --- a/menu/menu_displaylist.c +++ b/menu/menu_displaylist.c @@ -2157,7 +2157,7 @@ static int menu_displaylist_parse_load_content_settings( { rarch_system_info_t *system = NULL; - runloop_get_system_info((void**)&system); + runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system); menu_entries_add(info->list, menu_hash_to_str(MENU_LABEL_VALUE_RESUME_CONTENT), @@ -2518,7 +2518,7 @@ static int menu_displaylist_parse_options_remappings( if (!menu_driver_ctl(RARCH_MENU_CTL_DRIVER_DATA_GET, &menu)) return -1; - runloop_get_system_info((void**)&system); + runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system); for (p = 0; p < settings->input.max_users; p++) { @@ -3326,7 +3326,7 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, void *data) case DISPLAYLIST_MAIN_MENU: { rarch_system_info_t *system = NULL; - runloop_get_system_info((void**)&system); + runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system); if (!rarch_ctl(RARCH_CTL_IS_DUMMY_CORE, NULL)) menu_displaylist_parse_settings(menu, info, diff --git a/menu/menu_entries.c b/menu/menu_entries.c index f79da5fb0e..9b430e2c26 100644 --- a/menu/menu_entries.c +++ b/menu/menu_entries.c @@ -448,7 +448,7 @@ int menu_entries_get_core_title(char *s, size_t len) core_name = system->library_name; core_version = system->library_version; - runloop_get_system_info((void**)&info); + runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &info); if (!settings->menu.core_enable) return -1; diff --git a/menu/menu_setting.c b/menu/menu_setting.c index d6b69d3307..0959b2ccc7 100644 --- a/menu/menu_setting.c +++ b/menu/menu_setting.c @@ -1068,7 +1068,7 @@ static void setting_get_string_representation_uint_libretro_device(void *data, settings_t *settings = config_get_ptr(); rarch_system_info_t *system = NULL; - runloop_get_system_info((void**)&system); + runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system); if (!setting) return; @@ -2290,7 +2290,7 @@ static int setting_action_start_libretro_device_type(void *data) settings_t *settings = config_get_ptr(); rarch_system_info_t *system = NULL; - runloop_get_system_info((void**)&system); + runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system); if (setting_generic_action_start_default(setting) != 0) return -1; @@ -2440,7 +2440,7 @@ static int setting_action_left_libretro_device_type( settings_t *settings = config_get_ptr(); rarch_system_info_t *system = NULL; - runloop_get_system_info((void**)&system); + runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system); if (!setting) return -1; @@ -2505,7 +2505,7 @@ static int setting_action_right_libretro_device_type( settings_t *settings = config_get_ptr(); rarch_system_info_t *system = NULL; - runloop_get_system_info((void**)&system); + runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system); if (!setting) return -1; @@ -2888,7 +2888,7 @@ void general_write_handler(void *data) uint32_t hash = setting ? menu_hash_calculate(setting->name) : 0; uint64_t flags = menu_setting_get_flags(setting); - runloop_get_system_info((void**)&system); + runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system); if (!setting) return; @@ -3238,7 +3238,7 @@ static bool setting_append_list_input_player_options( (user == 0) ? retro_keybinds_1 : retro_keybinds_rest; rarch_system_info_t *system = NULL; - runloop_get_system_info((void**)&system); + runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system); snprintf(buffer[user], sizeof(buffer[user]), "%s %u", menu_hash_to_str(MENU_VALUE_USER), user + 1); diff --git a/network/netplay_common.c b/network/netplay_common.c index 40b2e3b853..f6bc3deb0b 100644 --- a/network/netplay_common.c +++ b/network/netplay_common.c @@ -169,7 +169,7 @@ uint32_t np_impl_magic(void) api = api_info.version; - runloop_get_system_info((void**)&info); + runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &info); if (info) lib = info->info.library_name; diff --git a/retroarch.c b/retroarch.c index 4fcdae0caf..f4c5fb3ba5 100644 --- a/retroarch.c +++ b/retroarch.c @@ -412,8 +412,7 @@ static void retroarch_set_paths_redirect(const char *path) settings_t *settings = config_get_ptr(); rarch_system_info_t *info = NULL; - runloop_get_system_info((void**)&info); - + runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &info); if (!global) { RARCH_WARN("retroarch_set_paths_redirect was sent a NULL \"global\" pointer."); @@ -1067,9 +1066,9 @@ static void retroarch_parse_input(int argc, char *argv[]) static void retroarch_init_savefile_paths(void) { global_t *global = global_get_ptr(); - rarch_system_info_t *info = NULL; + rarch_system_info_t *system = NULL; - runloop_get_system_info((void**)&info); + runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system); command_event(CMD_EVENT_SAVEFILES_DEINIT, NULL); @@ -1081,15 +1080,14 @@ static void retroarch_init_savefile_paths(void) /* For subsystems, we know exactly which RAM types are supported. */ unsigned i, j; - const struct retro_subsystem_info *subsystem_info = + const struct retro_subsystem_info *info = libretro_find_subsystem_info( - info->subsystem.data, - info->subsystem.size, + system->subsystem.data, + system->subsystem.size, global->subsystem); /* We'll handle this error gracefully later. */ - unsigned num_content = MIN(info - ? subsystem_info->num_roms : 0, + unsigned num_content = MIN(info ? info->num_roms : 0, global->subsystem_fullpaths ? global->subsystem_fullpaths->size : 0); @@ -1097,14 +1095,14 @@ static void retroarch_init_savefile_paths(void) for (i = 0; i < num_content; i++) { - for (j = 0; j < subsystem_info->roms[i].num_memory; j++) + for (j = 0; j < info->roms[i].num_memory; j++) { union string_list_elem_attr attr; char path[PATH_MAX_LENGTH] = {0}; char ext[32] = {0}; const struct retro_subsystem_memory_info *mem = (const struct retro_subsystem_memory_info*) - &subsystem_info->roms[i].memory[j]; + &info->roms[i].memory[j]; snprintf(ext, sizeof(ext), ".%s", mem->extension); @@ -1174,12 +1172,12 @@ bool retroarch_validate_game_options(char *s, size_t len, bool mkdir) const char *game_name = NULL; global_t *global = global_get_ptr(); settings_t *settings = config_get_ptr(); - rarch_system_info_t *info = NULL; + rarch_system_info_t *system = NULL; - runloop_get_system_info((void**)&info); + runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system); - if (info) - core_name = info->info.library_name; + if (system) + core_name = system->info.library_name; if (global) game_name = path_basename(global->name.base); diff --git a/runloop.c b/runloop.c index 4d75054087..ce0f8f18a4 100644 --- a/runloop.c +++ b/runloop.c @@ -740,57 +740,6 @@ bool runloop_prepare_dummy(void) return true; } -bool runloop_get_system_info(void **data) -{ - rarch_system_info_t **system = (rarch_system_info_t**)data; - if (!system) - return false; - *system = &runloop_system; - return true; -} - -void runloop_init_system_info(void) -{ - core_get_system_info(&runloop_system.info); - - if (!runloop_system.info.library_name) - runloop_system.info.library_name = msg_hash_to_str(MSG_UNKNOWN); - if (!runloop_system.info.library_version) - runloop_system.info.library_version = "v0"; - - video_driver_set_title_buf(); - - strlcpy(runloop_system.valid_extensions, - runloop_system.info.valid_extensions ? - runloop_system.info.valid_extensions : DEFAULT_EXT, - sizeof(runloop_system.valid_extensions)); -} - -void runloop_free_system_info(void) -{ - /* No longer valid. */ - if (runloop_system.subsystem.data) - free(runloop_system.subsystem.data); - runloop_system.subsystem.data = NULL; - runloop_system.subsystem.size = 0; - - if (runloop_system.ports.data) - free(runloop_system.ports.data); - runloop_system.ports.data = NULL; - runloop_system.ports.size = 0; - - if (runloop_system.mmaps.descriptors) - free((void *)runloop_system.mmaps.descriptors); - runloop_system.mmaps.descriptors = NULL; - runloop_system.mmaps.num_descriptors = 0; - - runloop_key_event = NULL; - runloop_frontend_key_event = NULL; - - audio_driver_unset_callback(); - memset(&runloop_system, 0, sizeof(rarch_system_info_t)); -} - bool runloop_ctl(enum runloop_ctl_state state, void *data) { settings_t *settings = config_get_ptr(); @@ -802,6 +751,21 @@ bool runloop_ctl(enum runloop_ctl_state state, void *data) break; case RUNLOOP_CTL_SHADER_DIR_INIT: return shader_dir_init(&runloop_shader_dir); + case RUNLOOP_CTL_SYSTEM_INFO_INIT: + core_get_system_info(&runloop_system.info); + + if (!runloop_system.info.library_name) + runloop_system.info.library_name = msg_hash_to_str(MSG_UNKNOWN); + if (!runloop_system.info.library_version) + runloop_system.info.library_version = "v0"; + + video_driver_set_title_buf(); + + strlcpy(runloop_system.valid_extensions, + runloop_system.info.valid_extensions ? + runloop_system.info.valid_extensions : DEFAULT_EXT, + sizeof(runloop_system.valid_extensions)); + break; case RUNLOOP_CTL_GET_CORE_OPTION_SIZE: { unsigned *idx = (unsigned*)data; @@ -820,6 +784,38 @@ bool runloop_ctl(enum runloop_ctl_state state, void *data) *coreopts = runloop_core_options; } break; + case RUNLOOP_CTL_SYSTEM_INFO_GET: + { + rarch_system_info_t **system = (rarch_system_info_t**)data; + if (!system) + return false; + *system = &runloop_system; + } + break; + case RUNLOOP_CTL_SYSTEM_INFO_FREE: + + /* No longer valid. */ + if (runloop_system.subsystem.data) + free(runloop_system.subsystem.data); + runloop_system.subsystem.data = NULL; + runloop_system.subsystem.size = 0; + + if (runloop_system.ports.data) + free(runloop_system.ports.data); + runloop_system.ports.data = NULL; + runloop_system.ports.size = 0; + + if (runloop_system.mmaps.descriptors) + free((void *)runloop_system.mmaps.descriptors); + runloop_system.mmaps.descriptors = NULL; + runloop_system.mmaps.num_descriptors = 0; + + runloop_key_event = NULL; + runloop_frontend_key_event = NULL; + + audio_driver_unset_callback(); + memset(&runloop_system, 0, sizeof(rarch_system_info_t)); + break; case RUNLOOP_CTL_SET_FRAME_TIME_LAST: runloop_frame_time_last_enable = true; break; diff --git a/runloop.h b/runloop.h index d92643b929..3c7f5ad9b6 100644 --- a/runloop.h +++ b/runloop.h @@ -99,7 +99,10 @@ enum runloop_ctl_state RUNLOOP_CTL_CORE_OPTIONS_DEINIT, RUNLOOP_CTL_CORE_OPTIONS_FREE, RUNLOOP_CTL_SHADER_DIR_DEINIT, - RUNLOOP_CTL_SHADER_DIR_INIT + RUNLOOP_CTL_SHADER_DIR_INIT, + RUNLOOP_CTL_SYSTEM_INFO_GET, + RUNLOOP_CTL_SYSTEM_INFO_INIT, + RUNLOOP_CTL_SYSTEM_INFO_FREE }; typedef int (*transfer_cb_t)(void *data, size_t len); @@ -293,14 +296,9 @@ char* runloop_msg_queue_pull(void); bool runloop_prepare_dummy(void); -void runloop_init_system_info(void); - -void runloop_free_system_info(void); - -bool runloop_get_system_info(void **data); - bool runloop_ctl(enum runloop_ctl_state state, void *data); + #ifdef __cplusplus } #endif From a7d4379011b068442dcdf4a01042fd1670dd95b4 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 12 May 2016 10:20:14 +0200 Subject: [PATCH 55/61] Rename np_is_server to netplay_is_server --- network/netplay_common.c | 2 +- network/netplay_net.c | 2 +- network/netplay_private.h | 4 +++- network/netplay_spectate.c | 6 +++--- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/network/netplay_common.c b/network/netplay_common.c index f6bc3deb0b..764846b7af 100644 --- a/network/netplay_common.c +++ b/network/netplay_common.c @@ -311,7 +311,7 @@ bool np_get_info(netplay_t *netplay) return true; } -bool np_is_server(netplay_t* netplay) +bool netplay_is_server(netplay_t* netplay) { if (!netplay) return false; diff --git a/network/netplay_net.c b/network/netplay_net.c index 42a224f77a..5a2fd1c911 100644 --- a/network/netplay_net.c +++ b/network/netplay_net.c @@ -137,7 +137,7 @@ static bool netplay_net_init_buffers(netplay_t *netplay) static bool netplay_net_info_cb(netplay_t* netplay, unsigned frames) { - if (np_is_server(netplay)) + if (netplay_is_server(netplay)) { if (!np_send_info(netplay)) return false; diff --git a/network/netplay_private.h b/network/netplay_private.h index d1d7e8b489..49158ca859 100644 --- a/network/netplay_private.h +++ b/network/netplay_private.h @@ -16,6 +16,7 @@ #ifndef __RARCH_NETPLAY_PRIVATE_H #define __RARCH_NETPLAY_PRIVATE_H + #include "netplay.h" #include @@ -149,6 +150,7 @@ bool np_bsv_parse_header(const uint32_t *header, uint32_t magic); uint32_t np_impl_magic(void); bool np_send_info(netplay_t *netplay); bool np_get_info(netplay_t *netplay); -bool np_is_server(netplay_t* netplay); +bool netplay_is_server(netplay_t* netplay); bool np_is_spectate(netplay_t* netplay); + #endif diff --git a/network/netplay_spectate.c b/network/netplay_spectate.c index d257c61212..fea0576625 100644 --- a/network/netplay_spectate.c +++ b/network/netplay_spectate.c @@ -41,7 +41,7 @@ static void netplay_spectate_pre_frame(netplay_t *netplay) fd_set fds; struct timeval tmp_tv = {0}; - if (!np_is_server(netplay)) + if (!netplay_is_server(netplay)) return; FD_ZERO(&fds); @@ -133,7 +133,7 @@ static void netplay_spectate_post_frame(netplay_t *netplay) { unsigned i; - if (!np_is_server(netplay)) + if (!netplay_is_server(netplay)) return; for (i = 0; i < MAX_SPECTATORS; i++) @@ -165,7 +165,7 @@ static void netplay_spectate_post_frame(netplay_t *netplay) static bool netplay_spectate_info_cb(netplay_t *netplay, unsigned frames) { unsigned i; - if(np_is_server(netplay)) + if(netplay_is_server(netplay)) { if(!np_get_info(netplay)) return false; From 193eb623541e8cb2628ff2d9f83431fba7358946 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 12 May 2016 10:29:19 +0200 Subject: [PATCH 56/61] (Android) Add include dirs --- pkg/android/phoenix/jni/Android.mk | 3 ++- pkg/android/phoenix/jni/Android2.mk | 5 ++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/pkg/android/phoenix/jni/Android.mk b/pkg/android/phoenix/jni/Android.mk index fac9cf6e7e..702b06f30b 100644 --- a/pkg/android/phoenix/jni/Android.mk +++ b/pkg/android/phoenix/jni/Android.mk @@ -79,7 +79,8 @@ LOCAL_CPPFLAGS += -I$(LOCAL_PATH)/$(RARCH_DIR)/deps/glslang \ -I$(LOCAL_PATH)/$(RARCH_DIR)/deps/glslang/glslang/glslang/Public \ -I$(LOCAL_PATH)/$(RARCH_DIR)/deps/glslang/glslang/glslang/MachineIndependent \ -I$(LOCAL_PATH)/$(RARCH_DIR)/deps/glslang/glslang/SPIRV \ - -I$(LOCAL_PATH)/$(RARCH_DIR)/deps/spir2cross + -I$(LOCAL_PATH)/$(RARCH_DIR)/deps/spir2cross \ + -I$(LOCAL_PATH)/$(RARCH_DIR)/deps/SPIRV-Cross LOCAL_SRC_FILES += $(RARCH_DIR)/deps/glslang/glslang.cpp \ $(RARCH_DIR)/deps/glslang/glslang/SPIRV/SpvBuilder.cpp \ diff --git a/pkg/android/phoenix/jni/Android2.mk b/pkg/android/phoenix/jni/Android2.mk index 06ec713d76..265d051fd1 100644 --- a/pkg/android/phoenix/jni/Android2.mk +++ b/pkg/android/phoenix/jni/Android2.mk @@ -83,7 +83,10 @@ LOCAL_C_INCLUDES += $(INCFLAGS) LOCAL_CPPFLAGS += -I$(LOCAL_PATH)/$(RARCH_DIR)/deps/glslang \ -I$(LOCAL_PATH)/$(RARCH_DIR)/deps/glslang/glslang/glslang/Public \ -I$(LOCAL_PATH)/$(RARCH_DIR)/deps/glslang/glslang/glslang/MachineIndependent \ - -I$(LOCAL_PATH)/$(RARCH_DIR)/deps/glslang/glslang/SPIRV + -I$(LOCAL_PATH)/$(RARCH_DIR)/deps/glslang/glslang/SPIRV \ + -I$(LOCAL_PATH)/$(RARCH_DIR)/deps/spir2cross \ + -I$(LOCAL_PATH)/$(RARCH_DIR)/deps/SPIRV-Cross + LOCAL_SRC_FILES += $(RARCH_DIR)/deps/glslang/glslang.cpp \ $(RARCH_DIR)/deps/glslang/glslang/SPIRV/SpvBuilder.cpp \ $(RARCH_DIR)/deps/glslang/glslang/SPIRV/SPVRemapper.cpp \ From 315c6b968736de578861328d2129b3060fe941e4 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 12 May 2016 10:44:15 +0200 Subject: [PATCH 57/61] Cleanups --- pkg/android/phoenix/jni/Android.mk | 2 +- pkg/android/phoenix/jni/Android2.mk | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/android/phoenix/jni/Android.mk b/pkg/android/phoenix/jni/Android.mk index 702b06f30b..5125d92e9c 100644 --- a/pkg/android/phoenix/jni/Android.mk +++ b/pkg/android/phoenix/jni/Android.mk @@ -63,7 +63,7 @@ DEFINES += -DHAVE_CHEEVOS DEFINES += -DHAVE_SL LOCAL_CFLAGS += -Wall -std=gnu99 -pthread -Wno-unused-function -fno-stack-protector -funroll-loops $(DEFINES) -LOCAL_CPPFLAGS := -fno-exceptions -std=gnu++11 -fno-rtti -Wno-reorder $(DEFINES) +LOCAL_CPPFLAGS := -fexceptions -std=gnu++11 -fno-rtti -Wno-reorder $(DEFINES) # Let ndk-build set the optimization flags but remove -O3 like in cf3c3 LOCAL_CFLAGS := $(subst -O3,-O2,$(LOCAL_CFLAGS)) diff --git a/pkg/android/phoenix/jni/Android2.mk b/pkg/android/phoenix/jni/Android2.mk index 265d051fd1..f1177b051e 100644 --- a/pkg/android/phoenix/jni/Android2.mk +++ b/pkg/android/phoenix/jni/Android2.mk @@ -65,7 +65,7 @@ DEFINES += -DDEBUG_ANDROID DEFINES += -DHAVE_SL LOCAL_CFLAGS += -Wall -std=gnu99 -pthread -Wno-unused-function -fno-stack-protector -funroll-loops $(DEFINES) -LOCAL_CPPFLAGS := -std=gnu++11 $(DEFINES) +LOCAL_CPPFLAGS := -fexceptions -std=gnu++11 -fno-rtti -Wno-reorder $(DEFINES) ifeq ($(NDK_DEBUG),1) LOCAL_CFLAGS += -O0 -g From cba281052a6e7ae616674ece18f328db972a2ad1 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 12 May 2016 12:03:43 +0200 Subject: [PATCH 58/61] Rename np_ functions --- network/netplay.c | 2 +- network/netplay_common.c | 32 ++++++++++++++++---------------- network/netplay_net.c | 4 ++-- network/netplay_private.h | 20 ++++++++++---------- network/netplay_spectate.c | 12 ++++++------ 5 files changed, 35 insertions(+), 35 deletions(-) diff --git a/network/netplay.c b/network/netplay.c index 2a26c5b523..2491f569a8 100644 --- a/network/netplay.c +++ b/network/netplay.c @@ -589,7 +589,7 @@ int16_t input_state_net(unsigned port, unsigned device, #ifndef HAVE_SOCKET_LEGACY /* Custom inet_ntop. Win32 doesn't seem to support this ... */ -void np_log_connection(const struct sockaddr_storage *their_addr, +void netplay_log_connection(const struct sockaddr_storage *their_addr, unsigned slot, const char *nick) { union diff --git a/network/netplay_common.c b/network/netplay_common.c index 764846b7af..7d438e3525 100644 --- a/network/netplay_common.c +++ b/network/netplay_common.c @@ -18,7 +18,7 @@ #include #include "../content.h" -bool np_get_nickname(netplay_t *netplay, int fd) +bool netplay_get_nickname(netplay_t *netplay, int fd) { uint8_t nick_size; @@ -42,7 +42,7 @@ bool np_get_nickname(netplay_t *netplay, int fd) return true; } -bool np_send_nickname(netplay_t *netplay, int fd) +bool netplay_send_nickname(netplay_t *netplay, int fd) { uint8_t nick_size = strlen(netplay->nick); @@ -61,7 +61,7 @@ bool np_send_nickname(netplay_t *netplay, int fd) return true; } -uint32_t *np_bsv_header_generate(size_t *size, uint32_t magic) +uint32_t *netplay_bsv_header_generate(size_t *size, uint32_t magic) { retro_ctx_serialize_info_t serial_info; retro_ctx_size_info_t info; @@ -100,7 +100,7 @@ error: return NULL; } -bool np_bsv_parse_header(const uint32_t *header, uint32_t magic) +bool netplay_bsv_parse_header(const uint32_t *header, uint32_t magic) { retro_ctx_size_info_t info; uint32_t *content_crc_ptr; @@ -146,7 +146,7 @@ bool np_bsv_parse_header(const uint32_t *header, uint32_t magic) } /** - * np_impl_magic: + * netplay_impl_magic: * * Not really a hash, but should be enough to differentiate * implementations from each other. @@ -155,7 +155,7 @@ bool np_bsv_parse_header(const uint32_t *header, uint32_t magic) * The alternative would have been checking serialization sizes, but it * was troublesome for cross platform compat. **/ -uint32_t np_impl_magic(void) +uint32_t netplay_impl_magic(void) { size_t i, len; retro_ctx_api_info_t api_info; @@ -193,7 +193,7 @@ uint32_t np_impl_magic(void) return res; } -bool np_send_info(netplay_t *netplay) +bool netplay_send_info(netplay_t *netplay) { unsigned sram_size; retro_ctx_memory_info_t mem_info; @@ -208,13 +208,13 @@ bool np_send_info(netplay_t *netplay) content_get_crc(&content_crc_ptr); header[0] = htonl(*content_crc_ptr); - header[1] = htonl(np_impl_magic()); + header[1] = htonl(netplay_impl_magic()); header[2] = htonl(mem_info.size); if (!socket_send_all_blocking(netplay->fd, header, sizeof(header), false)) return false; - if (!np_send_nickname(netplay, netplay->fd)) + if (!netplay_send_nickname(netplay, netplay->fd)) { RARCH_ERR("Failed to send nick to host.\n"); return false; @@ -230,7 +230,7 @@ bool np_send_info(netplay_t *netplay) return false; } - if (!np_get_nickname(netplay, netplay->fd)) + if (!netplay_get_nickname(netplay, netplay->fd)) { RARCH_ERR("Failed to receive nick from host.\n"); return false; @@ -243,7 +243,7 @@ bool np_send_info(netplay_t *netplay) return true; } -bool np_get_info(netplay_t *netplay) +bool netplay_get_info(netplay_t *netplay) { unsigned sram_size; uint32_t header[3]; @@ -265,7 +265,7 @@ bool np_get_info(netplay_t *netplay) return false; } - if (np_impl_magic() != ntohl(header[1])) + if (netplay_impl_magic() != ntohl(header[1])) { RARCH_ERR("Implementations differ, make sure you're using exact same " "libretro implementations and RetroArch version.\n"); @@ -282,7 +282,7 @@ bool np_get_info(netplay_t *netplay) return false; } - if (!np_get_nickname(netplay, netplay->fd)) + if (!netplay_get_nickname(netplay, netplay->fd)) { RARCH_ERR("Failed to get nickname from client.\n"); return false; @@ -298,14 +298,14 @@ bool np_get_info(netplay_t *netplay) return false; } - if (!np_send_nickname(netplay, netplay->fd)) + if (!netplay_send_nickname(netplay, netplay->fd)) { RARCH_ERR("Failed to send nickname to client.\n"); return false; } #ifndef HAVE_SOCKET_LEGACY - np_log_connection(&netplay->other_addr, 0, netplay->other_nick); + netplay_log_connection(&netplay->other_addr, 0, netplay->other_nick); #endif return true; @@ -318,7 +318,7 @@ bool netplay_is_server(netplay_t* netplay) return netplay->is_server; } -bool np_is_spectate(netplay_t* netplay) +bool netplay_is_spectate(netplay_t* netplay) { if (!netplay) return false; diff --git a/network/netplay_net.c b/network/netplay_net.c index 5a2fd1c911..d119c73c53 100644 --- a/network/netplay_net.c +++ b/network/netplay_net.c @@ -139,12 +139,12 @@ static bool netplay_net_info_cb(netplay_t* netplay, unsigned frames) { if (netplay_is_server(netplay)) { - if (!np_send_info(netplay)) + if (!netplay_send_info(netplay)) return false; } else { - if (!np_get_info(netplay)) + if (!netplay_get_info(netplay)) return false; } diff --git a/network/netplay_private.h b/network/netplay_private.h index 49158ca859..e52ceae46a 100644 --- a/network/netplay_private.h +++ b/network/netplay_private.h @@ -139,18 +139,18 @@ extern void *netplay_data; struct netplay_callbacks* netplay_get_cbs_net(void); struct netplay_callbacks* netplay_get_cbs_spectate(void); -void np_log_connection(const struct sockaddr_storage *their_addr, +void netplay_log_connection(const struct sockaddr_storage *their_addr, unsigned slot, const char *nick); -bool np_get_nickname(netplay_t *netplay, int fd); -bool np_send_nickname(netplay_t *netplay, int fd); -bool np_send_info(netplay_t *netplay); -uint32_t *np_bsv_header_generate(size_t *size, uint32_t magic); -bool np_bsv_parse_header(const uint32_t *header, uint32_t magic); -uint32_t np_impl_magic(void); -bool np_send_info(netplay_t *netplay); -bool np_get_info(netplay_t *netplay); +bool netplay_get_nickname(netplay_t *netplay, int fd); +bool netplay_send_nickname(netplay_t *netplay, int fd); +bool netplay_send_info(netplay_t *netplay); +uint32_t *netplay_bsv_header_generate(size_t *size, uint32_t magic); +bool netplay_bsv_parse_header(const uint32_t *header, uint32_t magic); +uint32_t netplay_impl_magic(void); +bool netplay_send_info(netplay_t *netplay); +bool netplay_get_info(netplay_t *netplay); bool netplay_is_server(netplay_t* netplay); -bool np_is_spectate(netplay_t* netplay); +bool netplay_is_spectate(netplay_t* netplay); #endif diff --git a/network/netplay_spectate.c b/network/netplay_spectate.c index fea0576625..455b4de174 100644 --- a/network/netplay_spectate.c +++ b/network/netplay_spectate.c @@ -78,22 +78,22 @@ static void netplay_spectate_pre_frame(netplay_t *netplay) return; } - if (!np_get_nickname(netplay, new_fd)) + if (!netplay_get_nickname(netplay, new_fd)) { RARCH_ERR("Failed to get nickname from client.\n"); socket_close(new_fd); return; } - if (!np_send_nickname(netplay, new_fd)) + if (!netplay_send_nickname(netplay, new_fd)) { RARCH_ERR("Failed to send nickname to client.\n"); socket_close(new_fd); return; } - header = np_bsv_header_generate(&header_size, - np_impl_magic()); + header = netplay_bsv_header_generate(&header_size, + netplay_impl_magic()); if (!header) { @@ -118,7 +118,7 @@ static void netplay_spectate_pre_frame(netplay_t *netplay) netplay->spectate.fds[idx] = new_fd; #ifndef HAVE_SOCKET_LEGACY - np_log_connection(&their_addr, idx, netplay->other_nick); + netplay_log_connection(&their_addr, idx, netplay->other_nick); #endif } @@ -167,7 +167,7 @@ static bool netplay_spectate_info_cb(netplay_t *netplay, unsigned frames) unsigned i; if(netplay_is_server(netplay)) { - if(!np_get_info(netplay)) + if(!netplay_get_info(netplay)) return false; } From 597102e863a07aa19713ecc1a9a7b049549171a7 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 12 May 2016 12:15:53 +0200 Subject: [PATCH 59/61] Remove __ARM_ARCH__ ifdefs --- libretro-common/features/features_cpu.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/libretro-common/features/features_cpu.c b/libretro-common/features/features_cpu.c index 185de2932c..c85271f5e0 100644 --- a/libretro-common/features/features_cpu.c +++ b/libretro-common/features/features_cpu.c @@ -288,7 +288,6 @@ static void arm_enable_runfast_mode(void) #if defined(__linux__) -#ifdef __ARM_ARCH__ /* Extract the content of a the first occurrence of a given field in * the content of /proc/cpuinfo and return it as a heap-allocated * string that must be freed by the caller. @@ -376,7 +375,6 @@ static int has_list_item(const char* list, const char* item) } return 0; } -#endif typedef struct { @@ -737,8 +735,8 @@ uint64_t cpu_features_get(void) } #elif defined(__linux__) - static bool cpu_inited_once = false; - static uint64_t g_cpuFeatures; + static bool cpu_inited_once = false; + static uint64_t g_cpuFeatures = 0; enum { @@ -753,11 +751,8 @@ uint64_t cpu_features_get(void) ssize_t length; void *buf = NULL; - g_cpuFeatures = 0; - if (filestream_read_file("/proc/cpuinfo", &buf, &length) == 1) { -#ifdef __ARM_ARCH__ /* Extract architecture from the "CPU Architecture" field. * The list is well-known, unlike the the output of * the 'Processor' field which can vary greatly. @@ -838,7 +833,6 @@ uint64_t cpu_features_get(void) g_cpuFeatures |= CPU_ARM_FEATURE_NEON | CPU_ARM_FEATURE_VFPv3; free(cpu_features); } -#endif /* __ARM_ARCH__ */ if (buf) free(buf); From 3bdfbb63180a793ac309c362634b753d7d4f0efe Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 12 May 2016 12:22:32 +0200 Subject: [PATCH 60/61] features_cpu.c - cleanups --- libretro-common/features/features_cpu.c | 28 +++++++++++++------------ 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/libretro-common/features/features_cpu.c b/libretro-common/features/features_cpu.c index c85271f5e0..3977bbf5b4 100644 --- a/libretro-common/features/features_cpu.c +++ b/libretro-common/features/features_cpu.c @@ -286,7 +286,7 @@ static void arm_enable_runfast_mode(void) } #endif -#if defined(__linux__) +#if defined(__linux__) && !defined(CPU_X86) /* Extract the content of a the first occurrence of a given field in * the content of /proc/cpuinfo and return it as a heap-allocated @@ -753,6 +753,7 @@ uint64_t cpu_features_get(void) if (filestream_read_file("/proc/cpuinfo", &buf, &length) == 1) { + char* cpu_features = NULL; /* Extract architecture from the "CPU Architecture" field. * The list is well-known, unlike the the output of * the 'Processor' field which can vary greatly. @@ -765,9 +766,9 @@ uint64_t cpu_features_get(void) if (cpu_arch) { - char* end; - int has_armv7 = 0; - /* read the initial decimal number, ignore the rest */ + char* end = NULL; + int has_armv7 = 0; + /* Read the initial decimal number, ignore the rest */ long arch_number = strtol(cpu_arch, &end, 10); /* Here we assume that ARMv8 will be upwards compatible with v7 @@ -792,13 +793,11 @@ uint64_t cpu_features_get(void) char *cpu_proc = extract_cpuinfo_field(buf, length, "Processor"); - if (cpu_proc != NULL) + if (cpu_proc) { + /* CPU processor and architecture mismatch. */ if (has_list_item(cpu_proc, "(v6l)")) - { - /* CPU processor and architecture mismatch. */ has_armv7 = 0; - } free(cpu_proc); } } @@ -810,17 +809,15 @@ uint64_t cpu_features_get(void) if (arch_number >= 6) g_cpuFeatures |= CPU_ARM_FEATURE_LDREX_STREX; - free(cpu_arch); } /* Extract the list of CPU features from 'Features' field */ - char* cpu_features = extract_cpuinfo_field(buf, length, "Features"); + cpu_features = extract_cpuinfo_field(buf, length, "Features"); if (cpu_features) { if (has_list_item(cpu_features, "vfpv3")) g_cpuFeatures |= CPU_ARM_FEATURE_VFPv3; - else if (has_list_item(cpu_features, "vfpv3d16")) g_cpuFeatures |= CPU_ARM_FEATURE_VFPv3; @@ -831,12 +828,17 @@ uint64_t cpu_features_get(void) */ if (has_list_item(cpu_features, "neon")) g_cpuFeatures |= CPU_ARM_FEATURE_NEON | CPU_ARM_FEATURE_VFPv3; - free(cpu_features); } + if (cpu_features) + free(cpu_features); + if (cpu_arch) + free(cpu_arch); if (buf) free(buf); - buf = NULL; + cpu_features = NULL; + cpu_arch = NULL; + buf = NULL; } cpu_inited_once = true; } From be506c6d64d6cadc2c945a9057346e339502353d Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 12 May 2016 13:13:14 +0200 Subject: [PATCH 61/61] (task_image.c) Cleanups --- tasks/task_image.c | 76 ++++++++++++++++++++++++++++++---------------- 1 file changed, 49 insertions(+), 27 deletions(-) diff --git a/tasks/task_image.c b/tasks/task_image.c index 63fdaf6461..d5fe2c0bea 100644 --- a/tasks/task_image.c +++ b/tasks/task_image.c @@ -99,23 +99,22 @@ static int cb_nbio_default(void *data, size_t len) return 0; } -static int rarch_main_data_image_process( - nbio_handle_t *nbio, - unsigned *width, - unsigned *height) +static int image_transfer_process( + void *data, + enum image_type_enum type, + uint32_t **buf, + unsigned *width, unsigned *height) { - int retval = 0; - - switch (nbio->image_type) + switch (type) { case IMAGE_TYPE_PNG: #ifdef HAVE_RPNG - if (!rpng_is_valid((rpng_t*)nbio->image.handle)) + if (!rpng_is_valid((rpng_t*)data)) return IMAGE_PROCESS_ERROR; - retval = rpng_nbio_load_image_argb_process( - (rpng_t*)nbio->image.handle, - &nbio->image.ti.pixels, + return rpng_nbio_load_image_argb_process( + (rpng_t*)data, + buf, width, height); #endif break; @@ -125,6 +124,41 @@ static int rarch_main_data_image_process( break; } + return 0; +} + +static bool image_transfer_iterate(void *data, enum image_type_enum type) +{ + switch (type) + { + case IMAGE_TYPE_PNG: +#ifdef HAVE_RPNG + if (!rpng_nbio_load_image_argb_iterate((rpng_t*)data)) + return false; +#endif + break; + case IMAGE_TYPE_JPEG: +#ifdef HAVE_RJPEG +#endif + break; + } + + return true; +} + +static int rarch_main_data_image_process( + nbio_handle_t *nbio, + unsigned *width, + unsigned *height) +{ + int retval = image_transfer_process( + (rpng_t*)nbio->image.handle, + nbio->image_type, + &nbio->image.ti.pixels, width, height); + + if (retval == IMAGE_PROCESS_ERROR) + return IMAGE_PROCESS_ERROR; + nbio->image.ti.width = *width; nbio->image.ti.height = *height; @@ -191,40 +225,28 @@ static int rarch_main_data_image_iterate_process_transfer(nbio_handle_t *nbio) return -1; } + static int rarch_main_data_image_iterate_transfer(nbio_handle_t *nbio) { unsigned i; if (!nbio) - return -1; + goto error; if (nbio->image.is_finished) return 0; for (i = 0; i < nbio->image.pos_increment; i++) { - switch (nbio->image_type) - { - case IMAGE_TYPE_PNG: -#ifdef HAVE_RPNG - if (!rpng_nbio_load_image_argb_iterate((rpng_t*)nbio->image.handle)) - goto error; -#endif - break; - case IMAGE_TYPE_JPEG: -#ifdef HAVE_RJPEG -#endif - break; - } + if (!image_transfer_iterate(nbio->image.handle, nbio->image_type)) + goto error; } nbio->image.frame_count++; return 0; -#ifdef HAVE_RPNG error: return -1; -#endif } static void rarch_task_image_load_free_internal(nbio_handle_t *nbio)