mirror of
https://github.com/libretro/RetroArch
synced 2024-12-28 09:29:16 +00:00
Cleanups
This commit is contained in:
parent
f6c4890063
commit
6b466c6013
@ -46,48 +46,8 @@
|
||||
#include "../../tasks/tasks_internal.h"
|
||||
#include "../../file_path_special.h"
|
||||
|
||||
void RWebAudioRecalibrateTime(void);
|
||||
void dummyErrnoCodes(void);
|
||||
|
||||
static unsigned emscripten_frame_count = 0;
|
||||
|
||||
static void emscripten_mainloop(void)
|
||||
{
|
||||
int ret;
|
||||
video_frame_info_t video_info;
|
||||
|
||||
RWebAudioRecalibrateTime();
|
||||
|
||||
emscripten_frame_count++;
|
||||
|
||||
video_driver_build_info(&video_info);
|
||||
|
||||
/* Disable BFI during fast forward, slow-motion,
|
||||
* and pause to prevent flicker. */
|
||||
if (
|
||||
video_info.black_frame_insertion
|
||||
&& !video_info.input_driver_nonblock_state
|
||||
&& !video_info.runloop_is_slowmotion
|
||||
&& !video_info.runloop_is_paused)
|
||||
{
|
||||
if ((emscripten_frame_count & 1) == 0)
|
||||
{
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
video_info.cb_swap_buffers(video_info.context_data);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
ret = runloop_iterate();
|
||||
|
||||
task_queue_check();
|
||||
|
||||
if (ret != -1)
|
||||
return;
|
||||
|
||||
main_exit(NULL);
|
||||
emscripten_force_exit(0);
|
||||
}
|
||||
void emscripten_mainloop(void);
|
||||
|
||||
void cmd_savefiles(void)
|
||||
{
|
||||
|
@ -352,7 +352,7 @@ static bool gdi_gfx_frame(void *data, const void *frame,
|
||||
|
||||
if (gdi->ctx_driver->update_window_title)
|
||||
gdi->ctx_driver->update_window_title(
|
||||
video_info->context_data);
|
||||
gdi->ctx_data);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -2829,7 +2829,6 @@ static bool gl2_frame(void *data, const void *frame,
|
||||
bool runloop_is_paused = video_info->runloop_is_paused;
|
||||
bool hard_sync = video_info->hard_sync;
|
||||
unsigned hard_sync_frames = video_info->hard_sync_frames;
|
||||
void *context_data = video_info->context_data;
|
||||
struct font_params *osd_params = (struct font_params*)
|
||||
&video_info->osd_stat_params;
|
||||
const char *stat_text = video_info->stat_text;
|
||||
@ -2866,7 +2865,7 @@ static bool gl2_frame(void *data, const void *frame,
|
||||
if (gl->should_resize)
|
||||
{
|
||||
if (gl->ctx_driver->set_resize)
|
||||
gl->ctx_driver->set_resize(context_data,
|
||||
gl->ctx_driver->set_resize(gl->ctx_data,
|
||||
width, height);
|
||||
gl->should_resize = false;
|
||||
|
||||
@ -3073,7 +3072,7 @@ static bool gl2_frame(void *data, const void *frame,
|
||||
}
|
||||
|
||||
if (gl->ctx_driver->update_window_title)
|
||||
gl->ctx_driver->update_window_title(context_data);
|
||||
gl->ctx_driver->update_window_title(gl->ctx_data);
|
||||
|
||||
/* Reset state which could easily mess up libretro core. */
|
||||
if (gl->hw_render_fbo_init)
|
||||
@ -3108,13 +3107,13 @@ static bool gl2_frame(void *data, const void *frame,
|
||||
&& !runloop_is_paused)
|
||||
{
|
||||
if (gl->ctx_driver->swap_buffers)
|
||||
gl->ctx_driver->swap_buffers(context_data);
|
||||
gl->ctx_driver->swap_buffers(gl->ctx_data);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (gl->ctx_driver->swap_buffers)
|
||||
gl->ctx_driver->swap_buffers(context_data);
|
||||
gl->ctx_driver->swap_buffers(gl->ctx_data);
|
||||
|
||||
/* check if we are fast forwarding or in menu, if we are ignore hard sync */
|
||||
if ( gl->have_sync
|
||||
|
@ -721,7 +721,7 @@ static bool gl1_gfx_frame(void *data, const void *frame,
|
||||
mode.height = height;
|
||||
|
||||
if (gl1->ctx_driver->set_resize)
|
||||
gl1->ctx_driver->set_resize(video_info->context_data,
|
||||
gl1->ctx_driver->set_resize(gl1->ctx_data,
|
||||
mode.width, mode.height);
|
||||
|
||||
gl1_gfx_set_viewport(gl1,
|
||||
@ -881,7 +881,7 @@ static bool gl1_gfx_frame(void *data, const void *frame,
|
||||
|
||||
if (gl1->ctx_driver->update_window_title)
|
||||
gl1->ctx_driver->update_window_title(
|
||||
video_info->context_data);
|
||||
gl1->ctx_data);
|
||||
|
||||
/* Screenshots. */
|
||||
if (gl1->readback_buffer_screenshot)
|
||||
@ -899,12 +899,12 @@ static bool gl1_gfx_frame(void *data, const void *frame,
|
||||
&& !video_info->runloop_is_slowmotion
|
||||
&& !video_info->runloop_is_paused)
|
||||
{
|
||||
gl1->ctx_driver->swap_buffers(video_info->context_data);
|
||||
gl1->ctx_driver->swap_buffers(gl1->ctx_data);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
}
|
||||
#endif
|
||||
|
||||
gl1->ctx_driver->swap_buffers(video_info->context_data);
|
||||
gl1->ctx_driver->swap_buffers(gl1->ctx_data);
|
||||
|
||||
/* check if we are fast forwarding or in menu, if we are ignore hard sync */
|
||||
if (video_info->hard_sync
|
||||
|
@ -1847,7 +1847,6 @@ static bool gl_core_frame(void *data, const void *frame,
|
||||
bool statistics_show = video_info->statistics_show;
|
||||
bool msg_bgcolor_enable = video_info->msg_bgcolor_enable;
|
||||
bool black_frame_insertion = video_info->black_frame_insertion;
|
||||
void *context_data = video_info->context_data;
|
||||
unsigned hard_sync_frames = video_info->hard_sync_frames;
|
||||
bool runloop_is_paused = video_info->runloop_is_paused;
|
||||
bool runloop_is_slowmotion = video_info->runloop_is_slowmotion;
|
||||
@ -1878,7 +1877,7 @@ static bool gl_core_frame(void *data, const void *frame,
|
||||
if (gl->should_resize)
|
||||
{
|
||||
if (gl->ctx_driver->set_resize)
|
||||
gl->ctx_driver->set_resize(context_data,
|
||||
gl->ctx_driver->set_resize(gl->ctx_data,
|
||||
width, height);
|
||||
gl->should_resize = false;
|
||||
}
|
||||
@ -1961,7 +1960,7 @@ static bool gl_core_frame(void *data, const void *frame,
|
||||
}
|
||||
|
||||
if (gl->ctx_driver->update_window_title)
|
||||
gl->ctx_driver->update_window_title(context_data);
|
||||
gl->ctx_driver->update_window_title(gl->ctx_data);
|
||||
|
||||
if (gl->readback_buffer_screenshot)
|
||||
{
|
||||
@ -1985,11 +1984,11 @@ static bool gl_core_frame(void *data, const void *frame,
|
||||
&& !runloop_is_slowmotion
|
||||
&& !runloop_is_paused)
|
||||
{
|
||||
gl->ctx_driver->swap_buffers(context_data);
|
||||
gl->ctx_driver->swap_buffers(gl->ctx_data);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
}
|
||||
|
||||
gl->ctx_driver->swap_buffers(context_data);
|
||||
gl->ctx_driver->swap_buffers(gl->ctx_data);
|
||||
|
||||
if (video_info->hard_sync &&
|
||||
!input_driver_nonblock_state &&
|
||||
|
@ -456,9 +456,9 @@ static bool vg_frame(void *data, const void *frame,
|
||||
#endif
|
||||
|
||||
if (vg->ctx_driver->update_window_title)
|
||||
vg->ctx_driver->update_window_title(video_info->context_data);
|
||||
vg->ctx_driver->update_window_title(vg->ctx_data);
|
||||
|
||||
vg->ctx_driver->swap_buffers(video_info->context_data);
|
||||
vg->ctx_driver->swap_buffers(vg->ctx_data);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -1716,7 +1716,6 @@ static bool vulkan_frame(void *data, const void *frame,
|
||||
bool waits_for_semaphores = false;
|
||||
unsigned width = video_info->width;
|
||||
unsigned height = video_info->height;
|
||||
void *context_data = video_info->context_data;
|
||||
bool statistics_show = video_info->statistics_show;
|
||||
const char *stat_text = video_info->stat_text;
|
||||
bool black_frame_insertion = video_info->black_frame_insertion;
|
||||
@ -2225,12 +2224,12 @@ static bool vulkan_frame(void *data, const void *frame,
|
||||
slock_unlock(vk->context->queue_lock);
|
||||
#endif
|
||||
|
||||
vk->ctx_driver->swap_buffers(context_data);
|
||||
vk->ctx_driver->swap_buffers(vk->ctx_data);
|
||||
|
||||
if (!vk->context->swap_interval_emulation_lock)
|
||||
{
|
||||
if (vk->ctx_driver->update_window_title)
|
||||
vk->ctx_driver->update_window_title(context_data);
|
||||
vk->ctx_driver->update_window_title(vk->ctx_data);
|
||||
}
|
||||
|
||||
/* Handle spurious swapchain invalidations as soon as we can,
|
||||
@ -2242,7 +2241,7 @@ static bool vulkan_frame(void *data, const void *frame,
|
||||
mode.height = height;
|
||||
|
||||
if (vk->ctx_driver->set_resize)
|
||||
vk->ctx_driver->set_resize(context_data, mode.width, mode.height);
|
||||
vk->ctx_driver->set_resize(vk->ctx_data, mode.width, mode.height);
|
||||
|
||||
vk->should_resize = false;
|
||||
}
|
||||
@ -2258,7 +2257,7 @@ static bool vulkan_frame(void *data, const void *frame,
|
||||
&& !input_driver_nonblock_state
|
||||
&& !runloop_is_slowmotion
|
||||
&& !runloop_is_paused)
|
||||
vulkan_inject_black_frame(vk, video_info, context_data);
|
||||
vulkan_inject_black_frame(vk, video_info, vk->ctx_data);
|
||||
|
||||
/* Vulkan doesn't directly support swap_interval > 1,
|
||||
* so we fake it by duping out more frames. */
|
||||
|
51
retroarch.c
51
retroarch.c
@ -17244,6 +17244,54 @@ int rarch_main(int argc, char *argv[], void *data)
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if defined(EMSCRIPTEN)
|
||||
void RWebAudioRecalibrateTime(void);
|
||||
|
||||
void emscripten_mainloop(void)
|
||||
{
|
||||
int ret;
|
||||
static unsigned emscripten_frame_count = 0;
|
||||
struct rarch_state *p_rarch = &rarch_st;
|
||||
settings_t *settings = p_rarch->configuration_settings;
|
||||
bool black_frame_insertion = settings->bools.video_black_frame_insertion;
|
||||
bool input_driver_nonblock_state = p_rarch->input_driver_nonblock_state;
|
||||
bool runloop_is_slowmotion = p_rarch->runloop_slowmotion;
|
||||
bool runloop_is_paused = p_rarch->runloop_paused;
|
||||
|
||||
RWebAudioRecalibrateTime();
|
||||
|
||||
emscripten_frame_count++;
|
||||
|
||||
/* Disable BFI during fast forward, slow-motion,
|
||||
* and pause to prevent flicker. */
|
||||
if (
|
||||
black_frame_insertion
|
||||
&& !input_driver_nonblock_state
|
||||
&& !runloop_is_slowmotion
|
||||
&& !runloop_is_paused)
|
||||
{
|
||||
if ((emscripten_frame_count & 1) == 0)
|
||||
{
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
if (p_rarch->current_video_context.swap_buffers)
|
||||
p_rarch->current_video_context.swap_buffers(
|
||||
p_rarch->video_context_data);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
ret = runloop_iterate();
|
||||
|
||||
task_queue_check();
|
||||
|
||||
if (ret != -1)
|
||||
return;
|
||||
|
||||
main_exit(NULL);
|
||||
emscripten_force_exit(0);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_MAIN
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
@ -32692,9 +32740,6 @@ void video_driver_build_info(video_frame_info_t *video_info)
|
||||
video_info->runloop_is_slowmotion = p_rarch->runloop_slowmotion;
|
||||
|
||||
video_info->input_driver_nonblock_state = p_rarch->input_driver_nonblock_state;
|
||||
video_info->context_data = p_rarch->video_context_data;
|
||||
video_info->cb_swap_buffers = p_rarch->current_video_context.swap_buffers;
|
||||
|
||||
video_info->userdata = VIDEO_DRIVER_GET_PTR_INTERNAL(false);
|
||||
|
||||
#ifdef HAVE_THREADS
|
||||
|
@ -1197,9 +1197,6 @@ typedef struct video_frame_info
|
||||
enum text_alignment text_align;
|
||||
} osd_stat_params;
|
||||
|
||||
void (*cb_swap_buffers)(void*);
|
||||
|
||||
void *context_data;
|
||||
void *userdata;
|
||||
} video_frame_info_t;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user