mirror of
https://github.com/libretro/RetroArch
synced 2025-03-23 19:21:03 +00:00
(Console) Bakes in filters now for ifndef HAVE_DYLIB targets
This commit is contained in:
parent
45c917afa4
commit
8d6a7dbe1f
12
driver.c
12
driver.c
@ -1291,7 +1291,11 @@ void rarch_deinit_filter(void)
|
||||
void rarch_init_filter(enum retro_pixel_format colfmt)
|
||||
{
|
||||
rarch_deinit_filter();
|
||||
#ifdef HAVE_FILTERS_BUILTIN
|
||||
if (!g_settings.video.filter_idx)
|
||||
#else
|
||||
if (!*g_settings.video.filter_path)
|
||||
#endif
|
||||
return;
|
||||
|
||||
// Deprecated format. Gets pre-converted.
|
||||
@ -1311,13 +1315,21 @@ void rarch_init_filter(enum retro_pixel_format colfmt)
|
||||
unsigned pow2_y = 0;
|
||||
unsigned maxsize = 0;
|
||||
|
||||
#ifdef HAVE_FILTERS_BUILTIN
|
||||
RARCH_LOG("Loading softfilter %d\n", g_settings.video.filter_idx);
|
||||
#else
|
||||
RARCH_LOG("Loading softfilter from \"%s\"\n", g_settings.video.filter_path);
|
||||
#endif
|
||||
g_extern.filter.filter = rarch_softfilter_new(g_settings.video.filter_path,
|
||||
RARCH_SOFTFILTER_THREADS_AUTO, colfmt, width, height);
|
||||
|
||||
if (!g_extern.filter.filter)
|
||||
{
|
||||
#ifdef HAVE_FILTERS_BUILTIN
|
||||
RARCH_LOG("Loading softfilter %d\n", g_settings.video.filter_idx);
|
||||
#else
|
||||
RARCH_ERR("Failed to load filter \"%s\"\n", g_settings.video.filter_path);
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -777,14 +777,32 @@ int menu_set_settings(void *data, unsigned setting, unsigned action)
|
||||
case RGUI_SETTINGS_VIDEO_SOFTFILTER:
|
||||
switch (action)
|
||||
{
|
||||
#ifdef HAVE_DYLIB
|
||||
#if defined(HAVE_FILTERS_BUILTIN)
|
||||
case RGUI_ACTION_LEFT:
|
||||
if (g_settings.video.filter_idx > 0)
|
||||
g_settings.video.filter_idx--;
|
||||
break;
|
||||
case RGUI_ACTION_RIGHT:
|
||||
if ((g_settings.video.filter_idx + 1) != SOFTFILTER_LAST)
|
||||
g_settings.video.filter_idx++;
|
||||
break;
|
||||
#endif
|
||||
case RGUI_ACTION_OK:
|
||||
#if defined(HAVE_FILTERS_BUILTIN)
|
||||
rarch_set_fullscreen(g_settings.video.fullscreen);
|
||||
rgui->need_refresh = true;
|
||||
#if defined(HAVE_DYLIB)
|
||||
file_list_push(rgui->menu_stack, g_settings.video.filter_dir, setting, rgui->selection_ptr);
|
||||
menu_clear_navigation(rgui);
|
||||
rgui->need_refresh = true;
|
||||
#endif
|
||||
break;
|
||||
case RGUI_ACTION_START:
|
||||
#if defined(HAVE_FILTERS_BUILTIN)
|
||||
g_settings.video.filter_idx = SOFTFILTER_NONE;
|
||||
#else
|
||||
strlcpy(g_settings.video.filter_path, "", sizeof(g_settings.video.filter_path));
|
||||
#endif
|
||||
rarch_set_fullscreen(g_settings.video.fullscreen);
|
||||
break;
|
||||
default:
|
||||
@ -2242,7 +2260,24 @@ void menu_set_settings_label(char *type_str, size_t type_str_size, unsigned *w,
|
||||
strlcpy(type_str, "...", type_str_size);
|
||||
break;
|
||||
case RGUI_SETTINGS_VIDEO_SOFTFILTER:
|
||||
strlcpy(type_str, path_basename(g_settings.video.filter_path), type_str_size);
|
||||
{
|
||||
#ifdef HAVE_FILTERS_BUILTIN
|
||||
unsigned cpu_features;
|
||||
const struct softfilter_implementation *impl;
|
||||
softfilter_get_implementation_t cb = softfilter_get_implementation_from_idx(g_settings.video.filter_idx);
|
||||
if (cb)
|
||||
{
|
||||
cpu_features = rarch_get_cpu_features();
|
||||
impl = (const struct softfilter_implementation *)cb(cpu_features);
|
||||
if (impl)
|
||||
strlcpy(type_str, impl->ident, type_str_size);
|
||||
}
|
||||
else
|
||||
strlcpy(type_str, "N/A", type_str_size);
|
||||
#else
|
||||
strlcpy(type_str, path_basename(g_settings.video.filter_path), type_str_size);
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
#ifdef HAVE_OVERLAY
|
||||
case RGUI_SETTINGS_OVERLAY_PRESET:
|
||||
|
@ -156,6 +156,9 @@ struct settings
|
||||
char shader_path[PATH_MAX];
|
||||
bool shader_enable;
|
||||
|
||||
#ifdef HAVE_FILTERS_BUILTIN
|
||||
unsigned filter_idx;
|
||||
#endif
|
||||
char filter_path[PATH_MAX];
|
||||
float refresh_rate;
|
||||
bool threaded;
|
||||
|
32
gfx/filter.c
32
gfx/filter.c
@ -14,6 +14,7 @@
|
||||
*/
|
||||
|
||||
#include "filter.h"
|
||||
#include "filters/softfilter.h"
|
||||
#include "../dynamic.h"
|
||||
#include "../general.h"
|
||||
#include "../performance.h"
|
||||
@ -64,7 +65,7 @@ static void filter_thread_loop(void *data)
|
||||
|
||||
struct rarch_softfilter
|
||||
{
|
||||
#ifdef HAVE_DYLIB
|
||||
#if !defined(HAVE_FILTERS_BUILTIN) && defined(HAVE_DYLIB)
|
||||
dylib_t lib;
|
||||
#endif
|
||||
|
||||
@ -82,6 +83,26 @@ struct rarch_softfilter
|
||||
#endif
|
||||
};
|
||||
|
||||
#ifdef HAVE_FILTERS_BUILTIN
|
||||
static softfilter_get_implementation_t softfilter_get_implementation_from_idx(unsigned idx)
|
||||
{
|
||||
switch (idx)
|
||||
{
|
||||
#if 0
|
||||
case SOFTFILTER_2XBR:
|
||||
return twoxbr_get_implementation;
|
||||
break;
|
||||
#endif
|
||||
case SOFTFILTER_DARKEN:
|
||||
return darken_get_implementation;
|
||||
case SOFTFILTER_SCALE2X:
|
||||
return scale2x_get_implementation;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
rarch_softfilter_t *rarch_softfilter_new(const char *filter_path,
|
||||
unsigned threads,
|
||||
enum retro_pixel_format in_pixel_format,
|
||||
@ -95,15 +116,14 @@ rarch_softfilter_t *rarch_softfilter_new(const char *filter_path,
|
||||
if (!filt)
|
||||
return NULL;
|
||||
|
||||
(void)cb;
|
||||
#ifdef HAVE_DYLIB
|
||||
#if defined(HAVE_FILTERS_BUILTIN)
|
||||
cb = softfilter_get_implementation_from_idx(g_settings.video.filter_idx);
|
||||
#elif defined(HAVE_DYLIB)
|
||||
filt->lib = dylib_load(filter_path);
|
||||
if (!filt->lib)
|
||||
goto error;
|
||||
|
||||
cb = (softfilter_get_implementation_t)dylib_proc(filt->lib, "softfilter_get_implementation");
|
||||
#else
|
||||
// FIXME - TODO - implement for non-HAVE_DYLIB
|
||||
#endif
|
||||
if (!cb)
|
||||
{
|
||||
@ -225,7 +245,7 @@ void rarch_softfilter_free(rarch_softfilter_t *filt)
|
||||
free(filt->packets);
|
||||
if (filt->impl && filt->impl_data)
|
||||
filt->impl->destroy(filt->impl_data);
|
||||
#ifdef HAVE_DYLIB
|
||||
#if !defined(HAVE_FILTERS_BUILTIN) && defined(HAVE_DYLIB)
|
||||
if (filt->lib)
|
||||
dylib_close(filt->lib);
|
||||
#endif
|
||||
|
15
gfx/filter.h
15
gfx/filter.h
@ -44,5 +44,20 @@ void rarch_softfilter_process(rarch_softfilter_t *filt,
|
||||
void *output, size_t output_stride,
|
||||
const void *input, unsigned width, unsigned height, size_t input_stride);
|
||||
|
||||
enum
|
||||
{
|
||||
SOFTFILTER_NONE = 0,
|
||||
//SOFTFILTER_2XBR,
|
||||
SOFTFILTER_DARKEN,
|
||||
SOFTFILTER_SCALE2X,
|
||||
SOFTFILTER_LAST,
|
||||
};
|
||||
|
||||
#ifdef HAVE_FILTERS_BUILTIN
|
||||
const struct softfilter_implementation *twoxbr_get_implementation(softfilter_simd_mask_t simd);
|
||||
const struct softfilter_implementation *darken_get_implementation(softfilter_simd_mask_t simd);
|
||||
const struct softfilter_implementation *scale2x_get_implementation(softfilter_simd_mask_t simd);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -14,6 +14,10 @@
|
||||
* If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef HAVE_DYLIB
|
||||
#define HAVE_FILTERS_BUILTIN
|
||||
#endif
|
||||
|
||||
#if defined(_XBOX)
|
||||
#include "../msvc/msvc_compat.h"
|
||||
#endif
|
||||
@ -471,7 +475,8 @@ SCALERS
|
||||
/*============================================================
|
||||
FILTERS
|
||||
============================================================ */
|
||||
#ifndef HAVE_DYLIB
|
||||
|
||||
#ifdef HAVE_FILTERS_BUILTIN
|
||||
#include "../gfx/filters/2xbr.c"
|
||||
#include "../gfx/filters/darken.c"
|
||||
#include "../gfx/filters/scale2x.c"
|
||||
|
@ -301,6 +301,8 @@ unsigned rarch_get_cpu_cores(void)
|
||||
return sysinfo.dwNumberOfProcessors;
|
||||
#elif defined(ANDROID)
|
||||
return android_getCpuCount();
|
||||
#elif defined(GEKKO)
|
||||
return 1;
|
||||
#elif defined(_SC_NPROCESSORS_ONLN) // Linux, most unix-likes.
|
||||
long ret = sysconf(_SC_NPROCESSORS_ONLN);
|
||||
if (ret <= 0)
|
||||
|
Loading…
x
Reference in New Issue
Block a user