From 563e205a72ff4b431b02c57da901e1b155ade6a6 Mon Sep 17 00:00:00 2001 From: kd-11 Date: Tue, 26 Feb 2019 13:31:32 +0300 Subject: [PATCH] rsx/texture_cache: Fix 'AA' scaling hack and restore collection template selection --- rpcs3/Emu/RSX/Common/texture_cache.h | 8 ++++---- rpcs3/Emu/RSX/GL/GLTextureCache.h | 9 ++++++++- rpcs3/Emu/RSX/VK/VKTextureCache.h | 8 +++++++- 3 files changed, 19 insertions(+), 6 deletions(-) diff --git a/rpcs3/Emu/RSX/Common/texture_cache.h b/rpcs3/Emu/RSX/Common/texture_cache.h index 0216a639b1..5cefb0ef5f 100644 --- a/rpcs3/Emu/RSX/Common/texture_cache.h +++ b/rpcs3/Emu/RSX/Common/texture_cache.h @@ -1628,8 +1628,8 @@ namespace rsx const auto h = std::min(section_end, slice_end) - section.dst_y; auto src_width = rsx::apply_resolution_scale(section.width, true); auto src_height = rsx::apply_resolution_scale(h, true); - auto dst_width = src_width; - auto dst_height = src_height; + auto dst_width = u16(src_width * scale_x); + auto dst_height = u16(src_height * scale_y); if (scale_x > 1.f) { @@ -1639,13 +1639,13 @@ namespace rsx if (limit_x > slice_w) { - dst_width = (limit_x - dst_x); + dst_width = (slice_w - dst_x); src_width = dst_width / scale_x; } if (limit_y > slice_h) { - dst_height = (limit_y - dst_y); + dst_height = (slice_h - dst_y); src_height = dst_height / scale_y; } } diff --git a/rpcs3/Emu/RSX/GL/GLTextureCache.h b/rpcs3/Emu/RSX/GL/GLTextureCache.h index ec89b4a9ba..4ff29aa932 100644 --- a/rpcs3/Emu/RSX/GL/GLTextureCache.h +++ b/rpcs3/Emu/RSX/GL/GLTextureCache.h @@ -762,6 +762,11 @@ namespace gl gl::texture* get_template_from_collection_impl(const std::vector& sections_to_transfer) const { + if (LIKELY(sections_to_transfer.size() == 1)) + { + return sections_to_transfer.front().src; + } + gl::texture* result = nullptr; for (const auto §ion : sections_to_transfer) { @@ -854,7 +859,9 @@ namespace gl gl::texture_view* generate_atlas_from_images(gl::command_context& cmd, u32 gcm_format, u16 width, u16 height, const std::vector& sections_to_copy, const texture_channel_remap_t& remap_vector) override { - auto result = create_temporary_subresource_impl(nullptr, GL_NONE, GL_TEXTURE_2D, gcm_format, 0, 0, width, height, remap_vector, false); + auto _template = get_template_from_collection_impl(sections_to_copy); + const GLenum ifmt = _template ? (GLenum)_template->get_internal_format() : GL_NONE; + auto result = create_temporary_subresource_impl(_template, ifmt, GL_TEXTURE_2D, gcm_format, 0, 0, width, height, remap_vector, false); copy_transfer_regions_impl(cmd, result->image(), sections_to_copy); return result; diff --git a/rpcs3/Emu/RSX/VK/VKTextureCache.h b/rpcs3/Emu/RSX/VK/VKTextureCache.h index d577eb216e..7de207cf77 100644 --- a/rpcs3/Emu/RSX/VK/VKTextureCache.h +++ b/rpcs3/Emu/RSX/VK/VKTextureCache.h @@ -590,6 +590,11 @@ namespace vk vk::image* get_template_from_collection_impl(const std::vector& sections_to_transfer) const { + if (LIKELY(sections_to_transfer.size() == 1)) + { + return sections_to_transfer.front().src; + } + vk::image* result = nullptr; for (const auto §ion : sections_to_transfer) { @@ -804,7 +809,8 @@ namespace vk vk::image_view* generate_atlas_from_images(vk::command_buffer& cmd, u32 gcm_format, u16 width, u16 height, const std::vector& sections_to_copy, const texture_channel_remap_t& remap_vector) override { - auto result = create_temporary_subresource_view_impl(cmd, nullptr, VK_IMAGE_TYPE_2D, + auto _template = get_template_from_collection_impl(sections_to_copy); + auto result = create_temporary_subresource_view_impl(cmd, _template, VK_IMAGE_TYPE_2D, VK_IMAGE_VIEW_TYPE_2D, gcm_format, 0, 0, width, height, remap_vector, false); const auto image = result->image();