Compile in filters for console ports (HAVE_DYLIB not defined in

Griffin)
This commit is contained in:
twinaphex 2014-04-16 02:09:09 +02:00
parent 4cd1094151
commit 45c917afa4
9 changed files with 72 additions and 90 deletions

View File

@ -1281,7 +1281,6 @@ void uninit_audio(void)
compute_audio_buffer_statistics();
}
#ifdef HAVE_DYLIB
void rarch_deinit_filter(void)
{
rarch_softfilter_free(g_extern.filter.filter);
@ -1291,7 +1290,6 @@ void rarch_deinit_filter(void)
void rarch_init_filter(enum retro_pixel_format colfmt)
{
unsigned i;
rarch_deinit_filter();
if (!*g_settings.video.filter_path)
return;
@ -1343,7 +1341,6 @@ error:
RARCH_ERR("Softfilter init failed.\n");
rarch_deinit_filter();
}
#endif
static void deinit_shader_dir(void)
{
@ -1407,9 +1404,7 @@ static bool init_video_pixel_converter(unsigned size)
void init_video_input(void)
{
#ifdef HAVE_DYLIB
rarch_init_filter(g_extern.system.pix_fmt);
#endif
init_shader_dir();
@ -1590,9 +1585,7 @@ void uninit_video_input(void)
deinit_pixel_converter();
#ifdef HAVE_DYLIB
rarch_deinit_filter();
#endif
deinit_shader_dir();
compute_monitor_fps_statistics();

View File

@ -777,6 +777,7 @@ int menu_set_settings(void *data, unsigned setting, unsigned action)
case RGUI_SETTINGS_VIDEO_SOFTFILTER:
switch (action)
{
#ifdef HAVE_DYLIB
case RGUI_ACTION_OK:
file_list_push(rgui->menu_stack, g_settings.video.filter_dir, setting, rgui->selection_ptr);
menu_clear_navigation(rgui);
@ -788,6 +789,7 @@ int menu_set_settings(void *data, unsigned setting, unsigned action)
break;
default:
break;
#endif
}
break;

View File

@ -64,7 +64,9 @@ static void filter_thread_loop(void *data)
struct rarch_softfilter
{
#ifdef HAVE_DYLIB
dylib_t lib;
#endif
const struct softfilter_implementation *impl;
void *impl_data;
@ -93,11 +95,16 @@ rarch_softfilter_t *rarch_softfilter_new(const char *filter_path,
if (!filt)
return NULL;
(void)cb;
#ifdef 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)
{
RARCH_ERR("Couldn't find softfilter symbol.\n");
@ -218,8 +225,10 @@ 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 (filt->lib)
dylib_close(filt->lib);
#endif
#ifdef HAVE_THREADS
for (i = 0; i < filt->threads; i++)
{

View File

@ -259,25 +259,6 @@ static unsigned twoxbr_generic_output_fmts(unsigned input_fmts)
return input_fmts;
}
struct thread_data
{
void *out_data;
const void *in_data;
size_t out_pitch;
size_t in_pitch;
unsigned width;
unsigned height;
int first, last;
};
struct filter_data
{
unsigned threads;
struct thread_data *workers;
unsigned in_fmt;
};
static unsigned twoxbr_generic_threads(void *data)
{
struct filter_data *filt = (struct filter_data*)data;
@ -293,7 +274,7 @@ static void *twoxbr_generic_create(unsigned in_fmt, unsigned out_fmt,
struct filter_data *filt = (struct filter_data*)calloc(1, sizeof(*filt));
if (!filt)
return NULL;
filt->workers = (struct thread_data*)calloc(threads, sizeof(struct thread_data));
filt->workers = (struct softfilter_thread_data*)calloc(threads, sizeof(struct softfilter_thread_data));
filt->threads = threads;
filt->in_fmt = in_fmt;
if (!filt->workers)
@ -318,9 +299,9 @@ static void twoxbr_generic_destroy(void *data)
free(filt);
}
static void work_cb_rgb565(void *data, void *thread_data)
static void twoxbr_work_cb_rgb565(void *data, void *thread_data)
{
struct thread_data *thr = (struct thread_data*)thread_data;
struct softfilter_thread_data *thr = (struct softfilter_thread_data*)thread_data;
const uint16_t *input = (const uint16_t*)thr->in_data;
uint16_t *output = (uint16_t*)thr->out_data;
unsigned width = thr->width;
@ -339,7 +320,7 @@ static void twoxbr_generic_packets(void *data,
unsigned i;
for (i = 0; i < filt->threads; i++)
{
struct thread_data *thr = &filt->workers[i];
struct softfilter_thread_data *thr = (struct softfilter_thread_data*)&filt->workers[i];
unsigned y_start = (height * i) / filt->threads;
unsigned y_end = (height * (i + 1)) / filt->threads;
@ -355,7 +336,7 @@ static void twoxbr_generic_packets(void *data,
thr->last = y_end == height;
if (filt->in_fmt == SOFTFILTER_FMT_RGB565)
packets[i].work = work_cb_rgb565;
packets[i].work = twoxbr_work_cb_rgb565;
packets[i].thread_data = thr;
}
}
@ -379,3 +360,7 @@ const struct softfilter_implementation *softfilter_get_implementation(softfilter
(void)simd;
return &twoxbr_generic;
}
#ifdef RARCH_INTERNAL
#undef softfilter_get_implementation
#endif

View File

@ -34,23 +34,6 @@ static unsigned darken_output_fmts(unsigned input_fmts)
return input_fmts;
}
struct thread_data
{
void *out_data;
const void *in_data;
size_t out_pitch;
size_t in_pitch;
unsigned width;
unsigned height;
};
struct filter_data
{
unsigned threads;
struct thread_data *workers;
unsigned in_fmt;
};
static unsigned darken_threads(void *data)
{
struct filter_data *filt = (struct filter_data*)data;
@ -66,7 +49,7 @@ static void *darken_create(unsigned in_fmt, unsigned out_fmt,
struct filter_data *filt = (struct filter_data*)calloc(1, sizeof(*filt));
if (!filt)
return NULL;
filt->workers = calloc(threads, sizeof(struct thread_data));
filt->workers = calloc(threads, sizeof(struct softfilter_thread_data));
filt->threads = threads;
filt->in_fmt = in_fmt;
if (!filt->workers)
@ -91,9 +74,9 @@ static void darken_destroy(void *data)
free(filt);
}
static void work_cb_xrgb8888(void *data, void *thread_data)
static void darken_work_cb_xrgb8888(void *data, void *thread_data)
{
struct thread_data *thr = (struct thread_data*)thread_data;
struct softfilter_thread_data *thr = (struct softfilter_thread_data*)thread_data;
const uint32_t *input = (const uint32_t*)thr->in_data;
uint32_t *output = (uint32_t*)thr->out_data;
unsigned width = thr->width;
@ -105,9 +88,9 @@ static void work_cb_xrgb8888(void *data, void *thread_data)
output[x] = (input[x] >> 2) & (0x3f * 0x01010101);
}
static void work_cb_rgb565(void *data, void *thread_data)
static void darken_work_cb_rgb565(void *data, void *thread_data)
{
struct thread_data *thr = (struct thread_data*)thread_data;
struct softfilter_thread_data *thr = (struct softfilter_thread_data*)thread_data;
const uint16_t *input = (const uint16_t*)thr->in_data;
uint16_t *output = (uint16_t*)thr->out_data;
unsigned width = thr->width;
@ -128,7 +111,7 @@ static void darken_packets(void *data,
struct filter_data *filt = (struct filter_data*)data;
for (i = 0; i < filt->threads; i++)
{
struct thread_data *thr = (struct thread_data*)&filt->workers[i];
struct softfilter_thread_data *thr = (struct softfilter_thread_data*)&filt->workers[i];
unsigned y_start = (height * i) / filt->threads;
unsigned y_end = (height * (i + 1)) / filt->threads;
thr->out_data = (uint8_t*)output + y_start * output_stride;
@ -139,9 +122,9 @@ static void darken_packets(void *data,
thr->height = y_end - y_start;
if (filt->in_fmt == SOFTFILTER_FMT_XRGB8888)
packets[i].work = work_cb_xrgb8888;
packets[i].work = darken_work_cb_xrgb8888;
else if (filt->in_fmt == SOFTFILTER_FMT_RGB565)
packets[i].work = work_cb_rgb565;
packets[i].work = darken_work_cb_rgb565;
packets[i].thread_data = thr;
}
}
@ -165,3 +148,7 @@ const struct softfilter_implementation *softfilter_get_implementation(softfilter
(void)simd;
return &darken;
}
#ifdef RARCH_INTERNAL
#undef softfilter_get_implementation
#endif

View File

@ -93,25 +93,6 @@ static unsigned scale2x_generic_output_fmts(unsigned input_fmts)
return input_fmts;
}
struct thread_data
{
void *out_data;
const void *in_data;
size_t out_pitch;
size_t in_pitch;
unsigned width;
unsigned height;
int first, last;
};
struct filter_data
{
unsigned threads;
struct thread_data *workers;
unsigned in_fmt;
};
static unsigned scale2x_generic_threads(void *data)
{
struct filter_data *filt = (struct filter_data*)data;
@ -127,7 +108,7 @@ static void *scale2x_generic_create(unsigned in_fmt, unsigned out_fmt,
struct filter_data *filt = (struct filter_data*)calloc(1, sizeof(*filt));
if (!filt)
return NULL;
filt->workers = (struct thread_data*)calloc(threads, sizeof(struct thread_data));
filt->workers = (struct softfilter_thread_data*)calloc(threads, sizeof(struct softfilter_thread_data));
filt->threads = threads;
filt->in_fmt = in_fmt;
if (!filt->workers)
@ -152,9 +133,9 @@ static void scale2x_generic_destroy(void *data)
free(filt);
}
static void work_cb_xrgb8888(void *data, void *thread_data)
static void scale2x_work_cb_xrgb8888(void *data, void *thread_data)
{
struct thread_data *thr = (struct thread_data*)thread_data;
struct softfilter_thread_data *thr = (struct softfilter_thread_data*)thread_data;
const uint32_t *input = (const uint32_t*)thr->in_data;
uint32_t *output = (uint32_t*)thr->out_data;
unsigned width = thr->width;
@ -164,9 +145,9 @@ static void work_cb_xrgb8888(void *data, void *thread_data)
thr->first, thr->last, input, thr->in_pitch / SOFTFILTER_BPP_XRGB8888, output, thr->out_pitch / SOFTFILTER_BPP_XRGB8888);
}
static void work_cb_rgb565(void *data, void *thread_data)
static void scale2x_work_cb_rgb565(void *data, void *thread_data)
{
struct thread_data *thr = (struct thread_data*)thread_data;
struct softfilter_thread_data *thr = (struct softfilter_thread_data*)thread_data;
const uint16_t *input = (const uint16_t*)thr->in_data;
uint16_t *output = (uint16_t*)thr->out_data;
unsigned width = thr->width;
@ -185,7 +166,7 @@ static void scale2x_generic_packets(void *data,
unsigned i;
for (i = 0; i < filt->threads; i++)
{
struct thread_data *thr = &filt->workers[i];
struct softfilter_thread_data *thr = (struct softfilter_thread_data*)&filt->workers[i];
unsigned y_start = (height * i) / filt->threads;
unsigned y_end = (height * (i + 1)) / filt->threads;
@ -201,9 +182,9 @@ static void scale2x_generic_packets(void *data,
thr->last = y_end == height;
if (filt->in_fmt == SOFTFILTER_FMT_XRGB8888)
packets[i].work = work_cb_xrgb8888;
packets[i].work = scale2x_work_cb_xrgb8888;
else if (filt->in_fmt == SOFTFILTER_FMT_RGB565)
packets[i].work = work_cb_rgb565;
packets[i].work = scale2x_work_cb_rgb565;
packets[i].thread_data = thr;
}
}
@ -227,3 +208,7 @@ const struct softfilter_implementation *softfilter_get_implementation(softfilter
(void)simd;
return &scale2x_generic;
}
#ifdef RARCH_INTERNAL
#undef softfilter_get_implementation
#endif

View File

@ -98,6 +98,25 @@ typedef void (*softfilter_get_work_packets_t)(void *data,
typedef unsigned (*softfilter_query_num_threads_t)(void *data);
/////
struct softfilter_thread_data
{
void *out_data;
const void *in_data;
size_t out_pitch;
size_t in_pitch;
unsigned width;
unsigned height;
int first;
int last;
};
struct filter_data
{
unsigned threads;
struct softfilter_thread_data *workers;
unsigned in_fmt;
};
struct softfilter_implementation
{
softfilter_query_input_formats_t query_input_formats;

View File

@ -468,14 +468,21 @@ SCALERS
#include "../gfx/scaler/scaler.c"
#include "../gfx/scaler/scaler_int.c"
/*============================================================
FILTERS
============================================================ */
#ifndef HAVE_DYLIB
#include "../gfx/filters/2xbr.c"
#include "../gfx/filters/darken.c"
#include "../gfx/filters/scale2x.c"
#endif
/*============================================================
DYNAMIC
============================================================ */
#include "../dynamic.c"
#include "../dynamic_dummy.c"
#ifdef HAVE_DYLIB
#include "../gfx/filter.c"
#endif
/*============================================================
FILE

View File

@ -304,7 +304,6 @@ static void video_frame(const void *data, unsigned width, unsigned height, size_
const char *msg = msg_queue_pull(g_extern.msg_queue);
driver.current_msg = msg;
#ifdef HAVE_DYLIB
if (g_extern.filter.filter && data)
{
unsigned owidth = 0;
@ -332,10 +331,6 @@ static void video_frame(const void *data, unsigned width, unsigned height, size_
}
else if (!video_frame_func(data, width, height, pitch, msg))
g_extern.video_active = false;
#else
if (!video_frame_func(data, width, height, pitch, msg))
g_extern.video_active = false;
#endif
}
void rarch_render_cached_frame(void)