diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/video_core/engines/fermi_2d.cpp | 42 |
1 files changed, 28 insertions, 14 deletions
diff --git a/src/video_core/engines/fermi_2d.cpp b/src/video_core/engines/fermi_2d.cpp index c2d4dcc09..85d308e26 100644 --- a/src/video_core/engines/fermi_2d.cpp +++ b/src/video_core/engines/fermi_2d.cpp | |||
| @@ -28,6 +28,13 @@ void Fermi2D::CallMethod(const GPU::MethodCall& method_call) { | |||
| 28 | } | 28 | } |
| 29 | } | 29 | } |
| 30 | 30 | ||
| 31 | std::pair<u32, u32> DelimitLine(u32 src_1, u32 src_2, u32 dst_1, u32 dst_2, u32 src_line) { | ||
| 32 | const u32 line_a = src_2 - src_1; | ||
| 33 | const u32 line_b = dst_2 - dst_1; | ||
| 34 | const u32 excess = std::max<s32>(0, line_a - src_line + src_1); | ||
| 35 | return {line_b - (excess * line_b) / line_a, excess}; | ||
| 36 | } | ||
| 37 | |||
| 31 | void Fermi2D::HandleSurfaceCopy() { | 38 | void Fermi2D::HandleSurfaceCopy() { |
| 32 | LOG_DEBUG(HW_GPU, "Requested a surface copy with operation {}", | 39 | LOG_DEBUG(HW_GPU, "Requested a surface copy with operation {}", |
| 33 | static_cast<u32>(regs.operation)); | 40 | static_cast<u32>(regs.operation)); |
| @@ -47,20 +54,27 @@ void Fermi2D::HandleSurfaceCopy() { | |||
| 47 | src_blit_x2 = static_cast<u32>((regs.blit_src_x >> 32) + regs.blit_dst_width); | 54 | src_blit_x2 = static_cast<u32>((regs.blit_src_x >> 32) + regs.blit_dst_width); |
| 48 | src_blit_y2 = static_cast<u32>((regs.blit_src_y >> 32) + regs.blit_dst_height); | 55 | src_blit_y2 = static_cast<u32>((regs.blit_src_y >> 32) + regs.blit_dst_height); |
| 49 | } | 56 | } |
| 50 | const u32 dst_blit_x2 = regs.blit_dst_x + regs.blit_dst_width; | 57 | u32 dst_blit_x2 = regs.blit_dst_x + regs.blit_dst_width; |
| 51 | const u32 dst_blit_y2 = regs.blit_dst_x + regs.blit_dst_height; | 58 | u32 dst_blit_y2 = regs.blit_dst_y + regs.blit_dst_height; |
| 52 | const u32 excess_src_x2 = std::max<s32>(0, dst_blit_x2 - regs.dst.width); | 59 | const auto [new_dst_w, src_excess_x] = |
| 53 | const u32 excess_src_y2 = std::max<s32>(0, dst_blit_y2 - regs.dst.height); | 60 | DelimitLine(src_blit_x1, src_blit_x2, regs.blit_dst_x, dst_blit_x2, regs.src.width); |
| 54 | const u32 excess_dst_x2 = std::max<s32>(0, src_blit_x2 - regs.src.width); | 61 | const auto [new_dst_h, src_excess_y] = |
| 55 | const u32 excess_dst_y2 = std::max<s32>(0, src_blit_y2 - regs.src.height); | 62 | DelimitLine(src_blit_y1, src_blit_y2, regs.blit_dst_y, dst_blit_y2, regs.src.height); |
| 56 | 63 | dst_blit_x2 = new_dst_w + regs.blit_dst_x; | |
| 57 | const Common::Rectangle<u32> src_rect{ | 64 | src_blit_x2 = src_blit_x2 - src_excess_x; |
| 58 | src_blit_x1, src_blit_y1, std::min<u32>(regs.src.width, src_blit_x2) - excess_src_x2, | 65 | dst_blit_y2 = new_dst_h + regs.blit_dst_y; |
| 59 | std::min<u32>(regs.src.height, src_blit_y2) - excess_src_y2}; | 66 | src_blit_y2 = src_blit_y2 - src_excess_y; |
| 60 | const Common::Rectangle<u32> dst_rect{ | 67 | const auto [new_src_w, dst_excess_x] = |
| 61 | regs.blit_dst_x, regs.blit_dst_y, | 68 | DelimitLine(regs.blit_dst_x, dst_blit_x2, src_blit_x1, src_blit_x2, regs.dst.width); |
| 62 | std::min<u32>(regs.dst.width, dst_blit_x2) - excess_dst_x2, | 69 | const auto [new_src_h, dst_excess_y] = |
| 63 | std::min<u32>(regs.dst.height, dst_blit_y2) - excess_dst_y2}; | 70 | DelimitLine(regs.blit_dst_y, dst_blit_y2, src_blit_y1, src_blit_y2, regs.dst.height); |
| 71 | src_blit_x2 = new_src_w + src_blit_x1; | ||
| 72 | dst_blit_x2 = dst_blit_x2 - dst_excess_x; | ||
| 73 | src_blit_y2 = new_src_h + src_blit_y1; | ||
| 74 | dst_blit_y2 = dst_blit_y2 - dst_excess_y; | ||
| 75 | const Common::Rectangle<u32> src_rect{src_blit_x1, src_blit_y1, src_blit_x2, src_blit_y2}; | ||
| 76 | const Common::Rectangle<u32> dst_rect{regs.blit_dst_x, regs.blit_dst_y, dst_blit_x2, | ||
| 77 | dst_blit_y2}; | ||
| 64 | Config copy_config; | 78 | Config copy_config; |
| 65 | copy_config.operation = regs.operation; | 79 | copy_config.operation = regs.operation; |
| 66 | copy_config.filter = regs.blit_control.filter; | 80 | copy_config.filter = regs.blit_control.filter; |