Unverified Commit fe1fb69d authored by Libretro-Admin's avatar Libretro-Admin Committed by GitHub
Browse files

Merge pull request #815 from ds22x/master

Make "Additional Cropping" option compatible with hardware renderers
parents 6c932990 f9c3537f
Pipeline #56031 passed with stage
in 38 minutes and 17 seconds
...@@ -4163,8 +4163,6 @@ bool retro_load_game(const struct retro_game_info *info) ...@@ -4163,8 +4163,6 @@ bool retro_load_game(const struct retro_game_info *info)
option_display.key = BEETLE_OPT(image_offset); option_display.key = BEETLE_OPT(image_offset);
environ_cb(RETRO_ENVIRONMENT_SET_CORE_OPTIONS_DISPLAY, &option_display); environ_cb(RETRO_ENVIRONMENT_SET_CORE_OPTIONS_DISPLAY, &option_display);
option_display.key = BEETLE_OPT(image_crop);
environ_cb(RETRO_ENVIRONMENT_SET_CORE_OPTIONS_DISPLAY, &option_display);
option_display.key = BEETLE_OPT(frame_duping); option_display.key = BEETLE_OPT(frame_duping);
environ_cb(RETRO_ENVIRONMENT_SET_CORE_OPTIONS_DISPLAY, &option_display); environ_cb(RETRO_ENVIRONMENT_SET_CORE_OPTIONS_DISPLAY, &option_display);
...@@ -4183,8 +4181,6 @@ bool retro_load_game(const struct retro_game_info *info) ...@@ -4183,8 +4181,6 @@ bool retro_load_game(const struct retro_game_info *info)
option_display.key = BEETLE_OPT(image_offset); option_display.key = BEETLE_OPT(image_offset);
environ_cb(RETRO_ENVIRONMENT_SET_CORE_OPTIONS_DISPLAY, &option_display); environ_cb(RETRO_ENVIRONMENT_SET_CORE_OPTIONS_DISPLAY, &option_display);
option_display.key = BEETLE_OPT(image_crop);
environ_cb(RETRO_ENVIRONMENT_SET_CORE_OPTIONS_DISPLAY, &option_display);
break; break;
} }
......
...@@ -1107,7 +1107,7 @@ struct retro_core_option_v2_definition option_defs_us[] = { ...@@ -1107,7 +1107,7 @@ struct retro_core_option_v2_definition option_defs_us[] = {
BEETLE_OPT(image_crop), BEETLE_OPT(image_crop),
"Additional Cropping", "Additional Cropping",
NULL, NULL,
"When 'Crop Horizontal Overscan' is enabled, this option further reduces the width of the cropped image by the specified number of pixels. Only supported by the software renderer.", "When 'Crop Horizontal Overscan' is enabled, this option further reduces the width of the cropped image by the specified number of pixels",
NULL, NULL,
"video", "video",
{ {
......
...@@ -794,8 +794,8 @@ Renderer::DisplayRect Renderer::compute_display_rect() ...@@ -794,8 +794,8 @@ Renderer::DisplayRect Renderer::compute_display_rect()
if (render_state.crop_overscan) if (render_state.crop_overscan)
{ {
// Horizontal crop amount is currently hardcoded. Future improvement could allow adjusting this. // Horizontal crop amount is currently hardcoded. Future improvement could allow adjusting this.
display_width = 2560/clock_div; display_width = (2560/clock_div) - render_state.image_crop;
left_offset = floor((render_state.horiz_start + render_state.offset_cycles - 608) / (double) clock_div); left_offset = floor(((render_state.horiz_start + render_state.offset_cycles - 608) / (double) clock_div) - (render_state.image_crop / 2));
} }
else else
{ {
......
...@@ -118,6 +118,7 @@ public: ...@@ -118,6 +118,7 @@ public:
bool is_480i = false; bool is_480i = false;
WidthMode width_mode = WidthMode::WIDTH_MODE_320; WidthMode width_mode = WidthMode::WIDTH_MODE_320;
bool crop_overscan = false; bool crop_overscan = false;
unsigned image_crop = 0;
// Experimental horizontal offset feature // Experimental horizontal offset feature
int offset_cycles = 0; int offset_cycles = 0;
...@@ -246,6 +247,11 @@ public: ...@@ -246,6 +247,11 @@ public:
{ {
render_state.offset_cycles = offset_cycles; render_state.offset_cycles = offset_cycles;
} }
void set_horizontal_additional_cropping(unsigned image_crop)
{
render_state.image_crop = image_crop;
}
void set_visible_scanlines(int slstart, int slend, int slstart_pal, int slend_pal) void set_visible_scanlines(int slstart, int slend, int slstart_pal, int slend_pal)
{ {
......
...@@ -325,6 +325,9 @@ struct GlRenderer { ...@@ -325,6 +325,9 @@ struct GlRenderer {
/* Experimental offset feature */ /* Experimental offset feature */
int32_t image_offset_cycles; int32_t image_offset_cycles;
/* Image Crop option */
unsigned image_crop;
/* Scanline core options */ /* Scanline core options */
int32_t initial_scanline; int32_t initial_scanline;
int32_t initial_scanline_pal; int32_t initial_scanline_pal;
...@@ -1242,6 +1245,16 @@ static bool GlRenderer_new(GlRenderer *renderer, DrawConfig config) ...@@ -1242,6 +1245,16 @@ static bool GlRenderer_new(GlRenderer *renderer, DrawConfig config)
image_offset_cycles = atoi(var.value); image_offset_cycles = atoi(var.value);
} }
unsigned image_crop = 0;
var.key = BEETLE_OPT(image_crop);
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value)
{
if (strcmp(var.value, "disabled") == 0)
image_crop = 0;
else
image_crop = atoi(var.value);
}
int32_t initial_scanline = 0; int32_t initial_scanline = 0;
var.key = BEETLE_OPT(initial_scanline); var.key = BEETLE_OPT(initial_scanline);
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value)
...@@ -1440,6 +1453,7 @@ static bool GlRenderer_new(GlRenderer *renderer, DrawConfig config) ...@@ -1440,6 +1453,7 @@ static bool GlRenderer_new(GlRenderer *renderer, DrawConfig config)
renderer->internal_color_depth = depth; renderer->internal_color_depth = depth;
renderer->crop_overscan = crop_overscan; renderer->crop_overscan = crop_overscan;
renderer->image_offset_cycles = image_offset_cycles; renderer->image_offset_cycles = image_offset_cycles;
renderer->image_crop = image_crop;
renderer->curr_width_mode = WIDTH_MODE_320; renderer->curr_width_mode = WIDTH_MODE_320;
renderer->initial_scanline = initial_scanline; renderer->initial_scanline = initial_scanline;
renderer->last_scanline = last_scanline; renderer->last_scanline = last_scanline;
...@@ -1570,10 +1584,10 @@ static GlDisplayRect compute_gl_display_rect(GlRenderer *renderer) ...@@ -1570,10 +1584,10 @@ static GlDisplayRect compute_gl_display_rect(GlRenderer *renderer)
int32_t x; int32_t x;
if (renderer->crop_overscan) if (renderer->crop_overscan)
{ {
width = (uint32_t) (2560/clock_div); width = (uint32_t) ((2560/clock_div) - renderer->image_crop);
int32_t offset_cycles = renderer->image_offset_cycles; int32_t offset_cycles = renderer->image_offset_cycles;
int32_t h_start = (int32_t) renderer->config.display_area_hrange[0]; int32_t h_start = (int32_t) renderer->config.display_area_hrange[0];
x = floor((h_start - 608 + offset_cycles) / (double) clock_div); x = floor(((h_start - 608 + offset_cycles) / (double) clock_div) - (renderer->image_crop / 2));
} }
else else
{ {
...@@ -1720,6 +1734,16 @@ static bool retro_refresh_variables(GlRenderer *renderer) ...@@ -1720,6 +1734,16 @@ static bool retro_refresh_variables(GlRenderer *renderer)
{ {
image_offset_cycles = atoi(var.value); image_offset_cycles = atoi(var.value);
} }
unsigned image_crop;
var.key = BEETLE_OPT(image_crop);
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value)
{
if (strcmp(var.value, "disabled") == 0)
image_crop = 0;
else
image_crop = atoi(var.value);
}
int32_t initial_scanline = 0; int32_t initial_scanline = 0;
var.key = BEETLE_OPT(initial_scanline); var.key = BEETLE_OPT(initial_scanline);
...@@ -1883,6 +1907,7 @@ static bool retro_refresh_variables(GlRenderer *renderer) ...@@ -1883,6 +1907,7 @@ static bool retro_refresh_variables(GlRenderer *renderer)
renderer->filter_type = filter; renderer->filter_type = filter;
renderer->crop_overscan = crop_overscan; renderer->crop_overscan = crop_overscan;
renderer->image_offset_cycles = image_offset_cycles; renderer->image_offset_cycles = image_offset_cycles;
renderer->image_crop = image_crop;
renderer->initial_scanline = initial_scanline; renderer->initial_scanline = initial_scanline;
renderer->last_scanline = last_scanline; renderer->last_scanline = last_scanline;
renderer->initial_scanline_pal = initial_scanline_pal; renderer->initial_scanline_pal = initial_scanline_pal;
......
...@@ -61,6 +61,7 @@ static bool replace_textures = false; ...@@ -61,6 +61,7 @@ static bool replace_textures = false;
static bool track_textures = false; static bool track_textures = false;
static bool crop_overscan; static bool crop_overscan;
static int image_offset_cycles; static int image_offset_cycles;
static unsigned image_crop;
static int initial_scanline; static int initial_scanline;
static int last_scanline; static int last_scanline;
static int initial_scanline_pal; static int initial_scanline_pal;
...@@ -249,6 +250,7 @@ void rsx_vulkan_refresh_variables(void) ...@@ -249,6 +250,7 @@ void rsx_vulkan_refresh_variables(void)
bool old_super_sampling = super_sampling; bool old_super_sampling = super_sampling;
bool old_show_vram = show_vram; bool old_show_vram = show_vram;
bool old_crop_overscan = crop_overscan; bool old_crop_overscan = crop_overscan;
unsigned old_image_crop = image_crop;
bool old_widescreen_hack = widescreen_hack; bool old_widescreen_hack = widescreen_hack;
unsigned old_widescreen_hack_aspect_ratio_setting = widescreen_hack_aspect_ratio_setting; unsigned old_widescreen_hack_aspect_ratio_setting = widescreen_hack_aspect_ratio_setting;
bool visible_scanlines_changed = false; bool visible_scanlines_changed = false;
...@@ -353,6 +355,15 @@ void rsx_vulkan_refresh_variables(void) ...@@ -353,6 +355,15 @@ void rsx_vulkan_refresh_variables(void)
{ {
image_offset_cycles = atoi(var.value); image_offset_cycles = atoi(var.value);
} }
var.key = BEETLE_OPT(image_crop);
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value)
{
if (strcmp(var.value, "disabled") == 0)
image_crop = 0;
else
image_crop = atoi(var.value);
}
var.key = BEETLE_OPT(initial_scanline); var.key = BEETLE_OPT(initial_scanline);
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value)
...@@ -493,6 +504,7 @@ void rsx_vulkan_refresh_variables(void) ...@@ -493,6 +504,7 @@ void rsx_vulkan_refresh_variables(void)
old_msaa != msaa || old_msaa != msaa ||
old_show_vram != show_vram || old_show_vram != show_vram ||
old_crop_overscan != crop_overscan || old_crop_overscan != crop_overscan ||
old_image_crop != image_crop ||
old_widescreen_hack != widescreen_hack || old_widescreen_hack != widescreen_hack ||
old_widescreen_hack_aspect_ratio_setting != widescreen_hack_aspect_ratio_setting || old_widescreen_hack_aspect_ratio_setting != widescreen_hack_aspect_ratio_setting ||
visible_scanlines_changed) visible_scanlines_changed)
...@@ -559,6 +571,7 @@ void rsx_vulkan_finalize_frame(const void *fb, unsigned width, ...@@ -559,6 +571,7 @@ void rsx_vulkan_finalize_frame(const void *fb, unsigned width,
renderer->set_horizontal_overscan_cropping(crop_overscan); renderer->set_horizontal_overscan_cropping(crop_overscan);
renderer->set_horizontal_offset_cycles(image_offset_cycles); renderer->set_horizontal_offset_cycles(image_offset_cycles);
renderer->set_visible_scanlines(initial_scanline, last_scanline, initial_scanline_pal, last_scanline_pal); renderer->set_visible_scanlines(initial_scanline, last_scanline, initial_scanline_pal, last_scanline_pal);
renderer->set_horizontal_additional_cropping(image_crop);
renderer->set_display_filter(super_sampling ? Renderer::ScanoutFilter::SSAA : Renderer::ScanoutFilter::None); renderer->set_display_filter(super_sampling ? Renderer::ScanoutFilter::SSAA : Renderer::ScanoutFilter::None);
if (renderer->get_scanout_mode() == Renderer::ScanoutMode::BGR24) if (renderer->get_scanout_mode() == Renderer::ScanoutMode::BGR24)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment