mirror of
https://github.com/libretro/RetroArch
synced 2025-04-18 14:42:30 +00:00
Flesh out filter stuff a bit more.
This commit is contained in:
parent
5cb3438389
commit
f72445798b
@ -16,6 +16,7 @@
|
|||||||
#include "filter.h"
|
#include "filter.h"
|
||||||
#include "../dynamic.h"
|
#include "../dynamic.h"
|
||||||
#include "../general.h"
|
#include "../general.h"
|
||||||
|
#include "../performance.h"
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
struct rarch_softfilter
|
struct rarch_softfilter
|
||||||
@ -50,7 +51,8 @@ rarch_softfilter_t *rarch_softfilter_new(const char *filter_path,
|
|||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
filt->impl = cb(0);
|
unsigned cpu_features = rarch_get_cpu_features();
|
||||||
|
filt->impl = cb(cpu_features);
|
||||||
if (!filt->impl)
|
if (!filt->impl)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
@ -59,6 +61,8 @@ rarch_softfilter_t *rarch_softfilter_new(const char *filter_path,
|
|||||||
filt->pix_fmt = in_pixel_format;
|
filt->pix_fmt = in_pixel_format;
|
||||||
filt->threads = threads;
|
filt->threads = threads;
|
||||||
|
|
||||||
|
filt->out_pix_fmt = in_pixel_format;
|
||||||
|
|
||||||
return filt;
|
return filt;
|
||||||
|
|
||||||
error:
|
error:
|
||||||
@ -81,12 +85,14 @@ void rarch_softfilter_free(rarch_softfilter_t *filt)
|
|||||||
void rarch_softfilter_get_max_output_size(rarch_softfilter_t *filt,
|
void rarch_softfilter_get_max_output_size(rarch_softfilter_t *filt,
|
||||||
unsigned *width, unsigned *height)
|
unsigned *width, unsigned *height)
|
||||||
{
|
{
|
||||||
|
rarch_softfilter_get_output_size(filt, width, height, filt->max_width, filt->max_height);
|
||||||
}
|
}
|
||||||
|
|
||||||
void rarch_softfilter_get_output_size(rarch_softfilter_t *filt,
|
void rarch_softfilter_get_output_size(rarch_softfilter_t *filt,
|
||||||
unsigned *out_width, unsigned *out_height,
|
unsigned *out_width, unsigned *out_height,
|
||||||
unsigned width, unsigned height)
|
unsigned width, unsigned height)
|
||||||
{
|
{
|
||||||
|
filt->impl->query_output_size(filt->impl_data, out_width, out_height, width, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
enum retro_pixel_format rarch_softfilter_get_output_format(rarch_softfilter_t *filt)
|
enum retro_pixel_format rarch_softfilter_get_output_format(rarch_softfilter_t *filt)
|
||||||
|
@ -23,10 +23,29 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define SOFTFILTER_SIMD_SSE (1 << 0)
|
||||||
|
#define SOFTFILTER_SIMD_SSE2 (1 << 1)
|
||||||
|
#define SOFTFILTER_SIMD_VMX (1 << 2)
|
||||||
|
#define SOFTFILTER_SIMD_VMX128 (1 << 3)
|
||||||
|
#define SOFTFILTER_SIMD_AVX (1 << 4)
|
||||||
|
#define SOFTFILTER_SIMD_NEON (1 << 5)
|
||||||
|
#define SOFTFILTER_SIMD_SSE3 (1 << 6)
|
||||||
|
#define SOFTFILTER_SIMD_SSSE3 (1 << 7)
|
||||||
|
#define SOFTFILTER_SIMD_MMX (1 << 8)
|
||||||
|
#define SOFTFILTER_SIMD_MMXEXT (1 << 9)
|
||||||
|
#define SOFTFILTER_SIMD_SSE4 (1 << 10)
|
||||||
|
#define SOFTFILTER_SIMD_SSE42 (1 << 11)
|
||||||
|
#define SOFTFILTER_SIMD_AVX2 (1 << 12)
|
||||||
|
#define SOFTFILTER_SIMD_VFPU (1 << 13)
|
||||||
|
#define SOFTFILTER_SIMD_PS (1 << 14)
|
||||||
|
|
||||||
|
// A bit-mask of all supported SIMD instruction sets.
|
||||||
|
// Allows an implementation to pick different softfilter_implementation structs.
|
||||||
typedef unsigned softfilter_simd_mask_t;
|
typedef unsigned softfilter_simd_mask_t;
|
||||||
|
|
||||||
// Dynamic library entrypoint.
|
// Dynamic library entrypoint.
|
||||||
typedef const struct softfilter_implementation *(*softfilter_get_implementation_t)(softfilter_simd_mask_t);
|
typedef const struct softfilter_implementation *(*softfilter_get_implementation_t)(softfilter_simd_mask_t);
|
||||||
|
// The same SIMD mask argument is forwarded to create() callback as well to avoid having to keep lots of state around.
|
||||||
const struct softfilter_implementation *softfilter_get_implementation(softfilter_simd_mask_t simd);
|
const struct softfilter_implementation *softfilter_get_implementation(softfilter_simd_mask_t simd);
|
||||||
|
|
||||||
#define SOFTFILTER_API_VERSION 1
|
#define SOFTFILTER_API_VERSION 1
|
||||||
@ -35,27 +54,48 @@ const struct softfilter_implementation *softfilter_get_implementation(softfilter
|
|||||||
#define SOFTFILTER_FMT_RGB565 (1 << 0)
|
#define SOFTFILTER_FMT_RGB565 (1 << 0)
|
||||||
#define SOFTFILTER_FMT_XRGB8888 (1 << 1)
|
#define SOFTFILTER_FMT_XRGB8888 (1 << 1)
|
||||||
|
|
||||||
|
// Softfilter implementation.
|
||||||
|
// Returns a bitmask of supported input formats.
|
||||||
typedef unsigned (*softfilter_query_input_formats_t)(void);
|
typedef unsigned (*softfilter_query_input_formats_t)(void);
|
||||||
|
|
||||||
|
// Returns a bitmask of supported output formats for a given input format.
|
||||||
typedef unsigned (*softfilter_query_output_formats_t)(unsigned input_format);
|
typedef unsigned (*softfilter_query_output_formats_t)(unsigned input_format);
|
||||||
|
|
||||||
|
// In softfilter_process_t, the softfilter implementation submits work units to a worker thread pool.
|
||||||
typedef void (*softfilter_work_t)(void *userdata, void *thread_data);
|
typedef void (*softfilter_work_t)(void *userdata, void *thread_data);
|
||||||
typedef void (*softfilter_submit_t)(softfilter_work_t work, void *userdata);
|
struct softfilter_work_packet
|
||||||
|
{
|
||||||
|
softfilter_work_t work;
|
||||||
|
void *userdata;
|
||||||
|
void *thread_data;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Create a filter with given input and output formats as well as maximum possible input size.
|
||||||
|
// Input sizes can very per call to softfilter_process_t, but they will never be larger than the maximum.
|
||||||
typedef void *(*softfilter_create_t)(unsigned in_fmt, unsigned out_fmt,
|
typedef void *(*softfilter_create_t)(unsigned in_fmt, unsigned out_fmt,
|
||||||
unsigned max_width, unsigned max_height,
|
unsigned max_width, unsigned max_height,
|
||||||
unsigned threads);
|
unsigned threads, softfilter_simd_mask_t simd);
|
||||||
typedef void (*softfilter_destroy_t)(void *data);
|
typedef void (*softfilter_destroy_t)(void *data);
|
||||||
|
|
||||||
|
// Given an input size, query the output size of the filter.
|
||||||
|
// If width and height == max_width/max_height, no other combination of width/height must return a larger size in any dimension.
|
||||||
typedef void (*softfilter_query_output_size_t)(void *data,
|
typedef void (*softfilter_query_output_size_t)(void *data,
|
||||||
unsigned *out_width, unsigned *out_height,
|
unsigned *out_width, unsigned *out_height,
|
||||||
unsigned width, unsigned height);
|
unsigned width, unsigned height);
|
||||||
|
|
||||||
|
// Process a frame. The filter submits work by filling in the packets array.
|
||||||
|
// The number of elements in the array is as returned by query_num_threads.
|
||||||
|
// The processing itself happens in worker threads after this returns.
|
||||||
|
// The filter can ignore the process callback.
|
||||||
typedef void (*softfilter_process_t)(void *data,
|
typedef void (*softfilter_process_t)(void *data,
|
||||||
softfilter_submit_t callback,
|
struct softfilter_work_packet *packets,
|
||||||
void *output, size_t output_stride,
|
void *output, size_t output_stride,
|
||||||
const void *input, unsigned width, unsigned height, size_t input_stride);
|
const void *input, unsigned width, unsigned height, size_t input_stride);
|
||||||
|
|
||||||
typedef unsigned (*softfilter_query_num_threads_t)(void *data, unsigned desired_threads);
|
// Returns the number of worker threads the filter will use.
|
||||||
|
// This can differ from the value passed to create() instead the filter cannot be parallelized, etc. The number of threads must be less-or-equal compared to the value passed to create().
|
||||||
|
typedef unsigned (*softfilter_query_num_threads_t)(void *data);
|
||||||
|
/////
|
||||||
|
|
||||||
struct softfilter_implementation
|
struct softfilter_implementation
|
||||||
{
|
{
|
||||||
@ -69,8 +109,8 @@ struct softfilter_implementation
|
|||||||
softfilter_query_output_size_t query_output_size;
|
softfilter_query_output_size_t query_output_size;
|
||||||
softfilter_process_t process;
|
softfilter_process_t process;
|
||||||
|
|
||||||
const char *ident;
|
const char *ident; // Human readable identifier of implementation.
|
||||||
unsigned api_version;
|
unsigned api_version; // Must be SOFTFILTER_API_VERSION
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
Loading…
x
Reference in New Issue
Block a user