From 5e0ca4c0c42ffbe713a74ad7dd9cc4599ada455c Mon Sep 17 00:00:00 2001 From: kd-11 Date: Sat, 18 Jan 2020 12:21:31 +0300 Subject: [PATCH] rsx: Fixup for missing visuals when framebuffer is larger than requested display dimensions. --- rpcs3/Emu/RSX/GL/GLPresent.cpp | 32 +++++++++++++++++++++++--------- rpcs3/Emu/RSX/VK/VKPresent.cpp | 32 +++++++++++++++++++++++--------- 2 files changed, 46 insertions(+), 18 deletions(-) diff --git a/rpcs3/Emu/RSX/GL/GLPresent.cpp b/rpcs3/Emu/RSX/GL/GLPresent.cpp index bf40c58e1c..97dd622efd 100644 --- a/rpcs3/Emu/RSX/GL/GLPresent.cpp +++ b/rpcs3/Emu/RSX/GL/GLPresent.cpp @@ -15,24 +15,38 @@ GLuint GLGSRender::get_present_source(gl::present_surface_info* info, const rsx: { const auto& section = overlap_info.back(); auto surface = gl::as_rtt(section.surface); + bool viable = false; if (section.base_address >= info->address) { - // Check for intentional 'borders' - const u32 inset_offset = section.base_address - info->address; - const u32 inset_y = inset_offset / info->pitch; - const u32 inset_x = (inset_offset % info->pitch) / format_bpp; + const auto surface_width = surface->get_surface_width(rsx::surface_metrics::samples); + const auto surface_height = surface->get_surface_height(rsx::surface_metrics::samples); - const u32 full_width = surface->get_surface_width(rsx::surface_metrics::samples) + inset_x + inset_x; - const u32 full_height = surface->get_surface_height(rsx::surface_metrics::samples) + inset_y + inset_y; + if (section.base_address == info->address) + { + // Check for fit or crop + viable = (surface_width >= info->width && surface_height >= info->height); + } + else + { + // Check for borders and letterboxing + const u32 inset_offset = section.base_address - info->address; + const u32 inset_y = inset_offset / info->pitch; + const u32 inset_x = (inset_offset % info->pitch) / format_bpp; - if (full_width == info->width && full_height == info->height) + const u32 full_width = surface_width + inset_x + inset_x; + const u32 full_height = surface_height + inset_y + inset_y; + + viable = (full_width == info->width && full_height == info->height); + } + + if (viable) { surface->read_barrier(cmd); image = section.surface->get_surface(rsx::surface_access::read)->id(); - info->width = rsx::apply_resolution_scale(full_width - (inset_x + inset_x), true); - info->height = rsx::apply_resolution_scale(full_height - (inset_y + inset_y), true); + info->width = rsx::apply_resolution_scale(std::min(surface_width, static_cast(info->width)), true); + info->height = rsx::apply_resolution_scale(std::min(surface_height, static_cast(info->height)), true); } } } diff --git a/rpcs3/Emu/RSX/VK/VKPresent.cpp b/rpcs3/Emu/RSX/VK/VKPresent.cpp index 9a4606459f..3739143e7b 100644 --- a/rpcs3/Emu/RSX/VK/VKPresent.cpp +++ b/rpcs3/Emu/RSX/VK/VKPresent.cpp @@ -274,24 +274,38 @@ vk::image* VKGSRender::get_present_source(vk::present_surface_info* info, const { const auto& section = overlap_info.back(); auto surface = vk::as_rtt(section.surface); + bool viable = false; if (section.base_address >= info->address) { - // Check for intentional 'borders' - const u32 inset_offset = section.base_address - info->address; - const u32 inset_y = inset_offset / info->pitch; - const u32 inset_x = (inset_offset % info->pitch) / format_bpp; + const auto surface_width = surface->get_surface_width(rsx::surface_metrics::samples); + const auto surface_height = surface->get_surface_height(rsx::surface_metrics::samples); - const u32 full_width = surface->get_surface_width(rsx::surface_metrics::samples) + inset_x + inset_x; - const u32 full_height = surface->get_surface_height(rsx::surface_metrics::samples) + inset_y + inset_y; + if (section.base_address == info->address) + { + // Check for fit or crop + viable = (surface_width >= info->width && surface_height >= info->height); + } + else + { + // Check for borders and letterboxing + const u32 inset_offset = section.base_address - info->address; + const u32 inset_y = inset_offset / info->pitch; + const u32 inset_x = (inset_offset % info->pitch) / format_bpp; - if (full_width == info->width && full_height == info->height) + const u32 full_width = surface_width + inset_x + inset_x; + const u32 full_height = surface_height + inset_y + inset_y; + + viable = (full_width == info->width && full_height == info->height); + } + + if (viable) { surface->read_barrier(*m_current_command_buffer); image_to_flip = section.surface->get_surface(rsx::surface_access::read); - info->width = rsx::apply_resolution_scale(full_width - (inset_x + inset_x), true); - info->height = rsx::apply_resolution_scale(full_height - (inset_y + inset_y), true); + info->width = rsx::apply_resolution_scale(std::min(surface_width, static_cast(info->width)), true); + info->height = rsx::apply_resolution_scale(std::min(surface_height, static_cast(info->height)), true); } } }