From e61401c1011e5a8cda47dfbeafa356812a89c46c Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 7 May 2014 16:46:28 +0200 Subject: [PATCH 01/16] (CC resampler) Add RARCH_INTERNAL check --- audio/cc_resampler.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/audio/cc_resampler.c b/audio/cc_resampler.c index a0971296c3..8b9a34806f 100644 --- a/audio/cc_resampler.c +++ b/audio/cc_resampler.c @@ -22,7 +22,7 @@ #include #include -#ifndef RESAMPLER_TEST +#if !defined(RESAMPLER_TEST) && defined(RARCH_INTERNAL) #include "../general.h" #else #define RARCH_LOG(...) fprintf(stderr, __VA_ARGS__) @@ -230,9 +230,9 @@ static void resampler_CC_upsample(void *re_, struct resampler_data *data) float b, ratio; rarch_CC_resampler_t *re = (rarch_CC_resampler_t*)re_; - audio_frame_float_t *inp = (audio_frame_float_t*)data->data_in; - audio_frame_float_t *inp_max = inp + data->input_frames; - audio_frame_float_t *outp = (audio_frame_float_t*)data->data_out; + audio_frame_float_t *inp = (audio_frame_float_t*)data->data_in; + audio_frame_float_t *inp_max = (audio_frame_float_t*)(inp + data->input_frames); + audio_frame_float_t *outp = (audio_frame_float_t*)data->data_out; b = min(data->ratio, 1.00); // cutoff frequency ratio = 1.0 / data->ratio; @@ -320,4 +320,3 @@ const rarch_resampler_t CC_resampler = { resampler_CC_free, "CC", }; - From 41e526a1639fccbfdb73da364e7b6068d99cb03d Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 8 May 2014 03:30:43 +0200 Subject: [PATCH 02/16] Split up rglgen header includes to separate header file --- gfx/glsym/rglgen.h | 35 +--------------------------------- gfx/glsym/rglgen_headers.h | 39 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 34 deletions(-) create mode 100644 gfx/glsym/rglgen_headers.h diff --git a/gfx/glsym/rglgen.h b/gfx/glsym/rglgen.h index 1710829393..aacfa70d03 100644 --- a/gfx/glsym/rglgen.h +++ b/gfx/glsym/rglgen.h @@ -5,40 +5,7 @@ #include "config.h" #endif -#ifdef HAVE_EGL -#include -#include -#endif - -#if defined(IOS) -#include -#include -#elif defined(__APPLE__) -#include -#include -#elif defined(HAVE_PSGL) -#include -#include -#elif defined(HAVE_OPENGL_MODERN) -#include -#include -#elif defined(HAVE_OPENGLES3) -#include -#include // There are no GLES3 extensions yet. -#elif defined(HAVE_OPENGLES2) -#include -#include -#elif defined(HAVE_OPENGLES1) -#include -#include -#else -#if defined(_WIN32) && !defined(_XBOX) -#define WIN32_LEAN_AND_MEAN -#include -#endif -#include -#include -#endif +#include "rglgen_headers.h" #ifdef __cplusplus extern "C" { diff --git a/gfx/glsym/rglgen_headers.h b/gfx/glsym/rglgen_headers.h new file mode 100644 index 0000000000..53fdb7cd55 --- /dev/null +++ b/gfx/glsym/rglgen_headers.h @@ -0,0 +1,39 @@ +#ifndef RGLGEN_HEADERS_H__ +#define RGLGEN_HEADERS_H__ + +#ifdef HAVE_EGL +#include +#include +#endif + +#if defined(IOS) +#include +#include +#elif defined(__APPLE__) +#include +#include +#elif defined(HAVE_PSGL) +#include +#include +#elif defined(HAVE_OPENGL_MODERN) +#include +#include +#elif defined(HAVE_OPENGLES3) +#include +#include // There are no GLES3 extensions yet. +#elif defined(HAVE_OPENGLES2) +#include +#include +#elif defined(HAVE_OPENGLES1) +#include +#include +#else +#if defined(_WIN32) && !defined(_XBOX) +#define WIN32_LEAN_AND_MEAN +#include +#endif +#include +#include +#endif + +#endif From c15d188ecf56ca7682cee5980e43425db0160c96 Mon Sep 17 00:00:00 2001 From: TroggleMonkey Date: Thu, 8 May 2014 13:39:12 -0400 Subject: [PATCH 03/16] Refactored duplicate Cg/GLSL LUT texture loading code into shader_common.c. Fixed a bug where "Apply Shader Changes" in RGUI saved/set the wrong texture filter for LUT textures. Unofficially extended Cg shader spec with an LUT mipmap option: To mipmap LUT "foo," add 'foo_mipmap = "true"' to your .cgp/.glslp file. Mipmapping is currently implemented for the OpenGL driver only. --- Makefile | 1 + gfx/shader_cg.c | 52 ++-------------------------- gfx/shader_common.c | 82 +++++++++++++++++++++++++++++++++++++++++++++ gfx/shader_common.h | 4 +++ gfx/shader_glsl.c | 46 +------------------------ gfx/shader_parse.c | 15 +++++++-- gfx/shader_parse.h | 1 + 7 files changed, 103 insertions(+), 98 deletions(-) create mode 100644 gfx/shader_common.c diff --git a/Makefile b/Makefile index 644de6e901..64c65ec5b2 100644 --- a/Makefile +++ b/Makefile @@ -30,6 +30,7 @@ OBJ = frontend/frontend.o \ conf/config_file.o \ screenshot.o \ gfx/scaler/scaler.o \ + gfx/shader_common.o \ gfx/shader_parse.o \ gfx/scaler/pixconv.o \ gfx/scaler/scaler_int.o \ diff --git a/gfx/shader_cg.c b/gfx/shader_cg.c index 16e2cb3a47..75c394d6ad 100644 --- a/gfx/shader_cg.c +++ b/gfx/shader_cg.c @@ -102,7 +102,6 @@ struct cg_fbo_params CGparameter coord; }; -#define MAX_LUT_TEXTURES 8 #define MAX_VARIABLES 64 #define PREV_TEXTURES (MAX_TEXTURES - 1) @@ -142,7 +141,7 @@ static unsigned active_index; static struct gfx_shader *cg_shader; static state_tracker_t *state_tracker; -static GLuint lut_textures[MAX_LUT_TEXTURES]; +static GLuint lut_textures[GFX_MAX_TEXTURES]; static CGparameter cg_attribs[PREV_TEXTURES + 1 + 4 + GFX_MAX_SHADERS]; static unsigned cg_attrib_index; @@ -496,53 +495,6 @@ static bool load_plain(const char *path) #define print_buf(buf, ...) snprintf(buf, sizeof(buf), __VA_ARGS__) -static void load_texture_data(GLuint obj, const struct texture_image *img, bool smooth, GLenum wrap) -{ - glBindTexture(GL_TEXTURE_2D, obj); - - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, wrap); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, wrap); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, smooth ? GL_LINEAR : GL_NEAREST); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, smooth ? GL_LINEAR : GL_NEAREST); - -#ifndef HAVE_PSGL - glPixelStorei(GL_UNPACK_ALIGNMENT, 4); -#endif - 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_TEXTURE_TYPE32, RARCH_GL_FORMAT32, img->pixels); -} - -static bool load_textures(void) -{ - unsigned i; - if (!cg_shader->luts) - return true; - - glGenTextures(cg_shader->luts, lut_textures); - - for (i = 0; i < cg_shader->luts; i++) - { - RARCH_LOG("Loading image from: \"%s\".\n", - cg_shader->lut[i].path); - - struct texture_image img = {0}; - if (!texture_image_load(cg_shader->lut[i].path, &img)) - { - RARCH_ERR("Failed to load picture ...\n"); - return false; - } - - load_texture_data(lut_textures[i], &img, - cg_shader->lut[i].filter != RARCH_FILTER_NEAREST, - gl_wrap_type_to_enum(cg_shader->lut[i].wrap)); - texture_image_free(&img); - } - - glBindTexture(GL_TEXTURE_2D, 0); - return true; -} - static bool load_imports(void) { unsigned i; @@ -646,7 +598,7 @@ static bool load_preset(const char *path) } } - if (!load_textures()) + if (!gl_load_luts(cg_shader, lut_textures)) { RARCH_ERR("Failed to load lookup textures ...\n"); return false; diff --git a/gfx/shader_common.c b/gfx/shader_common.c new file mode 100644 index 0000000000..26d0d2e8d9 --- /dev/null +++ b/gfx/shader_common.c @@ -0,0 +1,82 @@ +/* RetroArch - A frontend for libretro. + * Copyright (C) 2010-2014 - Hans-Kristian Arntzen + * + * 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 . + */ + +#include "shader_common.h" +#include "../retroarch_logger.h" + +#ifdef HAVE_OPENGL +// gl_common.c may or may not be a better location for these functions. +void gl_load_texture_data(GLuint obj, const struct texture_image *img, + GLenum wrap, bool linear, bool mipmap) +{ + glBindTexture(GL_TEXTURE_2D, obj); + +#ifdef HAVE_OPENGLES2 + GLenum wrap = GL_CLAMP_TO_EDGE; +#endif + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, wrap); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, wrap); + + GLint filter = linear ? (mipmap ? GL_LINEAR_MIPMAP_LINEAR : GL_LINEAR) : + (mipmap ? GL_NEAREST_MIPMAP_NEAREST : GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, filter); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, filter); + +#ifndef HAVE_PSGL + glPixelStorei(GL_UNPACK_ALIGNMENT, 4); +#endif + 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_TEXTURE_TYPE32, RARCH_GL_FORMAT32, img->pixels); + if (mipmap) + { + glGenerateMipmap(GL_TEXTURE_2D); + } +} + +bool gl_load_luts(const struct gfx_shader *generic_shader, GLuint *lut_textures) +{ + unsigned i; + unsigned num_luts = min(generic_shader->luts, GFX_MAX_TEXTURES); + if (!generic_shader->luts) + return true; + + // Original shader_glsl.c code only generated one 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); + for (i = 0; i < num_luts; i++) + { + RARCH_LOG("Loading texture image from: \"%s\" ...\n", + generic_shader->lut[i].path); + struct texture_image img = {0}; + if (!texture_image_load(generic_shader->lut[i].path, &img)) + { + RARCH_ERR("Failed to load texture image from: \"%s\"\n", generic_shader->lut[i].path); + return false; + } + + gl_load_texture_data(lut_textures[i], &img, + gl_wrap_type_to_enum(generic_shader->lut[i].wrap), + generic_shader->lut[i].filter != RARCH_FILTER_NEAREST, + generic_shader->lut[i].mipmap); + texture_image_free(&img); + } + + glBindTexture(GL_TEXTURE_2D, 0); + return true; +} +#endif // HAVE_OPENGL + + diff --git a/gfx/shader_common.h b/gfx/shader_common.h index 1edf331fbe..628dbafa6b 100644 --- a/gfx/shader_common.h +++ b/gfx/shader_common.h @@ -56,5 +56,9 @@ struct gl_shader_backend enum rarch_shader_type type; }; +void gl_load_texture_data(GLuint obj, const struct texture_image *img, + GLenum wrap, bool linear, bool mipmap); +bool gl_load_luts(const struct gfx_shader *generic_shader, GLuint *lut_textures); + #endif diff --git a/gfx/shader_glsl.c b/gfx/shader_glsl.c index 6d9e745c1a..75a98c2775 100644 --- a/gfx/shader_glsl.c +++ b/gfx/shader_glsl.c @@ -263,50 +263,6 @@ static GLint get_attrib(GLuint prog, const char *base) return -1; } -static bool load_luts(void) -{ - unsigned i; - if (!glsl_shader->luts) - return true; - - glGenTextures(1, gl_teximage); - - for (i = 0; i < glsl_shader->luts; i++) - { - RARCH_LOG("Loading texture image from: \"%s\" ...\n", - glsl_shader->lut[i].path); - - struct texture_image img = {0}; - if (!texture_image_load(glsl_shader->lut[i].path, &img)) - { - RARCH_ERR("Failed to load texture image from: \"%s\"\n", glsl_shader->lut[i].path); - return false; - } - - glBindTexture(GL_TEXTURE_2D, gl_teximage[i]); - - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, BORDER_FUNC); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, BORDER_FUNC); - - GLenum filter = glsl_shader->lut[i].filter == RARCH_FILTER_NEAREST ? - GL_NEAREST : GL_LINEAR; - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, filter); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, filter); - - glPixelStorei(GL_UNPACK_ALIGNMENT, 4); - 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_TEXTURE_TYPE32, - RARCH_GL_FORMAT32, img.pixels); - - glBindTexture(GL_TEXTURE_2D, 0); - texture_image_free(&img); - } - - return true; -} - static void print_shader_log(GLuint obj) { GLint info_len = 0; @@ -786,7 +742,7 @@ static bool gl_glsl_init(void *data, const char *path) if (!compile_programs(&gl_program[1])) goto error; - if (!load_luts()) + if (!gl_load_luts(glsl_shader, gl_teximage)) { RARCH_ERR("[GL]: Failed to load LUTs.\n"); goto error; diff --git a/gfx/shader_parse.c b/gfx/shader_parse.c index 9fc3ccc0a2..5c58a113e7 100644 --- a/gfx/shader_parse.c +++ b/gfx/shader_parse.c @@ -80,7 +80,6 @@ static bool shader_parse_pass(config_file_t *conf, struct gfx_shader_pass *pass, // Smooth char filter_name_buf[64]; print_buf(filter_name_buf, "filter_linear%u", i); - bool smooth = false; if (config_get_bool(conf, filter_name_buf, &smooth)) pass->filter = smooth ? RARCH_FILTER_LINEAR : RARCH_FILTER_NEAREST; @@ -244,7 +243,6 @@ static bool shader_parse_textures(config_file_t *conf, struct gfx_shader *shader char id_filter[64]; print_buf(id_filter, "%s_linear", id); - bool smooth = false; if (config_get_bool(conf, id_filter, &smooth)) shader->lut[shader->luts].filter = smooth ? RARCH_FILTER_LINEAR : RARCH_FILTER_NEAREST; @@ -256,6 +254,14 @@ static bool shader_parse_textures(config_file_t *conf, struct gfx_shader *shader char wrap_mode[64]; if (config_get_array(conf, id_wrap, wrap_mode, sizeof(wrap_mode))) shader->lut[shader->luts].wrap = wrap_str_to_mode(wrap_mode); + + char id_mipmap[64]; + print_buf(id_mipmap, "%s_mipmap", id); + bool mipmap = false; + if (config_get_bool(conf, id_mipmap, &mipmap)) + shader->lut[shader->luts].mipmap = mipmap; + else + shader->lut[shader->luts].mipmap = false; } return true; @@ -1084,11 +1090,14 @@ void gfx_shader_write_conf_cgp(config_file_t *conf, const struct gfx_shader *sha if (shader->lut[i].filter != RARCH_FILTER_UNSPEC) { print_buf(key, "%s_linear", shader->lut[i].id); - config_set_bool(conf, key, shader->lut[i].filter != RARCH_FILTER_LINEAR); + config_set_bool(conf, key, shader->lut[i].filter == RARCH_FILTER_LINEAR); } print_buf(key, "%s_wrap_mode", shader->lut[i].id); config_set_string(conf, key, wrap_mode_to_str(shader->lut[i].wrap)); + + print_buf(key, "%s_mipmap", shader->lut[i].id); + config_set_bool(conf, key, shader->lut[i].mipmap); } } diff --git a/gfx/shader_parse.h b/gfx/shader_parse.h index 2802756d9d..86eb24e4d7 100644 --- a/gfx/shader_parse.h +++ b/gfx/shader_parse.h @@ -88,6 +88,7 @@ struct gfx_shader_lut char path[PATH_MAX]; enum gfx_filter_type filter; enum gfx_wrap_type wrap; + bool mipmap; }; // This is pretty big, shouldn't be put on the stack. From 853179a2fb1f6fdf00aae80a30c1df4932c200d2 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 8 May 2014 21:49:18 +0200 Subject: [PATCH 04/16] Add inclusion of gfx/shader_common.c to other Makefiles --- Makefile.emscripten | 1 + Makefile.win | 1 + gfx/shader_common.c | 2 +- griffin/griffin.c | 11 +++++++++-- msvc/msvc-2010/RetroArch-msvc2010.vcxproj | 2 ++ 5 files changed, 14 insertions(+), 3 deletions(-) diff --git a/Makefile.emscripten b/Makefile.emscripten index a77a28c39c..d12fe0a43b 100644 --- a/Makefile.emscripten +++ b/Makefile.emscripten @@ -29,6 +29,7 @@ OBJ = frontend/platform/platform_emscripten.o \ input/overlay.o \ fifo_buffer.o \ gfx/scaler/scaler.o \ + gfx/shader_common.o \ gfx/scaler/pixconv.o \ gfx/scaler/scaler_int.o \ gfx/scaler/scaler_filter.o \ diff --git a/Makefile.win b/Makefile.win index 486849cfec..1c07f211d8 100644 --- a/Makefile.win +++ b/Makefile.win @@ -34,6 +34,7 @@ OBJ = frontend/frontend.o \ media/rarch.o \ gfx/context/win32_common.o \ gfx/scaler/scaler.o \ + gfx/shader_common.o \ gfx/scaler/pixconv.o \ gfx/scaler/scaler_int.o \ gfx/scaler/scaler_filter.o \ diff --git a/gfx/shader_common.c b/gfx/shader_common.c index 26d0d2e8d9..4698507301 100644 --- a/gfx/shader_common.c +++ b/gfx/shader_common.c @@ -24,7 +24,7 @@ void gl_load_texture_data(GLuint obj, const struct texture_image *img, glBindTexture(GL_TEXTURE_2D, obj); #ifdef HAVE_OPENGLES2 - GLenum wrap = GL_CLAMP_TO_EDGE; + wrap = GL_CLAMP_TO_EDGE; #endif glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, wrap); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, wrap); diff --git a/griffin/griffin.c b/griffin/griffin.c index 2045a545aa..f2e58a768a 100644 --- a/griffin/griffin.c +++ b/griffin/griffin.c @@ -18,6 +18,10 @@ #define HAVE_FILTERS_BUILTIN #endif +#if defined(HAVE_CG) || defined(HAVE_HLSL) || defined(HAVE_GLSL) +#define HAVE_SHADERS +#endif + #if defined(_XBOX) #include "../msvc/msvc_compat.h" #endif @@ -141,9 +145,10 @@ VIDEO CONTEXT /*============================================================ VIDEO SHADERS ============================================================ */ -#if defined(HAVE_CG) || defined(HAVE_HLSL) || defined(HAVE_GLSL) +#include "../gfx/shader_common.c" + +#ifdef HAVE_SHADERS #include "../gfx/shader_parse.c" -#endif #ifdef HAVE_CG #include "../gfx/shader_cg.c" @@ -157,6 +162,8 @@ VIDEO SHADERS #include "../gfx/shader_glsl.c" #endif +#endif + /*============================================================ VIDEO IMAGE ============================================================ */ diff --git a/msvc/msvc-2010/RetroArch-msvc2010.vcxproj b/msvc/msvc-2010/RetroArch-msvc2010.vcxproj index 1d83cdfff1..4e6fa89fc0 100644 --- a/msvc/msvc-2010/RetroArch-msvc2010.vcxproj +++ b/msvc/msvc-2010/RetroArch-msvc2010.vcxproj @@ -288,6 +288,8 @@ + + From 7bba107415e476628434fcc4e940545e7e142751 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 8 May 2014 21:50:49 +0200 Subject: [PATCH 05/16] (shader_common.c) Some build fixes for PS3 --- gfx/shader_common.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/gfx/shader_common.c b/gfx/shader_common.c index 4698507301..45740c8314 100644 --- a/gfx/shader_common.c +++ b/gfx/shader_common.c @@ -40,10 +40,12 @@ void gl_load_texture_data(GLuint obj, const struct texture_image *img, 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_TEXTURE_TYPE32, RARCH_GL_FORMAT32, img->pixels); +#ifndef HAVE_PSGL if (mipmap) { glGenerateMipmap(GL_TEXTURE_2D); } +#endif } bool gl_load_luts(const struct gfx_shader *generic_shader, GLuint *lut_textures) From d7a273feb047dda5c4b1dfc3519d00952287e336 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 8 May 2014 22:27:58 +0200 Subject: [PATCH 06/16] (PSGL) Force mipmap to false for now for PSGL --- gfx/shader_common.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/gfx/shader_common.c b/gfx/shader_common.c index 45740c8314..683e8ec779 100644 --- a/gfx/shader_common.c +++ b/gfx/shader_common.c @@ -23,6 +23,9 @@ void gl_load_texture_data(GLuint obj, const struct texture_image *img, { glBindTexture(GL_TEXTURE_2D, obj); +#ifdef HAVE_PSGL + mipmap = false +#endif #ifdef HAVE_OPENGLES2 wrap = GL_CLAMP_TO_EDGE; #endif From d7f50bdeac6961f74e139ac23de834663b0a385b Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 8 May 2014 22:40:00 +0200 Subject: [PATCH 07/16] (PS3) Missed semicolon --- gfx/shader_common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gfx/shader_common.c b/gfx/shader_common.c index 683e8ec779..6911aecdad 100644 --- a/gfx/shader_common.c +++ b/gfx/shader_common.c @@ -24,7 +24,7 @@ void gl_load_texture_data(GLuint obj, const struct texture_image *img, glBindTexture(GL_TEXTURE_2D, obj); #ifdef HAVE_PSGL - mipmap = false + mipmap = false; #endif #ifdef HAVE_OPENGLES2 wrap = GL_CLAMP_TO_EDGE; From c35c1fdb74dd2289a17f6e1c5800e7e7e3ba5df4 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 9 May 2014 04:54:54 +0200 Subject: [PATCH 08/16] (shader_common.c) Style nits --- gfx/shader_common.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/gfx/shader_common.c b/gfx/shader_common.c index 6911aecdad..4ef590f9fc 100644 --- a/gfx/shader_common.c +++ b/gfx/shader_common.c @@ -45,16 +45,16 @@ void gl_load_texture_data(GLuint obj, const struct texture_image *img, 0, driver.gfx_use_rgba ? GL_RGBA : RARCH_GL_TEXTURE_TYPE32, RARCH_GL_FORMAT32, img->pixels); #ifndef HAVE_PSGL if (mipmap) - { glGenerateMipmap(GL_TEXTURE_2D); - } #endif } bool gl_load_luts(const struct gfx_shader *generic_shader, GLuint *lut_textures) { - unsigned i; - unsigned num_luts = min(generic_shader->luts, GFX_MAX_TEXTURES); + unsigned i, num_luts; + + num_luts = min(generic_shader->luts, GFX_MAX_TEXTURES); + if (!generic_shader->luts) return true; @@ -63,9 +63,9 @@ bool gl_load_luts(const struct gfx_shader *generic_shader, GLuint *lut_textures) glGenTextures(num_luts, lut_textures); for (i = 0; i < num_luts; i++) { + struct texture_image img = {0}; RARCH_LOG("Loading texture image from: \"%s\" ...\n", generic_shader->lut[i].path); - struct texture_image img = {0}; if (!texture_image_load(generic_shader->lut[i].path, &img)) { RARCH_ERR("Failed to load texture image from: \"%s\"\n", generic_shader->lut[i].path); From 0454ac623e23e0d3e91076264345dd265613c96b Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 9 May 2014 05:47:32 +0200 Subject: [PATCH 09/16] (Menu) Move 'rgui' global variable to 'driver' struct --- driver.h | 1 + frontend/frontend.c | 23 +-- frontend/menu/backend/menu_common_backend.c | 13 +- frontend/menu/disp/rgui.c | 8 +- frontend/menu/disp/rmenu.c | 5 +- frontend/menu/menu_common.c | 151 ++++++++++++++------ frontend/menu/menu_common.h | 26 ++-- frontend/menu/menu_input_line_cb.c | 1 + frontend/platform/platform_apple.c | 4 +- frontend/platform/platform_emscripten.c | 4 +- settings_data.c | 2 +- 11 files changed, 157 insertions(+), 81 deletions(-) diff --git a/driver.h b/driver.h index 0ac93028dd..140165bb82 100644 --- a/driver.h +++ b/driver.h @@ -466,6 +466,7 @@ typedef struct driver void *video_data; void *input_data; #ifdef HAVE_MENU + void *menu; const menu_ctx_driver_t *menu_ctx; #endif diff --git a/frontend/frontend.c b/frontend/frontend.c index ff6994f398..26a4813412 100644 --- a/frontend/frontend.c +++ b/frontend/frontend.c @@ -127,7 +127,7 @@ static retro_keyboard_event_t key_event; static int main_entry_iterate_clear_input(args_type() args) { rarch_input_poll(); - if (!menu_input()) + if (!menu_input(driver.menu)) { // Restore libretro keyboard callback. g_extern.system.key_event = key_event; @@ -143,7 +143,7 @@ static int main_entry_iterate_shutdown(args_type() args) #ifdef HAVE_MENU // Load dummy core instead of exiting RetroArch completely. if (g_settings.load_dummy_on_core_shutdown) - load_menu_game_prepare_dummy(); + load_menu_game_prepare_dummy(driver.menu); else #endif return 1; @@ -173,9 +173,9 @@ static int main_entry_iterate_content(args_type() args) static int main_entry_iterate_load_content(args_type() args) { - load_menu_game_prepare(); + load_menu_game_prepare(driver.menu); - if (load_menu_game()) + if (load_menu_game(driver.menu)) { g_extern.lifecycle_state |= (1ULL << MODE_GAME); if (driver.video_data && driver.video_poke && driver.video_poke->set_aspect_ratio) @@ -203,6 +203,7 @@ static int main_entry_iterate_load_content(args_type() args) static int main_entry_iterate_menu_preinit(args_type() args) { int i; + rgui_handle_t *rgui = (rgui_handle_t*)driver.menu; // Menu should always run with vsync on. video_set_nonblock_state_func(false); @@ -222,6 +223,12 @@ static int main_entry_iterate_menu_preinit(args_type() args) if (driver.audio_data) audio_stop_func(); + if (!rgui) + { + driver.menu = (rgui_handle_t*)menu_init(); + rgui = (rgui_handle_t*)driver.menu; + } + rgui->need_refresh = true; rgui->old_input_state |= 1ULL << RARCH_MENU_TOGGLE; @@ -233,7 +240,7 @@ static int main_entry_iterate_menu_preinit(args_type() args) static int main_entry_iterate_menu(args_type() args) { - if (menu_iterate()) + if (menu_iterate(driver.menu)) { if (frontend_ctx && frontend_ctx->process_events) frontend_ctx->process_events(args); @@ -288,7 +295,7 @@ void main_exit(args_type() args) #ifdef HAVE_MENU g_extern.system.shutdown = false; - menu_free(); + menu_free(driver.menu); if (g_extern.config_save_on_exit && *g_extern.config_path) { @@ -366,7 +373,7 @@ returntype main_entry(signature()) #if defined(HAVE_MENU) if (menu_init_enable) - menu_init(); + driver.menu = (rgui_handle_t*)menu_init(); if (frontend_ctx && frontend_ctx->process_args) frontend_ctx->process_args(argc, argv, args); @@ -379,7 +386,7 @@ returntype main_entry(signature()) // If we started a ROM directly from command line, // push it to ROM history. if (!g_extern.libretro_dummy) - menu_rom_history_push_current(); + menu_rom_history_push_current(driver.menu); } while (!main_entry_iterate(signature_expand(), args)); diff --git a/frontend/menu/backend/menu_common_backend.c b/frontend/menu/backend/menu_common_backend.c index 61cb5f8db4..14e28ad554 100644 --- a/frontend/menu/backend/menu_common_backend.c +++ b/frontend/menu/backend/menu_common_backend.c @@ -1340,7 +1340,7 @@ static int menu_common_iterate(void *data, unsigned action) // FIXME: Add for consoles. strlcpy(g_settings.libretro, path, sizeof(g_settings.libretro)); strlcpy(g_extern.fullpath, rgui->deferred_path, sizeof(g_extern.fullpath)); - load_menu_game_new_core(); + load_menu_game_new_core(rgui); rgui->msg_force = true; ret = -1; menu_flush_stack_type(rgui, RGUI_SETTINGS); @@ -1384,7 +1384,7 @@ static int menu_common_iterate(void *data, unsigned action) fill_pathname_join(config, dir, path, sizeof(config)); menu_flush_stack_type(rgui, RGUI_SETTINGS); rgui->msg_force = true; - if (menu_replace_config(config)) + if (menu_replace_config(rgui, config)) { menu_clear_navigation(rgui); ret = -1; @@ -1417,7 +1417,7 @@ static int menu_common_iterate(void *data, unsigned action) } else if (menu_type == RGUI_SETTINGS_OPEN_HISTORY) { - load_menu_game_history(rgui->selection_ptr); + load_menu_game_history(rgui, rgui->selection_ptr); menu_flush_stack_type(rgui, RGUI_SETTINGS); ret = -1; } @@ -1688,6 +1688,7 @@ static void menu_common_shader_manager_set_preset(void *data, unsigned type, con if (path && shader) { + rgui_handle_t *rgui = (rgui_handle_t*)driver.menu; // Load stored CGP into RGUI menu on success. // Used when a preset is directly loaded. // No point in updating when the CGP was created from RGUI itself. @@ -2141,7 +2142,9 @@ static bool osk_callback_enter_audio_device_init(void *data) static bool osk_callback_enter_filename(void *data) { - if (!driver.osk) + rgui_handle_t *rgui = (rgui_handle_t*)driver.menu; + + if (!driver.osk || !rgui) return false; if (g_extern.lifecycle_state & (1ULL << MODE_OSK_ENTRY_SUCCESS)) @@ -3778,6 +3781,8 @@ static int menu_common_setting_set(void *data, unsigned setting, unsigned action static void menu_common_setting_set_label(char *type_str, size_t type_str_size, unsigned *w, unsigned type) { + rgui_handle_t *rgui = (rgui_handle_t*)driver.menu; + switch (type) { case RGUI_SETTINGS_VIDEO_ROTATION: diff --git a/frontend/menu/disp/rgui.c b/frontend/menu/disp/rgui.c index f496b7ed75..a33eed58c4 100644 --- a/frontend/menu/disp/rgui.c +++ b/frontend/menu/disp/rgui.c @@ -595,9 +595,11 @@ static void rgui_free(void *data) static int rgui_input_postprocess(void *data, uint64_t old_state) { - (void)data; - - int ret = 0; + int ret; + rgui_handle_t *rgui; + + rgui = (rgui_handle_t*)data; + ret = 0; if ((rgui->trigger_state & (1ULL << RARCH_MENU_TOGGLE)) && g_extern.main_is_init && diff --git a/frontend/menu/disp/rmenu.c b/frontend/menu/disp/rmenu.c index d30b10d7c6..2df3cab2c9 100644 --- a/frontend/menu/disp/rmenu.c +++ b/frontend/menu/disp/rmenu.c @@ -464,9 +464,10 @@ static void rmenu_free(void *data) static int rmenu_input_postprocess(void *data, uint64_t old_state) { - (void)data; + int ret; + rgui_handle_t *rgui = (rgui_handle_t*)data; - int ret = 0; + ret = 0; if ((rgui->trigger_state & (1ULL << RARCH_MENU_TOGGLE)) && g_extern.main_is_init && diff --git a/frontend/menu/menu_common.c b/frontend/menu/menu_common.c index 6a5504e971..0c5ae30af3 100644 --- a/frontend/menu/menu_common.c +++ b/frontend/menu/menu_common.c @@ -33,8 +33,6 @@ #include "../../compat/posix_string.h" -rgui_handle_t *rgui; - void menu_update_system_info(void *data, bool *load_no_rom) { rgui_handle_t *rgui = (rgui_handle_t*)data; @@ -68,20 +66,22 @@ void menu_update_system_info(void *data, bool *load_no_rom) #endif } -void menu_rom_history_push(const char *path, +void menu_rom_history_push(void *data, const char *path, const char *core_path, const char *core_name) { + rgui_handle_t *rgui = (rgui_handle_t*)data; + if (rgui->history) rom_history_push(rgui->history, path, core_path, core_name); } -void menu_rom_history_push_current(void) +void menu_rom_history_push_current(void *data) { // g_extern.fullpath can be relative here. // Ensure we're pushing absolute path. - char tmp[PATH_MAX]; + rgui_handle_t *rgui = (rgui_handle_t*)data; strlcpy(tmp, g_extern.fullpath, sizeof(tmp)); @@ -89,14 +89,16 @@ void menu_rom_history_push_current(void) path_resolve_realpath(tmp, sizeof(tmp)); if (g_extern.system.no_game || *tmp) - menu_rom_history_push(*tmp ? tmp : NULL, + menu_rom_history_push(rgui, *tmp ? tmp : NULL, g_settings.libretro, g_extern.system.info.library_name); } -void load_menu_game_prepare(void) +void load_menu_game_prepare(void *data) { - if (*g_extern.fullpath || rgui->load_no_rom) + rgui_handle_t *rgui = (rgui_handle_t*)data; + + if (*g_extern.fullpath || (rgui && rgui->load_no_rom)) { if (*g_extern.fullpath) { @@ -111,7 +113,7 @@ void load_menu_game_prepare(void) #ifdef RARCH_CONSOLE if (g_extern.system.no_game || *g_extern.fullpath) #endif - menu_rom_history_push(*g_extern.fullpath ? g_extern.fullpath : NULL, + menu_rom_history_push(rgui, *g_extern.fullpath ? g_extern.fullpath : NULL, g_settings.libretro, rgui->info.library_name ? rgui->info.library_name : ""); } @@ -138,12 +140,18 @@ void load_menu_game_prepare(void) MENU_TEXTURE_FULLSCREEN); } -void load_menu_game_history(unsigned game_index) +void load_menu_game_history(void *data, unsigned game_index) { + rgui_handle_t *rgui; const char *path = NULL; const char *core_path = NULL; const char *core_name = NULL; + rgui = (rgui_handle_t*)data; + + if (!rgui) + return; + rom_history_get_index(rgui->history, game_index, &path, &core_path, &core_name); @@ -163,9 +171,11 @@ void load_menu_game_history(unsigned game_index) #endif } -static void menu_init_history(void) +static void menu_init_history(void *data) { - if (rgui->history) + rgui_handle_t *rgui = (rgui_handle_t*)data; + + if (rgui && rgui->history) { rom_history_free(rgui->history); rgui->history = NULL; @@ -187,8 +197,13 @@ static void menu_init_history(void) } } -static void menu_update_libretro_info(void) +static void menu_update_libretro_info(void *data) { + rgui_handle_t *rgui = (rgui_handle_t*)data; + + if (!rgui) + return; + *rgui->libretro_dir = '\0'; #if defined(RARCH_CONSOLE) @@ -213,8 +228,13 @@ static void menu_update_libretro_info(void) menu_update_system_info(rgui, NULL); } -void load_menu_game_prepare_dummy(void) +void load_menu_game_prepare_dummy(void *data) { + rgui_handle_t *rgui = (rgui_handle_t*)data; + + if (!rgui) + return; + // Starts dummy core. *g_extern.fullpath = '\0'; rgui->load_no_rom = false; @@ -224,13 +244,14 @@ void load_menu_game_prepare_dummy(void) g_extern.system.shutdown = false; } -bool load_menu_game(void) +bool load_menu_game(void *data) { + struct rarch_main_wrap args = {0}; + rgui_handle_t *rgui = (rgui_handle_t*)data; + if (g_extern.main_is_init) rarch_main_deinit(); - struct rarch_main_wrap args = {0}; - args.verbose = g_extern.verbose; args.config_path = *g_extern.config_path ? g_extern.config_path : NULL; args.sram_path = *g_extern.savefile_dir ? g_extern.savefile_dir : NULL; @@ -238,33 +259,44 @@ bool load_menu_game(void) args.rom_path = *g_extern.fullpath ? g_extern.fullpath : NULL; args.libretro_path = *g_settings.libretro ? g_settings.libretro : NULL; args.no_rom = rgui->load_no_rom; - rgui->load_no_rom = false; - if (rarch_main_init_wrap(&args) == 0) + if (rgui) + rgui->load_no_rom = false; + + if (rarch_main_init_wrap(&args) != 0) { - RARCH_LOG("rarch_main_init_wrap() succeeded.\n"); - // Update menu state which depends on config. - menu_update_libretro_info(); - menu_init_history(); - if (driver.menu_ctx && driver.menu_ctx->backend && driver.menu_ctx->backend->shader_manager_init) - driver.menu_ctx->backend->shader_manager_init(rgui); - return true; - } - else - { - char name[PATH_MAX]; - char msg[PATH_MAX]; + char name[PATH_MAX], msg[PATH_MAX]; + fill_pathname_base(name, g_extern.fullpath, sizeof(name)); snprintf(msg, sizeof(msg), "Failed to load %s.\n", name); msg_queue_push(g_extern.msg_queue, msg, 1, 90); - rgui->msg_force = true; + if (rgui) + rgui->msg_force = true; RARCH_ERR("rarch_main_init_wrap() failed.\n"); return false; } + + RARCH_LOG("rarch_main_init_wrap() succeeded.\n"); + + if (rgui) + { + // Update menu state which depends on config. + menu_update_libretro_info(rgui); + menu_init_history(rgui); + if (driver.menu_ctx && driver.menu_ctx->backend && driver.menu_ctx->backend->shader_manager_init) + driver.menu_ctx->backend->shader_manager_init(rgui); + } + + return true; } -void menu_init(void) +void *menu_init(void) { + rgui_handle_t *rgui = (rgui_handle_t*)calloc(1, sizeof(rgui)); + + if (!rgui) + return NULL; + if (!menu_ctx_init_first(&driver.menu_ctx, (void**)&rgui)) { RARCH_ERR("Could not initialize menu.\n"); @@ -287,17 +319,24 @@ void menu_init(void) rgui->frame_buf_show = true; rgui->current_pad = 0; - menu_update_libretro_info(); + menu_update_libretro_info(rgui); if (driver.menu_ctx && driver.menu_ctx->backend && driver.menu_ctx->backend->shader_manager_init) driver.menu_ctx->backend->shader_manager_init(rgui); - menu_init_history(); + menu_init_history(rgui); rgui->last_time = rarch_get_time_usec(); + + return rgui; } -void menu_free(void) +void menu_free(void *data) { + rgui_handle_t *rgui = (rgui_handle_t*)data; + + if (!rgui) + return; + if (driver.menu_ctx && driver.menu_ctx->free) driver.menu_ctx->free(rgui); @@ -354,17 +393,23 @@ void menu_ticker_line(char *buf, size_t len, unsigned index, const char *str, bo } #ifdef HAVE_MENU -uint64_t menu_input(void) +uint64_t menu_input(void *data) { unsigned i; - uint64_t input_state = 0; - + uint64_t input_state; + rgui_handle_t *rgui; #ifdef RARCH_CONSOLE static const struct retro_keybind *binds[] = { g_settings.input.menu_binds }; #else static const struct retro_keybind *binds[] = { g_settings.input.binds[0] }; #endif + rgui = (rgui_handle_t*)data; + input_state = 0; + + if (!rgui) + return 0; + input_push_analog_dpad((struct retro_keybind*)binds[0], g_settings.input.analog_dpad_mode[0]); for (i = 0; i < MAX_PLAYERS; i++) input_push_analog_dpad(g_settings.input.autoconf_binds[i], g_settings.input.analog_dpad_mode[i]); @@ -422,8 +467,13 @@ void menu_flush_stack_type(void *data, unsigned final_type) } } -void load_menu_game_new_core(void) +void load_menu_game_new_core(void *data) { + rgui_handle_t *rgui = (rgui_handle_t*)data; + + if (!rgui) + return; + #ifdef HAVE_DYNAMIC menu_update_system_info(rgui, &rgui->load_no_rom); g_extern.lifecycle_state |= (1ULL << MODE_LOAD_GAME); @@ -433,17 +483,23 @@ void load_menu_game_new_core(void) #endif } -bool menu_iterate(void) +bool menu_iterate(void *data) { retro_time_t time, delta, target_msec, sleep_msec; unsigned action; static bool initial_held = true; static bool first_held = false; - uint64_t input_state = 0; + uint64_t input_state; int32_t input_entry_ret, ret; + rgui_handle_t *rgui; + input_state = 0; input_entry_ret = 0; ret = 0; + rgui = (rgui_handle_t*)data; + + if (!rgui) + return false; if (g_extern.lifecycle_state & (1ULL << MODE_MENU_PREINIT)) { @@ -465,7 +521,7 @@ bool menu_iterate(void) return false; } - input_state = menu_input(); + input_state = menu_input(rgui); if (rgui->do_held) { @@ -566,9 +622,13 @@ bool menu_iterate(void) // Likely to have lots of small bugs. // Cleanly exit the main loop to ensure that all the tiny details get set properly. // This should mitigate most of the smaller bugs. -bool menu_replace_config(const char *path) +bool menu_replace_config(void *data, const char *path) { - if (strcmp(path, g_extern.config_path) == 0) + rgui_handle_t *rgui; + + rgui = (rgui_handle_t*)data; + + if (strcmp(path, g_extern.config_path) == 0 || !rgui) return false; if (g_extern.config_save_on_exit && *g_extern.config_path) @@ -851,6 +911,7 @@ void menu_build_scroll_indices(void *data, file_list_t *buf) void menu_init_core_info(void *data) { rgui_handle_t *rgui = (rgui_handle_t*)data; + core_info_list_free(rgui->core_info); rgui->core_info = NULL; if (*rgui->libretro_dir) diff --git a/frontend/menu/menu_common.h b/frontend/menu/menu_common.h index 7f4ff7b89e..72e3c7c002 100644 --- a/frontend/menu/menu_common.h +++ b/frontend/menu/menu_common.h @@ -182,30 +182,28 @@ typedef struct bool bind_mode_keyboard; } rgui_handle_t; -extern rgui_handle_t *rgui; - -void menu_init(void); -bool menu_iterate(void); -void menu_free(void); +void *menu_init(void); +bool menu_iterate(void *data); +void menu_free(void *data); void menu_ticker_line(char *buf, size_t len, unsigned tick, const char *str, bool selected); void menu_init_core_info(void *data); -void load_menu_game_prepare(void); -void load_menu_game_prepare_dummy(void); -bool load_menu_game(void); -void load_menu_game_history(unsigned game_index); -extern void load_menu_game_new_core(void); -void menu_rom_history_push(const char *path, const char *core_path, +void load_menu_game_prepare(void *data); +void load_menu_game_prepare_dummy(void *data); +bool load_menu_game(void *data); +void load_menu_game_history(void *data, unsigned game_index); +extern void load_menu_game_new_core(void *data); +void menu_rom_history_push(void *data, const char *path, const char *core_path, const char *core_name); -void menu_rom_history_push_current(void); +void menu_rom_history_push_current(void *data); -bool menu_replace_config(const char *path); +bool menu_replace_config(void *data, const char *path); bool menu_save_new_config(void); -uint64_t menu_input(void); +uint64_t menu_input(void *data); void menu_flush_stack_type(void *data, unsigned final_type); void menu_update_system_info(void *data, bool *load_no_rom); diff --git a/frontend/menu/menu_input_line_cb.c b/frontend/menu/menu_input_line_cb.c index 9e4fd8a6f7..77f5bfb245 100644 --- a/frontend/menu/menu_input_line_cb.c +++ b/frontend/menu/menu_input_line_cb.c @@ -112,6 +112,7 @@ void preset_filename_callback(void *userdata, const char *str) void menu_key_event(bool down, unsigned keycode, uint32_t character, uint16_t mod) { + rgui_handle_t *rgui = (rgui_handle_t*)driver.menu; (void)down; (void)keycode; (void)mod; diff --git a/frontend/platform/platform_apple.c b/frontend/platform/platform_apple.c index 9ce9a37e06..60c31d0677 100644 --- a/frontend/platform/platform_apple.c +++ b/frontend/platform/platform_apple.c @@ -109,10 +109,10 @@ int apple_rarch_load_content(int argc, char* argv[]) if (rarch_main_init(argc, argv)) return 1; - menu_init(); + menu_init(driver.menu); if (!g_extern.libretro_dummy) - menu_rom_history_push_current(); + menu_rom_history_push_current(driver.menu); g_extern.lifecycle_state |= 1ULL << MODE_GAME; diff --git a/frontend/platform/platform_emscripten.c b/frontend/platform/platform_emscripten.c index cd5b4644ba..2be95c0b59 100644 --- a/frontend/platform/platform_emscripten.c +++ b/frontend/platform/platform_emscripten.c @@ -45,13 +45,13 @@ int main(int argc, char *argv[]) if ((init_ret = rarch_main_init(argc, argv))) return init_ret; #ifdef HAVE_MENU - menu_init(); + menu_init(driver.menu); g_extern.lifecycle_state |= 1ULL << MODE_GAME; // If we started a ROM directly from command line, // push it to ROM history. if (!g_extern.libretro_dummy) - menu_rom_history_push_current(); + menu_rom_history_push_current(driver.menu); #endif emscripten_set_main_loop(emscripten_mainloop, g_settings.video.vsync ? 0 : INT_MAX, 1); diff --git a/settings_data.c b/settings_data.c index d3865550d3..18a65fed7e 100644 --- a/settings_data.c +++ b/settings_data.c @@ -498,7 +498,7 @@ const rarch_setting_t* setting_data_get_list(void) CONFIG_PATH(g_settings.game_history_path, "game_history_path", "Content History Path", DEFAULT_ME_YO) WITH_FLAGS(SD_FLAG_ALLOW_EMPTY) CONFIG_UINT(g_settings.game_history_size, "game_history_size", "Content History Size", game_history_size) -#ifdef HAVE_RGUI +#ifdef HAVE_MENU CONFIG_PATH(g_settings.rgui_content_directory, "rgui_browser_directory", "Content Directory", DEFAULT_ME_YO) WITH_FLAGS(SD_FLAG_ALLOW_EMPTY | SD_FLAG_PATH_DIR) CONFIG_PATH(g_settings.rgui_config_directory, "rgui_config_directory", "Config Directory", DEFAULT_ME_YO) WITH_FLAGS(SD_FLAG_ALLOW_EMPTY | SD_FLAG_PATH_DIR) CONFIG_BOOL(g_settings.rgui_show_start_screen, "rgui_show_start_screen", "Show Start Screen", rgui_show_start_screen) From f483d862b236c6d48bcb66534c6cd1096128b595 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 9 May 2014 05:52:18 +0200 Subject: [PATCH 10/16] (Apple) Build fix --- frontend/platform/platform_apple.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/frontend/platform/platform_apple.c b/frontend/platform/platform_apple.c index 60c31d0677..4a341e707c 100644 --- a/frontend/platform/platform_apple.c +++ b/frontend/platform/platform_apple.c @@ -103,16 +103,19 @@ void apple_refresh_config(void) int apple_rarch_load_content(int argc, char* argv[]) { + rgui_handle_t *rgui; rarch_main_clear_state(); rarch_init_msg_queue(); if (rarch_main_init(argc, argv)) return 1; - menu_init(driver.menu); + driver.menu = (rgui_handle_t*)menu_init(); + + rgui = (rgui_handle_t*)driver.menu; - if (!g_extern.libretro_dummy) - menu_rom_history_push_current(driver.menu); + if (!g_extern.libretro_dummy && rgui) + menu_rom_history_push_current(rgui); g_extern.lifecycle_state |= 1ULL << MODE_GAME; From 4d46c3691727f98e29dca085b963592448ceac12 Mon Sep 17 00:00:00 2001 From: Twinaphex Date: Thu, 8 May 2014 20:56:55 -0700 Subject: [PATCH 11/16] (360) Build fix --- gfx/shader_common.h | 3 +++ msvc/msvc-2010/RetroArch-msvc2010.vcxproj.filters | 6 +++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/gfx/shader_common.h b/gfx/shader_common.h index 628dbafa6b..f318b3f97c 100644 --- a/gfx/shader_common.h +++ b/gfx/shader_common.h @@ -56,9 +56,12 @@ struct gl_shader_backend enum rarch_shader_type type; }; +#ifdef HAVE_OPENGL void gl_load_texture_data(GLuint obj, const struct texture_image *img, GLenum wrap, bool linear, bool mipmap); bool gl_load_luts(const struct gfx_shader *generic_shader, GLuint *lut_textures); #endif +#endif + diff --git a/msvc/msvc-2010/RetroArch-msvc2010.vcxproj.filters b/msvc/msvc-2010/RetroArch-msvc2010.vcxproj.filters index 9b27a274f1..63a917bc82 100644 --- a/msvc/msvc-2010/RetroArch-msvc2010.vcxproj.filters +++ b/msvc/msvc-2010/RetroArch-msvc2010.vcxproj.filters @@ -234,6 +234,10 @@ frontend\menu\backend + + + gfx + @@ -303,4 +307,4 @@ {dd1ca879-56f4-43f6-8bd8-ae50222061e8} - + \ No newline at end of file From cf669f21caf569d188673679aba04722e6be4b78 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 9 May 2014 06:12:53 +0200 Subject: [PATCH 12/16] * Add 'null' frontend context driver (will come into use later on in more important ways) * RetroArch when compiled with menu support will now cleanly exit if menu driver cannot be initialized properly --- Makefile | 1 + Makefile.emscripten | 1 + Makefile.win | 1 + frontend/frontend.c | 28 +++++++++++++------------ frontend/frontend_context.c | 1 + frontend/frontend_context.h | 1 + frontend/platform/platform_null.c | 34 +++++++++++++++++++++++++++++++ griffin/griffin.c | 1 + 8 files changed, 55 insertions(+), 13 deletions(-) create mode 100644 frontend/platform/platform_null.c diff --git a/Makefile b/Makefile index 64c65ec5b2..61b678d38d 100644 --- a/Makefile +++ b/Makefile @@ -6,6 +6,7 @@ OBJDIR := obj-unix OBJ = frontend/frontend.o \ frontend/frontend_context.o \ + frontend/platform/platform_null.o \ retroarch.o \ file.o \ file_path.o \ diff --git a/Makefile.emscripten b/Makefile.emscripten index d12fe0a43b..3b38873fff 100644 --- a/Makefile.emscripten +++ b/Makefile.emscripten @@ -1,6 +1,7 @@ TARGET = retroarch.js OBJ = frontend/platform/platform_emscripten.o \ + frontend/platform/platform_null.o \ frontend/frontend.o \ retroarch.o \ file.o \ diff --git a/Makefile.win b/Makefile.win index 1c07f211d8..ea50c31932 100644 --- a/Makefile.win +++ b/Makefile.win @@ -5,6 +5,7 @@ OBJDIR := obj-w32 OBJ = frontend/frontend.o \ frontend/frontend_context.o \ + frontend/platform/platform_null.o \ retroarch.o \ file.o \ file_path.o \ diff --git a/frontend/frontend.c b/frontend/frontend.c index 26a4813412..fbe9773be1 100644 --- a/frontend/frontend.c +++ b/frontend/frontend.c @@ -117,10 +117,6 @@ static void rarch_get_environment_console(void) #define attempt_load_game_fails (1ULL << MODE_EXIT) #endif -#define frontend_init_enable true -#define menu_init_enable true -#define initial_lifecycle_state_preinit false - static retro_keyboard_event_t key_event; #ifdef HAVE_MENU @@ -345,14 +341,16 @@ returntype main_entry(signature()) declare_argv(); args_type() args = (args_type())args_initial_ptr(); - if (frontend_init_enable) - { - frontend_ctx = (frontend_ctx_driver_t*)frontend_ctx_init_first(); + frontend_ctx = (frontend_ctx_driver_t*)frontend_ctx_init_first(); - if (frontend_ctx && frontend_ctx->init) - frontend_ctx->init(args); + if (!frontend_ctx) + { + RARCH_WARN("Frontend context could not be initialized.\n"); } + if (frontend_ctx && frontend_ctx->init) + frontend_ctx->init(args); + if (!ra_preinited) { rarch_main_clear_state(); @@ -372,14 +370,18 @@ returntype main_entry(signature()) } #if defined(HAVE_MENU) - if (menu_init_enable) - driver.menu = (rgui_handle_t*)menu_init(); + driver.menu = (rgui_handle_t*)menu_init(); + + if (!driver.menu) + { + RARCH_ERR("Couldn't initialize menu, exiting...\n"); + returnfunc(); + } if (frontend_ctx && frontend_ctx->process_args) frontend_ctx->process_args(argc, argv, args); - if (!initial_lifecycle_state_preinit) - g_extern.lifecycle_state |= initial_menu_lifecycle_state; + g_extern.lifecycle_state |= initial_menu_lifecycle_state; if (attempt_load_game_push_history) { diff --git a/frontend/frontend_context.c b/frontend/frontend_context.c index 7b7996f537..ab5c93314f 100644 --- a/frontend/frontend_context.c +++ b/frontend/frontend_context.c @@ -42,6 +42,7 @@ static const frontend_ctx_driver_t *frontend_ctx_drivers[] = { #if defined(PSP) &frontend_ctx_psp, #endif + &frontend_ctx_null, NULL // zero length array is not valid }; diff --git a/frontend/frontend_context.h b/frontend/frontend_context.h index f6074bd268..3cf88c0260 100644 --- a/frontend/frontend_context.h +++ b/frontend/frontend_context.h @@ -51,6 +51,7 @@ extern const frontend_ctx_driver_t frontend_ctx_qnx; extern const frontend_ctx_driver_t frontend_ctx_apple; extern const frontend_ctx_driver_t frontend_ctx_android; extern const frontend_ctx_driver_t frontend_ctx_psp; +extern const frontend_ctx_driver_t frontend_ctx_null; const frontend_ctx_driver_t *frontend_ctx_find_driver(const char *ident); // Finds driver with ident. Does not initialize. const frontend_ctx_driver_t *frontend_ctx_init_first(void); // Finds first suitable driver and initializes. diff --git a/frontend/platform/platform_null.c b/frontend/platform/platform_null.c new file mode 100644 index 0000000000..083ff917dc --- /dev/null +++ b/frontend/platform/platform_null.c @@ -0,0 +1,34 @@ +/* RetroArch - A frontend for libretro. + * Copyright (C) 2010-2014 - Hans-Kristian Arntzen + * Copyright (C) 2011-2014 - Daniel De Matteis + * Copyright (C) 2012-2014 - Jason Fetters + * + * 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 . + */ + +#include "../frontend_context.h" + +#include +#include "../../boolean.h" +#include +#include + +const frontend_ctx_driver_t frontend_ctx_null = { + NULL, /* environment_get */ + NULL, /* init */ + NULL, /* deinit */ + NULL, /* exitspawn */ + NULL, /* process_args */ + NULL, /* process_events */ + NULL, /* exec */ + NULL, /* shutdown */ + "null", +}; diff --git a/griffin/griffin.c b/griffin/griffin.c index f2e58a768a..43e1ac7e07 100644 --- a/griffin/griffin.c +++ b/griffin/griffin.c @@ -560,6 +560,7 @@ FRONTEND #elif defined(ANDROID) #include "../frontend/platform/platform_android.c" #endif +#include "../frontend/platform/platform_null.c" #include "../frontend/info/core_info.c" From a8642eb686baa30bb7349822e7a528a1f6419f5a Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 9 May 2014 06:16:14 +0200 Subject: [PATCH 13/16] (PS3/Wii) Salamander build fix --- Makefile.ps3.salamander | 2 +- Makefile.wii.salamander | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile.ps3.salamander b/Makefile.ps3.salamander index 2eb908e966..9e69e59fa0 100644 --- a/Makefile.ps3.salamander +++ b/Makefile.ps3.salamander @@ -19,7 +19,7 @@ endif STRIP = $(CELL_SDK)/host-win32/ppu/bin/ppu-lv2-strip.exe PPU_CFLAGS += -I. -D__CELLOS_LV2__ -DIS_SALAMANDER -DRARCH_CONSOLE -DHAVE_SYSUTILS -DHAVE_SYSMODULES -DHAVE_RARCH_EXEC -DRARCH_INTERNAL -PPU_SRCS = frontend/frontend_salamander.c frontend/frontend_context.c file_path.c compat/compat.c conf/config_file.c +PPU_SRCS = frontend/frontend_salamander.c frontend/frontend_context.c frontend/platform/platform_null.c file_path.c compat/compat.c conf/config_file.c ifeq ($(HAVE_LOGGER), 1) PPU_CFLAGS += -DHAVE_LOGGER -Iconsole/logger diff --git a/Makefile.wii.salamander b/Makefile.wii.salamander index fa303bd71c..7dc56d3d2e 100644 --- a/Makefile.wii.salamander +++ b/Makefile.wii.salamander @@ -39,7 +39,7 @@ LIBS := -lfat -lwiiuse -logc -lbte APP_BOOTER_DIR = wii/app_booter -OBJ = frontend/frontend_salamander.o frontend/frontend_context.o file_path.o compat/compat.o conf/config_file.o $(APP_BOOTER_DIR)/app_booter.binobj +OBJ = frontend/frontend_salamander.o frontend/frontend_context.o frontend/platform/platform_null.o file_path.o compat/compat.o conf/config_file.o $(APP_BOOTER_DIR)/app_booter.binobj ifeq ($(HAVE_LOGGER), 1) CFLAGS += -DHAVE_LOGGER From beb0a8069219a6c8f195c3853bf9fe1448209594 Mon Sep 17 00:00:00 2001 From: Twinaphex Date: Thu, 8 May 2014 21:22:55 -0700 Subject: [PATCH 14/16] (MSVC 2010) Build fix --- msvc/msvc-2010/RetroArch-msvc2010.vcxproj | 3 ++- msvc/msvc-2010/RetroArch-msvc2010.vcxproj.filters | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/msvc/msvc-2010/RetroArch-msvc2010.vcxproj b/msvc/msvc-2010/RetroArch-msvc2010.vcxproj index 4e6fa89fc0..f4c3be7d92 100644 --- a/msvc/msvc-2010/RetroArch-msvc2010.vcxproj +++ b/msvc/msvc-2010/RetroArch-msvc2010.vcxproj @@ -224,6 +224,7 @@ + @@ -338,4 +339,4 @@ - + \ No newline at end of file diff --git a/msvc/msvc-2010/RetroArch-msvc2010.vcxproj.filters b/msvc/msvc-2010/RetroArch-msvc2010.vcxproj.filters index 63a917bc82..a9a2e70e3a 100644 --- a/msvc/msvc-2010/RetroArch-msvc2010.vcxproj.filters +++ b/msvc/msvc-2010/RetroArch-msvc2010.vcxproj.filters @@ -238,6 +238,9 @@ gfx + + frontend\platform + @@ -306,5 +309,8 @@ {dd1ca879-56f4-43f6-8bd8-ae50222061e8} + + {09d78055-1c93-4f12-ae3e-97aaa90cf78f} + \ No newline at end of file From 540fad51a6d9f5b993adfff178b3179bbc439297 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 9 May 2014 06:45:03 +0200 Subject: [PATCH 15/16] (RARCH_CONSOLE) Can finally get rid of global_driver_init --- driver.c | 12 ------------ driver.h | 1 - frontend/frontend.c | 37 +++++++++++++++---------------------- 3 files changed, 15 insertions(+), 35 deletions(-) diff --git a/driver.c b/driver.c index a62e622edb..2241c92199 100644 --- a/driver.c +++ b/driver.c @@ -713,18 +713,6 @@ bool driver_update_system_av_info(const struct retro_system_av_info *info) return true; } -// Only called once on init and deinit. -// Video and input drivers need to be active (owned) -// before retroarch core starts. -// Core handles audio. - -void global_init_drivers(void) -{ - find_audio_driver(); - find_input_driver(); - init_video_input(); -} - void global_uninit_drivers(void) { if (driver.video && driver.video_data) diff --git a/driver.h b/driver.h index 140165bb82..0f6c01cfed 100644 --- a/driver.h +++ b/driver.h @@ -539,7 +539,6 @@ void init_drivers(void); void init_drivers_pre(void); void uninit_drivers(void); -void global_init_drivers(void); void global_uninit_drivers(void); void init_video_input(void); diff --git a/frontend/frontend.c b/frontend/frontend.c index fbe9773be1..aa8e54688b 100644 --- a/frontend/frontend.c +++ b/frontend/frontend.c @@ -32,23 +32,7 @@ frontend_ctx_driver_t *frontend_ctx; #ifdef RARCH_CONSOLE #include "../config.def.h" - default_paths_t default_paths; - -static void rarch_get_environment_console(void) -{ - path_mkdir(default_paths.port_dir); - path_mkdir(default_paths.system_dir); - path_mkdir(default_paths.savestate_dir); - path_mkdir(default_paths.sram_dir); - - config_load(); - - init_libretro_sym(false); - rarch_init_system_info(); - - global_init_drivers(); -} #endif #if defined(ANDROID) @@ -89,27 +73,24 @@ static void rarch_get_environment_console(void) #define ra_preinited false #endif -#if defined(HAVE_BB10) || defined(RARCH_CONSOLE) +#if defined(HAVE_BB10) #define attempt_load_game false #else #define attempt_load_game true #endif -#if defined(RARCH_CONSOLE) || defined(HAVE_BB10) || defined(ANDROID) +#if defined(HAVE_BB10) || defined(ANDROID) #define initial_menu_lifecycle_state (1ULL << MODE_LOAD_GAME) #else #define initial_menu_lifecycle_state (1ULL << MODE_GAME) #endif -#if !defined(RARCH_CONSOLE) && !defined(HAVE_BB10) && !defined(ANDROID) +#if !defined(HAVE_BB10) && !defined(ANDROID) #define attempt_load_game_push_history true #else #define attempt_load_game_push_history false #endif -#ifndef RARCH_CONSOLE -#define rarch_get_environment_console() (void)0 -#endif #if defined(RARCH_CONSOLE) || defined(__QNX__) || defined(ANDROID) #define attempt_load_game_fails (1ULL << MODE_MENU_PREINIT) @@ -119,6 +100,18 @@ static void rarch_get_environment_console(void) static retro_keyboard_event_t key_event; +static void rarch_get_environment_console(void) +{ +#ifdef RARCH_CONSOLE + path_mkdir(default_paths.port_dir); + path_mkdir(default_paths.system_dir); + path_mkdir(default_paths.savestate_dir); + path_mkdir(default_paths.sram_dir); + + config_load(); +#endif +} + #ifdef HAVE_MENU static int main_entry_iterate_clear_input(args_type() args) { From 9773d001a4d32913a25bbbb0b116913cc1e26ca1 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 9 May 2014 16:18:08 +0200 Subject: [PATCH 16/16] (SoftFilters) Update 2xbr/2xsai/blargg_ntsc_snes_composite/blargg_ntsc_snes_rgb --- gfx/filters/2xbr.c | 270 ++++++++++++++++------- gfx/filters/2xsai.c | 25 ++- gfx/filters/blargg_ntsc_snes_composite.c | 96 ++++---- gfx/filters/blargg_ntsc_snes_rgb.c | 93 ++++---- 4 files changed, 329 insertions(+), 155 deletions(-) diff --git a/gfx/filters/2xbr.c b/gfx/filters/2xbr.c index 74af6503bf..6b466e0bdc 100644 --- a/gfx/filters/2xbr.c +++ b/gfx/filters/2xbr.c @@ -36,14 +36,38 @@ // Compile: gcc -o twoxbr.so -shared twoxbr.c -std=c99 -O3 -Wall -pedantic -fPIC #include "softfilter.h" -#include "softfilter_prototypes.h" #include - + #ifdef RARCH_INTERNAL #define softfilter_get_implementation twoxbr_get_implementation +#define softfilter_thread_data twoxbr_softfilter_thread_data +#define filter_data twoxbr_filter_data #endif #define TWOXBR_SCALE 2 + +struct softfilter_thread_data +{ + void *out_data; + const void *in_data; + size_t out_pitch; + size_t in_pitch; + unsigned colfmt; + unsigned width; + unsigned height; + int first; + int last; +}; + +struct filter_data +{ + unsigned threads; + struct softfilter_thread_data *workers; + unsigned in_fmt; + uint16_t RGBtoYUV[65536]; + uint16_t tbl_5_to_8[32]; + uint16_t tbl_6_to_8[64]; +}; static unsigned twoxbr_generic_input_fmts(void) { @@ -60,6 +84,141 @@ static unsigned twoxbr_generic_threads(void *data) struct filter_data *filt = (struct filter_data*)data; return filt->threads; } + +#define RED_MASK565 0xF800 +#define GREEN_MASK565 0x07E0 +#define BLUE_MASK565 0x001F +#define PG_LBMASK565 0xF7DE + +#ifdef MSB_FIRST + #define RED_MASK8888 0xFF000000 + #define GREEN_MASK8888 0x00FF0000 + #define BLUE_MASK8888 0x0000FF00 + #define PG_LBMASK8888 0xFEFEFEFE + #define ALPHA_MASK8888 0x000000FF +#else + #define RED_MASK8888 0x000000FF + #define GREEN_MASK8888 0x0000FF00 + #define BLUE_MASK8888 0x00FF0000 + #define PG_LBMASK8888 0xFEFEFEFE + #define ALPHA_MASK8888 0xFF000000 +#endif + +static void SetupFormat(void * data) +{ + uint16_t r, g, b, y, u, v; + uint32_t c; + struct filter_data *filt = (struct filter_data*)data; + + filt->tbl_5_to_8[0] = 0; + filt->tbl_5_to_8[1] = 8; + filt->tbl_5_to_8[2] = 16; + filt->tbl_5_to_8[3] = 25; + filt->tbl_5_to_8[4] = 33; + filt->tbl_5_to_8[5] = 41; + filt->tbl_5_to_8[6] = 49; + filt->tbl_5_to_8[7] = 58; + filt->tbl_5_to_8[8] = 66; + filt->tbl_5_to_8[9] = 74; + filt->tbl_5_to_8[10] = 82; + filt->tbl_5_to_8[11] = 90; + filt->tbl_5_to_8[12] = 99; + filt->tbl_5_to_8[13] = 107; + filt->tbl_5_to_8[14] = 115; + filt->tbl_5_to_8[15] = 123; + filt->tbl_5_to_8[16] = 132; + filt->tbl_5_to_8[17] = 140; + filt->tbl_5_to_8[18] = 148; + filt->tbl_5_to_8[19] = 156; + filt->tbl_5_to_8[20] = 165; + filt->tbl_5_to_8[21] = 173; + filt->tbl_5_to_8[22] = 181; + filt->tbl_5_to_8[23] = 189; + filt->tbl_5_to_8[24] = 197; + filt->tbl_5_to_8[25] = 206; + filt->tbl_5_to_8[26] = 214; + filt->tbl_5_to_8[27] = 222; + filt->tbl_5_to_8[28] = 230; + filt->tbl_5_to_8[29] = 239; + filt->tbl_5_to_8[30] = 247; + filt->tbl_5_to_8[31] = 255; + + filt->tbl_6_to_8[0] = 0; + filt->tbl_6_to_8[1] = 4; + filt->tbl_6_to_8[2] = 8; + filt->tbl_6_to_8[3] = 12; + filt->tbl_6_to_8[4] = 16; + filt->tbl_6_to_8[5] = 20; + filt->tbl_6_to_8[6] = 24; + filt->tbl_6_to_8[7] = 28; + filt->tbl_6_to_8[8] = 32; + filt->tbl_6_to_8[9] = 36; + filt->tbl_6_to_8[10] = 40; + filt->tbl_6_to_8[11] = 45; + filt->tbl_6_to_8[12] = 49; + filt->tbl_6_to_8[13] = 53; + filt->tbl_6_to_8[14] = 57; + filt->tbl_6_to_8[15] = 61; + filt->tbl_6_to_8[16] = 65; + filt->tbl_6_to_8[17] = 69; + filt->tbl_6_to_8[18] = 73; + filt->tbl_6_to_8[19] = 77; + filt->tbl_6_to_8[20] = 81; + filt->tbl_6_to_8[21] = 85; + filt->tbl_6_to_8[22] = 89; + filt->tbl_6_to_8[23] = 93; + filt->tbl_6_to_8[24] = 97; + filt->tbl_6_to_8[25] = 101; + filt->tbl_6_to_8[26] = 105; + filt->tbl_6_to_8[27] = 109; + filt->tbl_6_to_8[28] = 113; + filt->tbl_6_to_8[29] = 117; + filt->tbl_6_to_8[30] = 121; + filt->tbl_6_to_8[31] = 125; + filt->tbl_6_to_8[32] = 130; + filt->tbl_6_to_8[33] = 134; + filt->tbl_6_to_8[34] = 138; + filt->tbl_6_to_8[35] = 142; + filt->tbl_6_to_8[36] = 146; + filt->tbl_6_to_8[37] = 150; + filt->tbl_6_to_8[38] = 154; + filt->tbl_6_to_8[39] = 158; + filt->tbl_6_to_8[40] = 162; + filt->tbl_6_to_8[41] = 166; + filt->tbl_6_to_8[42] = 170; + filt->tbl_6_to_8[43] = 174; + filt->tbl_6_to_8[44] = 178; + filt->tbl_6_to_8[45] = 182; + filt->tbl_6_to_8[46] = 186; + filt->tbl_6_to_8[47] = 190; + filt->tbl_6_to_8[48] = 194; + filt->tbl_6_to_8[49] = 198; + filt->tbl_6_to_8[50] = 202; + filt->tbl_6_to_8[51] = 206; + filt->tbl_6_to_8[52] = 210; + filt->tbl_6_to_8[53] = 215; + filt->tbl_6_to_8[54] = 219; + filt->tbl_6_to_8[55] = 223; + filt->tbl_6_to_8[56] = 227; + filt->tbl_6_to_8[57] = 231; + filt->tbl_6_to_8[58] = 235; + filt->tbl_6_to_8[59] = 239; + filt->tbl_6_to_8[60] = 243; + filt->tbl_6_to_8[61] = 247; + filt->tbl_6_to_8[62] = 251; + filt->tbl_6_to_8[63] = 255; + + for (c = 0; c < 65536; c++) + { + r = filt->tbl_5_to_8[(c & RED_MASK565) >> 11]; + g = filt->tbl_6_to_8[(c & GREEN_MASK565) >> 5]; + b = filt->tbl_5_to_8[(c & BLUE_MASK565) ]; + y = ((r << 4) + (g << 5) + (b << 2)); + u = ( -r - (g << 1) + (b << 2)); + v = ((r << 1) - (g << 1) - (b >> 1)); + filt->RGBtoYUV[c] = y + u + v; + } +} static void *twoxbr_generic_create(unsigned in_fmt, unsigned out_fmt, unsigned max_width, unsigned max_height, @@ -78,6 +237,9 @@ static void *twoxbr_generic_create(unsigned in_fmt, unsigned out_fmt, free(filt); return NULL; } + + SetupFormat(filt); + return filt; } @@ -95,32 +257,10 @@ static void twoxbr_generic_destroy(void *data) free(filt); } -static uint8_t initialized = 0; -uint16_t RGBtoYUV[65536]; -const static uint16_t tbl_5_to_8[32]={0, 8, 16, 25, 33, 41, 49, 58, 66, 74, 82, 90, 99, 107, 115, 123, 132, 140, 148, 156, 165, 173, 181, 189, 197, 206, 214, 222, 230, 239, 247, 255}; -const static uint16_t tbl_6_to_8[64]={0, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 45, 49, 53, 57, 61, 65, 69, 73, 77, 81, 85, 89, 93, 97, 101, 105, 109, 113, 117, 121, 125, 130, 134, 138, 142, 146, 150, 154, 158, 162, 166, 170, 174, 178, 182, 186, 190, 194, 198, 202, 206, 210, 215, 219, 223, 227, 231, 235, 239, 243, 247, 251, 255}; //--------------------------------------------------------------------------------------------------------------------------- - #define RED_MASK565 0xF800 - #define GREEN_MASK565 0x07E0 - #define BLUE_MASK565 0x001F - #define PG_LBMASK565 0xF7DE - -#ifdef MSB_FIRST - #define RED_MASK8888 0xFF000000 - #define GREEN_MASK8888 0x00FF0000 - #define BLUE_MASK8888 0x0000FF00 - #define PG_LBMASK8888 0xFEFEFEFE - #define ALPHA_MASK8888 0x000000FF -#else - #define RED_MASK8888 0x000000FF - #define GREEN_MASK8888 0x0000FF00 - #define BLUE_MASK8888 0x00FF0000 - #define PG_LBMASK8888 0xFEFEFEFE - #define ALPHA_MASK8888 0xFF000000 -#endif #define ALPHA_BLEND_128_W(dst, src) dst = ((src & pg_lbmask) >> 1) + ((dst & pg_lbmask) >> 1) @@ -266,11 +406,11 @@ const static uint16_t tbl_6_to_8[64]={0, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, ALPHA_BLEND_128_W(E[N3], PIXEL); \ -#define df(A, B)\ - abs(RGBtoYUV[A] - RGBtoYUV[B])\ +#define df(Z, A, B)\ + abs(Z->RGBtoYUV[A] - Z->RGBtoYUV[B])\ -#define eq(A, B)\ - (df(A, B) < 155)\ +#define eq(Z, A, B)\ + (df(Z, A, B) < 155)\ @@ -319,16 +459,17 @@ int eq8(uint32_t A, uint32_t B, uint32_t pg_red_mask, uint32_t pg_green_mask, ui } -#define FILTRO_RGB565(PE, PI, PH, PF, PG, PC, PD, PB, PA, G5, C4, G0, D0, C1, B1, F4, I4, H5, I5, A0, A1, N0, N1, N2, N3, pg_red_mask, pg_green_mask, pg_blue_mask) \ +#define FILTRO_RGB565(Z, PE, PI, PH, PF, PG, PC, PD, PB, PA, G5, C4, G0, D0, C1, B1, F4, I4, H5, I5, A0, A1, N0, N1, N2, N3, pg_red_mask, pg_green_mask, pg_blue_mask) \ ex = (PE!=PH && PE!=PF); \ if ( ex )\ {\ - e = (df(PE,PC)+df(PE,PG)+df(PI,H5)+df(PI,F4))+(df(PH,PF)<<2); \ - i = (df(PH,PD)+df(PH,I5)+df(PF,I4)+df(PF,PB))+(df(PE,PI)<<2); \ - if ((e=(ki<<1)) && ex2 ) \ {\ LEFT_UP_2_2X(N3, N2, N1, px)\ @@ -348,11 +489,11 @@ int eq8(uint32_t A, uint32_t B, uint32_t pg_red_mask, uint32_t pg_green_mask, ui }\ else if (e<=i)\ {\ - ALPHA_BLEND_128_W( E[N3], ((df(PE,PF) <= df(PE,PH)) ? PF : PH)); \ + ALPHA_BLEND_128_W( E[N3], ((df(Z, PE,PF) <= df(Z, PE,PH)) ? PF : PH)); \ }\ }\ -#define FILTRO_RGB8888(PE, PI, PH, PF, PG, PC, PD, PB, PA, G5, C4, G0, D0, C1, B1, F4, I4, H5, I5, A0, A1, N0, N1, N2, N3, pg_red_mask, pg_green_mask, pg_blue_mask) \ +#define FILTRO_RGB8888(Z, PE, PI, PH, PF, PG, PC, PD, PB, PA, G5, C4, G0, D0, C1, B1, F4, I4, H5, I5, A0, A1, N0, N1, N2, N3, pg_red_mask, pg_green_mask, pg_blue_mask) \ ex = (PE!=PH && PE!=PF); \ if ( ex )\ {\ @@ -415,12 +556,12 @@ int eq8(uint32_t A, uint32_t B, uint32_t pg_red_mask, uint32_t pg_green_mask, ui typename_t I5 = *(in + nextline + nextline + 1); \ #ifndef twoxbr_function -#define twoxbr_function(FILTRO) \ +#define twoxbr_function(FILTRO, Z) \ E[0] = E[1] = E[2] = E[3] = PE;\ - FILTRO(PE, PI, PH, PF, PG, PC, PD, PB, PA, G5, C4, G0, D0, C1, B1, F4, I4, H5, I5, A0, A1, 0, 1, 2, 3, pg_red_mask, pg_green_mask, pg_blue_mask);\ - FILTRO(PE, PC, PF, PB, PI, PA, PH, PD, PG, I4, A1, I5, H5, A0, D0, B1, C1, F4, C4, G5, G0, 2, 0, 3, 1, pg_red_mask, pg_green_mask, pg_blue_mask);\ - FILTRO(PE, PA, PB, PD, PC, PG, PF, PH, PI, C1, G0, C4, F4, G5, H5, D0, A0, B1, A1, I4, I5, 3, 2, 1, 0, pg_red_mask, pg_green_mask, pg_blue_mask);\ - FILTRO(PE, PG, PD, PH, PA, PI, PB, PF, PC, A0, I5, A1, B1, I4, F4, H5, G5, D0, G0, C1, C4, 1, 3, 0, 2, pg_red_mask, pg_green_mask, pg_blue_mask);\ + FILTRO(Z, PE, PI, PH, PF, PG, PC, PD, PB, PA, G5, C4, G0, D0, C1, B1, F4, I4, H5, I5, A0, A1, 0, 1, 2, 3, pg_red_mask, pg_green_mask, pg_blue_mask);\ + FILTRO(Z, PE, PC, PF, PB, PI, PA, PH, PD, PG, I4, A1, I5, H5, A0, D0, B1, C1, F4, C4, G5, G0, 2, 0, 3, 1, pg_red_mask, pg_green_mask, pg_blue_mask);\ + FILTRO(Z, PE, PA, PB, PD, PC, PG, PF, PH, PI, C1, G0, C4, F4, G5, H5, D0, A0, B1, A1, I4, I5, 3, 2, 1, 0, pg_red_mask, pg_green_mask, pg_blue_mask);\ + FILTRO(Z, PE, PG, PD, PH, PA, PI, PB, PF, PC, A0, I5, A1, B1, I4, F4, H5, G5, D0, G0, C1, C4, 1, 3, 0, 2, pg_red_mask, pg_green_mask, pg_blue_mask);\ out[0] = E[0]; \ out[1] = E[1]; \ out[dst_stride] = E[2]; \ @@ -429,42 +570,21 @@ int eq8(uint32_t A, uint32_t B, uint32_t pg_red_mask, uint32_t pg_green_mask, ui out += 2 #endif -static void SetupFormat(void) -{ - uint16_t r, g, b, y, u, v; - uint32_t c; - - for (c = 0; c < 65536; c++) - { - r = tbl_5_to_8[(c & RED_MASK565) >> 11]; - g = tbl_6_to_8[(c & GREEN_MASK565) >> 5]; - b = tbl_5_to_8[(c & BLUE_MASK565) ]; - y = ((r<<4) + (g<<5) + (b<<2)); - u = ( -r - (g<<1) + (b<<2)); - v = ((r<<1) - (g<<1) - (b>>1)); - RGBtoYUV[c] = y + u + v; - } -} - -static void twoxbr_generic_xrgb8888(unsigned width, unsigned height, +static void twoxbr_generic_xrgb8888(void *data, unsigned width, unsigned height, int first, int last, uint32_t *src, unsigned src_stride, uint32_t *dst, unsigned dst_stride) { + unsigned nextline, finish; + struct filter_data *filt = (struct filter_data*)data; uint32_t pg_red_mask = RED_MASK8888; uint32_t pg_green_mask = GREEN_MASK8888; uint32_t pg_blue_mask = BLUE_MASK8888; uint32_t pg_lbmask = PG_LBMASK8888; uint32_t pg_alpha_mask = ALPHA_MASK8888; - unsigned nextline, finish; + nextline = (last) ? 0 : src_stride; - if (!initialized) - { - initialized = 1; - } - - for (; height; height--) { uint32_t *in = (uint32_t*)src; @@ -481,7 +601,7 @@ static void twoxbr_generic_xrgb8888(unsigned width, unsigned height, // G0 PG PH PI I4 // G5 H5 I5 - twoxbr_function(FILTRO_RGB8888); + twoxbr_function(FILTRO_RGB8888, filt); } src += src_stride; @@ -489,12 +609,13 @@ static void twoxbr_generic_xrgb8888(unsigned width, unsigned height, } } -static void twoxbr_generic_rgb565(unsigned width, unsigned height, +static void twoxbr_generic_rgb565(void *data, unsigned width, unsigned height, int first, int last, uint16_t *src, unsigned src_stride, uint16_t *dst, unsigned dst_stride) { uint16_t pg_red_mask, pg_green_mask, pg_blue_mask, pg_lbmask; unsigned nextline, finish; + struct filter_data *filt = (struct filter_data*)data; pg_red_mask = RED_MASK565; pg_green_mask = GREEN_MASK565; @@ -502,11 +623,6 @@ static void twoxbr_generic_rgb565(unsigned width, unsigned height, pg_lbmask = PG_LBMASK565; nextline = (last) ? 0 : src_stride; - if (!initialized) - { - SetupFormat(); - initialized = 1; - } for (; height; height--) { @@ -524,7 +640,7 @@ static void twoxbr_generic_rgb565(unsigned width, unsigned height, // G0 PG PH PI I4 // G5 H5 I5 - twoxbr_function(FILTRO_RGB565); + twoxbr_function(FILTRO_RGB565, filt); } src += src_stride; @@ -540,7 +656,7 @@ static void twoxbr_work_cb_rgb565(void *data, void *thread_data) unsigned width = thr->width; unsigned height = thr->height; - twoxbr_generic_rgb565(width, height, + twoxbr_generic_rgb565(data, width, height, thr->first, thr->last, input, thr->in_pitch / SOFTFILTER_BPP_RGB565, output, thr->out_pitch / SOFTFILTER_BPP_RGB565); } @@ -552,7 +668,7 @@ static void twoxbr_work_cb_xrgb8888(void *data, void *thread_data) unsigned width = thr->width; unsigned height = thr->height; - twoxbr_generic_xrgb8888(width, height, + twoxbr_generic_xrgb8888(data, width, height, thr->first, thr->last, input, thr->in_pitch / SOFTFILTER_BPP_XRGB8888, output, thr->out_pitch / SOFTFILTER_BPP_XRGB8888); } @@ -612,4 +728,6 @@ const struct softfilter_implementation *softfilter_get_implementation(softfilter #ifdef RARCH_INTERNAL #undef softfilter_get_implementation +#undef softfilter_thread_data +#undef filter_data #endif diff --git a/gfx/filters/2xsai.c b/gfx/filters/2xsai.c index 35a949b72c..cf63ebf923 100644 --- a/gfx/filters/2xsai.c +++ b/gfx/filters/2xsai.c @@ -17,15 +17,36 @@ // Compile: gcc -o twoxsai.so -shared twoxsai.c -std=c99 -O3 -Wall -pedantic -fPIC #include "softfilter.h" -#include "softfilter_prototypes.h" #include #ifdef RARCH_INTERNAL #define softfilter_get_implementation twoxsai_get_implementation +#define softfilter_thread_data twoxsai_softfilter_thread_data +#define filter_data twoxsai_filter_data #endif #define TWOXSAI_SCALE 2 +struct softfilter_thread_data +{ + void *out_data; + const void *in_data; + size_t out_pitch; + size_t in_pitch; + unsigned colfmt; + unsigned width; + unsigned height; + int first; + int last; +}; + +struct filter_data +{ + unsigned threads; + struct softfilter_thread_data *workers; + unsigned in_fmt; +}; + static unsigned twoxsai_generic_input_fmts(void) { return SOFTFILTER_FMT_RGB565 | SOFTFILTER_FMT_XRGB8888; @@ -336,4 +357,6 @@ const struct softfilter_implementation *softfilter_get_implementation(softfilter #ifdef RARCH_INTERNAL #undef softfilter_get_implementation +#undef softfilter_thread_data +#undef filter_data #endif diff --git a/gfx/filters/blargg_ntsc_snes_composite.c b/gfx/filters/blargg_ntsc_snes_composite.c index 225c1bdf10..a39f81506c 100755 --- a/gfx/filters/blargg_ntsc_snes_composite.c +++ b/gfx/filters/blargg_ntsc_snes_composite.c @@ -15,20 +15,40 @@ */ #include "softfilter.h" -#include "softfilter_prototypes.h" #include #include "boolean.h" - -#ifdef RARCH_INTERNAL -#define softfilter_get_implementation blargg_ntsc_snes_composite_get_implementation -#endif - #include "snes_ntsc/snes_ntsc.h" #include "snes_ntsc/snes_ntsc.c" -static struct snes_ntsc_t *ntsc_composite; -static int burst_composite; -static int burst_toggle_composite; +#ifdef RARCH_INTERNAL +#define softfilter_get_implementation blargg_ntsc_snes_composite_get_implementation +#define softfilter_thread_data blargg_ntsc_snes_composite_softfilter_thread_data +#define filter_data blargg_ntsc_snes_composite_filter_data +#endif + +struct softfilter_thread_data +{ + void *out_data; + const void *in_data; + size_t out_pitch; + size_t in_pitch; + unsigned colfmt; + unsigned width; + unsigned height; + int first; + int last; +}; + +struct filter_data +{ + unsigned threads; + struct softfilter_thread_data *workers; + unsigned in_fmt; + struct snes_ntsc_t *ntsc; + int burst; + int burst_toggle; +}; + static unsigned blargg_ntsc_snes_composite_generic_input_fmts(void) { @@ -46,6 +66,20 @@ static unsigned blargg_ntsc_snes_composite_generic_threads(void *data) return filt->threads; } +static void blargg_ntsc_snes_composite_initialize(void *data) +{ + snes_ntsc_setup_t setup; + struct filter_data *filt = (struct filter_data*)data; + + filt->ntsc = (snes_ntsc_t*)calloc(1, sizeof(*filt->ntsc)); + setup = snes_ntsc_composite; + setup.merge_fields = 1; + snes_ntsc_init(filt->ntsc, &setup); + + filt->burst = 0; + filt->burst_toggle = (setup.merge_fields ? 0 : 1); +} + static void *blargg_ntsc_snes_composite_generic_create(unsigned in_fmt, unsigned out_fmt, unsigned max_width, unsigned max_height, unsigned threads, softfilter_simd_mask_t simd) @@ -63,30 +97,15 @@ static void *blargg_ntsc_snes_composite_generic_create(unsigned in_fmt, unsigned free(filt); return NULL; } + blargg_ntsc_snes_composite_initialize(filt); + return filt; } -static void blargg_ntsc_snes_composite_initialize(void) -{ - snes_ntsc_setup_t setup; - static bool initialized = false; - if(initialized == true) - return; - initialized = true; - - ntsc_composite = (snes_ntsc_t*)malloc(sizeof(*ntsc_composite)); - setup = snes_ntsc_composite; - setup.merge_fields = 1; - snes_ntsc_init(ntsc_composite, &setup); - - burst_composite = 0; - burst_toggle_composite = (setup.merge_fields ? 0 : 1); -} static void blargg_ntsc_snes_composite_generic_output(void *data, unsigned *out_width, unsigned *out_height, unsigned width, unsigned height) { - blargg_ntsc_snes_composite_initialize(); *out_width = SNES_NTSC_OUT_WIDTH(256); *out_height = height; } @@ -95,34 +114,31 @@ static void blargg_ntsc_snes_composite_generic_destroy(void *data) { struct filter_data *filt = (struct filter_data*)data; - if(ntsc_composite) - free(ntsc_composite); + if(filt->ntsc) + free(filt->ntsc); free(filt->workers); free(filt); } -static void blargg_ntsc_snes_composite_render_rgb565(int width, int height, +static void blargg_ntsc_snes_composite_render_rgb565(void *data, int width, int height, int first, int last, uint16_t *input, int pitch, uint16_t *output, int outpitch) { - blargg_ntsc_snes_composite_initialize(); - if(!ntsc_composite) - return; - + struct filter_data *filt = (struct filter_data*)data; if(width <= 256) - snes_ntsc_blit(ntsc_composite, input, pitch, burst_composite, width, height, output, outpitch * 2, first, last); + snes_ntsc_blit(filt->ntsc, input, pitch, filt->burst, width, height, output, outpitch * 2, first, last); else - snes_ntsc_blit_hires(ntsc_composite, input, pitch, burst_composite, width, height, output, outpitch * 2, first, last); + snes_ntsc_blit_hires(filt->ntsc, input, pitch, filt->burst, width, height, output, outpitch * 2, first, last); - burst_composite ^= burst_toggle_composite; + filt->burst ^= filt->burst_toggle; } -static void blargg_ntsc_snes_composite_rgb565(unsigned width, unsigned height, +static void blargg_ntsc_snes_composite_rgb565(void *data, unsigned width, unsigned height, int first, int last, uint16_t *src, unsigned src_stride, uint16_t *dst, unsigned dst_stride) { - blargg_ntsc_snes_composite_render_rgb565(width, height, + blargg_ntsc_snes_composite_render_rgb565(data, width, height, first, last, src, src_stride, dst, dst_stride); @@ -137,7 +153,7 @@ static void blargg_ntsc_snes_composite_work_cb_rgb565(void *data, void *thread_d unsigned width = thr->width; unsigned height = thr->height; - blargg_ntsc_snes_composite_rgb565(width, height, + blargg_ntsc_snes_composite_rgb565(data, width, height, thr->first, thr->last, input, thr->in_pitch / SOFTFILTER_BPP_RGB565, output, thr->out_pitch / SOFTFILTER_BPP_RGB565); } @@ -193,4 +209,6 @@ const struct softfilter_implementation *softfilter_get_implementation(softfilter #ifdef RARCH_INTERNAL #undef softfilter_get_implementation +#undef softfilter_thread_data +#undef filter_data #endif diff --git a/gfx/filters/blargg_ntsc_snes_rgb.c b/gfx/filters/blargg_ntsc_snes_rgb.c index 0052aa3cc9..168e6b0df5 100755 --- a/gfx/filters/blargg_ntsc_snes_rgb.c +++ b/gfx/filters/blargg_ntsc_snes_rgb.c @@ -15,20 +15,39 @@ */ #include "softfilter.h" -#include "softfilter_prototypes.h" #include #include "boolean.h" - -#ifdef RARCH_INTERNAL -#define softfilter_get_implementation blargg_ntsc_snes_rgb_get_implementation -#endif - #include "snes_ntsc/snes_ntsc.h" #include "snes_ntsc/snes_ntsc.c" -static struct snes_ntsc_t *ntsc_rgb; -static int burst_rgb; -static int burst_toggle_rgb; +#ifdef RARCH_INTERNAL +#define softfilter_get_implementation blargg_ntsc_snes_rgb_get_implementation +#define softfilter_thread_data blargg_ntsc_snes_rgb_softfilter_thread_data +#define filter_data blargg_ntsc_snes_rgb_filter_data +#endif + +struct softfilter_thread_data +{ + void *out_data; + const void *in_data; + size_t out_pitch; + size_t in_pitch; + unsigned colfmt; + unsigned width; + unsigned height; + int first; + int last; +}; + +struct filter_data +{ + unsigned threads; + struct softfilter_thread_data *workers; + unsigned in_fmt; + struct snes_ntsc_t *ntsc; + int burst; + int burst_toggle; +}; static unsigned blargg_ntsc_snes_rgb_generic_input_fmts(void) { @@ -46,6 +65,20 @@ static unsigned blargg_ntsc_snes_rgb_generic_threads(void *data) return filt->threads; } +static void blargg_ntsc_snes_rgb_initialize(void *data) +{ + snes_ntsc_setup_t setup; + struct filter_data *filt = (struct filter_data*)data; + + filt->ntsc = (snes_ntsc_t*)calloc(1, sizeof(*filt->ntsc)); + setup = snes_ntsc_rgb; + setup.merge_fields = 1; + snes_ntsc_init(filt->ntsc, &setup); + + filt->burst = 0; + filt->burst_toggle = (setup.merge_fields ? 0 : 1); +} + static void *blargg_ntsc_snes_rgb_generic_create(unsigned in_fmt, unsigned out_fmt, unsigned max_width, unsigned max_height, unsigned threads, softfilter_simd_mask_t simd) @@ -63,30 +96,14 @@ static void *blargg_ntsc_snes_rgb_generic_create(unsigned in_fmt, unsigned out_f free(filt); return NULL; } + blargg_ntsc_snes_rgb_initialize(filt); + return filt; } -static void blargg_ntsc_snes_rgb_initialize(void) -{ - snes_ntsc_setup_t setup; - static bool initialized = false; - if(initialized == true) - return; - initialized = true; - - ntsc_rgb = (snes_ntsc_t*)malloc(sizeof(*ntsc_rgb)); - setup = snes_ntsc_rgb; - setup.merge_fields = 1; - snes_ntsc_init(ntsc_rgb, &setup); - - burst_rgb = 0; - burst_toggle_rgb = (setup.merge_fields ? 0 : 1); -} - static void blargg_ntsc_snes_rgb_generic_output(void *data, unsigned *out_width, unsigned *out_height, unsigned width, unsigned height) { - blargg_ntsc_snes_rgb_initialize(); *out_width = SNES_NTSC_OUT_WIDTH(256); *out_height = height; } @@ -95,34 +112,32 @@ static void blargg_ntsc_snes_rgb_generic_destroy(void *data) { struct filter_data *filt = (struct filter_data*)data; - if(ntsc_rgb) - free(ntsc_rgb); + if(filt->ntsc) + free(filt->ntsc); free(filt->workers); free(filt); } -static void blargg_ntsc_snes_rgb_render_rgb565(int width, int height, +static void blargg_ntsc_snes_rgb_render_rgb565(void *data, int width, int height, int first, int last, uint16_t *input, int pitch, uint16_t *output, int outpitch) { - blargg_ntsc_snes_rgb_initialize(); - if(!ntsc_rgb) - return; + struct filter_data *filt = (struct filter_data*)data; if(width <= 256) - snes_ntsc_blit(ntsc_rgb, input, pitch, burst_rgb, width, height, output, outpitch * 2, first, last); + snes_ntsc_blit(filt->ntsc, input, pitch, filt->burst, width, height, output, outpitch * 2, first, last); else - snes_ntsc_blit_hires(ntsc_rgb, input, pitch, burst_rgb, width, height, output, outpitch * 2, first, last); + snes_ntsc_blit_hires(filt->ntsc, input, pitch, filt->burst, width, height, output, outpitch * 2, first, last); - burst_rgb ^= burst_toggle_rgb; + filt->burst ^= filt->burst_toggle; } -static void blargg_ntsc_snes_rgb_rgb565(unsigned width, unsigned height, +static void blargg_ntsc_snes_rgb_rgb565(void *data, unsigned width, unsigned height, int first, int last, uint16_t *src, unsigned src_stride, uint16_t *dst, unsigned dst_stride) { - blargg_ntsc_snes_rgb_render_rgb565(width, height, + blargg_ntsc_snes_rgb_render_rgb565(data, width, height, first, last, src, src_stride, dst, dst_stride); @@ -137,7 +152,7 @@ static void blargg_ntsc_snes_rgb_work_cb_rgb565(void *data, void *thread_data) unsigned width = thr->width; unsigned height = thr->height; - blargg_ntsc_snes_rgb_rgb565(width, height, + blargg_ntsc_snes_rgb_rgb565(data, width, height, thr->first, thr->last, input, thr->in_pitch / SOFTFILTER_BPP_RGB565, output, thr->out_pitch / SOFTFILTER_BPP_RGB565); }