mirror of
https://github.com/libretro/RetroArch
synced 2025-03-02 19:13:34 +00:00
(Lakka) fix texture loading when video_threaded is set to 'true'
This commit is contained in:
parent
ce9cd4ac8f
commit
a30ca8a082
@ -28,6 +28,7 @@
|
||||
#include "../../../general.h"
|
||||
#include "../../../gfx/gfx_common.h"
|
||||
#include "../../../gfx/gl_common.h"
|
||||
#include "../../../gfx/video_thread_wrapper.h"
|
||||
#include "../../../gfx/shader/shader_context.h"
|
||||
#include "../../../config.def.h"
|
||||
#include "../../../file.h"
|
||||
@ -702,7 +703,7 @@ static void lakka_frame(void)
|
||||
glDisable(GL_BLEND);
|
||||
}
|
||||
|
||||
static GLuint lakka_png_texture_load(const char * file_name)
|
||||
static GLuint lakka_png_texture_load_(const char * file_name)
|
||||
{
|
||||
if (! path_file_exists(file_name))
|
||||
return 0;
|
||||
@ -723,6 +724,29 @@ static GLuint lakka_png_texture_load(const char * file_name)
|
||||
|
||||
return texture;
|
||||
}
|
||||
static int lakka_png_texture_load_wrap(void * file_name)
|
||||
{
|
||||
return lakka_png_texture_load_(file_name);
|
||||
}
|
||||
|
||||
|
||||
static GLuint lakka_png_texture_load(const char* file_name)
|
||||
{
|
||||
if (g_settings.video.threaded
|
||||
&& !g_extern.system.hw_render_callback.context_type)
|
||||
{
|
||||
thread_video_t *thr = (thread_video_t*)driver.video_data;
|
||||
thr->cmd_data.custom_command.method = lakka_png_texture_load_wrap;
|
||||
thr->cmd_data.custom_command.data = (void*)file_name;
|
||||
thr->send_cmd_func(thr, CMD_CUSTOM_COMMAND);
|
||||
thr->wait_reply_func(thr, CMD_CUSTOM_COMMAND);
|
||||
|
||||
return thr->cmd_data.custom_command.return_value;
|
||||
|
||||
}
|
||||
|
||||
return lakka_png_texture_load_(file_name);
|
||||
}
|
||||
|
||||
static void lakka_context_destroy(void *data)
|
||||
{
|
||||
|
@ -14,150 +14,11 @@
|
||||
*/
|
||||
|
||||
#include "video_thread_wrapper.h"
|
||||
#include "../thread.h"
|
||||
#include "../general.h"
|
||||
#include "../performance.h"
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <limits.h>
|
||||
|
||||
enum thread_cmd
|
||||
{
|
||||
CMD_NONE = 0,
|
||||
CMD_INIT,
|
||||
CMD_SET_SHADER,
|
||||
CMD_FREE,
|
||||
CMD_ALIVE, /* Blocking alive check. Used when paused. */
|
||||
CMD_SET_ROTATION,
|
||||
CMD_READ_VIEWPORT,
|
||||
|
||||
#ifdef HAVE_OVERLAY
|
||||
CMD_OVERLAY_ENABLE,
|
||||
CMD_OVERLAY_LOAD,
|
||||
CMD_OVERLAY_TEX_GEOM,
|
||||
CMD_OVERLAY_VERTEX_GEOM,
|
||||
CMD_OVERLAY_FULL_SCREEN,
|
||||
#endif
|
||||
|
||||
CMD_POKE_SET_FILTERING,
|
||||
#ifdef HAVE_FBO
|
||||
CMD_POKE_SET_FBO_STATE,
|
||||
CMD_POKE_GET_FBO_STATE,
|
||||
#endif
|
||||
CMD_POKE_SET_ASPECT_RATIO,
|
||||
CMD_POKE_SET_OSD_MSG,
|
||||
|
||||
CMD_DUMMY = INT_MAX
|
||||
};
|
||||
|
||||
typedef struct thread_video
|
||||
{
|
||||
slock_t *lock;
|
||||
scond_t *cond_cmd;
|
||||
scond_t *cond_thread;
|
||||
sthread_t *thread;
|
||||
|
||||
video_info_t info;
|
||||
const video_driver_t *driver;
|
||||
|
||||
#ifdef HAVE_OVERLAY
|
||||
const video_overlay_interface_t *overlay;
|
||||
#endif
|
||||
const video_poke_interface_t *poke;
|
||||
|
||||
void *driver_data;
|
||||
const input_driver_t **input;
|
||||
void **input_data;
|
||||
|
||||
#if defined(HAVE_MENU)
|
||||
struct
|
||||
{
|
||||
void *frame;
|
||||
size_t frame_cap;
|
||||
unsigned width;
|
||||
unsigned height;
|
||||
float alpha;
|
||||
bool frame_updated;
|
||||
bool rgb32;
|
||||
bool enable;
|
||||
bool full_screen;
|
||||
} texture;
|
||||
#endif
|
||||
bool apply_state_changes;
|
||||
|
||||
bool alive;
|
||||
bool focus;
|
||||
bool nonblock;
|
||||
|
||||
retro_time_t last_time;
|
||||
unsigned hit_count;
|
||||
unsigned miss_count;
|
||||
|
||||
float *alpha_mod;
|
||||
unsigned alpha_mods;
|
||||
bool alpha_update;
|
||||
slock_t *alpha_lock;
|
||||
|
||||
enum thread_cmd send_cmd;
|
||||
enum thread_cmd reply_cmd;
|
||||
union
|
||||
{
|
||||
bool b;
|
||||
int i;
|
||||
float f;
|
||||
const char *str;
|
||||
void *v;
|
||||
|
||||
struct
|
||||
{
|
||||
enum rarch_shader_type type;
|
||||
const char *path;
|
||||
} set_shader;
|
||||
|
||||
struct
|
||||
{
|
||||
unsigned index;
|
||||
float x, y, w, h;
|
||||
} rect;
|
||||
|
||||
struct
|
||||
{
|
||||
const struct texture_image *data;
|
||||
unsigned num;
|
||||
} image;
|
||||
|
||||
struct
|
||||
{
|
||||
unsigned index;
|
||||
bool smooth;
|
||||
} filtering;
|
||||
|
||||
struct
|
||||
{
|
||||
char msg[PATH_MAX];
|
||||
struct font_params params;
|
||||
} osd_message;
|
||||
|
||||
} cmd_data;
|
||||
|
||||
struct rarch_viewport vp;
|
||||
struct rarch_viewport read_vp; /* Last viewport reported to caller. */
|
||||
|
||||
struct
|
||||
{
|
||||
slock_t *lock;
|
||||
uint8_t *buffer;
|
||||
unsigned width;
|
||||
unsigned height;
|
||||
unsigned pitch;
|
||||
bool updated;
|
||||
bool within_thread;
|
||||
char msg[PATH_MAX];
|
||||
} frame;
|
||||
|
||||
video_driver_t video_thread;
|
||||
|
||||
} thread_video_t;
|
||||
|
||||
static void *thread_init_never_call(const video_info_t *video,
|
||||
const input_driver_t **input, void **input_data)
|
||||
@ -404,6 +265,14 @@ static void thread_loop(void *data)
|
||||
thread_reply(thr, CMD_POKE_SET_OSD_MSG);
|
||||
break;
|
||||
|
||||
case CMD_CUSTOM_COMMAND:
|
||||
if (thr->cmd_data.custom_command.method)
|
||||
thr->cmd_data.custom_command.return_value =
|
||||
thr->cmd_data.custom_command.method
|
||||
(thr->cmd_data.custom_command.data);
|
||||
thread_reply(thr, CMD_CUSTOM_COMMAND);
|
||||
break;
|
||||
|
||||
case CMD_NONE:
|
||||
/* Never reply on no command. Possible deadlock if
|
||||
* thread sends command right after frame update. */
|
||||
@ -625,6 +494,9 @@ static bool thread_init(thread_video_t *thr, const video_info_t *info,
|
||||
thread_send_cmd(thr, CMD_INIT);
|
||||
thread_wait_reply(thr, CMD_INIT);
|
||||
|
||||
thr->send_cmd_func = thread_send_cmd;
|
||||
thr->wait_reply_func = thread_wait_reply;
|
||||
|
||||
return thr->cmd_data.b;
|
||||
}
|
||||
|
||||
|
@ -18,6 +18,8 @@
|
||||
|
||||
#include "../driver.h"
|
||||
#include "../boolean.h"
|
||||
#include "../thread.h"
|
||||
#include "../general.h"
|
||||
|
||||
/* Starts a video driver in a new thread.
|
||||
* Access to video driver will be mediated through this driver. */
|
||||
@ -28,5 +30,154 @@ bool rarch_threaded_video_init(
|
||||
|
||||
void *rarch_threaded_video_resolve(const video_driver_t **drv);
|
||||
|
||||
enum thread_cmd
|
||||
{
|
||||
CMD_NONE = 0,
|
||||
CMD_INIT,
|
||||
CMD_SET_SHADER,
|
||||
CMD_FREE,
|
||||
CMD_ALIVE, /* Blocking alive check. Used when paused. */
|
||||
CMD_SET_ROTATION,
|
||||
CMD_READ_VIEWPORT,
|
||||
|
||||
#ifdef HAVE_OVERLAY
|
||||
CMD_OVERLAY_ENABLE,
|
||||
CMD_OVERLAY_LOAD,
|
||||
CMD_OVERLAY_TEX_GEOM,
|
||||
CMD_OVERLAY_VERTEX_GEOM,
|
||||
CMD_OVERLAY_FULL_SCREEN,
|
||||
#endif
|
||||
|
||||
CMD_POKE_SET_FILTERING,
|
||||
#ifdef HAVE_FBO
|
||||
CMD_POKE_SET_FBO_STATE,
|
||||
CMD_POKE_GET_FBO_STATE,
|
||||
#endif
|
||||
CMD_POKE_SET_ASPECT_RATIO,
|
||||
CMD_POKE_SET_OSD_MSG,
|
||||
CMD_CUSTOM_COMMAND,
|
||||
|
||||
CMD_DUMMY = INT_MAX
|
||||
};
|
||||
|
||||
typedef struct thread_video
|
||||
{
|
||||
slock_t *lock;
|
||||
scond_t *cond_cmd;
|
||||
scond_t *cond_thread;
|
||||
sthread_t *thread;
|
||||
|
||||
video_info_t info;
|
||||
const video_driver_t *driver;
|
||||
|
||||
#ifdef HAVE_OVERLAY
|
||||
const video_overlay_interface_t *overlay;
|
||||
#endif
|
||||
const video_poke_interface_t *poke;
|
||||
|
||||
void *driver_data;
|
||||
const input_driver_t **input;
|
||||
void **input_data;
|
||||
|
||||
#if defined(HAVE_MENU)
|
||||
struct
|
||||
{
|
||||
void *frame;
|
||||
size_t frame_cap;
|
||||
unsigned width;
|
||||
unsigned height;
|
||||
float alpha;
|
||||
bool frame_updated;
|
||||
bool rgb32;
|
||||
bool enable;
|
||||
bool full_screen;
|
||||
} texture;
|
||||
#endif
|
||||
bool apply_state_changes;
|
||||
|
||||
bool alive;
|
||||
bool focus;
|
||||
bool nonblock;
|
||||
|
||||
retro_time_t last_time;
|
||||
unsigned hit_count;
|
||||
unsigned miss_count;
|
||||
|
||||
float *alpha_mod;
|
||||
unsigned alpha_mods;
|
||||
bool alpha_update;
|
||||
slock_t *alpha_lock;
|
||||
|
||||
void (*send_cmd_func)(struct thread_video *, enum thread_cmd);
|
||||
void (*wait_reply_func)(struct thread_video *, enum thread_cmd);
|
||||
enum thread_cmd send_cmd;
|
||||
enum thread_cmd reply_cmd;
|
||||
union
|
||||
{
|
||||
bool b;
|
||||
int i;
|
||||
float f;
|
||||
const char *str;
|
||||
void *v;
|
||||
|
||||
struct
|
||||
{
|
||||
enum rarch_shader_type type;
|
||||
const char *path;
|
||||
} set_shader;
|
||||
|
||||
struct
|
||||
{
|
||||
unsigned index;
|
||||
float x, y, w, h;
|
||||
} rect;
|
||||
|
||||
struct
|
||||
{
|
||||
const struct texture_image *data;
|
||||
unsigned num;
|
||||
} image;
|
||||
|
||||
struct
|
||||
{
|
||||
unsigned index;
|
||||
bool smooth;
|
||||
} filtering;
|
||||
|
||||
struct
|
||||
{
|
||||
char msg[PATH_MAX];
|
||||
struct font_params params;
|
||||
} osd_message;
|
||||
|
||||
struct
|
||||
{
|
||||
int (*method)(void*);
|
||||
void* data;
|
||||
int return_value;
|
||||
} custom_command;
|
||||
|
||||
|
||||
} cmd_data;
|
||||
|
||||
struct rarch_viewport vp;
|
||||
struct rarch_viewport read_vp; /* Last viewport reported to caller. */
|
||||
|
||||
struct
|
||||
{
|
||||
slock_t *lock;
|
||||
uint8_t *buffer;
|
||||
unsigned width;
|
||||
unsigned height;
|
||||
unsigned pitch;
|
||||
bool updated;
|
||||
bool within_thread;
|
||||
char msg[PATH_MAX];
|
||||
} frame;
|
||||
|
||||
video_driver_t video_thread;
|
||||
|
||||
} thread_video_t;
|
||||
|
||||
#endif
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user