mirror of
https://github.com/libretro/RetroArch.git
synced 2024-11-24 00:20:01 +00:00
Create two new threading command wrapper functions
This commit is contained in:
parent
a18811bff6
commit
aa6c7a5ed3
@ -263,33 +263,14 @@ bool font_driver_init_first(const void **font_driver, void **font_handle,
|
||||
: (const void**)&font_osd_driver;
|
||||
void **new_font_handle = font_handle ? font_handle
|
||||
: (void**)&font_osd_data;
|
||||
|
||||
#ifdef HAVE_THREADS
|
||||
settings_t *settings = config_get_ptr();
|
||||
const struct retro_hw_render_callback *hw_render =
|
||||
(const struct retro_hw_render_callback*)video_driver_callback();
|
||||
|
||||
if (threading_hint && settings->video.threaded && !hw_render->context_type)
|
||||
{
|
||||
thread_packet_t pkt;
|
||||
thread_video_t *thr = (thread_video_t*)video_driver_get_ptr(true);
|
||||
|
||||
if (!thr)
|
||||
return false;
|
||||
|
||||
pkt.type = CMD_FONT_INIT;
|
||||
pkt.data.font_init.method = font_init_first;
|
||||
pkt.data.font_init.font_driver = new_font_driver;
|
||||
pkt.data.font_init.font_handle = new_font_handle;
|
||||
pkt.data.font_init.video_data = data;
|
||||
pkt.data.font_init.font_path = font_path;
|
||||
pkt.data.font_init.font_size = font_size;
|
||||
pkt.data.font_init.api = api;
|
||||
|
||||
rarch_threaded_video_send_and_wait(thr, &pkt);
|
||||
|
||||
return pkt.data.font_init.return_value;
|
||||
}
|
||||
return rarch_threaded_video_font_init(new_font_driver, new_font_handle,
|
||||
data, font_path, font_size, api, font_init_first);
|
||||
#endif
|
||||
|
||||
return font_init_first(new_font_driver, new_font_handle,
|
||||
|
@ -203,11 +203,7 @@ unsigned video_texture_load(void *data,
|
||||
|
||||
if (settings->video.threaded && !hw_render->context_type)
|
||||
{
|
||||
thread_video_t *thr = (thread_video_t*)video_driver_get_ptr(true);
|
||||
thread_packet_t pkt = { CMD_CUSTOM_COMMAND };
|
||||
|
||||
if (!thr)
|
||||
return 0;
|
||||
custom_command_method_t func = video_texture_png_load_wrap;
|
||||
|
||||
switch (type)
|
||||
{
|
||||
@ -215,31 +211,26 @@ unsigned video_texture_load(void *data,
|
||||
#ifdef HAVE_OPENGL
|
||||
if (filter_type == TEXTURE_FILTER_MIPMAP_LINEAR ||
|
||||
filter_type == TEXTURE_FILTER_MIPMAP_NEAREST)
|
||||
pkt.data.custom_command.method = video_texture_png_load_wrap_gl_mipmap;
|
||||
func = video_texture_png_load_wrap_gl_mipmap;
|
||||
else
|
||||
pkt.data.custom_command.method = video_texture_png_load_wrap_gl;
|
||||
func = video_texture_png_load_wrap_gl;
|
||||
#endif
|
||||
break;
|
||||
case TEXTURE_BACKEND_DIRECT3D:
|
||||
#ifdef HAVE_D3D
|
||||
if (filter_type == TEXTURE_FILTER_MIPMAP_LINEAR ||
|
||||
filter_type == TEXTURE_FILTER_MIPMAP_NEAREST)
|
||||
pkt.data.custom_command.method = video_texture_png_load_wrap_d3d_mipmap;
|
||||
func = video_texture_png_load_wrap_d3d_mipmap;
|
||||
else
|
||||
pkt.data.custom_command.method = video_texture_png_load_wrap_d3d;
|
||||
func = video_texture_png_load_wrap_d3d;
|
||||
#endif
|
||||
break;
|
||||
case TEXTURE_BACKEND_DEFAULT:
|
||||
default:
|
||||
pkt.data.custom_command.method = video_texture_png_load_wrap;
|
||||
break;
|
||||
}
|
||||
|
||||
pkt.data.custom_command.data = (void*)data;
|
||||
|
||||
rarch_threaded_video_send_and_wait(thr, &pkt);
|
||||
|
||||
return pkt.data.custom_command.return_value;
|
||||
return rarch_threaded_video_texture_load(data, func);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -1226,3 +1226,44 @@ void rarch_threaded_video_send_and_wait(thread_video_t *thr, thread_packet_t *pk
|
||||
return;
|
||||
thr->send_and_wait(thr, pkt);
|
||||
}
|
||||
|
||||
bool rarch_threaded_video_font_init(const void **font_driver, void **font_handle,
|
||||
void *data, const char *font_path, float font_size,
|
||||
enum font_driver_render_api api, custom_font_command_method_t func)
|
||||
{
|
||||
thread_packet_t pkt;
|
||||
thread_video_t *thr = (thread_video_t*)video_driver_get_ptr(true);
|
||||
|
||||
if (!thr)
|
||||
return false;
|
||||
|
||||
pkt.type = CMD_FONT_INIT;
|
||||
pkt.data.font_init.method = func;
|
||||
pkt.data.font_init.font_driver = font_driver;
|
||||
pkt.data.font_init.font_handle = font_handle;
|
||||
pkt.data.font_init.video_data = data;
|
||||
pkt.data.font_init.font_path = font_path;
|
||||
pkt.data.font_init.font_size = font_size;
|
||||
pkt.data.font_init.api = api;
|
||||
|
||||
rarch_threaded_video_send_and_wait(thr, &pkt);
|
||||
|
||||
return pkt.data.font_init.return_value;
|
||||
}
|
||||
|
||||
unsigned rarch_threaded_video_texture_load(void *data,
|
||||
custom_command_method_t func)
|
||||
{
|
||||
thread_video_t *thr = (thread_video_t*)video_driver_get_ptr(true);
|
||||
thread_packet_t pkt = { CMD_CUSTOM_COMMAND };
|
||||
|
||||
if (!thr)
|
||||
return 0;
|
||||
|
||||
pkt.data.custom_command.method = func;
|
||||
pkt.data.custom_command.data = (void*)data;
|
||||
|
||||
rarch_threaded_video_send_and_wait(thr, &pkt);
|
||||
|
||||
return pkt.data.custom_command.return_value;
|
||||
}
|
||||
|
@ -62,6 +62,11 @@ enum thread_cmd
|
||||
CMD_DUMMY = INT_MAX
|
||||
};
|
||||
|
||||
typedef int (*custom_command_method_t)(void*);
|
||||
|
||||
typedef bool (*custom_font_command_method_t)(const void **font_driver,
|
||||
void **font_handle, void *video_data, const char *font_path,
|
||||
float font_size, enum font_driver_render_api api);
|
||||
|
||||
typedef struct
|
||||
{
|
||||
@ -127,16 +132,14 @@ typedef struct
|
||||
|
||||
struct
|
||||
{
|
||||
int (*method)(void*);
|
||||
custom_command_method_t method;
|
||||
void* data;
|
||||
int return_value;
|
||||
} custom_command;
|
||||
|
||||
struct
|
||||
{
|
||||
bool (*method)(const void **font_driver,
|
||||
void **font_handle, void *video_data, const char *font_path,
|
||||
float font_size, enum font_driver_render_api api);
|
||||
custom_font_command_method_t method;
|
||||
const void **font_driver;
|
||||
void **font_handle;
|
||||
void *video_data;
|
||||
@ -187,6 +190,14 @@ void *rarch_threaded_video_get_ptr(const video_driver_t **drv);
|
||||
|
||||
const char *rarch_threaded_video_get_ident(void);
|
||||
|
||||
bool rarch_threaded_video_font_init(const void **font_driver,
|
||||
void **font_handle,
|
||||
void *data, const char *font_path, float font_size,
|
||||
enum font_driver_render_api api, custom_font_command_method_t func);
|
||||
|
||||
unsigned rarch_threaded_video_texture_load(void *data,
|
||||
custom_command_method_t func);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user