mirror of
https://github.com/libretro/RetroArch
synced 2025-04-24 06:02:36 +00:00
Style nits
This commit is contained in:
parent
4835f1df53
commit
c6c1fbbf0a
@ -51,7 +51,8 @@ struct rarch_dsp_filter
|
|||||||
unsigned num_instances;
|
unsigned num_instances;
|
||||||
};
|
};
|
||||||
|
|
||||||
static const struct dspfilter_implementation *find_implementation(rarch_dsp_filter_t *dsp, const char *ident)
|
static const struct dspfilter_implementation *find_implementation(
|
||||||
|
rarch_dsp_filter_t *dsp, const char *ident)
|
||||||
{
|
{
|
||||||
unsigned i;
|
unsigned i;
|
||||||
for (i = 0; i < dsp->num_plugs; i++)
|
for (i = 0; i < dsp->num_plugs; i++)
|
||||||
@ -69,7 +70,8 @@ struct dsp_userdata
|
|||||||
const char *prefix[2];
|
const char *prefix[2];
|
||||||
};
|
};
|
||||||
|
|
||||||
static int get_float(void *userdata, const char *key_str, float *value, float default_value)
|
static int get_float(void *userdata, const char *key_str,
|
||||||
|
float *value, float default_value)
|
||||||
{
|
{
|
||||||
struct dsp_userdata *dsp = (struct dsp_userdata*)userdata;
|
struct dsp_userdata *dsp = (struct dsp_userdata*)userdata;
|
||||||
|
|
||||||
@ -85,7 +87,8 @@ static int get_float(void *userdata, const char *key_str, float *value, float de
|
|||||||
return got;
|
return got;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int get_int(void *userdata, const char *key_str, int *value, int default_value)
|
static int get_int(void *userdata, const char *key_str,
|
||||||
|
int *value, int default_value)
|
||||||
{
|
{
|
||||||
struct dsp_userdata *dsp = (struct dsp_userdata*)userdata;
|
struct dsp_userdata *dsp = (struct dsp_userdata*)userdata;
|
||||||
|
|
||||||
@ -185,7 +188,8 @@ static bool create_filter_graph(rarch_dsp_filter_t *dsp, float sample_rate)
|
|||||||
if (!config_get_uint(dsp->conf, "filters", &filters))
|
if (!config_get_uint(dsp->conf, "filters", &filters))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
dsp->instances = (struct rarch_dsp_instance*)calloc(filters, sizeof(*dsp->instances));
|
dsp->instances = (struct rarch_dsp_instance*)
|
||||||
|
calloc(filters, sizeof(*dsp->instances));
|
||||||
if (!dsp->instances)
|
if (!dsp->instances)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@ -206,7 +210,8 @@ static bool create_filter_graph(rarch_dsp_filter_t *dsp, float sample_rate)
|
|||||||
|
|
||||||
struct dsp_userdata userdata;
|
struct dsp_userdata userdata;
|
||||||
userdata.conf = dsp->conf;
|
userdata.conf = dsp->conf;
|
||||||
userdata.prefix[0] = key; // Index-specific configs take priority over ident-specific.
|
/* Index-specific configs take priority over ident-specific. */
|
||||||
|
userdata.prefix[0] = key;
|
||||||
userdata.prefix[1] = dsp->instances[i].impl->short_ident;
|
userdata.prefix[1] = dsp->instances[i].impl->short_ident;
|
||||||
|
|
||||||
struct dspfilter_info info = { sample_rate };
|
struct dspfilter_info info = { sample_rate };
|
||||||
@ -242,7 +247,8 @@ static bool append_plugs(rarch_dsp_filter_t *dsp)
|
|||||||
unsigned i;
|
unsigned i;
|
||||||
dspfilter_simd_mask_t mask = rarch_get_cpu_features();
|
dspfilter_simd_mask_t mask = rarch_get_cpu_features();
|
||||||
|
|
||||||
dsp->plugs = (struct rarch_dsp_plug*)calloc(ARRAY_SIZE(dsp_plugs_builtin), sizeof(*dsp->plugs));
|
dsp->plugs = (struct rarch_dsp_plug*)
|
||||||
|
calloc(ARRAY_SIZE(dsp_plugs_builtin), sizeof(*dsp->plugs));
|
||||||
if (!dsp->plugs)
|
if (!dsp->plugs)
|
||||||
return false;
|
return false;
|
||||||
dsp->num_plugs = ARRAY_SIZE(dsp_plugs_builtin);
|
dsp->num_plugs = ARRAY_SIZE(dsp_plugs_builtin);
|
||||||
@ -268,7 +274,8 @@ static bool append_plugs(rarch_dsp_filter_t *dsp, struct string_list *list)
|
|||||||
if (!lib)
|
if (!lib)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
dspfilter_get_implementation_t cb = (dspfilter_get_implementation_t)dylib_proc(lib, "dspfilter_get_implementation");
|
dspfilter_get_implementation_t cb = (dspfilter_get_implementation_t)
|
||||||
|
dylib_proc(lib, "dspfilter_get_implementation");
|
||||||
if (!cb)
|
if (!cb)
|
||||||
{
|
{
|
||||||
dylib_close(lib);
|
dylib_close(lib);
|
||||||
@ -288,7 +295,8 @@ static bool append_plugs(rarch_dsp_filter_t *dsp, struct string_list *list)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct rarch_dsp_plug *new_plugs = (struct rarch_dsp_plug*)realloc(dsp->plugs, sizeof(*dsp->plugs) * (dsp->num_plugs + 1));
|
struct rarch_dsp_plug *new_plugs = (struct rarch_dsp_plug*)
|
||||||
|
realloc(dsp->plugs, sizeof(*dsp->plugs) * (dsp->num_plugs + 1));
|
||||||
if (!new_plugs)
|
if (!new_plugs)
|
||||||
{
|
{
|
||||||
dylib_close(lib);
|
dylib_close(lib);
|
||||||
@ -307,7 +315,8 @@ static bool append_plugs(rarch_dsp_filter_t *dsp, struct string_list *list)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
rarch_dsp_filter_t *rarch_dsp_filter_new(const char *filter_config, float sample_rate)
|
rarch_dsp_filter_t *rarch_dsp_filter_new(
|
||||||
|
const char *filter_config, float sample_rate)
|
||||||
{
|
{
|
||||||
#if !defined(HAVE_FILTERS_BUILTIN) && defined(HAVE_DYLIB)
|
#if !defined(HAVE_FILTERS_BUILTIN) && defined(HAVE_DYLIB)
|
||||||
char basedir[PATH_MAX];
|
char basedir[PATH_MAX];
|
||||||
@ -381,7 +390,8 @@ void rarch_dsp_filter_free(rarch_dsp_filter_t *dsp)
|
|||||||
free(dsp);
|
free(dsp);
|
||||||
}
|
}
|
||||||
|
|
||||||
void rarch_dsp_filter_process(rarch_dsp_filter_t *dsp, struct rarch_dsp_data *data)
|
void rarch_dsp_filter_process(rarch_dsp_filter_t *dsp,
|
||||||
|
struct rarch_dsp_data *data)
|
||||||
{
|
{
|
||||||
unsigned i;
|
unsigned i;
|
||||||
struct dspfilter_output output = {0};
|
struct dspfilter_output output = {0};
|
||||||
@ -394,7 +404,8 @@ void rarch_dsp_filter_process(rarch_dsp_filter_t *dsp, struct rarch_dsp_data *da
|
|||||||
{
|
{
|
||||||
input.samples = output.samples;
|
input.samples = output.samples;
|
||||||
input.frames = output.frames;
|
input.frames = output.frames;
|
||||||
dsp->instances[i].impl->process(dsp->instances[i].impl_data, &output, &input);
|
dsp->instances[i].impl->process(
|
||||||
|
dsp->instances[i].impl_data, &output, &input);
|
||||||
}
|
}
|
||||||
|
|
||||||
data->output = output.samples;
|
data->output = output.samples;
|
||||||
|
@ -18,7 +18,8 @@
|
|||||||
|
|
||||||
typedef struct rarch_dsp_filter rarch_dsp_filter_t;
|
typedef struct rarch_dsp_filter rarch_dsp_filter_t;
|
||||||
|
|
||||||
rarch_dsp_filter_t *rarch_dsp_filter_new(const char *filter_config, float sample_rate);
|
rarch_dsp_filter_t *rarch_dsp_filter_new(const char *filter_config,
|
||||||
|
float sample_rate);
|
||||||
|
|
||||||
void rarch_dsp_filter_free(rarch_dsp_filter_t *dsp);
|
void rarch_dsp_filter_free(rarch_dsp_filter_t *dsp);
|
||||||
|
|
||||||
@ -27,12 +28,13 @@ struct rarch_dsp_data
|
|||||||
float *input;
|
float *input;
|
||||||
unsigned input_frames;
|
unsigned input_frames;
|
||||||
|
|
||||||
// Set by rarch_dsp_filter_process().
|
/* Set by rarch_dsp_filter_process(). */
|
||||||
float *output;
|
float *output;
|
||||||
unsigned output_frames;
|
unsigned output_frames;
|
||||||
};
|
};
|
||||||
|
|
||||||
void rarch_dsp_filter_process(rarch_dsp_filter_t *dsp, struct rarch_dsp_data *data);
|
void rarch_dsp_filter_process(rarch_dsp_filter_t *dsp,
|
||||||
|
struct rarch_dsp_data *data);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -39,7 +39,9 @@ static int find_resampler_driver_index(const char *driver)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Resampler is used by multiple modules so avoid clobbering g_extern.audio_data.resampler here.
|
/* Resampler is used by multiple modules so avoid
|
||||||
|
* clobbering g_extern.audio_data.resampler here. */
|
||||||
|
|
||||||
static const rarch_resampler_t *find_resampler_driver(const char *ident)
|
static const rarch_resampler_t *find_resampler_driver(const char *ident)
|
||||||
{
|
{
|
||||||
int i = find_resampler_driver_index(ident);
|
int i = find_resampler_driver_index(ident);
|
||||||
@ -64,22 +66,27 @@ void find_prev_resampler_driver(void)
|
|||||||
{
|
{
|
||||||
int i = find_resampler_driver_index(g_settings.audio.resampler);
|
int i = find_resampler_driver_index(g_settings.audio.resampler);
|
||||||
if (i > 0)
|
if (i > 0)
|
||||||
strlcpy(g_settings.audio.resampler, resampler_drivers[i - 1]->ident, sizeof(g_settings.audio.resampler));
|
strlcpy(g_settings.audio.resampler, resampler_drivers[i - 1]->ident,
|
||||||
|
sizeof(g_settings.audio.resampler));
|
||||||
else
|
else
|
||||||
RARCH_WARN("Couldn't find any previous resampler driver (current one: \"%s\").\n", g_extern.audio_data.resampler->ident);
|
RARCH_WARN("Couldn't find any previous resampler driver (current one: \"%s\").\n",
|
||||||
|
g_extern.audio_data.resampler->ident);
|
||||||
}
|
}
|
||||||
|
|
||||||
void find_next_resampler_driver(void)
|
void find_next_resampler_driver(void)
|
||||||
{
|
{
|
||||||
int i = find_resampler_driver_index(g_settings.audio.resampler);
|
int i = find_resampler_driver_index(g_settings.audio.resampler);
|
||||||
if (i >= 0 && resampler_drivers[i + 1])
|
if (i >= 0 && resampler_drivers[i + 1])
|
||||||
strlcpy(g_settings.audio.resampler, resampler_drivers[i + 1]->ident, sizeof(g_settings.audio.resampler));
|
strlcpy(g_settings.audio.resampler, resampler_drivers[i + 1]->ident,
|
||||||
|
sizeof(g_settings.audio.resampler));
|
||||||
else
|
else
|
||||||
RARCH_WARN("Couldn't find any next resampler driver (current one: \"%s\").\n", g_extern.audio_data.resampler->ident);
|
RARCH_WARN("Couldn't find any next resampler driver (current one: \"%s\").\n",
|
||||||
|
g_extern.audio_data.resampler->ident);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
bool rarch_resampler_realloc(void **re, const rarch_resampler_t **backend, const char *ident, double bw_ratio)
|
bool rarch_resampler_realloc(void **re, const rarch_resampler_t **backend,
|
||||||
|
const char *ident, double bw_ratio)
|
||||||
{
|
{
|
||||||
if (*re && *backend)
|
if (*re && *backend)
|
||||||
(*backend)->free(*re);
|
(*backend)->free(*re);
|
||||||
|
@ -26,8 +26,8 @@
|
|||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include "../boolean.h"
|
#include "../boolean.h"
|
||||||
|
|
||||||
// M_PI is left out of ISO C99 :(
|
|
||||||
#ifndef M_PI
|
#ifndef M_PI
|
||||||
|
/* M_PI is left out of ISO C99 :( */
|
||||||
#define M_PI 3.14159265358979323846264338327
|
#define M_PI 3.14159265358979323846264338327
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -44,7 +44,9 @@ struct resampler_data
|
|||||||
|
|
||||||
typedef struct rarch_resampler
|
typedef struct rarch_resampler
|
||||||
{
|
{
|
||||||
void *(*init)(double bandwidth_mod); // Bandwidth factor. Will be < 1.0 for downsampling, > 1.0 for upsamling. Corresponds to expected resampling ratio.
|
/* Bandwidth factor. Will be < 1.0 for downsampling, > 1.0 for upsamling.
|
||||||
|
* Corresponds to expected resampling ratio. */
|
||||||
|
void *(*init)(double bandwidth_mod);
|
||||||
void (*process)(void *re, struct resampler_data *data);
|
void (*process)(void *re, struct resampler_data *data);
|
||||||
void (*free)(void *re);
|
void (*free)(void *re);
|
||||||
const char *ident;
|
const char *ident;
|
||||||
@ -53,12 +55,14 @@ typedef struct rarch_resampler
|
|||||||
extern const rarch_resampler_t sinc_resampler;
|
extern const rarch_resampler_t sinc_resampler;
|
||||||
extern const rarch_resampler_t CC_resampler;
|
extern const rarch_resampler_t CC_resampler;
|
||||||
|
|
||||||
// Reallocs resampler. Will free previous handle before allocating a new one.
|
/* Reallocs resampler. Will free previous handle before
|
||||||
// If ident is NULL, first resampler will be used.
|
* allocating a new one. If ident is NULL, first resampler will be used. */
|
||||||
bool rarch_resampler_realloc(void **re, const rarch_resampler_t **backend, const char *ident, double bw_ratio);
|
bool rarch_resampler_realloc(void **re, const rarch_resampler_t **backend,
|
||||||
|
const char *ident, double bw_ratio);
|
||||||
|
|
||||||
// Convenience macros.
|
/* Convenience macros.
|
||||||
// freep makes sure to set handles to NULL to avoid double-free in rarch_resampler_realloc.
|
* freep makes sure to set handles to NULL to avoid double-free
|
||||||
|
* in rarch_resampler_realloc. */
|
||||||
#define rarch_resampler_freep(backend, handle) do { \
|
#define rarch_resampler_freep(backend, handle) do { \
|
||||||
if (*(backend) && *(handle)) \
|
if (*(backend) && *(handle)) \
|
||||||
(*backend)->free(*handle); \
|
(*backend)->free(*handle); \
|
||||||
|
@ -42,7 +42,8 @@ void audio_convert_float_to_s16_C(int16_t *out,
|
|||||||
for (i = 0; i < samples; i++)
|
for (i = 0; i < samples; i++)
|
||||||
{
|
{
|
||||||
int32_t val = (int32_t)(in[i] * 0x8000);
|
int32_t val = (int32_t)(in[i] * 0x8000);
|
||||||
out[i] = (val > 0x7FFF) ? 0x7FFF : (val < -0x8000 ? -0x8000 : (int16_t)val);
|
out[i] = (val > 0x7FFF) ? 0x7FFF :
|
||||||
|
(val < -0x8000 ? -0x8000 : (int16_t)val);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -98,7 +99,9 @@ void audio_convert_s16_to_float_altivec(float *out,
|
|||||||
size_t samples_in = samples;
|
size_t samples_in = samples;
|
||||||
const vector float gain_vec = { gain, gain , gain, gain };
|
const vector float gain_vec = { gain, gain , gain, gain };
|
||||||
const vector float zero_vec = { 0.0f, 0.0f, 0.0f, 0.0f};
|
const vector float zero_vec = { 0.0f, 0.0f, 0.0f, 0.0f};
|
||||||
// Unaligned loads/store is a bit expensive, so we optimize for the good path (very likely).
|
|
||||||
|
/* Unaligned loads/store is a bit expensive, so we
|
||||||
|
* optimize for the good path (very likely). */
|
||||||
if (((uintptr_t)out & 15) + ((uintptr_t)in & 15) == 0)
|
if (((uintptr_t)out & 15) + ((uintptr_t)in & 15) == 0)
|
||||||
{
|
{
|
||||||
size_t i;
|
size_t i;
|
||||||
@ -123,7 +126,9 @@ void audio_convert_float_to_s16_altivec(int16_t *out,
|
|||||||
const float *in, size_t samples)
|
const float *in, size_t samples)
|
||||||
{
|
{
|
||||||
int samples_in = samples;
|
int samples_in = samples;
|
||||||
// Unaligned loads/store is a bit expensive, so we optimize for the good path (very likely).
|
|
||||||
|
/* Unaligned loads/store is a bit expensive,
|
||||||
|
* so we optimize for the good path (very likely). */
|
||||||
if (((uintptr_t)out & 15) + ((uintptr_t)in & 15) == 0)
|
if (((uintptr_t)out & 15) + ((uintptr_t)in & 15) == 0)
|
||||||
{
|
{
|
||||||
size_t i;
|
size_t i;
|
||||||
@ -141,21 +146,26 @@ void audio_convert_float_to_s16_altivec(int16_t *out,
|
|||||||
audio_convert_float_to_s16_C(out, in, samples_in);
|
audio_convert_float_to_s16_C(out, in, samples_in);
|
||||||
}
|
}
|
||||||
#elif defined(__ARM_NEON__)
|
#elif defined(__ARM_NEON__)
|
||||||
void audio_convert_s16_float_asm(float *out, const int16_t *in, size_t samples, const float *gain); // Avoid potential hard-float/soft-float ABI issues.
|
/* Avoid potential hard-float/soft-float ABI issues. */
|
||||||
static void audio_convert_s16_to_float_neon(float *out, const int16_t *in, size_t samples,
|
void audio_convert_s16_float_asm(float *out, const int16_t *in,
|
||||||
float gain)
|
size_t samples, const float *gain);
|
||||||
|
|
||||||
|
static void audio_convert_s16_to_float_neon(float *out,
|
||||||
|
const int16_t *in, size_t samples, float gain)
|
||||||
{
|
{
|
||||||
size_t aligned_samples = samples & ~7;
|
size_t aligned_samples = samples & ~7;
|
||||||
if (aligned_samples)
|
if (aligned_samples)
|
||||||
audio_convert_s16_float_asm(out, in, aligned_samples, &gain);
|
audio_convert_s16_float_asm(out, in, aligned_samples, &gain);
|
||||||
|
|
||||||
// Could do all conversion in ASM, but keep it simple for now.
|
/* Could do all conversion in ASM, but keep it simple for now. */
|
||||||
audio_convert_s16_to_float_C(out + aligned_samples, in + aligned_samples,
|
audio_convert_s16_to_float_C(out + aligned_samples, in + aligned_samples,
|
||||||
samples - aligned_samples, gain);
|
samples - aligned_samples, gain);
|
||||||
}
|
}
|
||||||
|
|
||||||
void audio_convert_float_s16_asm(int16_t *out, const float *in, size_t samples);
|
void audio_convert_float_s16_asm(int16_t *out, const float *in, size_t samples);
|
||||||
static void audio_convert_float_to_s16_neon(int16_t *out, const float *in, size_t samples)
|
|
||||||
|
static void audio_convert_float_to_s16_neon(int16_t *out,
|
||||||
|
const float *in, size_t samples)
|
||||||
{
|
{
|
||||||
size_t aligned_samples = samples & ~7;
|
size_t aligned_samples = samples & ~7;
|
||||||
if (aligned_samples)
|
if (aligned_samples)
|
||||||
@ -169,8 +179,9 @@ void audio_convert_s16_to_float_ALLEGREX(float *out,
|
|||||||
const int16_t *in, size_t samples, float gain)
|
const int16_t *in, size_t samples, float gain)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
// Make sure the buffer is 16 byte aligned, this should be the default behaviour of malloc in the PSPSDK.
|
/* Make sure the buffer is 16 byte aligned, this should be the
|
||||||
// Only the output buffer can be assumed to be 16-byte aligned.
|
* default behaviour of malloc in the PSPSDK.
|
||||||
|
* Only the output buffer can be assumed to be 16-byte aligned. */
|
||||||
rarch_assert(((uintptr_t)out & 0xf) == 0);
|
rarch_assert(((uintptr_t)out & 0xf) == 0);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -227,8 +238,9 @@ void audio_convert_float_to_s16_ALLEGREX(int16_t *out,
|
|||||||
const float *in, size_t samples)
|
const float *in, size_t samples)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
// Make sure the buffers are 16 byte aligned, this should be the default behaviour of malloc in the PSPSDK.
|
/* Make sure the buffers are 16 byte aligned, this should be
|
||||||
// Both buffers are allocated by RetroArch, so can assume alignment.
|
* the default behaviour of malloc in the PSPSDK.
|
||||||
|
* Both buffers are allocated by RetroArch, so can assume alignment. */
|
||||||
rarch_assert(((uintptr_t)in & 0xf) == 0);
|
rarch_assert(((uintptr_t)in & 0xf) == 0);
|
||||||
rarch_assert(((uintptr_t)out & 0xf) == 0);
|
rarch_assert(((uintptr_t)out & 0xf) == 0);
|
||||||
#endif
|
#endif
|
||||||
@ -257,7 +269,8 @@ void audio_convert_float_to_s16_ALLEGREX(int16_t *out,
|
|||||||
for (; i < samples; i++)
|
for (; i < samples; i++)
|
||||||
{
|
{
|
||||||
int32_t val = (int32_t)(in[i] * 0x8000);
|
int32_t val = (int32_t)(in[i] * 0x8000);
|
||||||
out[i] = (val > 0x7FFF) ? 0x7FFF : (val < -0x8000 ? -0x8000 : (int16_t)val);
|
out[i] = (val > 0x7FFF) ? 0x7FFF :
|
||||||
|
(val < -0x8000 ? -0x8000 : (int16_t)val);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
71
gfx/filter.c
71
gfx/filter.c
@ -92,7 +92,8 @@ struct rarch_softfilter
|
|||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
static const struct softfilter_implementation *softfilter_find_implementation(rarch_softfilter_t *filt, const char *ident)
|
static const struct softfilter_implementation *
|
||||||
|
softfilter_find_implementation(rarch_softfilter_t *filt, const char *ident)
|
||||||
{
|
{
|
||||||
unsigned i;
|
unsigned i;
|
||||||
for (i = 0; i < filt->num_plugs; i++)
|
for (i = 0; i < filt->num_plugs; i++)
|
||||||
@ -110,7 +111,8 @@ struct softfilter_userdata
|
|||||||
const char *prefix[2];
|
const char *prefix[2];
|
||||||
};
|
};
|
||||||
|
|
||||||
static int softfilter_get_float(void *userdata, const char *key_str, float *value, float default_value)
|
static int softfilter_get_float(void *userdata, const char *key_str,
|
||||||
|
float *value, float default_value)
|
||||||
{
|
{
|
||||||
struct softfilter_userdata *filt = (struct softfilter_userdata*)userdata;
|
struct softfilter_userdata *filt = (struct softfilter_userdata*)userdata;
|
||||||
|
|
||||||
@ -126,7 +128,8 @@ static int softfilter_get_float(void *userdata, const char *key_str, float *valu
|
|||||||
return got;
|
return got;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int softfilter_get_int(void *userdata, const char *key_str, int *value, int default_value)
|
static int softfilter_get_int(void *userdata, const char *key_str,
|
||||||
|
int *value, int default_value)
|
||||||
{
|
{
|
||||||
struct softfilter_userdata *filt = (struct softfilter_userdata*)userdata;
|
struct softfilter_userdata *filt = (struct softfilter_userdata*)userdata;
|
||||||
|
|
||||||
@ -242,10 +245,11 @@ static bool create_softfilter_graph(rarch_softfilter_t *filt,
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
userdata.conf = filt->conf;
|
userdata.conf = filt->conf;
|
||||||
userdata.prefix[0] = key; // Index-specific configs take priority over ident-specific.
|
/* Index-specific configs take priority over ident-specific. */
|
||||||
|
userdata.prefix[0] = key;
|
||||||
userdata.prefix[1] = filt->impl->short_ident;
|
userdata.prefix[1] = filt->impl->short_ident;
|
||||||
|
|
||||||
// Simple assumptions.
|
/* Simple assumptions. */
|
||||||
filt->pix_fmt = in_pixel_format;
|
filt->pix_fmt = in_pixel_format;
|
||||||
input_fmts = filt->impl->query_input_formats();
|
input_fmts = filt->impl->query_input_formats();
|
||||||
|
|
||||||
@ -268,7 +272,8 @@ static bool create_softfilter_graph(rarch_softfilter_t *filt,
|
|||||||
}
|
}
|
||||||
|
|
||||||
output_fmts = filt->impl->query_output_formats(input_fmt);
|
output_fmts = filt->impl->query_output_formats(input_fmt);
|
||||||
if (output_fmts & input_fmt) // If we have a match of input/output formats, use that.
|
/* If we have a match of input/output formats, use that. */
|
||||||
|
if (output_fmts & input_fmt)
|
||||||
filt->out_pix_fmt = in_pixel_format;
|
filt->out_pix_fmt = in_pixel_format;
|
||||||
else if (output_fmts & SOFTFILTER_FMT_XRGB8888)
|
else if (output_fmts & SOFTFILTER_FMT_XRGB8888)
|
||||||
filt->out_pix_fmt = RETRO_PIXEL_FORMAT_XRGB8888;
|
filt->out_pix_fmt = RETRO_PIXEL_FORMAT_XRGB8888;
|
||||||
@ -283,8 +288,10 @@ static bool create_softfilter_graph(rarch_softfilter_t *filt,
|
|||||||
filt->max_width = max_width;
|
filt->max_width = max_width;
|
||||||
filt->max_height = max_height;
|
filt->max_height = max_height;
|
||||||
|
|
||||||
filt->impl_data = filt->impl->create(&softfilter_config, input_fmt, input_fmt, max_width, max_height,
|
filt->impl_data = filt->impl->create(
|
||||||
threads != RARCH_SOFTFILTER_THREADS_AUTO ? threads : rarch_get_cpu_cores(), cpu_features,
|
&softfilter_config, input_fmt, input_fmt, max_width, max_height,
|
||||||
|
threads != RARCH_SOFTFILTER_THREADS_AUTO ? threads :
|
||||||
|
rarch_get_cpu_cores(), cpu_features,
|
||||||
&userdata);
|
&userdata);
|
||||||
if (!filt->impl_data)
|
if (!filt->impl_data)
|
||||||
{
|
{
|
||||||
@ -301,7 +308,8 @@ static bool create_softfilter_graph(rarch_softfilter_t *filt,
|
|||||||
|
|
||||||
RARCH_LOG("Using %u threads for softfilter.\n", threads);
|
RARCH_LOG("Using %u threads for softfilter.\n", threads);
|
||||||
|
|
||||||
filt->packets = (struct softfilter_work_packet*)calloc(threads, sizeof(*filt->packets));
|
filt->packets = (struct softfilter_work_packet*)
|
||||||
|
calloc(threads, sizeof(*filt->packets));
|
||||||
if (!filt->packets)
|
if (!filt->packets)
|
||||||
{
|
{
|
||||||
RARCH_ERR("Failed to allocate softfilter packets.\n");
|
RARCH_ERR("Failed to allocate softfilter packets.\n");
|
||||||
@ -309,7 +317,8 @@ static bool create_softfilter_graph(rarch_softfilter_t *filt,
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAVE_THREADS
|
#ifdef HAVE_THREADS
|
||||||
filt->thread_data = (struct filter_thread_data*)calloc(threads, sizeof(*filt->thread_data));
|
filt->thread_data = (struct filter_thread_data*)
|
||||||
|
calloc(threads, sizeof(*filt->thread_data));
|
||||||
if (!filt->thread_data)
|
if (!filt->thread_data)
|
||||||
return false;
|
return false;
|
||||||
filt->threads = threads;
|
filt->threads = threads;
|
||||||
@ -326,7 +335,8 @@ static bool create_softfilter_graph(rarch_softfilter_t *filt,
|
|||||||
filt->thread_data[i].cond = scond_new();
|
filt->thread_data[i].cond = scond_new();
|
||||||
if (!filt->thread_data[i].cond)
|
if (!filt->thread_data[i].cond)
|
||||||
return false;
|
return false;
|
||||||
filt->thread_data[i].thread = sthread_create(filter_thread_loop, &filt->thread_data[i]);
|
filt->thread_data[i].thread = sthread_create(
|
||||||
|
filter_thread_loop, &filt->thread_data[i]);
|
||||||
if (!filt->thread_data[i].thread)
|
if (!filt->thread_data[i].thread)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -336,7 +346,8 @@ static bool create_softfilter_graph(rarch_softfilter_t *filt,
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAVE_DYLIB
|
#ifdef HAVE_DYLIB
|
||||||
static bool append_softfilter_plugs(rarch_softfilter_t *filt, struct string_list *list)
|
static bool append_softfilter_plugs(rarch_softfilter_t *filt,
|
||||||
|
struct string_list *list)
|
||||||
{
|
{
|
||||||
unsigned i;
|
unsigned i;
|
||||||
softfilter_simd_mask_t mask = rarch_get_cpu_features();
|
softfilter_simd_mask_t mask = rarch_get_cpu_features();
|
||||||
@ -347,7 +358,8 @@ static bool append_softfilter_plugs(rarch_softfilter_t *filt, struct string_list
|
|||||||
if (!lib)
|
if (!lib)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
softfilter_get_implementation_t cb = (softfilter_get_implementation_t)dylib_proc(lib, "softfilter_get_implementation");
|
softfilter_get_implementation_t cb = (softfilter_get_implementation_t)
|
||||||
|
dylib_proc(lib, "softfilter_get_implementation");
|
||||||
if (!cb)
|
if (!cb)
|
||||||
{
|
{
|
||||||
dylib_close(lib);
|
dylib_close(lib);
|
||||||
@ -367,14 +379,16 @@ static bool append_softfilter_plugs(rarch_softfilter_t *filt, struct string_list
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct rarch_soft_plug *new_plugs = (struct rarch_soft_plug*)realloc(filt->plugs, sizeof(*filt->plugs) * (filt->num_plugs + 1));
|
struct rarch_soft_plug *new_plugs = (struct rarch_soft_plug*)
|
||||||
|
realloc(filt->plugs, sizeof(*filt->plugs) * (filt->num_plugs + 1));
|
||||||
if (!new_plugs)
|
if (!new_plugs)
|
||||||
{
|
{
|
||||||
dylib_close(lib);
|
dylib_close(lib);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
RARCH_LOG("[SoftFilter]: Found plug: %s (%s).\n", impl->ident, impl->short_ident);
|
RARCH_LOG("[SoftFilter]: Found plug: %s (%s).\n",
|
||||||
|
impl->ident, impl->short_ident);
|
||||||
|
|
||||||
filt->plugs = new_plugs;
|
filt->plugs = new_plugs;
|
||||||
filt->plugs[filt->num_plugs].lib = lib;
|
filt->plugs[filt->num_plugs].lib = lib;
|
||||||
@ -415,7 +429,8 @@ static bool append_softfilter_plugs(rarch_softfilter_t *filt)
|
|||||||
unsigned i;
|
unsigned i;
|
||||||
softfilter_simd_mask_t mask = rarch_get_cpu_features();
|
softfilter_simd_mask_t mask = rarch_get_cpu_features();
|
||||||
|
|
||||||
filt->plugs = (struct rarch_soft_plug*)calloc(ARRAY_SIZE(soft_plugs_builtin), sizeof(*filt->plugs));
|
filt->plugs = (struct rarch_soft_plug*)
|
||||||
|
calloc(ARRAY_SIZE(soft_plugs_builtin), sizeof(*filt->plugs));
|
||||||
if (!filt->plugs)
|
if (!filt->plugs)
|
||||||
return false;
|
return false;
|
||||||
filt->num_plugs = ARRAY_SIZE(soft_plugs_builtin);
|
filt->num_plugs = ARRAY_SIZE(soft_plugs_builtin);
|
||||||
@ -431,9 +446,6 @@ static bool append_softfilter_plugs(rarch_softfilter_t *filt)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
rarch_softfilter_t *rarch_softfilter_new(const char *filter_config,
|
rarch_softfilter_t *rarch_softfilter_new(const char *filter_config,
|
||||||
unsigned threads,
|
unsigned threads,
|
||||||
enum retro_pixel_format in_pixel_format,
|
enum retro_pixel_format in_pixel_format,
|
||||||
@ -527,7 +539,8 @@ 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);
|
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,
|
||||||
@ -535,10 +548,12 @@ void rarch_softfilter_get_output_size(rarch_softfilter_t *filt,
|
|||||||
unsigned width, unsigned height)
|
unsigned width, unsigned height)
|
||||||
{
|
{
|
||||||
if (filt && filt->impl && filt->impl->query_output_size)
|
if (filt && filt->impl && filt->impl->query_output_size)
|
||||||
filt->impl->query_output_size(filt->impl_data, out_width, out_height, width, 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)
|
||||||
{
|
{
|
||||||
return filt->out_pix_fmt;
|
return filt->out_pix_fmt;
|
||||||
}
|
}
|
||||||
@ -554,10 +569,12 @@ void rarch_softfilter_process(rarch_softfilter_t *filt,
|
|||||||
output, output_stride, input, width, height, input_stride);
|
output, output_stride, input, width, height, input_stride);
|
||||||
|
|
||||||
#ifdef HAVE_THREADS
|
#ifdef HAVE_THREADS
|
||||||
// Fire off workers
|
/* Fire off workers */
|
||||||
for (i = 0; i < filt->threads; i++)
|
for (i = 0; i < filt->threads; i++)
|
||||||
{
|
{
|
||||||
//RARCH_LOG("Firing off filter thread %u ...\n", i);
|
#if 0
|
||||||
|
RARCH_LOG("Firing off filter thread %u ...\n", i);
|
||||||
|
#endif
|
||||||
filt->thread_data[i].packet = &filt->packets[i];
|
filt->thread_data[i].packet = &filt->packets[i];
|
||||||
slock_lock(filt->thread_data[i].lock);
|
slock_lock(filt->thread_data[i].lock);
|
||||||
filt->thread_data[i].done = false;
|
filt->thread_data[i].done = false;
|
||||||
@ -565,10 +582,12 @@ void rarch_softfilter_process(rarch_softfilter_t *filt,
|
|||||||
slock_unlock(filt->thread_data[i].lock);
|
slock_unlock(filt->thread_data[i].lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Wait for workers
|
/* Wait for workers */
|
||||||
for (i = 0; i < filt->threads; i++)
|
for (i = 0; i < filt->threads; i++)
|
||||||
{
|
{
|
||||||
//RARCH_LOG("Waiting for filter thread %u ...\n", i);
|
#if 0
|
||||||
|
RARCH_LOG("Waiting for filter thread %u ...\n", i);
|
||||||
|
#endif
|
||||||
slock_lock(filt->thread_data[i].lock);
|
slock_lock(filt->thread_data[i].lock);
|
||||||
while (!filt->thread_data[i].done)
|
while (!filt->thread_data[i].done)
|
||||||
scond_wait(filt->thread_data[i].cond, filt->thread_data[i].lock);
|
scond_wait(filt->thread_data[i].cond, filt->thread_data[i].lock);
|
||||||
|
@ -38,7 +38,8 @@ 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);
|
||||||
|
|
||||||
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);
|
||||||
|
|
||||||
void rarch_softfilter_process(rarch_softfilter_t *filt,
|
void rarch_softfilter_process(rarch_softfilter_t *filt,
|
||||||
void *output, size_t output_stride,
|
void *output, size_t output_stride,
|
||||||
|
@ -38,15 +38,18 @@ void gl_load_texture_data(GLuint obj, const struct texture_image *img,
|
|||||||
glPixelStorei(GL_UNPACK_ALIGNMENT, 4);
|
glPixelStorei(GL_UNPACK_ALIGNMENT, 4);
|
||||||
#endif
|
#endif
|
||||||
glTexImage2D(GL_TEXTURE_2D,
|
glTexImage2D(GL_TEXTURE_2D,
|
||||||
0, driver.gfx_use_rgba ? GL_RGBA : RARCH_GL_INTERNAL_FORMAT32, img->width, img->height,
|
0, driver.gfx_use_rgba ? GL_RGBA : RARCH_GL_INTERNAL_FORMAT32,
|
||||||
0, driver.gfx_use_rgba ? GL_RGBA : RARCH_GL_TEXTURE_TYPE32, RARCH_GL_FORMAT32, img->pixels);
|
img->width, img->height,
|
||||||
|
0, driver.gfx_use_rgba ? GL_RGBA : RARCH_GL_TEXTURE_TYPE32,
|
||||||
|
RARCH_GL_FORMAT32, img->pixels);
|
||||||
#ifndef HAVE_PSGL
|
#ifndef HAVE_PSGL
|
||||||
if (mipmap)
|
if (mipmap)
|
||||||
glGenerateMipmap(GL_TEXTURE_2D);
|
glGenerateMipmap(GL_TEXTURE_2D);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
bool gl_load_luts(const struct gfx_shader *generic_shader, GLuint *lut_textures)
|
bool gl_load_luts(const struct gfx_shader *generic_shader,
|
||||||
|
GLuint *lut_textures)
|
||||||
{
|
{
|
||||||
unsigned i;
|
unsigned i;
|
||||||
unsigned num_luts = min(generic_shader->luts, GFX_MAX_TEXTURES);
|
unsigned num_luts = min(generic_shader->luts, GFX_MAX_TEXTURES);
|
||||||
@ -54,8 +57,9 @@ bool gl_load_luts(const struct gfx_shader *generic_shader, GLuint *lut_textures)
|
|||||||
if (!generic_shader->luts)
|
if (!generic_shader->luts)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
// Original shader_glsl.c code only generated one texture handle. I assume
|
/* Original shader_glsl.c code only generated one
|
||||||
// it was a bug, but if not, replace num_luts with 1 when GLSL is used.
|
* texture handle. I assume it was a bug, but if not,
|
||||||
|
* replace num_luts with 1 when GLSL is used. */
|
||||||
glGenTextures(num_luts, lut_textures);
|
glGenTextures(num_luts, lut_textures);
|
||||||
for (i = 0; i < num_luts; i++)
|
for (i = 0; i < num_luts; i++)
|
||||||
{
|
{
|
||||||
@ -65,7 +69,8 @@ bool gl_load_luts(const struct gfx_shader *generic_shader, GLuint *lut_textures)
|
|||||||
|
|
||||||
if (!texture_image_load(&img, generic_shader->lut[i].path))
|
if (!texture_image_load(&img, generic_shader->lut[i].path))
|
||||||
{
|
{
|
||||||
RARCH_ERR("Failed to load texture image from: \"%s\"\n", generic_shader->lut[i].path);
|
RARCH_ERR("Failed to load texture image from: \"%s\"\n",
|
||||||
|
generic_shader->lut[i].path);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -57,10 +57,10 @@ static enum gfx_wrap_type wrap_str_to_mode(const char *wrap_mode)
|
|||||||
return RARCH_WRAP_DEFAULT;
|
return RARCH_WRAP_DEFAULT;
|
||||||
}
|
}
|
||||||
|
|
||||||
// CGP
|
/* CGP */
|
||||||
static bool shader_parse_pass(config_file_t *conf, struct gfx_shader_pass *pass, unsigned i)
|
static bool shader_parse_pass(config_file_t *conf, struct gfx_shader_pass *pass, unsigned i)
|
||||||
{
|
{
|
||||||
// Source
|
/* Source */
|
||||||
char shader_name[64];
|
char shader_name[64];
|
||||||
print_buf(shader_name, "shader%u", i);
|
print_buf(shader_name, "shader%u", i);
|
||||||
if (!config_get_path(conf, shader_name, pass->source.path, sizeof(pass->source.path)))
|
if (!config_get_path(conf, shader_name, pass->source.path, sizeof(pass->source.path)))
|
||||||
@ -69,7 +69,7 @@ static bool shader_parse_pass(config_file_t *conf, struct gfx_shader_pass *pass,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Smooth
|
/* Smooth */
|
||||||
char filter_name_buf[64];
|
char filter_name_buf[64];
|
||||||
print_buf(filter_name_buf, "filter_linear%u", i);
|
print_buf(filter_name_buf, "filter_linear%u", i);
|
||||||
bool smooth = false;
|
bool smooth = false;
|
||||||
@ -78,14 +78,14 @@ static bool shader_parse_pass(config_file_t *conf, struct gfx_shader_pass *pass,
|
|||||||
else
|
else
|
||||||
pass->filter = RARCH_FILTER_UNSPEC;
|
pass->filter = RARCH_FILTER_UNSPEC;
|
||||||
|
|
||||||
// Wrapping mode
|
/* Wrapping mode */
|
||||||
char wrap_name_buf[64];
|
char wrap_name_buf[64];
|
||||||
print_buf(wrap_name_buf, "wrap_mode%u", i);
|
print_buf(wrap_name_buf, "wrap_mode%u", i);
|
||||||
char wrap_mode[64];
|
char wrap_mode[64];
|
||||||
if (config_get_array(conf, wrap_name_buf, wrap_mode, sizeof(wrap_mode)))
|
if (config_get_array(conf, wrap_name_buf, wrap_mode, sizeof(wrap_mode)))
|
||||||
pass->wrap = wrap_str_to_mode(wrap_mode);
|
pass->wrap = wrap_str_to_mode(wrap_mode);
|
||||||
|
|
||||||
// Frame count mod
|
/* Frame count mod */
|
||||||
char frame_count_mod[64] = {0};
|
char frame_count_mod[64] = {0};
|
||||||
char frame_count_mod_buf[64];
|
char frame_count_mod_buf[64];
|
||||||
print_buf(frame_count_mod_buf, "frame_count_mod%u", i);
|
print_buf(frame_count_mod_buf, "frame_count_mod%u", i);
|
||||||
@ -93,7 +93,7 @@ static bool shader_parse_pass(config_file_t *conf, struct gfx_shader_pass *pass,
|
|||||||
frame_count_mod, sizeof(frame_count_mod)))
|
frame_count_mod, sizeof(frame_count_mod)))
|
||||||
pass->frame_count_mod = strtoul(frame_count_mod, NULL, 0);
|
pass->frame_count_mod = strtoul(frame_count_mod, NULL, 0);
|
||||||
|
|
||||||
// FBO types and mipmapping
|
/* FBO types and mipmapping */
|
||||||
char srgb_output_buf[64];
|
char srgb_output_buf[64];
|
||||||
print_buf(srgb_output_buf, "srgb_framebuffer%u", i);
|
print_buf(srgb_output_buf, "srgb_framebuffer%u", i);
|
||||||
config_get_bool(conf, srgb_output_buf, &pass->fbo.srgb_fbo);
|
config_get_bool(conf, srgb_output_buf, &pass->fbo.srgb_fbo);
|
||||||
@ -111,7 +111,7 @@ static bool shader_parse_pass(config_file_t *conf, struct gfx_shader_pass *pass,
|
|||||||
if (!config_get_array(conf, alias_buf, pass->alias, sizeof(pass->alias)))
|
if (!config_get_array(conf, alias_buf, pass->alias, sizeof(pass->alias)))
|
||||||
*pass->alias = '\0';
|
*pass->alias = '\0';
|
||||||
|
|
||||||
// Scale
|
/* Scale */
|
||||||
struct gfx_fbo_scale *scale = &pass->fbo;
|
struct gfx_fbo_scale *scale = &pass->fbo;
|
||||||
char scale_type[64] = {0};
|
char scale_type[64] = {0};
|
||||||
char scale_type_x[64] = {0};
|
char scale_type_x[64] = {0};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user