From 6d2dcbd164002f7ef484a93336f8881243b1216e Mon Sep 17 00:00:00 2001 From: kd-11 Date: Fri, 10 Nov 2017 15:13:32 +0300 Subject: [PATCH] rsx: Enable hw blit engine for local->main memory blit operations as well --- rpcs3/Emu/RSX/Common/texture_cache.h | 35 ++++++++++++++++++++++++---- rpcs3/Emu/RSX/rsx_methods.cpp | 2 +- 2 files changed, 32 insertions(+), 5 deletions(-) diff --git a/rpcs3/Emu/RSX/Common/texture_cache.h b/rpcs3/Emu/RSX/Common/texture_cache.h index d53b726c66..5bca981ae4 100644 --- a/rpcs3/Emu/RSX/Common/texture_cache.h +++ b/rpcs3/Emu/RSX/Common/texture_cache.h @@ -1605,13 +1605,40 @@ namespace rsx //Create source texture if does not exist if (!src_is_render_target) { - auto preloaded_texture = find_texture_from_dimensions(src_address, src.width, src.slice_h); + auto overlapping_surfaces = find_texture_from_range(src_address, src.pitch * src.height); - if (preloaded_texture != nullptr) + auto old_src_area = src_area; + for (auto &surface : overlapping_surfaces) { - vram_texture = preloaded_texture->get_raw_texture(); + //look for any that will fit, unless its a shader read surface or framebuffer_storage + if (surface->get_context() == rsx::texture_upload_context::shader_read || + surface->get_context() == rsx::texture_upload_context::framebuffer_storage) + continue; + + if (const u32 address_offset = src_address - surface->get_section_base()) + { + const u16 bpp = dst_is_argb8 ? 4 : 2; + const u16 offset_y = address_offset / src.pitch; + const u16 offset_x = address_offset % src.pitch; + const u16 offset_x_in_block = offset_x / bpp; + + src_area.x1 += offset_x_in_block; + src_area.x2 += offset_x_in_block; + src_area.y1 += offset_y; + src_area.y2 += offset_y; + } + + if (src_area.x2 <= surface->get_width() && + src_area.y2 <= surface->get_height()) + { + vram_texture = surface->get_raw_texture(); + break; + } + + src_area = old_src_area; } - else + + if (!vram_texture) { lock.upgrade(); diff --git a/rpcs3/Emu/RSX/rsx_methods.cpp b/rpcs3/Emu/RSX/rsx_methods.cpp index 1cf8999d28..2a563af583 100644 --- a/rpcs3/Emu/RSX/rsx_methods.cpp +++ b/rpcs3/Emu/RSX/rsx_methods.cpp @@ -681,7 +681,7 @@ namespace rsx dst_info.max_tile_h = static_cast((dst_region.tile->size - dst_region.base) / out_pitch); } - if (!g_cfg.video.force_cpu_blit_processing && dst_dma == CELL_GCM_CONTEXT_DMA_MEMORY_FRAME_BUFFER) + if (!g_cfg.video.force_cpu_blit_processing && (dst_dma == CELL_GCM_CONTEXT_DMA_MEMORY_FRAME_BUFFER || src_dma == CELL_GCM_CONTEXT_DMA_MEMORY_FRAME_BUFFER)) { //For now, only use this for actual scaled images, there are use cases that should not go through 3d engine, e.g program ucode transfer //TODO: Figure out more instances where we can use this without problems