This commit is contained in:
libretroadmin 2023-05-30 22:10:03 +02:00
parent de63016bd3
commit 3737b99b05
13 changed files with 96 additions and 107 deletions

View File

@ -1414,8 +1414,9 @@ static bool ctr_frame(void* data, const void* frame,
* This fixes screen tearing, but it has a significant impact on
* performance...
* */
bool next_event = false;
struct retro_system_av_info *av_info = video_viewport_get_system_av_info();
bool next_event = false;
video_driver_state_t *video_st = video_state_get_ptr();
struct retro_system_av_info *av_info = &video_st->av_info;
if (av_info)
next_event = av_info->timing.fps < video_refresh_rate * 0.9f;
gspWaitForEvent(GSPGPU_EVENT_VBlank0, next_event);

View File

@ -346,7 +346,8 @@ static void *oga_gfx_init(const video_info_t *video,
int i;
oga_video_t *vid = NULL;
settings_t *settings = config_get_ptr();
struct retro_system_av_info *av_info = video_viewport_get_system_av_info();
video_driver_state_t *video_st = video_state_get_ptr();
struct retro_system_av_info *av_info = &video_st->av_info;
struct retro_game_geometry *geom = &av_info->geometry;
int aw = ALIGN(geom->base_width, 32);
int ah = ALIGN(geom->base_height, 32);

View File

@ -396,7 +396,8 @@ static int omapfb_alloc_mem(omapfb_data_t *pdata)
struct omapfb_mem_info mi;
void *mem = NULL;
const struct retro_game_geometry *geom = NULL;
struct retro_system_av_info *av_info = NULL;
video_driver_state_t *video_st = video_state_get_ptr();
struct retro_system_av_info *av_info = &video_st->av_info;
pdata->current_state = (omapfb_state_t*)calloc(1, sizeof(omapfb_state_t));
@ -426,12 +427,10 @@ static int omapfb_alloc_mem(omapfb_data_t *pdata)
}
}
av_info = video_viewport_get_system_av_info();
if (!av_info)
goto error;
if (av_info)
geom = &av_info->geometry;
if (!geom)
if (!(geom = &av_info->geometry))
goto error;
mem_size = geom->max_width * geom->max_height *

View File

@ -869,11 +869,12 @@ static void vulkan_deinit_textures(vk_t *vk)
{
int i;
const void* cached_frame;
video_driver_state_t *video_st = video_state_get_ptr();
/* Avoid memcpying from a destroyed/unmapped texture later on. */
video_driver_cached_frame_get(&cached_frame, NULL, NULL, NULL);
if (vulkan_is_mapped_swapchain_texture_ptr(vk, cached_frame))
video_driver_set_cached_frame_ptr(NULL);
video_st->frame_cache_data = NULL;
vkDestroySampler(vk->context->device, vk->samplers.nearest, NULL);
vkDestroySampler(vk->context->device, vk->samplers.linear, NULL);

View File

@ -656,7 +656,8 @@ static void *xv_init(const video_info_t *video,
XVisualInfo *visualinfo = NULL;
XvAdaptorInfo *adaptor_info = NULL;
const struct retro_game_geometry *geom = NULL;
struct retro_system_av_info *av_info = NULL;
video_driver_state_t *video_st = video_state_get_ptr();
struct retro_system_av_info *av_info = &video_st->av_info;
settings_t *settings = config_get_ptr();
bool video_disable_composition = settings->bools.video_disable_composition;
xv_t *xv = (xv_t*)calloc(1, sizeof(*xv));
@ -674,8 +675,6 @@ static void *xv_init(const video_info_t *video,
goto error;
}
av_info = video_viewport_get_system_av_info();
if (av_info)
geom = &av_info->geometry;

View File

@ -213,14 +213,13 @@ static bool gfx_ctx_go2_drm_set_video_mode(void *data,
unsigned width, unsigned height,
bool fullscreen)
{
struct retro_system_av_info *av_info = NULL;
video_driver_state_t *video_st = video_state_get_ptr();
struct retro_system_av_info *av_info = &video_st->av_info;
gfx_ctx_go2_drm_data_t *drm = (gfx_ctx_go2_drm_data_t*)data;
if (!drm)
return false;
av_info = video_viewport_get_system_av_info();
frontend_driver_install_signal_handler();
#ifdef HAVE_MENU
@ -278,8 +277,7 @@ unsigned *width, unsigned *height)
static void gfx_ctx_go2_drm_check_window(void *data, bool *quit,
bool *resize, unsigned *width, unsigned *height)
{
unsigned w;
unsigned h;
unsigned w, h;
gfx_ctx_go2_drm_data_t
*drm = (gfx_ctx_go2_drm_data_t*)data;
#ifdef HAVE_MENU
@ -289,8 +287,8 @@ static void gfx_ctx_go2_drm_check_window(void *data, bool *quit,
if ( use_ctx_scaling
&& !(menu_state_get_ptr()->flags & MENU_ST_FLAG_ALIVE))
{
struct retro_system_av_info*
av_info = video_viewport_get_system_av_info();
video_driver_state_t *video_st = video_state_get_ptr();
struct retro_system_av_info *av_info = &video_st->av_info;
w = av_info->geometry.base_width;
h = av_info->geometry.base_height;
}

View File

@ -917,11 +917,6 @@ bool video_driver_monitor_adjust_system_rates(
return input_fps <= target_video_sync_rate;
}
struct retro_system_av_info *video_viewport_get_system_av_info(void)
{
return &video_driver_st.av_info;
}
void video_driver_gpu_record_deinit(void)
{
video_driver_state_t *video_st = &video_driver_st;
@ -1644,7 +1639,6 @@ bool video_driver_set_video_mode(unsigned width,
if ( video_st->poke
&& video_st->poke->set_video_mode)
{
RARCH_LOG("[SUBS] video_driver_set_video_mode\n");
video_st->poke->set_video_mode(video_st->data,
width, height, fullscreen);
return true;
@ -1704,18 +1698,6 @@ void video_driver_set_filtering(unsigned index,
index, smooth, ctx_scaling);
}
void video_driver_cached_frame_set(const void *data, unsigned width,
unsigned height, size_t pitch)
{
video_driver_state_t *video_st= &video_driver_st;
if (data)
video_st->frame_cache_data = data;
video_st->frame_cache_width = width;
video_st->frame_cache_height = height;
video_st->frame_cache_pitch = pitch;
}
void video_driver_cached_frame_get(const void **data, unsigned *width,
unsigned *height, size_t *pitch)
{
@ -1846,12 +1828,6 @@ void video_driver_lock_new(void)
#endif
}
void video_driver_set_cached_frame_ptr(const void *data)
{
video_driver_state_t *video_st = &video_driver_st;
video_st->frame_cache_data = data;
}
void video_driver_set_stub_frame(void)
{
video_driver_state_t *video_st = &video_driver_st;
@ -2321,10 +2297,10 @@ void video_viewport_get_scaled_integer(struct video_viewport *vp,
unsigned int rotation = retroarch_get_rotation();
if (rotation % 2)
base_height = video_st->av_info.geometry.base_width;
base_height = video_st->av_info.geometry.base_width;
if (base_height == 0)
base_height = 1;
base_height = 1;
/* Account for non-square pixels.
* This is sort of contradictory with the goal of integer scale,
@ -3303,7 +3279,12 @@ bool video_driver_init_internal(bool *video_is_threaded, bool verbosity_enabled)
#endif
if (!(runloop_st->current_core.flags & RETRO_CORE_FLAG_GAME_LOADED))
video_driver_cached_frame_set(&dummy_pixels, 4, 4, 8);
{
video_st->frame_cache_data = &dummy_pixels;
video_st->frame_cache_width = 4;
video_st->frame_cache_height = 4;
video_st->frame_cache_pitch = 8;
}
#if defined(PSP)
video_driver_set_texture_frame(&dummy_pixels, false, 1, 1, 1.0f);

View File

@ -900,8 +900,6 @@ bool video_driver_has_focus(void);
bool video_driver_cached_frame_has_valid_framebuffer(void);
void video_driver_set_cached_frame_ptr(const void *data);
void video_driver_set_stub_frame(void);
void video_driver_unset_stub_frame(void);
@ -1016,8 +1014,6 @@ void video_viewport_get_scaled_integer(struct video_viewport *vp,
unsigned width, unsigned height,
float aspect_ratio, bool keep_aspect);
struct retro_system_av_info *video_viewport_get_system_av_info(void);
/**
* video_monitor_set_refresh_rate:
* @hz : New refresh rate for monitor.

View File

@ -644,7 +644,8 @@ static INLINE void android_mouse_calculate_deltas(android_input_t *android,
float x_scale = 1;
float y_scale = 1;
settings_t *settings = config_get_ptr();
struct retro_system_av_info *av_info = video_viewport_get_system_av_info();
video_driver_state_t *video_st = video_state_get_ptr();
struct retro_system_av_info *av_info = &video_st->av_info;
if (av_info)
{

View File

@ -4758,19 +4758,19 @@ static void setting_get_string_representation_uint_custom_viewport_width(rarch_s
char *s, size_t len)
{
struct retro_game_geometry *geom = NULL;
struct retro_system_av_info *av_info = NULL;
video_driver_state_t *video_st = video_state_get_ptr();
struct retro_system_av_info *av_info = &video_st->av_info;
unsigned int rotation = retroarch_get_rotation();
if (!setting)
if (!setting || !av_info)
return;
av_info = video_viewport_get_system_av_info();
geom = (struct retro_game_geometry*)&av_info->geometry;
if (!(rotation % 2) && (*setting->value.target.unsigned_integer%geom->base_width == 0))
if (!(rotation % 2) && (*setting->value.target.unsigned_integer % geom->base_width == 0))
snprintf(s, len, "%u (%ux)",
*setting->value.target.unsigned_integer,
*setting->value.target.unsigned_integer / geom->base_width);
else if ((rotation % 2) && (*setting->value.target.unsigned_integer%geom->base_height == 0))
else if ((rotation % 2) && (*setting->value.target.unsigned_integer % geom->base_height == 0))
snprintf(s, len, "%u (%ux)",
*setting->value.target.unsigned_integer,
*setting->value.target.unsigned_integer / geom->base_height);
@ -4783,12 +4783,12 @@ static void setting_get_string_representation_uint_custom_viewport_height(rarch_
char *s, size_t len)
{
struct retro_game_geometry *geom = NULL;
struct retro_system_av_info *av_info = NULL;
video_driver_state_t *video_st = video_state_get_ptr();
struct retro_system_av_info *av_info = &video_st->av_info;
unsigned int rotation = retroarch_get_rotation();
if (!setting)
if (!setting || !av_info)
return;
av_info = video_viewport_get_system_av_info();
geom = (struct retro_game_geometry*)&av_info->geometry;
if (!(rotation % 2) && (*setting->value.target.unsigned_integer % geom->base_height == 0))
@ -5496,11 +5496,10 @@ static int setting_uint_action_left_custom_viewport_width(
rarch_setting_t *setting, size_t idx, bool wraparound)
{
video_viewport_t vp;
struct retro_system_av_info *av_info = video_viewport_get_system_av_info();
video_driver_state_t *video_st = video_state_get_ptr();
struct retro_system_av_info *av_info = &video_st->av_info;
settings_t *settings = config_get_ptr();
video_viewport_t *custom = &settings->video_viewport_custom;
struct retro_game_geometry *geom = (struct retro_game_geometry*)
&av_info->geometry;
if (!settings || !av_info)
return -1;
@ -5511,6 +5510,8 @@ static int setting_uint_action_left_custom_viewport_width(
custom->width = setting->min;
else if (settings->bools.video_scale_integer)
{
struct retro_game_geometry *geom = (struct retro_game_geometry*)
&av_info->geometry;
unsigned int rotation = retroarch_get_rotation();
if (rotation % 2)
{
@ -5536,11 +5537,10 @@ static int setting_uint_action_left_custom_viewport_height(
rarch_setting_t *setting, size_t idx, bool wraparound)
{
video_viewport_t vp;
struct retro_system_av_info *av_info = video_viewport_get_system_av_info();
video_driver_state_t *video_st = video_state_get_ptr();
struct retro_system_av_info *av_info = &video_st->av_info;
settings_t *settings = config_get_ptr();
video_viewport_t *custom = &settings->video_viewport_custom;
struct retro_game_geometry *geom = (struct retro_game_geometry*)
&av_info->geometry;
if (!settings || !av_info)
return -1;
@ -5551,6 +5551,8 @@ static int setting_uint_action_left_custom_viewport_height(
custom->height = setting->min;
else if (settings->bools.video_scale_integer)
{
struct retro_game_geometry *geom =
(struct retro_game_geometry*)&av_info->geometry;
unsigned int rotation = retroarch_get_rotation();
if (rotation % 2)
{
@ -5797,11 +5799,10 @@ static int setting_uint_action_right_custom_viewport_width(
rarch_setting_t *setting, size_t idx, bool wraparound)
{
video_viewport_t vp;
struct retro_system_av_info *av_info = video_viewport_get_system_av_info();
settings_t *settings = config_get_ptr();
video_driver_state_t *video_st = video_state_get_ptr();
struct retro_system_av_info *av_info = &video_st->av_info;
video_viewport_t *custom = &settings->video_viewport_custom;
struct retro_game_geometry *geom = (struct retro_game_geometry*)
&av_info->geometry;
if (!settings || !av_info)
return -1;
@ -5812,6 +5813,8 @@ static int setting_uint_action_right_custom_viewport_width(
custom->width = setting->max;
else if (settings->bools.video_scale_integer)
{
struct retro_game_geometry *geom = (struct retro_game_geometry*)
&av_info->geometry;
unsigned int rotation = retroarch_get_rotation();
if (rotation % 2)
custom->width += geom->base_height;
@ -5831,11 +5834,10 @@ static int setting_uint_action_right_custom_viewport_height(
rarch_setting_t *setting, size_t idx, bool wraparound)
{
video_viewport_t vp;
struct retro_system_av_info *av_info = video_viewport_get_system_av_info();
video_driver_state_t *video_st = video_state_get_ptr();
struct retro_system_av_info *av_info = &video_st->av_info;
settings_t *settings = config_get_ptr();
video_viewport_t *custom = &settings->video_viewport_custom;
struct retro_game_geometry *geom = (struct retro_game_geometry*)
&av_info->geometry;
if (!settings || !av_info)
return -1;
@ -5846,6 +5848,8 @@ static int setting_uint_action_right_custom_viewport_height(
custom->height = setting->max;
else if (settings->bools.video_scale_integer)
{
struct retro_game_geometry *geom = (struct retro_game_geometry*)
&av_info->geometry;
unsigned int rotation = retroarch_get_rotation();
if (rotation % 2)
custom->height += geom->base_width;
@ -7224,11 +7228,10 @@ static int setting_action_start_input_device_index(rarch_setting_t *setting)
static int setting_action_start_custom_viewport_width(rarch_setting_t *setting)
{
video_viewport_t vp;
struct retro_system_av_info *av_info = video_viewport_get_system_av_info();
video_driver_state_t *video_st = video_state_get_ptr();
struct retro_system_av_info *av_info = &video_st->av_info;
settings_t *settings = config_get_ptr();
video_viewport_t *custom = &settings->video_viewport_custom;
struct retro_game_geometry *geom = (struct retro_game_geometry*)
&av_info->geometry;
if (!settings || !av_info)
return -1;
@ -7237,6 +7240,8 @@ static int setting_action_start_custom_viewport_width(rarch_setting_t *setting)
if (settings->bools.video_scale_integer)
{
struct retro_game_geometry *geom = (struct retro_game_geometry*)
&av_info->geometry;
unsigned int rotation = retroarch_get_rotation();
if (rotation % 2)
custom->width = ((custom->width + geom->base_height - 1) /
@ -7257,11 +7262,10 @@ static int setting_action_start_custom_viewport_width(rarch_setting_t *setting)
static int setting_action_start_custom_viewport_height(rarch_setting_t *setting)
{
video_viewport_t vp;
struct retro_system_av_info *av_info = video_viewport_get_system_av_info();
video_driver_state_t *video_st = video_state_get_ptr();
struct retro_system_av_info *av_info = &video_st->av_info;
settings_t *settings = config_get_ptr();
video_viewport_t *custom = &settings->video_viewport_custom;
struct retro_game_geometry *geom = (struct retro_game_geometry*)
&av_info->geometry;
if (!settings || !av_info)
return -1;
@ -7270,12 +7274,12 @@ static int setting_action_start_custom_viewport_height(rarch_setting_t *setting)
if (settings->bools.video_scale_integer)
{
struct retro_game_geometry *geom = (struct retro_game_geometry*)
&av_info->geometry;
unsigned int rotation = retroarch_get_rotation();
if (rotation % 2)
{
custom->height = ((custom->height + geom->base_width - 1) /
geom->base_width) * geom->base_width;
}
else
custom->height = ((custom->height + geom->base_height - 1) /
geom->base_height) * geom->base_height;
@ -7795,29 +7799,30 @@ static void general_write_handler(rarch_setting_t *setting)
case MENU_ENUM_LABEL_VIDEO_SCALE_INTEGER:
{
video_viewport_t vp;
struct retro_system_av_info *av_info = video_viewport_get_system_av_info();
video_driver_state_t *video_st = video_state_get_ptr();
struct retro_system_av_info *av_info = &video_st->av_info;
struct video_viewport *custom_vp = &settings->video_viewport_custom;
struct retro_game_geometry *geom = (struct retro_game_geometry*)
&av_info->geometry;
video_driver_get_viewport_info(&vp);
if (*setting->value.target.boolean)
{
unsigned int rotation = retroarch_get_rotation();
struct retro_game_geometry *geom = (struct retro_game_geometry*)
&av_info->geometry;
custom_vp->x = 0;
custom_vp->y = 0;
if (rotation % 2)
{
custom_vp->width = ((custom_vp->width + geom->base_height - 1) / geom->base_height) * geom->base_height;
custom_vp->height = ((custom_vp->height + geom->base_width - 1) / geom->base_width) * geom->base_width;
custom_vp->width = ((custom_vp->width + geom->base_height - 1) / geom->base_height) * geom->base_height;
custom_vp->height = ((custom_vp->height + geom->base_width - 1) / geom->base_width) * geom->base_width;
}
else
{
custom_vp->width = ((custom_vp->width + geom->base_width - 1) / geom->base_width) * geom->base_width;
custom_vp->height = ((custom_vp->height + geom->base_height - 1) / geom->base_height) * geom->base_height;
custom_vp->width = ((custom_vp->width + geom->base_width - 1) / geom->base_width) * geom->base_width;
custom_vp->height = ((custom_vp->height + geom->base_height - 1) / geom->base_height) * geom->base_height;
}
aspectratio_lut[ASPECT_RATIO_CUSTOM].value =
(float)custom_vp->width / custom_vp->height;
@ -8030,14 +8035,15 @@ static void general_write_handler(rarch_setting_t *setting)
{
video_viewport_t vp;
rarch_system_info_t *system = &runloop_state_get_ptr()->system;
struct retro_system_av_info *av_info = video_viewport_get_system_av_info();
video_driver_state_t *video_st = video_state_get_ptr();
struct retro_system_av_info *av_info = &video_st->av_info;
video_viewport_t *custom_vp = &settings->video_viewport_custom;
struct retro_game_geometry *geom = (struct retro_game_geometry*)
&av_info->geometry;
if (system)
{
unsigned int rotation = retroarch_get_rotation();
struct retro_game_geometry *geom = (struct retro_game_geometry*)
&av_info->geometry;
video_driver_set_rotation(
(*setting->value.target.unsigned_integer +

View File

@ -766,7 +766,7 @@ void drivers_init(
#ifdef HAVE_VIDEO_FILTER
video_driver_filter_free();
#endif
video_driver_set_cached_frame_ptr(NULL);
video_st->frame_cache_data = NULL;
if (!video_driver_init_internal(&video_is_threaded,
verbosity_enabled))
retroarch_fail(1, "video_driver_init_internal()");
@ -1041,8 +1041,8 @@ void driver_uninit(int flags)
{
video_driver_free_internal();
VIDEO_DRIVER_LOCK_FREE(video_st);
video_st->data = NULL;
video_driver_set_cached_frame_ptr(NULL);
video_st->data = NULL;
video_st->frame_cache_data = NULL;
}
if (flags & DRIVER_AUDIO_MASK)
@ -1104,7 +1104,7 @@ static void retroarch_deinit_drivers(struct retro_callbacks *cbs)
);
video_st->record_gpu_buffer = NULL;
video_st->current_video = NULL;
video_driver_set_cached_frame_ptr(NULL);
video_st->frame_cache_data = NULL;
/* Audio */
audio_state_get_ptr()->flags &= ~AUDIO_FLAG_ACTIVE;

View File

@ -3791,11 +3791,12 @@ static retro_time_t runloop_core_runtime_tick(
static bool core_unload_game(void)
{
runloop_state_t *runloop_st = &runloop_state;
runloop_state_t *runloop_st = &runloop_state;
video_driver_state_t *video_st = video_state_get_ptr();
video_driver_free_hw_context();
video_driver_set_cached_frame_ptr(NULL);
video_st->frame_cache_data = NULL;
if ((runloop_st->current_core.flags & RETRO_CORE_FLAG_GAME_LOADED))
{
@ -3892,7 +3893,7 @@ void runloop_event_deinit_core(void)
core_unload_game();
video_driver_set_cached_frame_ptr(NULL);
video_st->frame_cache_data = NULL;
if (runloop_st->current_core.flags & RETRO_CORE_FLAG_INITED)
{
@ -4578,7 +4579,7 @@ bool runloop_event_init_core(
/* Per-core saves: reset redirection paths */
runloop_path_set_redirect(settings, old_savefile_dir, old_savestate_dir);
video_driver_set_cached_frame_ptr(NULL);
video_st->frame_cache_data = NULL;
runloop_st->current_core.retro_init();
runloop_st->current_core.flags |= RETRO_CORE_FLAG_INITED;
@ -7505,10 +7506,11 @@ bool core_get_memory(retro_ctx_memory_info_t *info)
bool core_load_game(retro_ctx_load_content_info_t *load_info)
{
bool game_loaded = false;
runloop_state_t *runloop_st = &runloop_state;
bool game_loaded = false;
video_driver_state_t *video_st = video_state_get_ptr();
runloop_state_t *runloop_st = &runloop_state;
video_driver_set_cached_frame_ptr(NULL);
video_st->frame_cache_data = NULL;
#ifdef HAVE_RUNAHEAD
runahead_set_load_content_info(runloop_st, load_info);
@ -7642,9 +7644,9 @@ uint64_t core_serialization_quirks(void)
void core_reset(void)
{
runloop_state_t *runloop_st = &runloop_state;
video_driver_set_cached_frame_ptr(NULL);
runloop_state_t *runloop_st = &runloop_state;
video_driver_state_t *video_st = video_state_get_ptr();
video_st->frame_cache_data = NULL;
runloop_st->current_core.retro_reset();
}

View File

@ -484,6 +484,7 @@ static bool take_screenshot_raw(const char *screenshot_dir,
}
static bool take_screenshot_choice(
video_driver_state_t *video_st,
const char *screenshot_dir,
const char *name_base,
bool savestate,
@ -524,12 +525,14 @@ static bool take_screenshot_choice(
frame_data = video_driver_read_frame_raw(
&old_width, &old_height, &old_pitch);
video_driver_cached_frame_set(old_data, old_width, old_height,
old_pitch);
video_st->frame_cache_data = old_data;
video_st->frame_cache_width = old_width;
video_st->frame_cache_height = old_height;
video_st->frame_cache_pitch = old_pitch;
if (frame_data)
{
video_driver_set_cached_frame_ptr(frame_data);
video_st->frame_cache_data = frame_data;
return take_screenshot_raw(screenshot_dir,
name_base, frame_data, savestate, runloop_flags, fullpath, use_thread,
pixel_format_type);
@ -571,6 +574,7 @@ bool take_screenshot(
return false;
ret = take_screenshot_choice(
video_st,
screenshot_dir,
name_base, savestate, runloop_flags,
has_valid_framebuffer, fullpath, use_thread,