This commit is contained in:
libretroadmin 2023-05-30 12:19:53 +02:00
parent dbd7153526
commit c09fb6d95d
23 changed files with 356 additions and 513 deletions

View File

@ -2532,6 +2532,7 @@ void config_set_defaults(void *data)
const char *def_record = config_get_default_record(); const char *def_record = config_get_default_record();
const char *def_midi = config_get_default_midi(); const char *def_midi = config_get_default_midi();
const char *def_mitm = DEFAULT_NETPLAY_MITM_SERVER; const char *def_mitm = DEFAULT_NETPLAY_MITM_SERVER;
struct video_viewport *custom_vp = &settings->video_viewport_custom;
struct config_float_setting *float_settings = populate_settings_float (settings, &float_settings_size); struct config_float_setting *float_settings = populate_settings_float (settings, &float_settings_size);
struct config_bool_setting *bool_settings = populate_settings_bool (settings, &bool_settings_size); struct config_bool_setting *bool_settings = populate_settings_bool (settings, &bool_settings_size);
struct config_int_setting *int_settings = populate_settings_int (settings, &int_settings_size); struct config_int_setting *int_settings = populate_settings_int (settings, &int_settings_size);
@ -2743,7 +2744,10 @@ void config_set_defaults(void *data)
settings->uints.input_mouse_index[i] = (unsigned)i; settings->uints.input_mouse_index[i] = (unsigned)i;
} }
video_driver_reset_custom_viewport(settings); custom_vp->width = 0;
custom_vp->height = 0;
custom_vp->x = 0;
custom_vp->y = 0;
/* Make sure settings from other configs carry over into defaults /* Make sure settings from other configs carry over into defaults
* for another config. */ * for another config. */

View File

@ -1383,12 +1383,11 @@ void d3d9_calculate_rect(d3d9_video_t *d3d,
#if defined(HAVE_MENU) #if defined(HAVE_MENU)
if (settings->uints.video_aspect_ratio_idx == ASPECT_RATIO_CUSTOM) if (settings->uints.video_aspect_ratio_idx == ASPECT_RATIO_CUSTOM)
{ {
video_viewport_t *custom = video_viewport_get_custom(); video_viewport_t *custom_vp = &settings->video_viewport_custom;
*x = custom_vp->x;
*x = custom->x; *y = custom_vp->y;
*y = custom->y; *width = custom_vp->width;
*width = custom->width; *height = custom_vp->height;
*height = custom->height;
} }
else else
#endif #endif

View File

@ -1524,18 +1524,20 @@ static bool vulkan_context_init_device(gfx_ctx_vulkan_data_t *vk)
{ {
uint32_t queue_count; uint32_t queue_count;
unsigned i; unsigned i;
const char *enabled_device_extensions[8];
static const float one = 1.0f; static const float one = 1.0f;
bool found_queue = false; bool found_queue = false;
video_driver_state_t *video_st = video_state_get_ptr();
VkPhysicalDeviceFeatures features = { false }; VkPhysicalDeviceFeatures features = { false };
VkDeviceQueueCreateInfo queue_info = { VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO }; VkDeviceQueueCreateInfo queue_info = { VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO };
VkDeviceCreateInfo device_info = { VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO }; VkDeviceCreateInfo device_info = { VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO };
const char *enabled_device_extensions[8];
unsigned enabled_device_extension_count = 0; unsigned enabled_device_extension_count = 0;
struct retro_hw_render_context_negotiation_interface_vulkan *iface = struct retro_hw_render_context_negotiation_interface_vulkan
(struct retro_hw_render_context_negotiation_interface_vulkan*)video_driver_get_context_negotiation_interface(); *iface = (struct retro_hw_render_context_negotiation_interface_vulkan*)
video_st->hw_render_context_negotiation;
if (iface && iface->interface_type != RETRO_HW_RENDER_CONTEXT_NEGOTIATION_INTERFACE_VULKAN) if (iface && iface->interface_type != RETRO_HW_RENDER_CONTEXT_NEGOTIATION_INTERFACE_VULKAN)
{ {
@ -1593,11 +1595,7 @@ static bool vulkan_context_init_device(gfx_ctx_vulkan_data_t *vk)
&features); &features);
} }
if (!ret) if (ret)
{
RARCH_WARN("[Vulkan]: Failed to create device with negotiation interface. Falling back to default path.\n");
}
else
{ {
if (vk->context.gpu != VK_NULL_HANDLE && context.gpu != vk->context.gpu) if (vk->context.gpu != VK_NULL_HANDLE && context.gpu != vk->context.gpu)
RARCH_ERR("[Vulkan]: Got unexpected VkPhysicalDevice, despite RetroArch using explicit physical device.\n"); RARCH_ERR("[Vulkan]: Got unexpected VkPhysicalDevice, despite RetroArch using explicit physical device.\n");
@ -1616,6 +1614,10 @@ static bool vulkan_context_init_device(gfx_ctx_vulkan_data_t *vk)
return false; return false;
} }
} }
else
{
RARCH_WARN("[Vulkan]: Failed to create device with negotiation interface. Falling back to default path.\n");
}
} }
if (cached_device_vk && cached_destroy_device_vk) if (cached_device_vk && cached_destroy_device_vk)
@ -1752,7 +1754,7 @@ static bool vulkan_context_init_device(gfx_ctx_vulkan_data_t *vk)
vk->context.device = cached_device_vk; vk->context.device = cached_device_vk;
cached_device_vk = NULL; cached_device_vk = NULL;
video_state_get_ptr()->flags |= VIDEO_FLAG_CACHE_CONTEXT_ACK; video_st->flags |= VIDEO_FLAG_CACHE_CONTEXT_ACK;
RARCH_LOG("[Vulkan]: Using cached Vulkan context.\n"); RARCH_LOG("[Vulkan]: Using cached Vulkan context.\n");
} }
else if (vkCreateDevice(vk->context.gpu, &device_info, else if (vkCreateDevice(vk->context.gpu, &device_info,
@ -1896,8 +1898,9 @@ bool vulkan_context_init(gfx_ctx_vulkan_data_t *vk,
{ {
PFN_vkGetInstanceProcAddr GetInstanceProcAddr; PFN_vkGetInstanceProcAddr GetInstanceProcAddr;
VkApplicationInfo app = { VK_STRUCTURE_TYPE_APPLICATION_INFO }; VkApplicationInfo app = { VK_STRUCTURE_TYPE_APPLICATION_INFO };
struct retro_hw_render_context_negotiation_interface_vulkan *iface = video_driver_state_t *video_st = video_state_get_ptr();
(struct retro_hw_render_context_negotiation_interface_vulkan*)video_driver_get_context_negotiation_interface(); struct retro_hw_render_context_negotiation_interface_vulkan
*iface = (struct retro_hw_render_context_negotiation_interface_vulkan*)video_st->hw_render_context_negotiation;
if (iface && iface->interface_type != RETRO_HW_RENDER_CONTEXT_NEGOTIATION_INTERFACE_VULKAN) if (iface && iface->interface_type != RETRO_HW_RENDER_CONTEXT_NEGOTIATION_INTERFACE_VULKAN)
{ {

View File

@ -292,10 +292,11 @@ static bool d3d8_setup_init(void *data,
{ {
unsigned width, height; unsigned width, height;
d3d8_video_t *d3d = (d3d8_video_t*)data; d3d8_video_t *d3d = (d3d8_video_t*)data;
settings_t *settings = config_get_ptr();
LPDIRECT3DDEVICE8 d3dr = (LPDIRECT3DDEVICE8)d3d->dev; LPDIRECT3DDEVICE8 d3dr = (LPDIRECT3DDEVICE8)d3d->dev;
d3d8_renderchain_t *chain = (d3d8_renderchain_t*)d3d->renderchain_data; d3d8_renderchain_t *chain = (d3d8_renderchain_t*)d3d->renderchain_data;
unsigned fmt = (rgb32) ? RETRO_PIXEL_FORMAT_XRGB8888 : RETRO_PIXEL_FORMAT_RGB565; unsigned fmt = (rgb32) ? RETRO_PIXEL_FORMAT_XRGB8888 : RETRO_PIXEL_FORMAT_RGB565;
struct video_viewport *custom_vp = video_viewport_get_custom(); video_viewport_t *custom_vp = &settings->video_viewport_custom;
video_driver_get_size(&width, &height); video_driver_get_size(&width, &height);
@ -798,12 +799,12 @@ static void d3d8_calculate_rect(void *data,
#if defined(HAVE_MENU) #if defined(HAVE_MENU)
if (aspect_ratio_idx == ASPECT_RATIO_CUSTOM) if (aspect_ratio_idx == ASPECT_RATIO_CUSTOM)
{ {
video_viewport_t *custom = video_viewport_get_custom(); video_viewport_t *custom_vp = &settings->video_viewport_custom;
*x = custom->x; *x = custom_vp->x;
*y = custom->y; *y = custom_vp->y;
*width = custom->width; *width = custom_vp->width;
*height = custom->height; *height = custom_vp->height;
} }
else else
#endif #endif

View File

@ -505,12 +505,12 @@ void gl1_gfx_set_viewport(gl1_t *gl1,
#if defined(HAVE_MENU) #if defined(HAVE_MENU)
if (settings->uints.video_aspect_ratio_idx == ASPECT_RATIO_CUSTOM) if (settings->uints.video_aspect_ratio_idx == ASPECT_RATIO_CUSTOM)
{ {
const struct video_viewport *custom = video_viewport_get_custom(); video_viewport_t *custom_vp = &settings->video_viewport_custom;
/* GL has bottom-left origin viewport. */ /* OpenGL has bottom-left origin viewport. */
x = custom->x; x = custom_vp->x;
y = height - custom->y - custom->height; y = height - custom_vp->y - custom_vp->height;
viewport_width = custom->width; viewport_width = custom_vp->width;
viewport_height = custom->height; viewport_height = custom_vp->height;
} }
else else
#endif #endif

View File

@ -436,12 +436,12 @@ static void gl2_set_viewport(gl2_t *gl,
#if defined(HAVE_MENU) #if defined(HAVE_MENU)
if (settings->uints.video_aspect_ratio_idx == ASPECT_RATIO_CUSTOM) if (settings->uints.video_aspect_ratio_idx == ASPECT_RATIO_CUSTOM)
{ {
const struct video_viewport *custom = video_viewport_get_custom(); video_viewport_t *custom_vp = &settings->video_viewport_custom;
/* GL has bottom-left origin viewport. */ /* OpenGL has bottom-left origin viewport. */
x = custom->x; x = custom_vp->x;
y = height - custom->y - custom->height; y = height - custom_vp->y - custom_vp->height;
viewport_width = custom->width; viewport_width = custom_vp->width;
viewport_height = custom->height; viewport_height = custom_vp->height;
} }
else else
#endif #endif

View File

@ -599,12 +599,12 @@ static void gl3_set_viewport(gl3_t *gl,
#if defined(HAVE_MENU) #if defined(HAVE_MENU)
if (video_aspect_ratio_idx == ASPECT_RATIO_CUSTOM) if (video_aspect_ratio_idx == ASPECT_RATIO_CUSTOM)
{ {
const struct video_viewport *custom = video_viewport_get_custom(); video_viewport_t *custom_vp = &settings->video_viewport_custom;
/* GL has bottom-left origin viewport. */ /* OpenGL has bottom-left origin viewport. */
x = custom->x; x = custom_vp->x;
y = height - custom->y - custom->height; y = height - custom_vp->y - custom_vp->height;
viewport_width = custom->width; viewport_width = custom_vp->width;
viewport_height = custom->height; viewport_height = custom_vp->height;
} }
else else
#endif #endif

View File

@ -133,13 +133,12 @@ static void wiiu_gfx_update_viewport(wiiu_video_t *wiiu)
#if defined(HAVE_MENU) #if defined(HAVE_MENU)
if (video_aspect_ratio_idx == ASPECT_RATIO_CUSTOM) if (video_aspect_ratio_idx == ASPECT_RATIO_CUSTOM)
{ {
const struct video_viewport *custom = video_viewport_get_custom(); video_viewport_t *custom_vp = &settings->video_viewport_custom;
/* GX2 has top-left origin viewport. */
/* Vulkan has top-left origin viewport. */ x = custom_vp->x;
x = custom->x; y = custom_vp->y;
y = custom->y; viewport_width = custom_vp->width;
viewport_width = custom->width; viewport_height = custom_vp->height;
viewport_height = custom->height;
} }
else else
#endif #endif

View File

@ -990,6 +990,7 @@ static void gx_resize(gx_video_t *gx,
float top = 1, bottom = -1, left = -1, right = 1; float top = 1, bottom = -1, left = -1, right = 1;
int x = 0, y = 0; int x = 0, y = 0;
const global_t *global = global_get_ptr(); const global_t *global = global_get_ptr();
settings_t *settings = config_get_ptr();
unsigned width = gx->vp.full_width; unsigned width = gx->vp.full_width;
unsigned height = gx->vp.full_height; unsigned height = gx->vp.full_height;
@ -1013,13 +1014,13 @@ static void gx_resize(gx_video_t *gx,
float desired_aspect = video_driver_get_aspect_ratio(); float desired_aspect = video_driver_get_aspect_ratio();
if (desired_aspect == 0.0) if (desired_aspect == 0.0)
desired_aspect = 1.0; desired_aspect = 1.0;
if (gx->orientation == ORIENTATION_VERTICAL || if ( (gx->orientation == ORIENTATION_VERTICAL)
gx->orientation == ORIENTATION_FLIPPED_ROTATED) || (gx->orientation == ORIENTATION_FLIPPED_ROTATED))
desired_aspect = 1.0 / desired_aspect; desired_aspect = 1.0 / desired_aspect;
if (aspect_ratio_idx == ASPECT_RATIO_CUSTOM) if (aspect_ratio_idx == ASPECT_RATIO_CUSTOM)
{ {
struct video_viewport *custom_vp = video_viewport_get_custom(); video_viewport_t *custom_vp = &settings->video_viewport_custom;
if (!custom_vp->width || !custom_vp->height) if (!custom_vp->width || !custom_vp->height)
{ {

View File

@ -434,6 +434,7 @@ static void *psp_init(const video_info_t *video,
else else
{ {
u16 i; u16 i;
video_driver_state_t *video_st = video_state_get_ptr();
uint16_t* LUT_r_local = (uint16_t*)(SCEGU_VRAM_BP_2); uint16_t* LUT_r_local = (uint16_t*)(SCEGU_VRAM_BP_2);
uint16_t* LUT_b_local = (uint16_t*)(SCEGU_VRAM_BP_2) + (1 << 5); uint16_t* LUT_b_local = (uint16_t*)(SCEGU_VRAM_BP_2) + (1 << 5);
@ -446,8 +447,8 @@ static void *psp_init(const video_info_t *video,
psp->bpp_log2 = 1; psp->bpp_log2 = 1;
pixel_format = pixel_format =
(video_driver_get_pixel_format() == RETRO_PIXEL_FORMAT_0RGB1555) (video_st->pix_fmt == RETRO_PIXEL_FORMAT_0RGB1555)
? GU_PSM_5551 : GU_PSM_5650 ; ? GU_PSM_5551 : GU_PSM_5650;
lut_pixel_format = GU_PSM_T16; lut_pixel_format = GU_PSM_T16;
@ -824,7 +825,7 @@ static bool psp_read_viewport(void *data, uint8_t *buffer, bool is_idle)
switch(src_pixelformat) switch(src_pixelformat)
{ {
case PSP_DISPLAY_PIXEL_FORMAT_565: case PSP_DISPLAY_PIXEL_FORMAT_565:
for (j = (src_y_max - 1); j >= src_y ; j--) for (j = (src_y_max - 1); j >= src_y; j--)
{ {
uint16_t* src = (uint16_t*)src_buffer + src_bufferwidth * j + src_x; uint16_t* src = (uint16_t*)src_buffer + src_bufferwidth * j + src_x;
for (i = src_x; i < src_x_max; i++) for (i = src_x; i < src_x_max; i++)
@ -839,7 +840,7 @@ static bool psp_read_viewport(void *data, uint8_t *buffer, bool is_idle)
return true; return true;
case PSP_DISPLAY_PIXEL_FORMAT_5551: case PSP_DISPLAY_PIXEL_FORMAT_5551:
for (j = (src_y_max - 1); j >= src_y ; j--) for (j = (src_y_max - 1); j >= src_y; j--)
{ {
uint16_t* src = (uint16_t*)src_buffer + src_bufferwidth * j + src_x; uint16_t* src = (uint16_t*)src_buffer + src_bufferwidth * j + src_x;
for (i = src_x; i < src_x_max; i++) for (i = src_x; i < src_x_max; i++)
@ -854,7 +855,7 @@ static bool psp_read_viewport(void *data, uint8_t *buffer, bool is_idle)
return true; return true;
case PSP_DISPLAY_PIXEL_FORMAT_4444: case PSP_DISPLAY_PIXEL_FORMAT_4444:
for (j = (src_y_max - 1); j >= src_y ; j--) for (j = (src_y_max - 1); j >= src_y; j--)
{ {
uint16_t* src = (uint16_t*)src_buffer + src_bufferwidth * j + src_x; uint16_t* src = (uint16_t*)src_buffer + src_bufferwidth * j + src_x;
for (i = src_x; i < src_x_max; i++) for (i = src_x; i < src_x_max; i++)
@ -869,7 +870,7 @@ static bool psp_read_viewport(void *data, uint8_t *buffer, bool is_idle)
return true; return true;
case PSP_DISPLAY_PIXEL_FORMAT_8888: case PSP_DISPLAY_PIXEL_FORMAT_8888:
for (j = (src_y_max - 1); j >= src_y ; j--) for (j = (src_y_max - 1); j >= src_y; j--)
{ {
uint32_t* src = (uint32_t*)src_buffer + src_bufferwidth * j + src_x; uint32_t* src = (uint32_t*)src_buffer + src_bufferwidth * j + src_x;
for (i = src_x; i < src_x_max; i++) for (i = src_x; i < src_x_max; i++)

View File

@ -194,12 +194,12 @@ static void rsx_set_viewport(void *data, unsigned viewport_width,
#if defined(HAVE_MENU) #if defined(HAVE_MENU)
if (aspect_ratio_idx == ASPECT_RATIO_CUSTOM) if (aspect_ratio_idx == ASPECT_RATIO_CUSTOM)
{ {
const struct video_viewport *custom = video_viewport_get_custom(); video_viewport_t *custom_vp = &settings->video_viewport_custom;
/* RSX/libgcm has top-left origin viewport. */
x = custom->x; x = custom_vp->x;
y = custom->y; y = custom_vp->y;
viewport_width = custom->width; viewport_width = custom_vp->width;
viewport_height = custom->height; viewport_height = custom_vp->height;
} }
else else
#endif #endif
@ -691,12 +691,12 @@ static void rsx_update_viewport(rsx_t* rsx)
#if defined(HAVE_MENU) #if defined(HAVE_MENU)
if (aspect_ratio_idx == ASPECT_RATIO_CUSTOM) if (aspect_ratio_idx == ASPECT_RATIO_CUSTOM)
{ {
const struct video_viewport *custom = video_viewport_get_custom(); video_viewport_t *custom_vp = &settings->video_viewport_custom;
/* RSX/libgcm has top-left origin viewport. */
x = custom->x; x = custom_vp->x;
y = custom->y; y = custom_vp->y;
viewport_width = custom->width; viewport_width = custom_vp->width;
viewport_height = custom->height; viewport_height = custom_vp->height;
} }
else else
#endif #endif

View File

@ -242,13 +242,11 @@ static void sdl_refresh_viewport(sdl2_video_t *vid)
vid->video.force_aspect); vid->video.force_aspect);
else if (aspect_ratio_idx == ASPECT_RATIO_CUSTOM) else if (aspect_ratio_idx == ASPECT_RATIO_CUSTOM)
{ {
const struct video_viewport *custom = video_viewport_t *custom_vp = &settings->video_viewport_custom;
(const struct video_viewport*)video_viewport_get_custom(); vid->vp.x = custom_vp->x;
vid->vp.y = custom_vp->y;
vid->vp.x = custom->x; vid->vp.width = custom_vp->width;
vid->vp.y = custom->y; vid->vp.height = custom_vp->height;
vid->vp.width = custom->width;
vid->vp.height = custom->height;
} }
else if (vid->video.force_aspect) else if (vid->video.force_aspect)
{ {

View File

@ -522,18 +522,16 @@ static void vita2d_gfx_set_viewport(void *data, unsigned viewport_width,
#if defined(HAVE_MENU) #if defined(HAVE_MENU)
if (aspect_ratio_idx == ASPECT_RATIO_CUSTOM) if (aspect_ratio_idx == ASPECT_RATIO_CUSTOM)
{ {
const struct video_viewport *custom = video_viewport_get_custom(); video_viewport_t *custom_vp = &settings->video_viewport_custom;
x = custom_vp->x;
x = custom->x; y = custom_vp->y;
y = custom->y; viewport_width = custom_vp->width;
viewport_width = custom->width; viewport_height = custom_vp->height;
viewport_height = custom->height;
} }
else else
#endif #endif
{ {
float delta; float delta;
if (fabsf(device_aspect - desired_aspect) < 0.0001f) if (fabsf(device_aspect - desired_aspect) < 0.0001f)
{ {
/* If the aspect ratios of screen and desired aspect /* If the aspect ratios of screen and desired aspect

View File

@ -1975,17 +1975,15 @@ static void vulkan_set_viewport(void *data, unsigned viewport_width,
else if ((vk->flags & VK_FLAG_KEEP_ASPECT) && !force_full) else if ((vk->flags & VK_FLAG_KEEP_ASPECT) && !force_full)
{ {
float desired_aspect = video_driver_get_aspect_ratio(); float desired_aspect = video_driver_get_aspect_ratio();
#if defined(HAVE_MENU) #if defined(HAVE_MENU)
if (aspect_ratio_idx == ASPECT_RATIO_CUSTOM) if (aspect_ratio_idx == ASPECT_RATIO_CUSTOM)
{ {
const struct video_viewport *custom = video_viewport_get_custom(); video_viewport_t *custom_vp = &settings->video_viewport_custom;
/* Vulkan has top-left origin viewport. */ /* Vulkan has top-left origin viewport. */
x = custom->x; x = custom_vp->x;
y = custom->y; y = custom_vp->y;
viewport_width = custom->width; viewport_width = custom_vp->width;
viewport_height = custom->height; viewport_height = custom_vp->height;
} }
else else
#endif #endif

View File

@ -83,10 +83,11 @@ static void crt_aspect_ratio_switch(
float srm_width, float srm_height) float srm_width, float srm_height)
{ {
/* Send aspect float to video_driver */ /* Send aspect float to video_driver */
p_switch->fly_aspect = (float)width / (float)height; video_driver_state_t *video_st = video_state_get_ptr();
video_driver_set_aspect_ratio_value((float)p_switch->fly_aspect); float fly_aspect = (float)width / (float)height;
RARCH_LOG("[CRT]: Setting Aspect Ratio: %f \n", p_switch->fly_aspect = fly_aspect;
(float)p_switch->fly_aspect); video_st->aspect_ratio = fly_aspect;
RARCH_LOG("[CRT]: Setting Aspect Ratio: %f \n", fly_aspect);
RARCH_LOG("[CRT]: Setting Video Screen Size to: %dx%d \n", RARCH_LOG("[CRT]: Setting Video Screen Size to: %dx%d \n",
width, height); width, height);
video_driver_set_size(width , height); video_driver_set_size(width , height);
@ -419,9 +420,10 @@ void crt_switch_res_core(
if (video_driver_get_aspect_ratio() != p_switch->fly_aspect) if (video_driver_get_aspect_ratio() != p_switch->fly_aspect)
{ {
RARCH_LOG("[CRT]: Restoring Aspect Ratio: %f \n", video_driver_state_t *video_st = video_state_get_ptr();
(float)p_switch->fly_aspect); float fly_aspect = (float)p_switch->fly_aspect;
video_driver_set_aspect_ratio_value((float)p_switch->fly_aspect); RARCH_LOG("[CRT]: Restoring Aspect Ratio: %f \n", fly_aspect);
video_st->aspect_ratio = fly_aspect;
video_driver_apply_state_changes(); video_driver_apply_state_changes();
} }
} }

View File

@ -812,8 +812,7 @@ const char* config_get_video_driver_options(void)
return char_list_new_special(STRING_LIST_VIDEO_DRIVERS, NULL); return char_list_new_special(STRING_LIST_VIDEO_DRIVERS, NULL);
} }
void video_driver_pixel_converter_free( void video_driver_pixel_converter_free(video_pixel_scaler_t *scalr)
video_pixel_scaler_t *scalr)
{ {
if (!scalr) if (!scalr)
return; return;
@ -887,11 +886,6 @@ error:
return NULL; return NULL;
} }
struct video_viewport *video_viewport_get_custom(void)
{
return &config_get_ptr()->video_viewport_custom;
}
bool video_driver_monitor_adjust_system_rates( bool video_driver_monitor_adjust_system_rates(
float timing_skew_hz, float timing_skew_hz,
float video_refresh_rate, float video_refresh_rate,
@ -923,16 +917,6 @@ bool video_driver_monitor_adjust_system_rates(
return input_fps <= target_video_sync_rate; return input_fps <= target_video_sync_rate;
} }
void video_driver_reset_custom_viewport(settings_t *settings)
{
struct video_viewport *custom_vp = &settings->video_viewport_custom;
custom_vp->width = 0;
custom_vp->height = 0;
custom_vp->x = 0;
custom_vp->y = 0;
}
struct retro_system_av_info *video_viewport_get_system_av_info(void) struct retro_system_av_info *video_viewport_get_system_av_info(void)
{ {
return &video_driver_st.av_info; return &video_driver_st.av_info;
@ -985,8 +969,8 @@ void recording_dump_frame(
} }
/* User has resized. We kinda have a problem now. */ /* User has resized. We kinda have a problem now. */
if ( vp.width != record_st->gpu_width || if ( (vp.width != record_st->gpu_width)
vp.height != record_st->gpu_height) || (vp.height != record_st->gpu_height))
{ {
const char *recording_failed_str = const char *recording_failed_str =
msg_hash_to_str(MSG_RECORDING_TERMINATED_DUE_TO_RESIZE); msg_hash_to_str(MSG_RECORDING_TERMINATED_DUE_TO_RESIZE);
@ -1002,7 +986,9 @@ void recording_dump_frame(
/* Big bottleneck. /* Big bottleneck.
* Since we might need to do read-backs asynchronously, * Since we might need to do read-backs asynchronously,
* it might take 3-4 times before this returns true. */ * it might take 3-4 times before this returns true. */
if (!video_driver_read_viewport(video_st->record_gpu_buffer, is_idle)) if (!( video_st->current_video->read_viewport
&& video_st->current_video->read_viewport(
video_st->data, video_st->record_gpu_buffer, is_idle)))
return; return;
ffemu_data.pitch = (int)(record_st->gpu_width * 3); ffemu_data.pitch = (int)(record_st->gpu_width * 3);
@ -1020,9 +1006,9 @@ void recording_dump_frame(
const char *video_display_server_get_ident(void) const char *video_display_server_get_ident(void)
{ {
if (!current_display_server) if (current_display_server)
return FILE_PATH_UNKNOWN;
return current_display_server->ident; return current_display_server->ident;
return FILE_PATH_UNKNOWN;
} }
void* video_display_server_init(enum rarch_display_type type) void* video_display_server_init(enum rarch_display_type type)
@ -1160,9 +1146,9 @@ bool video_display_server_has_refresh_rate(float hz)
for (i = 0; i < size && !rate_exists; i++) for (i = 0; i < size && !rate_exists; i++)
{ {
if (video_list[i].width == video_driver_width && if ( (video_list[i].width == video_driver_width)
video_list[i].height == video_driver_height && && (video_list[i].height == video_driver_height)
video_list[i].refreshrate == floor(hz)) && (video_list[i].refreshrate == floor(hz)))
rate_exists = true; rate_exists = true;
} }
@ -1214,15 +1200,15 @@ void video_switch_refresh_rate_maybe(
* - 'CRT SwitchRes' OFF & 'Sync to Exact Content Framerate' OFF * - 'CRT SwitchRes' OFF & 'Sync to Exact Content Framerate' OFF
* - Automatic refresh rate switching not OFF * - Automatic refresh rate switching not OFF
*/ */
if ( refresh_rate != video_refresh_rate if ( (refresh_rate != video_refresh_rate)
&& !crt_switch_resolution && !crt_switch_resolution
&& !vrr_runloop_enable && !vrr_runloop_enable
&& (autoswitch_refresh_rate != AUTOSWITCH_REFRESH_RATE_OFF)) && (autoswitch_refresh_rate != AUTOSWITCH_REFRESH_RATE_OFF))
{ {
*video_switch_refresh_rate = ( *video_switch_refresh_rate = (
((autoswitch_refresh_rate == AUTOSWITCH_REFRESH_RATE_EXCLUSIVE_FULLSCREEN) && exclusive_fullscreen) || ((autoswitch_refresh_rate == AUTOSWITCH_REFRESH_RATE_EXCLUSIVE_FULLSCREEN) && exclusive_fullscreen)
((autoswitch_refresh_rate == AUTOSWITCH_REFRESH_RATE_WINDOWED_FULLSCREEN) && windowed_fullscreen) || || ((autoswitch_refresh_rate == AUTOSWITCH_REFRESH_RATE_WINDOWED_FULLSCREEN) && windowed_fullscreen)
((autoswitch_refresh_rate == AUTOSWITCH_REFRESH_RATE_ALL_FULLSCREEN) && all_fullscreen)); || ((autoswitch_refresh_rate == AUTOSWITCH_REFRESH_RATE_ALL_FULLSCREEN) && all_fullscreen));
/* Store original refresh rate on automatic change, and /* Store original refresh rate on automatic change, and
* restore it in deinit_core and main_quit, because not all * restore it in deinit_core and main_quit, because not all
@ -1422,8 +1408,8 @@ void video_driver_init_filter(enum retro_pixel_format colfmt_int,
unsigned height = geom->max_height; unsigned height = geom->max_height;
/* Deprecated format. Gets pre-converted. */ /* Deprecated format. Gets pre-converted. */
enum retro_pixel_format colfmt = enum retro_pixel_format colfmt =
(colfmt_int == RETRO_PIXEL_FORMAT_0RGB1555) ? (colfmt_int == RETRO_PIXEL_FORMAT_0RGB1555)
RETRO_PIXEL_FORMAT_RGB565 : colfmt_int; ? RETRO_PIXEL_FORMAT_RGB565 : colfmt_int;
if (video_driver_is_hw_context()) if (video_driver_is_hw_context())
{ {
@ -1431,11 +1417,9 @@ void video_driver_init_filter(enum retro_pixel_format colfmt_int,
return; return;
} }
video_st->state_filter = rarch_softfilter_new( if (!(video_st->state_filter = rarch_softfilter_new(
settings->paths.path_softfilter_plugin, settings->paths.path_softfilter_plugin,
RARCH_SOFTFILTER_THREADS_AUTO, colfmt, width, height); RARCH_SOFTFILTER_THREADS_AUTO, colfmt, width, height)))
if (!video_st->state_filter)
{ {
RARCH_ERR("[Video]: Failed to load filter.\n"); RARCH_ERR("[Video]: Failed to load filter.\n");
return; return;
@ -1847,18 +1831,6 @@ float video_driver_get_aspect_ratio(void)
return video_st->aspect_ratio; return video_st->aspect_ratio;
} }
void video_driver_set_aspect_ratio_value(float value)
{
video_driver_state_t *video_st = &video_driver_st;
video_st->aspect_ratio = value;
}
enum retro_pixel_format video_driver_get_pixel_format(void)
{
video_driver_state_t *video_st = &video_driver_st;
return video_st->pix_fmt;
}
void video_driver_lock_new(void) void video_driver_lock_new(void)
{ {
#ifdef HAVE_THREADS #ifdef HAVE_THREADS
@ -1896,28 +1868,6 @@ void video_driver_unset_stub_frame(void)
video_st->frame_bak = NULL; video_st->frame_bak = NULL;
} }
bool video_driver_supports_viewport_read(void)
{
video_driver_state_t *video_st = &video_driver_st;
return video_st->current_video->read_viewport
&& video_st->current_video->viewport_info;
}
bool video_driver_prefer_viewport_read(void)
{
video_driver_state_t *video_st = &video_driver_st;
return (video_driver_is_hw_context() &&
!video_st->current_video->read_frame_raw);
}
bool video_driver_supports_read_frame_raw(void)
{
video_driver_state_t *video_st = &video_driver_st;
if (video_st->current_video->read_frame_raw)
return true;
return false;
}
/* Get aspect ratio (DAR) requested by the core */ /* Get aspect ratio (DAR) requested by the core */
float video_driver_get_core_aspect(void) float video_driver_get_core_aspect(void)
{ {
@ -1926,7 +1876,7 @@ float video_driver_get_core_aspect(void)
float out_aspect = 0; float out_aspect = 0;
if (!geom || geom->base_width <= 0.0f || geom->base_height <= 0.0f) if (!geom || geom->base_width <= 0.0f || geom->base_height <= 0.0f)
return out_aspect; return 0.0f;
/* Fallback to 1:1 pixel ratio if none provided */ /* Fallback to 1:1 pixel ratio if none provided */
if (geom->aspect_ratio > 0.0f) if (geom->aspect_ratio > 0.0f)
@ -1936,7 +1886,7 @@ float video_driver_get_core_aspect(void)
/* Flip rotated aspect */ /* Flip rotated aspect */
if ((retroarch_get_rotation() + retroarch_get_core_requested_rotation()) % 2) if ((retroarch_get_rotation() + retroarch_get_core_requested_rotation()) % 2)
out_aspect = 1.0f / out_aspect; return (1.0f / out_aspect);
return out_aspect; return out_aspect;
} }
@ -2067,8 +2017,7 @@ void video_driver_set_aspect_ratio(void)
break; break;
} }
video_driver_set_aspect_ratio_value( video_st->aspect_ratio = aspectratio_lut[aspect_ratio_idx].value;
aspectratio_lut[aspect_ratio_idx].value);
if ( video_st->poke if ( video_st->poke
&& video_st->poke->set_aspect_ratio) && video_st->poke->set_aspect_ratio)
@ -2103,12 +2052,11 @@ void video_driver_update_viewport(
#if defined(HAVE_MENU) #if defined(HAVE_MENU)
if (video_aspect_ratio_idx == ASPECT_RATIO_CUSTOM) if (video_aspect_ratio_idx == ASPECT_RATIO_CUSTOM)
{ {
const struct video_viewport *custom = &settings->video_viewport_custom; const struct video_viewport *custom_vp = &settings->video_viewport_custom;
vp->x = custom_vp->x;
vp->x = custom->x; vp->y = custom_vp->y;
vp->y = custom->y; vp->width = custom_vp->width;
vp->width = custom->width; vp->height = custom_vp->height;
vp->height = custom->height;
} }
else else
#endif #endif
@ -2223,8 +2171,8 @@ bool video_driver_find_driver(
/* If we have configured one of the HW render /* If we have configured one of the HW render
* capable GL drivers, go with that. */ * capable GL drivers, go with that. */
#if defined(HAVE_OPENGL_CORE) #if defined(HAVE_OPENGL_CORE)
if ( !string_is_equal(settings->arrays.video_driver, "gl") && if ( !string_is_equal(settings->arrays.video_driver, "gl")
!string_is_equal(settings->arrays.video_driver, "glcore")) && !string_is_equal(settings->arrays.video_driver, "glcore"))
{ {
strlcpy(video_st->cached_driver_id, strlcpy(video_st->cached_driver_id,
settings->arrays.video_driver, settings->arrays.video_driver,
@ -2307,16 +2255,6 @@ void video_driver_apply_state_changes(void)
video_st->poke->apply_state_changes(video_st->data); video_st->poke->apply_state_changes(video_st->data);
} }
bool video_driver_read_viewport(uint8_t *buffer, bool is_idle)
{
video_driver_state_t *video_st = &video_driver_st;
if ( video_st->current_video->read_viewport
&& video_st->current_video->read_viewport(
video_st->data, buffer, is_idle))
return true;
return false;
}
bool video_driver_is_hw_context(void) bool video_driver_is_hw_context(void)
{ {
bool is_hw_context = false; bool is_hw_context = false;
@ -2330,13 +2268,6 @@ bool video_driver_is_hw_context(void)
return is_hw_context; return is_hw_context;
} }
const struct retro_hw_render_context_negotiation_interface *
video_driver_get_context_negotiation_interface(void)
{
video_driver_state_t *video_st = &video_driver_st;
return video_st->hw_render_context_negotiation;
}
bool video_driver_get_viewport_info(struct video_viewport *viewport) bool video_driver_get_viewport_info(struct video_viewport *viewport)
{ {
video_driver_state_t *video_st = &video_driver_st; video_driver_state_t *video_st = &video_driver_st;
@ -2370,14 +2301,14 @@ void video_viewport_get_scaled_integer(struct video_viewport *vp,
if (video_aspect_ratio_idx == ASPECT_RATIO_CUSTOM) if (video_aspect_ratio_idx == ASPECT_RATIO_CUSTOM)
{ {
struct video_viewport *custom = &settings->video_viewport_custom; struct video_viewport *custom_vp = &settings->video_viewport_custom;
if (custom) if (custom_vp)
{ {
padding_x = width - custom->width; padding_x = width - custom_vp->width;
padding_y = height - custom->height; padding_y = height - custom_vp->height;
width = custom->width; width = custom_vp->width;
height = custom->height; height = custom_vp->height;
} }
} }
else else
@ -2848,9 +2779,8 @@ bool video_context_driver_get_flags(gfx_ctx_flags_t *flags)
{ {
flags->flags = video_st->deferred_flag_data.flags; flags->flags = video_st->deferred_flag_data.flags;
video_st->flags &= ~VIDEO_FLAG_DEFERRED_VIDEO_CTX_DRIVER_SET_FLAGS; video_st->flags &= ~VIDEO_FLAG_DEFERRED_VIDEO_CTX_DRIVER_SET_FLAGS;
return true;
} }
else
flags->flags = video_st->current_video_context.get_flags( flags->flags = video_st->current_video_context.get_flags(
video_st->context_data); video_st->context_data);
return true; return true;
@ -3057,8 +2987,8 @@ bool video_driver_init_internal(bool *video_is_threaded, bool verbosity_enabled)
const char *path_softfilter_plugin = settings->paths.path_softfilter_plugin; const char *path_softfilter_plugin = settings->paths.path_softfilter_plugin;
/* Init video filter only when game is running */ /* Init video filter only when game is running */
if ((runloop_st->current_core.flags & RETRO_CORE_FLAG_GAME_LOADED) && if (( runloop_st->current_core.flags & RETRO_CORE_FLAG_GAME_LOADED)
!string_is_empty(path_softfilter_plugin)) && !string_is_empty(path_softfilter_plugin))
video_driver_init_filter(video_driver_pix_fmt, settings); video_driver_init_filter(video_driver_pix_fmt, settings);
#endif #endif
@ -3107,9 +3037,7 @@ bool video_driver_init_internal(bool *video_is_threaded, bool verbosity_enabled)
unsigned new_aspect_idx = settings->uints.video_aspect_ratio_idx; unsigned new_aspect_idx = settings->uints.video_aspect_ratio_idx;
if (new_aspect_idx > ASPECT_RATIO_END) if (new_aspect_idx > ASPECT_RATIO_END)
new_aspect_idx = settings->uints.video_aspect_ratio_idx = 0; new_aspect_idx = settings->uints.video_aspect_ratio_idx = 0;
video_st->aspect_ratio = aspectratio_lut[new_aspect_idx].value;
video_driver_set_aspect_ratio_value(
aspectratio_lut[new_aspect_idx].value);
} }
if ( settings->bools.video_fullscreen if ( settings->bools.video_fullscreen
@ -3135,10 +3063,10 @@ bool video_driver_init_internal(bool *video_is_threaded, bool verbosity_enabled)
#else #else
bool window_custom_size_enable = settings->bools.video_window_custom_size_enable; bool window_custom_size_enable = settings->bools.video_window_custom_size_enable;
#endif #endif
/* TODO: remove when the new window resizing core is hooked */ /* TODO/FIXME: remove when the new window resizing core is hooked */
if (window_custom_size_enable && if ( window_custom_size_enable
settings->uints.window_position_width && && settings->uints.window_position_width
settings->uints.window_position_height) && settings->uints.window_position_height)
{ {
width = settings->uints.window_position_width; width = settings->uints.window_position_width;
height = settings->uints.window_position_height; height = settings->uints.window_position_height;
@ -3150,7 +3078,6 @@ bool video_driver_init_internal(bool *video_is_threaded, bool verbosity_enabled)
* NOTE: We cannot read the actual display * NOTE: We cannot read the actual display
* metrics here, because the context driver * metrics here, because the context driver
* has not yet been initialised... */ * has not yet been initialised... */
/* > Try explicitly configured values */ /* > Try explicitly configured values */
unsigned max_win_width = settings->uints.window_auto_width_max; unsigned max_win_width = settings->uints.window_auto_width_max;
unsigned max_win_height = settings->uints.window_auto_height_max; unsigned max_win_height = settings->uints.window_auto_height_max;
@ -3475,10 +3402,10 @@ void video_driver_frame(const void *data, unsigned width,
* current frame is not (i.e. if core was * current frame is not (i.e. if core was
* previously sending duped frames, ensure * previously sending duped frames, ensure
* that the next frame update is captured) */ * that the next frame update is captured) */
if (video_info.input_driver_nonblock_state && if ( video_info.input_driver_nonblock_state
video_info.fastforward_frameskip && && video_info.fastforward_frameskip
!(video_info.menu_is_alive || && !(video_info.menu_is_alive
(last_frame_duped && !!data))) || (last_frame_duped && !!data)))
{ {
retro_time_t frame_time_accumulator_prev = frame_time_accumulator; retro_time_t frame_time_accumulator_prev = frame_time_accumulator;
retro_time_t frame_time_delta = new_time - last_time; retro_time_t frame_time_delta = new_time - last_time;
@ -3537,17 +3464,13 @@ void video_driver_frame(const void *data, unsigned width,
/* Get the amount of frames per seconds. */ /* Get the amount of frames per seconds. */
if (video_st->frame_count) if (video_st->frame_count)
{ {
unsigned fps_update_interval = unsigned fps_update_interval = video_info.fps_update_interval;
video_info.fps_update_interval; unsigned memory_update_interval = video_info.memory_update_interval;
unsigned memory_update_interval =
video_info.memory_update_interval;
/* set this to 1 to avoid an offset issue */ /* set this to 1 to avoid an offset issue */
unsigned write_index = unsigned write_index = video_st->frame_time_count++
video_st->frame_time_count++ & & (MEASURE_FRAME_TIME_SAMPLES_COUNT - 1);
(MEASURE_FRAME_TIME_SAMPLES_COUNT - 1);
frame_time = new_time - fps_time; frame_time = new_time - fps_time;
video_st->frame_time_samples video_st->frame_time_samples[write_index] = frame_time;
[write_index] = frame_time;
fps_time = new_time; fps_time = new_time;
if (video_info.fps_show) if (video_info.fps_show)
@ -3620,8 +3543,7 @@ void video_driver_frame(const void *data, unsigned width,
fps_update_interval); fps_update_interval);
video_st->window_title_len = strlcpy(video_st->window_title, video_st->window_title_len = strlcpy(video_st->window_title,
video_st->title_buf, video_st->title_buf, sizeof(video_st->window_title));
sizeof(video_st->window_title));
if (!string_is_empty(status_text)) if (!string_is_empty(status_text))
{ {
@ -3738,7 +3660,7 @@ void video_driver_frame(const void *data, unsigned width,
video_st->state_buffer, output_pitch, video_st->state_buffer, output_pitch,
data, width, height, pitch); data, width, height, pitch);
if (video_info.post_filter_record if ( video_info.post_filter_record
&& recording_st->data && recording_st->data
&& recording_st->driver && recording_st->driver
&& recording_st->driver->push_video) && recording_st->driver->push_video)
@ -3815,20 +3737,19 @@ void video_driver_frame(const void *data, unsigned width,
char tmp[128]; char tmp[128];
size_t len; size_t len;
double stddev = 0.0; double stddev = 0.0;
float scale = 1.0f;
float font_size_scale = video_info.font_size / 100; float font_size_scale = video_info.font_size / 100;
struct retro_system_av_info *av_info = &video_st->av_info; struct retro_system_av_info *av_info = &video_st->av_info;
unsigned red = 235; unsigned red = 235;
unsigned green = 235; unsigned green = 235;
unsigned blue = 235; unsigned blue = 235;
unsigned alpha = 255; unsigned alpha = 255;
float scale = ((float)video_info.height / 480)
scale = ((float)video_info.height / 480)
* 0.50f * (DEFAULT_FONT_SIZE / video_info.font_size); * 0.50f * (DEFAULT_FONT_SIZE / video_info.font_size);
scale = (scale < font_size_scale) /* Clamp scale */
? font_size_scale : scale; if (scale < font_size_scale)
scale = (scale > 1.00f) scale = font_size_scale;
? 1.00f : scale; if (scale > 1.00f)
scale = 1.00f;
if (scale > font_size_scale) if (scale > font_size_scale)
{ {
@ -3999,7 +3920,6 @@ void video_driver_frame(const void *data, unsigned width,
case 3840: case 3840:
case 1920: case 1920:
width = video_info.crt_switch_resolution_super; width = video_info.crt_switch_resolution_super;
dynamic_super_width = false;
break; break;
case 1: case 1:
dynamic_super_width = true; dynamic_super_width = true;

View File

@ -906,18 +906,10 @@ void video_driver_set_stub_frame(void);
void video_driver_unset_stub_frame(void); void video_driver_unset_stub_frame(void);
bool video_driver_supports_viewport_read(void);
bool video_driver_prefer_viewport_read(void);
bool video_driver_supports_read_frame_raw(void);
float video_driver_get_core_aspect(void); float video_driver_get_core_aspect(void);
void video_driver_set_viewport_core(void); void video_driver_set_viewport_core(void);
void video_driver_reset_custom_viewport(settings_t *settings);
void video_driver_set_rgba(void); void video_driver_set_rgba(void);
void video_driver_unset_rgba(void); void video_driver_unset_rgba(void);
@ -942,17 +934,12 @@ void video_driver_update_viewport(struct video_viewport* vp, bool force_full, bo
void video_driver_apply_state_changes(void); void video_driver_apply_state_changes(void);
bool video_driver_read_viewport(uint8_t *buffer, bool is_idle);
void video_driver_cached_frame(void); void video_driver_cached_frame(void);
bool video_driver_is_hw_context(void); bool video_driver_is_hw_context(void);
struct retro_hw_render_callback *video_driver_get_hw_context(void); struct retro_hw_render_callback *video_driver_get_hw_context(void);
const struct retro_hw_render_context_negotiation_interface
*video_driver_get_context_negotiation_interface(void);
bool video_driver_get_viewport_info(struct video_viewport *viewport); bool video_driver_get_viewport_info(struct video_viewport *viewport);
/** /**
@ -1005,10 +992,6 @@ void video_driver_set_size(unsigned width, unsigned height);
float video_driver_get_aspect_ratio(void); float video_driver_get_aspect_ratio(void);
void video_driver_set_aspect_ratio_value(float value);
enum retro_pixel_format video_driver_get_pixel_format(void);
void video_driver_cached_frame_set(const void *data, unsigned width, void video_driver_cached_frame_set(const void *data, unsigned width,
unsigned height, size_t pitch); unsigned height, size_t pitch);
@ -1035,8 +1018,6 @@ void video_viewport_get_scaled_integer(struct video_viewport *vp,
struct retro_system_av_info *video_viewport_get_system_av_info(void); struct retro_system_av_info *video_viewport_get_system_av_info(void);
struct video_viewport *video_viewport_get_custom(void);
/** /**
* video_monitor_set_refresh_rate: * video_monitor_set_refresh_rate:
* @hz : New refresh rate for monitor. * @hz : New refresh rate for monitor.

View File

@ -643,11 +643,12 @@ static INLINE void android_mouse_calculate_deltas(android_input_t *android,
float x = 0, y = 0; float x = 0, y = 0;
float x_scale = 1; float x_scale = 1;
float y_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(); struct retro_system_av_info *av_info = video_viewport_get_system_av_info();
if (av_info) if (av_info)
{ {
video_viewport_t *custom_vp = video_viewport_get_custom(); video_viewport_t *custom_vp = &settings->video_viewport_custom;
const struct retro_game_geometry *geom = (const struct retro_game_geometry*)&av_info->geometry; const struct retro_game_geometry *geom = (const struct retro_game_geometry*)&av_info->geometry;
x_scale = 2 * (float)geom->base_width / (float)custom_vp->width; x_scale = 2 * (float)geom->base_width / (float)custom_vp->width;
y_scale = 2 * (float)geom->base_height / (float)custom_vp->height; y_scale = 2 * (float)geom->base_height / (float)custom_vp->height;

View File

@ -5861,11 +5861,12 @@ bool rgui_is_video_config_equal(
static void rgui_get_video_config( static void rgui_get_video_config(
rgui_video_settings_t *video_settings, rgui_video_settings_t *video_settings,
settings_t *settings,
unsigned video_aspect_ratio_idx) unsigned video_aspect_ratio_idx)
{ {
/* Could use settings->video_viewport_custom directly, /* Could use settings->video_viewport_custom directly,
* but this seems to be the standard way of doing it... */ * but this seems to be the standard way of doing it... */
video_viewport_t *custom_vp = video_viewport_get_custom(); video_viewport_t *custom_vp = &settings->video_viewport_custom;
video_settings->aspect_ratio_idx = video_aspect_ratio_idx; video_settings->aspect_ratio_idx = video_aspect_ratio_idx;
video_settings->viewport.width = custom_vp->width; video_settings->viewport.width = custom_vp->width;
video_settings->viewport.height = custom_vp->height; video_settings->viewport.height = custom_vp->height;
@ -5881,7 +5882,7 @@ static void rgui_set_video_config(
{ {
/* Could use settings->video_viewport_custom directly, /* Could use settings->video_viewport_custom directly,
* but this seems to be the standard way of doing it... */ * but this seems to be the standard way of doing it... */
video_viewport_t *custom_vp = video_viewport_get_custom(); video_viewport_t *custom_vp = &settings->video_viewport_custom;
settings->uints.video_aspect_ratio_idx = video_settings->aspect_ratio_idx; settings->uints.video_aspect_ratio_idx = video_settings->aspect_ratio_idx;
custom_vp->width = video_settings->viewport.width; custom_vp->width = video_settings->viewport.width;
custom_vp->height = video_settings->viewport.height; custom_vp->height = video_settings->viewport.height;
@ -6432,7 +6433,7 @@ static void *rgui_init(void **userdata, bool video_is_threaded)
goto error; goto error;
/* Cache initial video settings */ /* Cache initial video settings */
rgui_get_video_config(&rgui->content_video_settings, settings->uints.video_aspect_ratio_idx); rgui_get_video_config(&rgui->content_video_settings, settings, settings->uints.video_aspect_ratio_idx);
/* Get initial 'window' dimensions */ /* Get initial 'window' dimensions */
video_driver_get_viewport_info(&vp); video_driver_get_viewport_info(&vp);
@ -7339,7 +7340,7 @@ static void rgui_populate_entries(
/* Make sure that any changes made while accessing /* Make sure that any changes made while accessing
* the video settings menu are preserved */ * the video settings menu are preserved */
rgui_video_settings_t current_video_settings = {{0}}; rgui_video_settings_t current_video_settings = {{0}};
rgui_get_video_config(&current_video_settings, settings->uints.video_aspect_ratio_idx); rgui_get_video_config(&current_video_settings, settings, settings->uints.video_aspect_ratio_idx);
if (rgui_is_video_config_equal(&current_video_settings, &rgui->menu_video_settings)) if (rgui_is_video_config_equal(&current_video_settings, &rgui->menu_video_settings))
{ {
rgui_set_video_config(rgui, settings, &rgui->content_video_settings, false); rgui_set_video_config(rgui, settings, &rgui->content_video_settings, false);
@ -7775,7 +7776,7 @@ static void rgui_toggle(void *userdata, bool menu_on)
if (aspect_ratio_lock != RGUI_ASPECT_RATIO_LOCK_NONE) if (aspect_ratio_lock != RGUI_ASPECT_RATIO_LOCK_NONE)
{ {
/* Cache content video settings */ /* Cache content video settings */
rgui_get_video_config(&rgui->content_video_settings, settings->uints.video_aspect_ratio_idx); rgui_get_video_config(&rgui->content_video_settings, settings, settings->uints.video_aspect_ratio_idx);
/* Update menu viewport */ /* Update menu viewport */
rgui_update_menu_viewport(rgui, p_disp, settings->uints.menu_rgui_aspect_ratio_lock); rgui_update_menu_viewport(rgui, p_disp, settings->uints.menu_rgui_aspect_ratio_lock);
/* Apply menu video settings */ /* Apply menu video settings */
@ -7790,7 +7791,7 @@ static void rgui_toggle(void *userdata, bool menu_on)
* has not changed video settings since menu was * has not changed video settings since menu was
* last toggled on */ * last toggled on */
rgui_video_settings_t current_video_settings = {{0}}; rgui_video_settings_t current_video_settings = {{0}};
rgui_get_video_config(&current_video_settings, settings->uints.video_aspect_ratio_idx); rgui_get_video_config(&current_video_settings, settings, settings->uints.video_aspect_ratio_idx);
if (rgui_is_video_config_equal(&current_video_settings, &rgui->menu_video_settings)) if (rgui_is_video_config_equal(&current_video_settings, &rgui->menu_video_settings))
rgui_set_video_config(rgui, settings, &rgui->content_video_settings, false); rgui_set_video_config(rgui, settings, &rgui->content_video_settings, false);
@ -7883,7 +7884,7 @@ static enum menu_action rgui_parse_menu_entry_action(
{ {
settings_t *settings = config_get_ptr(); settings_t *settings = config_get_ptr();
rgui_video_settings_t current_video_settings = {{0}}; rgui_video_settings_t current_video_settings = {{0}};
rgui_get_video_config(&current_video_settings, settings->uints.video_aspect_ratio_idx); rgui_get_video_config(&current_video_settings, settings, settings->uints.video_aspect_ratio_idx);
if (rgui_is_video_config_equal(&current_video_settings, if (rgui_is_video_config_equal(&current_video_settings,
&rgui->menu_video_settings)) &rgui->menu_video_settings))
{ {

View File

@ -7215,11 +7215,15 @@ unsigned menu_displaylist_build_list(
PARSE_ONLY_UINT, false) == 0) PARSE_ONLY_UINT, false) == 0)
count++; count++;
#ifdef HAVE_SCREENSHOTS #ifdef HAVE_SCREENSHOTS
if (video_driver_supports_viewport_read()) {
video_driver_state_t *video_st = video_state_get_ptr();
if ( video_st->current_video->read_viewport
&& video_st->current_video->viewport_info)
if (MENU_DISPLAYLIST_PARSE_SETTINGS_ENUM(list, if (MENU_DISPLAYLIST_PARSE_SETTINGS_ENUM(list,
MENU_ENUM_LABEL_VIDEO_GPU_SCREENSHOT, MENU_ENUM_LABEL_VIDEO_GPU_SCREENSHOT,
PARSE_ONLY_BOOL, false) == 0) PARSE_ONLY_BOOL, false) == 0)
count++; count++;
}
#endif #endif
if (MENU_DISPLAYLIST_PARSE_SETTINGS_ENUM(list, if (MENU_DISPLAYLIST_PARSE_SETTINGS_ENUM(list,
MENU_ENUM_LABEL_VIDEO_CTX_SCALING, MENU_ENUM_LABEL_VIDEO_CTX_SCALING,

View File

@ -5498,8 +5498,8 @@ static int setting_uint_action_left_custom_viewport_width(
{ {
video_viewport_t vp; video_viewport_t vp;
struct retro_system_av_info *av_info = video_viewport_get_system_av_info(); struct retro_system_av_info *av_info = video_viewport_get_system_av_info();
video_viewport_t *custom = video_viewport_get_custom();
settings_t *settings = config_get_ptr(); settings_t *settings = config_get_ptr();
video_viewport_t *custom = &settings->video_viewport_custom;
struct retro_game_geometry *geom = (struct retro_game_geometry*) struct retro_game_geometry *geom = (struct retro_game_geometry*)
&av_info->geometry; &av_info->geometry;
@ -5538,8 +5538,8 @@ static int setting_uint_action_left_custom_viewport_height(
{ {
video_viewport_t vp; video_viewport_t vp;
struct retro_system_av_info *av_info = video_viewport_get_system_av_info(); struct retro_system_av_info *av_info = video_viewport_get_system_av_info();
video_viewport_t *custom = video_viewport_get_custom();
settings_t *settings = config_get_ptr(); settings_t *settings = config_get_ptr();
video_viewport_t *custom = &settings->video_viewport_custom;
struct retro_game_geometry *geom = (struct retro_game_geometry*) struct retro_game_geometry *geom = (struct retro_game_geometry*)
&av_info->geometry; &av_info->geometry;
@ -5799,8 +5799,8 @@ static int setting_uint_action_right_custom_viewport_width(
{ {
video_viewport_t vp; video_viewport_t vp;
struct retro_system_av_info *av_info = video_viewport_get_system_av_info(); struct retro_system_av_info *av_info = video_viewport_get_system_av_info();
video_viewport_t *custom = video_viewport_get_custom();
settings_t *settings = config_get_ptr(); settings_t *settings = config_get_ptr();
video_viewport_t *custom = &settings->video_viewport_custom;
struct retro_game_geometry *geom = (struct retro_game_geometry*) struct retro_game_geometry *geom = (struct retro_game_geometry*)
&av_info->geometry; &av_info->geometry;
@ -5833,8 +5833,8 @@ static int setting_uint_action_right_custom_viewport_height(
{ {
video_viewport_t vp; video_viewport_t vp;
struct retro_system_av_info *av_info = video_viewport_get_system_av_info(); struct retro_system_av_info *av_info = video_viewport_get_system_av_info();
video_viewport_t *custom = video_viewport_get_custom();
settings_t *settings = config_get_ptr(); settings_t *settings = config_get_ptr();
video_viewport_t *custom = &settings->video_viewport_custom;
struct retro_game_geometry *geom = (struct retro_game_geometry*) struct retro_game_geometry *geom = (struct retro_game_geometry*)
&av_info->geometry; &av_info->geometry;
@ -7226,8 +7226,8 @@ static int setting_action_start_custom_viewport_width(rarch_setting_t *setting)
{ {
video_viewport_t vp; video_viewport_t vp;
struct retro_system_av_info *av_info = video_viewport_get_system_av_info(); struct retro_system_av_info *av_info = video_viewport_get_system_av_info();
video_viewport_t *custom = video_viewport_get_custom();
settings_t *settings = config_get_ptr(); settings_t *settings = config_get_ptr();
video_viewport_t *custom = &settings->video_viewport_custom;
struct retro_game_geometry *geom = (struct retro_game_geometry*) struct retro_game_geometry *geom = (struct retro_game_geometry*)
&av_info->geometry; &av_info->geometry;
@ -7259,8 +7259,8 @@ static int setting_action_start_custom_viewport_height(rarch_setting_t *setting)
{ {
video_viewport_t vp; video_viewport_t vp;
struct retro_system_av_info *av_info = video_viewport_get_system_av_info(); struct retro_system_av_info *av_info = video_viewport_get_system_av_info();
video_viewport_t *custom = video_viewport_get_custom();
settings_t *settings = config_get_ptr(); settings_t *settings = config_get_ptr();
video_viewport_t *custom = &settings->video_viewport_custom;
struct retro_game_geometry *geom = (struct retro_game_geometry*) struct retro_game_geometry *geom = (struct retro_game_geometry*)
&av_info->geometry; &av_info->geometry;
@ -7747,6 +7747,7 @@ static void write_handler_logging_verbosity(rarch_setting_t *setting)
static void general_write_handler(rarch_setting_t *setting) static void general_write_handler(rarch_setting_t *setting)
{ {
enum event_command rarch_cmd = CMD_EVENT_NONE; enum event_command rarch_cmd = CMD_EVENT_NONE;
settings_t *settings = config_get_ptr();
if (!setting) if (!setting)
return; return;
@ -7757,19 +7758,14 @@ static void general_write_handler(rarch_setting_t *setting)
{ {
case MENU_ENUM_LABEL_VIDEO_SHADERS_ENABLE: case MENU_ENUM_LABEL_VIDEO_SHADERS_ENABLE:
#if defined(HAVE_CG) || defined(HAVE_GLSL) || defined(HAVE_SLANG) || defined(HAVE_HLSL) #if defined(HAVE_CG) || defined(HAVE_GLSL) || defined(HAVE_SLANG) || defined(HAVE_HLSL)
{
settings_t *settings = config_get_ptr();
video_shader_toggle(settings); video_shader_toggle(settings);
}
#endif #endif
break; break;
case MENU_ENUM_LABEL_VIDEO_THREADED: case MENU_ENUM_LABEL_VIDEO_THREADED:
{
if (*setting->value.target.boolean) if (*setting->value.target.boolean)
task_queue_set_threaded(); task_queue_set_threaded();
else else
task_queue_unset_threaded(); task_queue_unset_threaded();
}
break; break;
case MENU_ENUM_LABEL_GAMEMODE_ENABLE: case MENU_ENUM_LABEL_GAMEMODE_ENABLE:
if (frontend_driver_has_gamemode()) if (frontend_driver_has_gamemode())
@ -7778,7 +7774,6 @@ static void general_write_handler(rarch_setting_t *setting)
if (!frontend_driver_set_gamemode(on) && on) if (!frontend_driver_set_gamemode(on) && on)
{ {
settings_t *settings = config_get_ptr();
/* If we failed to enable game mode, display /* If we failed to enable game mode, display
* a notification and force disable the feature */ * a notification and force disable the feature */
@ -7802,7 +7797,7 @@ static void general_write_handler(rarch_setting_t *setting)
{ {
video_viewport_t vp; video_viewport_t vp;
struct retro_system_av_info *av_info = video_viewport_get_system_av_info(); struct retro_system_av_info *av_info = video_viewport_get_system_av_info();
video_viewport_t *custom = video_viewport_get_custom(); struct video_viewport *custom_vp = &settings->video_viewport_custom;
struct retro_game_geometry *geom = (struct retro_game_geometry*) struct retro_game_geometry *geom = (struct retro_game_geometry*)
&av_info->geometry; &av_info->geometry;
@ -7812,21 +7807,21 @@ static void general_write_handler(rarch_setting_t *setting)
{ {
unsigned int rotation = retroarch_get_rotation(); unsigned int rotation = retroarch_get_rotation();
custom->x = 0; custom_vp->x = 0;
custom->y = 0; custom_vp->y = 0;
if (rotation % 2) if (rotation % 2)
{ {
custom->width = ((custom->width + geom->base_height - 1) / geom->base_height) * geom->base_height; custom_vp->width = ((custom_vp->width + geom->base_height - 1) / geom->base_height) * geom->base_height;
custom->height = ((custom->height + geom->base_width - 1) / geom->base_width) * geom->base_width; custom_vp->height = ((custom_vp->height + geom->base_width - 1) / geom->base_width) * geom->base_width;
} }
else else
{ {
custom->width = ((custom->width + geom->base_width - 1) / geom->base_width) * geom->base_width; custom_vp->width = ((custom_vp->width + geom->base_width - 1) / geom->base_width) * geom->base_width;
custom->height = ((custom->height + geom->base_height - 1) / geom->base_height) * geom->base_height; custom_vp->height = ((custom_vp->height + geom->base_height - 1) / geom->base_height) * geom->base_height;
} }
aspectratio_lut[ASPECT_RATIO_CUSTOM].value = aspectratio_lut[ASPECT_RATIO_CUSTOM].value =
(float)custom->width / custom->height; (float)custom_vp->width / custom_vp->height;
} }
} }
break; break;
@ -7834,7 +7829,6 @@ static void general_write_handler(rarch_setting_t *setting)
if (*setting->value.target.boolean) if (*setting->value.target.boolean)
{ {
menu_displaylist_info_t info; menu_displaylist_info_t info;
settings_t *settings = config_get_ptr();
struct menu_state *menu_st = menu_state_get_ptr(); struct menu_state *menu_st = menu_state_get_ptr();
menu_list_t *menu_list = menu_st->entries.list; menu_list_t *menu_list = menu_st->entries.list;
file_list_t *menu_stack = MENU_LIST_GET(menu_list, 0); file_list_t *menu_stack = MENU_LIST_GET(menu_list, 0);
@ -7853,12 +7847,9 @@ static void general_write_handler(rarch_setting_t *setting)
} }
break; break;
case MENU_ENUM_LABEL_AUDIO_MAX_TIMING_SKEW: case MENU_ENUM_LABEL_AUDIO_MAX_TIMING_SKEW:
{
settings_t *settings = config_get_ptr();
configuration_set_float(settings, configuration_set_float(settings,
settings->floats.audio_max_timing_skew, settings->floats.audio_max_timing_skew,
*setting->value.target.fraction); *setting->value.target.fraction);
}
break; break;
#ifdef HAVE_CHEEVOS #ifdef HAVE_CHEEVOS
case MENU_ENUM_LABEL_VIDEO_FRAME_DELAY: case MENU_ENUM_LABEL_VIDEO_FRAME_DELAY:
@ -7881,7 +7872,6 @@ static void general_write_handler(rarch_setting_t *setting)
#if defined(DINGUX) && defined(DINGUX_BETA) #if defined(DINGUX) && defined(DINGUX_BETA)
case MENU_ENUM_LABEL_VIDEO_DINGUX_REFRESH_RATE: case MENU_ENUM_LABEL_VIDEO_DINGUX_REFRESH_RATE:
{ {
settings_t *settings = config_get_ptr();
enum dingux_refresh_rate enum dingux_refresh_rate
current_refresh_rate = DINGUX_REFRESH_RATE_60HZ; current_refresh_rate = DINGUX_REFRESH_RATE_60HZ;
enum dingux_refresh_rate enum dingux_refresh_rate
@ -7922,27 +7912,20 @@ static void general_write_handler(rarch_setting_t *setting)
break; break;
#endif #endif
case MENU_ENUM_LABEL_VIDEO_SCALE: case MENU_ENUM_LABEL_VIDEO_SCALE:
{
settings_t *settings = config_get_ptr();
settings->modified = true; settings->modified = true;
settings->uints.video_scale = *setting->value.target.unsigned_integer; settings->uints.video_scale = *setting->value.target.unsigned_integer;
if (!settings->bools.video_fullscreen) if (!settings->bools.video_fullscreen)
rarch_cmd = CMD_EVENT_REINIT; rarch_cmd = CMD_EVENT_REINIT;
}
break; break;
case MENU_ENUM_LABEL_VIDEO_HDR_ENABLE: case MENU_ENUM_LABEL_VIDEO_HDR_ENABLE:
{
settings_t *settings = config_get_ptr();
settings->modified = true; settings->modified = true;
settings->bools.video_hdr_enable = *setting->value.target.boolean; settings->bools.video_hdr_enable = *setting->value.target.boolean;
rarch_cmd = CMD_EVENT_REINIT; rarch_cmd = CMD_EVENT_REINIT;
}
break; break;
case MENU_ENUM_LABEL_VIDEO_HDR_MAX_NITS: case MENU_ENUM_LABEL_VIDEO_HDR_MAX_NITS:
{ {
settings_t *settings = config_get_ptr();
video_driver_state_t *video_st = video_state_get_ptr(); video_driver_state_t *video_st = video_state_get_ptr();
settings->modified = true; settings->modified = true;
settings->floats.video_hdr_max_nits = roundf(*setting->value.target.fraction); settings->floats.video_hdr_max_nits = roundf(*setting->value.target.fraction);
@ -7965,7 +7948,6 @@ static void general_write_handler(rarch_setting_t *setting)
break; break;
case MENU_ENUM_LABEL_VIDEO_HDR_CONTRAST: case MENU_ENUM_LABEL_VIDEO_HDR_CONTRAST:
{ {
settings_t *settings = config_get_ptr();
video_driver_state_t *video_st = video_state_get_ptr(); video_driver_state_t *video_st = video_state_get_ptr();
settings->modified = true; settings->modified = true;
settings->floats.video_hdr_display_contrast = *setting->value.target.fraction; settings->floats.video_hdr_display_contrast = *setting->value.target.fraction;
@ -7976,7 +7958,6 @@ static void general_write_handler(rarch_setting_t *setting)
break; break;
case MENU_ENUM_LABEL_VIDEO_HDR_EXPAND_GAMUT: case MENU_ENUM_LABEL_VIDEO_HDR_EXPAND_GAMUT:
{ {
settings_t *settings = config_get_ptr();
video_driver_state_t *video_st = video_state_get_ptr(); video_driver_state_t *video_st = video_state_get_ptr();
settings->modified = true; settings->modified = true;
settings->bools.video_hdr_expand_gamut = *setting->value.target.boolean; settings->bools.video_hdr_expand_gamut = *setting->value.target.boolean;
@ -7993,25 +7974,18 @@ static void general_write_handler(rarch_setting_t *setting)
case MENU_ENUM_LABEL_INPUT_PLAYER3_JOYPAD_INDEX: case MENU_ENUM_LABEL_INPUT_PLAYER3_JOYPAD_INDEX:
case MENU_ENUM_LABEL_INPUT_PLAYER4_JOYPAD_INDEX: case MENU_ENUM_LABEL_INPUT_PLAYER4_JOYPAD_INDEX:
case MENU_ENUM_LABEL_INPUT_PLAYER5_JOYPAD_INDEX: case MENU_ENUM_LABEL_INPUT_PLAYER5_JOYPAD_INDEX:
{
settings_t *settings = config_get_ptr();
settings->modified = true; settings->modified = true;
settings->uints.input_joypad_index[setting->enum_idx - MENU_ENUM_LABEL_INPUT_PLAYER1_JOYPAD_INDEX] = *setting->value.target.integer; settings->uints.input_joypad_index[setting->enum_idx - MENU_ENUM_LABEL_INPUT_PLAYER1_JOYPAD_INDEX] = *setting->value.target.integer;
}
break; break;
#ifdef ANDROID #ifdef ANDROID
case MENU_ENUM_LABEL_INPUT_SELECT_PHYSICAL_KEYBOARD: case MENU_ENUM_LABEL_INPUT_SELECT_PHYSICAL_KEYBOARD:
{
settings_t *settings = config_get_ptr();
settings->modified = true; settings->modified = true;
strlcpy(settings->arrays.input_android_physical_keyboard, setting->value.target.string, sizeof(settings->arrays.input_android_physical_keyboard)); strlcpy(settings->arrays.input_android_physical_keyboard, setting->value.target.string, sizeof(settings->arrays.input_android_physical_keyboard));
}
break; break;
#endif #endif
case MENU_ENUM_LABEL_LOG_TO_FILE: case MENU_ENUM_LABEL_LOG_TO_FILE:
if (verbosity_is_enabled()) if (verbosity_is_enabled())
{ {
settings_t *settings = config_get_ptr();
bool log_to_file = settings->bools.log_to_file; bool log_to_file = settings->bools.log_to_file;
bool log_to_file_timestamp = settings->bools.log_to_file_timestamp; bool log_to_file_timestamp = settings->bools.log_to_file_timestamp;
const char *log_dir = settings->paths.log_dir; const char *log_dir = settings->paths.log_dir;
@ -8031,7 +8005,6 @@ static void general_write_handler(rarch_setting_t *setting)
case MENU_ENUM_LABEL_LOG_TO_FILE_TIMESTAMP: case MENU_ENUM_LABEL_LOG_TO_FILE_TIMESTAMP:
if (verbosity_is_enabled() && is_logging_to_file()) if (verbosity_is_enabled() && is_logging_to_file())
{ {
settings_t *settings = config_get_ptr();
bool log_to_file = settings->bools.log_to_file; bool log_to_file = settings->bools.log_to_file;
bool log_to_file_timestamp = settings->bools.log_to_file_timestamp; bool log_to_file_timestamp = settings->bools.log_to_file_timestamp;
const char *log_dir = settings->paths.log_dir; const char *log_dir = settings->paths.log_dir;
@ -8051,18 +8024,15 @@ static void general_write_handler(rarch_setting_t *setting)
case MENU_ENUM_LABEL_VIDEO_DINGUX_RS90_SOFTFILTER_TYPE: case MENU_ENUM_LABEL_VIDEO_DINGUX_RS90_SOFTFILTER_TYPE:
#endif #endif
#endif #endif
{
settings_t *settings = config_get_ptr();
video_driver_set_filtering(1, settings->bools.video_smooth, video_driver_set_filtering(1, settings->bools.video_smooth,
settings->bools.video_ctx_scaling); settings->bools.video_ctx_scaling);
}
break; break;
case MENU_ENUM_LABEL_VIDEO_ROTATION: case MENU_ENUM_LABEL_VIDEO_ROTATION:
{ {
video_viewport_t vp; video_viewport_t vp;
rarch_system_info_t *system = &runloop_state_get_ptr()->system; rarch_system_info_t *system = &runloop_state_get_ptr()->system;
struct retro_system_av_info *av_info = video_viewport_get_system_av_info(); struct retro_system_av_info *av_info = video_viewport_get_system_av_info();
video_viewport_t *custom = video_viewport_get_custom(); video_viewport_t *custom_vp = &settings->video_viewport_custom;
struct retro_game_geometry *geom = (struct retro_game_geometry*) struct retro_game_geometry *geom = (struct retro_game_geometry*)
&av_info->geometry; &av_info->geometry;
@ -8076,22 +8046,22 @@ static void general_write_handler(rarch_setting_t *setting)
/* Update Custom Aspect Ratio values */ /* Update Custom Aspect Ratio values */
video_driver_get_viewport_info(&vp); video_driver_get_viewport_info(&vp);
custom->x = 0; custom_vp->x = 0;
custom->y = 0; custom_vp->y = 0;
/* Round down when rotation is "horizontal", round up when rotation is "vertical" /* Round down when rotation is "horizontal", round up when rotation is "vertical"
to avoid expanding viewport each time user rotates */ to avoid expanding viewport each time user rotates */
if (rotation % 2) if (rotation % 2)
{ {
custom->width = MAX(1,(custom->width / geom->base_height)) * geom->base_height; custom_vp->width = MAX(1, (custom_vp->width / geom->base_height)) * geom->base_height;
custom->height = MAX(1,(custom->height/ geom->base_width )) * geom->base_width; custom_vp->height = MAX(1, (custom_vp->height / geom->base_width )) * geom->base_width;
} }
else else
{ {
custom->width = ((custom->width + geom->base_width - 1) / geom->base_width) * geom->base_width; custom_vp->width = ((custom_vp->width + geom->base_width - 1) / geom->base_width) * geom->base_width;
custom->height = ((custom->height + geom->base_height - 1) / geom->base_height) * geom->base_height; custom_vp->height = ((custom_vp->height + geom->base_height - 1) / geom->base_height) * geom->base_height;
} }
aspectratio_lut[ASPECT_RATIO_CUSTOM].value = (float)custom->width / custom->height; aspectratio_lut[ASPECT_RATIO_CUSTOM].value = (float)custom_vp->width / custom_vp->height;
/* Update Aspect Ratio (only useful for 1:1 PAR) */ /* Update Aspect Ratio (only useful for 1:1 PAR) */
video_driver_set_aspect_ratio(); video_driver_set_aspect_ratio();
@ -8099,13 +8069,11 @@ static void general_write_handler(rarch_setting_t *setting)
} }
break; break;
case MENU_ENUM_LABEL_SCREEN_ORIENTATION: case MENU_ENUM_LABEL_SCREEN_ORIENTATION:
{
#ifndef ANDROID #ifndef ANDROID
/* FIXME: Changing at runtime on Android causes setting to somehow be incremented again, many times */ /* FIXME: Changing at runtime on Android causes setting to somehow be incremented again, many times */
video_display_server_set_screen_orientation( video_display_server_set_screen_orientation(
(enum rotation)(*setting->value.target.unsigned_integer)); (enum rotation)(*setting->value.target.unsigned_integer));
#endif #endif
}
break; break;
case MENU_ENUM_LABEL_AUDIO_VOLUME: case MENU_ENUM_LABEL_AUDIO_VOLUME:
audio_set_float(AUDIO_ACTION_VOLUME_GAIN, *setting->value.target.fraction); audio_set_float(AUDIO_ACTION_VOLUME_GAIN, *setting->value.target.fraction);
@ -8123,13 +8091,10 @@ static void general_write_handler(rarch_setting_t *setting)
rarch_cmd = CMD_EVENT_AUDIO_REINIT; rarch_cmd = CMD_EVENT_AUDIO_REINIT;
break; break;
case MENU_ENUM_LABEL_PAL60_ENABLE: case MENU_ENUM_LABEL_PAL60_ENABLE:
{ if (*setting->value.target.boolean && global_get_ptr()->console.screen.pal_enable)
global_t *global = global_get_ptr();
if (*setting->value.target.boolean && global->console.screen.pal_enable)
rarch_cmd = CMD_EVENT_REINIT; rarch_cmd = CMD_EVENT_REINIT;
else else
setting_set_with_string_representation(setting, "false"); setting_set_with_string_representation(setting, "false");
}
break; break;
case MENU_ENUM_LABEL_SYSTEM_BGM_ENABLE: case MENU_ENUM_LABEL_SYSTEM_BGM_ENABLE:
if (*setting->value.target.boolean) if (*setting->value.target.boolean)
@ -8146,20 +8111,15 @@ static void general_write_handler(rarch_setting_t *setting)
} }
break; break;
case MENU_ENUM_LABEL_AUDIO_ENABLE_MENU: case MENU_ENUM_LABEL_AUDIO_ENABLE_MENU:
{
#ifdef HAVE_AUDIOMIXER #ifdef HAVE_AUDIOMIXER
settings_t *settings = config_get_ptr();
if (settings->bools.audio_enable_menu) if (settings->bools.audio_enable_menu)
audio_driver_load_system_sounds(); audio_driver_load_system_sounds();
else else
audio_driver_mixer_stop_stream(AUDIO_MIXER_SYSTEM_SLOT_BGM); audio_driver_mixer_stop_stream(AUDIO_MIXER_SYSTEM_SLOT_BGM);
#endif #endif
}
break; break;
case MENU_ENUM_LABEL_MENU_SOUND_BGM: case MENU_ENUM_LABEL_MENU_SOUND_BGM:
{
#ifdef HAVE_AUDIOMIXER #ifdef HAVE_AUDIOMIXER
settings_t *settings = config_get_ptr();
if (settings->bools.audio_enable_menu) if (settings->bools.audio_enable_menu)
{ {
if (settings->bools.audio_enable_menu_bgm) if (settings->bools.audio_enable_menu_bgm)
@ -8168,43 +8128,24 @@ static void general_write_handler(rarch_setting_t *setting)
audio_driver_mixer_stop_stream(AUDIO_MIXER_SYSTEM_SLOT_BGM); audio_driver_mixer_stop_stream(AUDIO_MIXER_SYSTEM_SLOT_BGM);
} }
#endif #endif
}
break; break;
case MENU_ENUM_LABEL_VIDEO_WINDOW_OPACITY: case MENU_ENUM_LABEL_VIDEO_WINDOW_OPACITY:
{
settings_t *settings = config_get_ptr();
video_display_server_set_window_opacity(settings->uints.video_window_opacity); video_display_server_set_window_opacity(settings->uints.video_window_opacity);
}
break; break;
case MENU_ENUM_LABEL_VIDEO_WINDOW_SHOW_DECORATIONS: case MENU_ENUM_LABEL_VIDEO_WINDOW_SHOW_DECORATIONS:
{
settings_t *settings = config_get_ptr();
video_display_server_set_window_decorations(settings->bools.video_window_show_decorations); video_display_server_set_window_decorations(settings->bools.video_window_show_decorations);
}
break; break;
case MENU_ENUM_LABEL_MIDI_INPUT: case MENU_ENUM_LABEL_MIDI_INPUT:
{
settings_t *settings = config_get_ptr();
midi_driver_set_input(settings->arrays.midi_input); midi_driver_set_input(settings->arrays.midi_input);
}
break; break;
case MENU_ENUM_LABEL_MIDI_OUTPUT: case MENU_ENUM_LABEL_MIDI_OUTPUT:
{
settings_t *settings = config_get_ptr();
midi_driver_set_output(settings, settings->arrays.midi_output); midi_driver_set_output(settings, settings->arrays.midi_output);
}
break; break;
case MENU_ENUM_LABEL_MIDI_VOLUME: case MENU_ENUM_LABEL_MIDI_VOLUME:
{
settings_t *settings = config_get_ptr();
midi_driver_set_volume(settings->uints.midi_volume); midi_driver_set_volume(settings->uints.midi_volume);
}
break; break;
case MENU_ENUM_LABEL_SUSTAINED_PERFORMANCE_MODE: case MENU_ENUM_LABEL_SUSTAINED_PERFORMANCE_MODE:
{
settings_t *settings = config_get_ptr();
frontend_driver_set_sustained_performance_mode(settings->bools.sustained_performance_mode); frontend_driver_set_sustained_performance_mode(settings->bools.sustained_performance_mode);
}
break; break;
case MENU_ENUM_LABEL_REWIND_BUFFER_SIZE_STEP: case MENU_ENUM_LABEL_REWIND_BUFFER_SIZE_STEP:
{ {
@ -8222,14 +8163,12 @@ static void general_write_handler(rarch_setting_t *setting)
*(setting->value.target.unsigned_integer) = 0; *(setting->value.target.unsigned_integer) = 0;
setting->max = cheat_manager_get_state_search_size(cheat_manager_state.working_cheat.memory_search_size); setting->max = cheat_manager_get_state_search_size(cheat_manager_state.working_cheat.memory_search_size);
} }
setting = menu_setting_find_enum(MENU_ENUM_LABEL_CHEAT_RUMBLE_VALUE); if ((setting = menu_setting_find_enum(MENU_ENUM_LABEL_CHEAT_RUMBLE_VALUE)))
if (setting)
{ {
*setting->value.target.unsigned_integer = 0; *setting->value.target.unsigned_integer = 0;
setting->max = cheat_manager_get_state_search_size(cheat_manager_state.working_cheat.memory_search_size); setting->max = cheat_manager_get_state_search_size(cheat_manager_state.working_cheat.memory_search_size);
} }
setting = menu_setting_find_enum(MENU_ENUM_LABEL_CHEAT_ADDRESS_BIT_POSITION); if ((setting = menu_setting_find_enum(MENU_ENUM_LABEL_CHEAT_ADDRESS_BIT_POSITION)))
if (setting)
{ {
int max_bit_position; int max_bit_position;
*setting->value.target.unsigned_integer = 0; *setting->value.target.unsigned_integer = 0;
@ -8248,14 +8187,12 @@ static void general_write_handler(rarch_setting_t *setting)
*setting->value.target.unsigned_integer = 0; *setting->value.target.unsigned_integer = 0;
setting->max = cheat_manager_get_state_search_size(cheat_manager_state.search_bit_size); setting->max = cheat_manager_get_state_search_size(cheat_manager_state.search_bit_size);
} }
setting = menu_setting_find_enum(MENU_ENUM_LABEL_CHEAT_SEARCH_EQPLUS); if ((setting = menu_setting_find_enum(MENU_ENUM_LABEL_CHEAT_SEARCH_EQPLUS)))
if (setting)
{ {
*setting->value.target.unsigned_integer = 0; *setting->value.target.unsigned_integer = 0;
setting->max = cheat_manager_get_state_search_size(cheat_manager_state.search_bit_size); setting->max = cheat_manager_get_state_search_size(cheat_manager_state.search_bit_size);
} }
setting = menu_setting_find_enum(MENU_ENUM_LABEL_CHEAT_SEARCH_EQMINUS); if ((setting = menu_setting_find_enum(MENU_ENUM_LABEL_CHEAT_SEARCH_EQMINUS)))
if (setting)
{ {
*setting->value.target.unsigned_integer = 0; *setting->value.target.unsigned_integer = 0;
setting->max = cheat_manager_get_state_search_size(cheat_manager_state.search_bit_size); setting->max = cheat_manager_get_state_search_size(cheat_manager_state.search_bit_size);
@ -8265,14 +8202,11 @@ static void general_write_handler(rarch_setting_t *setting)
break; break;
case MENU_ENUM_LABEL_CONTENT_FAVORITES_SIZE: case MENU_ENUM_LABEL_CONTENT_FAVORITES_SIZE:
{ {
unsigned new_capacity; unsigned new_capacity = COLLECTION_SIZE;
settings_t *settings = config_get_ptr();
int content_favorites_size = settings->ints.content_favorites_size; int content_favorites_size = settings->ints.content_favorites_size;
/* Get new size */ /* Get new size */
if (content_favorites_size < 0) if (content_favorites_size >= 0)
new_capacity = COLLECTION_SIZE;
else
new_capacity = (unsigned)content_favorites_size; new_capacity = (unsigned)content_favorites_size;
/* Check whether capacity has changed */ /* Check whether capacity has changed */
@ -8328,28 +8262,19 @@ static void general_write_handler(rarch_setting_t *setting)
} }
break; break;
case MENU_ENUM_LABEL_CHEEVOS_USERNAME: case MENU_ENUM_LABEL_CHEEVOS_USERNAME:
{ /* When changing the username, clear out the password and token */
settings_t *settings = config_get_ptr();
/* when changing the username, clear out the password and token */
settings->arrays.cheevos_password[0] = '\0'; settings->arrays.cheevos_password[0] = '\0';
settings->arrays.cheevos_token[0] = '\0'; settings->arrays.cheevos_token[0] = '\0';
}
break; break;
case MENU_ENUM_LABEL_CHEEVOS_PASSWORD: case MENU_ENUM_LABEL_CHEEVOS_PASSWORD:
{ /* When changing the password, clear out the token */
settings_t *settings = config_get_ptr();
/* when changing the password, clear out the token */
settings->arrays.cheevos_token[0] = '\0'; settings->arrays.cheevos_token[0] = '\0';
}
break; break;
case MENU_ENUM_LABEL_CHEEVOS_UNLOCK_SOUND_ENABLE: case MENU_ENUM_LABEL_CHEEVOS_UNLOCK_SOUND_ENABLE:
{
#ifdef HAVE_AUDIOMIXER #ifdef HAVE_AUDIOMIXER
settings_t *settings = config_get_ptr();
if (settings->bools.cheevos_unlock_sound_enable) if (settings->bools.cheevos_unlock_sound_enable)
audio_driver_load_system_sounds(); audio_driver_load_system_sounds();
#endif #endif
}
break; break;
case MENU_ENUM_LABEL_INPUT_SENSORS_ENABLE: case MENU_ENUM_LABEL_INPUT_SENSORS_ENABLE:
/* When toggling sensor input off, ensure /* When toggling sensor input off, ensure
@ -8395,7 +8320,6 @@ static void general_write_handler(rarch_setting_t *setting)
break; break;
case MENU_ENUM_LABEL_CORE_INFO_CACHE_ENABLE: case MENU_ENUM_LABEL_CORE_INFO_CACHE_ENABLE:
{ {
settings_t *settings = config_get_ptr();
const char *dir_libretro = settings->paths.directory_libretro; const char *dir_libretro = settings->paths.directory_libretro;
const char *path_libretro_info = settings->paths.path_libretro_info; const char *path_libretro_info = settings->paths.path_libretro_info;
@ -8429,7 +8353,7 @@ static void general_write_handler(rarch_setting_t *setting)
/* Whenever custom viewport dimensions are /* Whenever custom viewport dimensions are
* changed, ASPECT_RATIO_CUSTOM must be * changed, ASPECT_RATIO_CUSTOM must be
* recalculated */ * recalculated */
video_viewport_t *custom_vp = video_viewport_get_custom(); video_viewport_t *custom_vp = &settings->video_viewport_custom;
float default_aspect = aspectratio_lut[ASPECT_RATIO_CORE].value; float default_aspect = aspectratio_lut[ASPECT_RATIO_CORE].value;
aspectratio_lut[ASPECT_RATIO_CUSTOM].value = aspectratio_lut[ASPECT_RATIO_CUSTOM].value =
@ -11567,7 +11491,7 @@ static bool setting_append_list(
break; break;
case SETTINGS_LIST_VIDEO: case SETTINGS_LIST_VIDEO:
{ {
struct video_viewport *custom_vp = video_viewport_get_custom(); struct video_viewport *custom_vp = &settings->video_viewport_custom;
START_GROUP(list, list_info, &group_info, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_VIDEO_SETTINGS), parent_group); START_GROUP(list, list_info, &group_info, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_VIDEO_SETTINGS), parent_group);
MENU_SETTINGS_LIST_CURRENT_ADD_ENUM_IDX_PTR(list, list_info, MENU_ENUM_LABEL_VIDEO_SETTINGS); MENU_SETTINGS_LIST_CURRENT_ADD_ENUM_IDX_PTR(list, list_info, MENU_ENUM_LABEL_VIDEO_SETTINGS);

View File

@ -418,6 +418,7 @@ static bool take_screenshot_viewport(
unsigned pixel_format_type) unsigned pixel_format_type)
{ {
struct video_viewport vp; struct video_viewport vp;
video_driver_state_t *video_st = video_state_get_ptr();
uint8_t *buffer = NULL; uint8_t *buffer = NULL;
vp.x = 0; vp.x = 0;
@ -434,7 +435,9 @@ static bool take_screenshot_viewport(
if (!(buffer = (uint8_t*)malloc(vp.width * vp.height * 3))) if (!(buffer = (uint8_t*)malloc(vp.width * vp.height * 3)))
return false; return false;
if (!video_driver_read_viewport(buffer, runloop_flags & RUNLOOP_FLAG_IDLE)) if (!( video_st->current_video->read_viewport
&& video_st->current_video->read_viewport(
video_st->data, buffer, runloop_flags & RUNLOOP_FLAG_IDLE)))
goto error; goto error;
/* Data read from viewport is in bottom-up order, suitable for BMP. */ /* Data read from viewport is in bottom-up order, suitable for BMP. */
@ -545,10 +548,13 @@ bool take_screenshot(
bool ret = false; bool ret = false;
uint32_t runloop_flags = runloop_get_flags(); uint32_t runloop_flags = runloop_get_flags();
settings_t *settings = config_get_ptr(); settings_t *settings = config_get_ptr();
video_driver_state_t *video_st = video_state_get_ptr();
bool video_gpu_screenshot = settings->bools.video_gpu_screenshot; bool video_gpu_screenshot = settings->bools.video_gpu_screenshot;
bool supports_viewport_read = video_driver_supports_viewport_read(); bool supports_viewport_read = video_st->current_video->read_viewport
bool prefer_viewport_read = supports_viewport_read && && (video_st->current_video->viewport_info);
video_driver_prefer_viewport_read(); bool prefer_viewport_read = supports_viewport_read
&& video_driver_is_hw_context()
&& !video_st->current_video->read_frame_raw;
/* Avoid GPU screenshots with savestates */ /* Avoid GPU screenshots with savestates */
if (supports_viewport_read && video_gpu_screenshot && !savestate) if (supports_viewport_read && video_gpu_screenshot && !savestate)
@ -564,8 +570,8 @@ bool take_screenshot(
name_base, savestate, runloop_flags, name_base, savestate, runloop_flags,
has_valid_framebuffer, fullpath, use_thread, has_valid_framebuffer, fullpath, use_thread,
prefer_viewport_read, prefer_viewport_read,
video_driver_supports_read_frame_raw(), (video_st->current_video->read_frame_raw),
video_driver_get_pixel_format() video_st->pix_fmt
); );
if ( (runloop_flags & RUNLOOP_FLAG_PAUSED) if ( (runloop_flags & RUNLOOP_FLAG_PAUSED)

View File

@ -882,7 +882,9 @@ bool run_translation_service(settings_t *settings, bool paused)
if (!bit24_image_prev || !bit24_image) if (!bit24_image_prev || !bit24_image)
goto finish; goto finish;
if (!video_driver_read_viewport(bit24_image_prev, false)) if (!( video_st->current_video->read_viewport
&& video_st->current_video->read_viewport(
video_st->data, bit24_image_prev, false)))
{ {
RARCH_LOG("Could not read viewport for translation service...\n"); RARCH_LOG("Could not read viewport for translation service...\n");
goto finish; goto finish;