diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/video_core/renderer_vulkan/vk_texture_cache.cpp | 32 |
1 files changed, 18 insertions, 14 deletions
diff --git a/src/video_core/renderer_vulkan/vk_texture_cache.cpp b/src/video_core/renderer_vulkan/vk_texture_cache.cpp index 575f12566..b21992fce 100644 --- a/src/video_core/renderer_vulkan/vk_texture_cache.cpp +++ b/src/video_core/renderer_vulkan/vk_texture_cache.cpp | |||
| @@ -595,7 +595,8 @@ struct RangedBarrierRange { | |||
| 595 | } | 595 | } |
| 596 | 596 | ||
| 597 | void BlitScale(VKScheduler& scheduler, VkImage src_image, VkImage dst_image, const ImageInfo& info, | 597 | void BlitScale(VKScheduler& scheduler, VkImage src_image, VkImage dst_image, const ImageInfo& info, |
| 598 | VkImageAspectFlags aspect_mask, const Settings::ResolutionScalingInfo& resolution) { | 598 | VkImageAspectFlags aspect_mask, const Settings::ResolutionScalingInfo& resolution, |
| 599 | bool scaling) { | ||
| 599 | const auto type = info.type; | 600 | const auto type = info.type; |
| 600 | const auto resources = info.resources; | 601 | const auto resources = info.resources; |
| 601 | const VkExtent2D extent{ | 602 | const VkExtent2D extent{ |
| @@ -603,15 +604,18 @@ void BlitScale(VKScheduler& scheduler, VkImage src_image, VkImage dst_image, con | |||
| 603 | .height = info.size.height, | 604 | .height = info.size.height, |
| 604 | }; | 605 | }; |
| 605 | scheduler.RequestOutsideRenderPassOperationContext(); | 606 | scheduler.RequestOutsideRenderPassOperationContext(); |
| 606 | scheduler.Record([dst_image, src_image, extent, resources, aspect_mask, resolution, | 607 | scheduler.Record([dst_image, src_image, extent, resources, aspect_mask, resolution, type, |
| 607 | type](vk::CommandBuffer cmdbuf) { | 608 | scaling](vk::CommandBuffer cmdbuf) { |
| 608 | const auto scale_up = [&](u32 value) { | 609 | const auto scale_up = [&](u32 value) { |
| 609 | return std::max<u32>((value * resolution.up_scale) >> resolution.down_shift, 1U); | 610 | return std::max<u32>((value * resolution.up_scale) >> resolution.down_shift, 1U); |
| 610 | }; | 611 | }; |
| 611 | const bool is_2d = type == ImageType::e2D; | 612 | const VkOffset2D src_size{ |
| 612 | const VkOffset2D mip0_size{ | 613 | .x = static_cast<s32>(scaling ? extent.width : scale_up(extent.width)), |
| 613 | .x = static_cast<s32>(scale_up(extent.width)), | 614 | .y = static_cast<s32>(scaling ? extent.height : scale_up(extent.height)), |
| 614 | .y = static_cast<s32>(is_2d ? scale_up(extent.height) : extent.height), | 615 | }; |
| 616 | const VkOffset2D dst_size{ | ||
| 617 | .x = static_cast<s32>(scaling ? scale_up(extent.width) : extent.width), | ||
| 618 | .y = static_cast<s32>(scaling ? scale_up(extent.height) : extent.height), | ||
| 615 | }; | 619 | }; |
| 616 | boost::container::small_vector<VkImageBlit, 4> regions; | 620 | boost::container::small_vector<VkImageBlit, 4> regions; |
| 617 | regions.reserve(resources.levels); | 621 | regions.reserve(resources.levels); |
| @@ -630,8 +634,8 @@ void BlitScale(VKScheduler& scheduler, VkImage src_image, VkImage dst_image, con | |||
| 630 | .z = 0, | 634 | .z = 0, |
| 631 | }, | 635 | }, |
| 632 | { | 636 | { |
| 633 | .x = std::max(1, static_cast<s32>(extent.width) >> level), | 637 | .x = std::max(1, src_size.x >> level), |
| 634 | .y = std::max(1, static_cast<s32>(extent.height) >> level), | 638 | .y = std::max(1, src_size.y >> level), |
| 635 | .z = 1, | 639 | .z = 1, |
| 636 | }, | 640 | }, |
| 637 | }, | 641 | }, |
| @@ -648,8 +652,8 @@ void BlitScale(VKScheduler& scheduler, VkImage src_image, VkImage dst_image, con | |||
| 648 | .z = 0, | 652 | .z = 0, |
| 649 | }, | 653 | }, |
| 650 | { | 654 | { |
| 651 | .x = std::max(1, mip0_size.x >> level), | 655 | .x = std::max(1, dst_size.x >> level), |
| 652 | .y = std::max(1, mip0_size.y >> level), | 656 | .y = std::max(1, dst_size.y >> level), |
| 653 | .z = 1, | 657 | .z = 1, |
| 654 | }, | 658 | }, |
| 655 | }, | 659 | }, |
| @@ -1157,7 +1161,7 @@ bool Image::ScaleUp(bool save_as_backup) { | |||
| 1157 | if (aspect_mask == 0) { | 1161 | if (aspect_mask == 0) { |
| 1158 | aspect_mask = ImageAspectMask(info.format); | 1162 | aspect_mask = ImageAspectMask(info.format); |
| 1159 | } | 1163 | } |
| 1160 | BlitScale(*scheduler, *image, *rescaled_image, info, aspect_mask, resolution); | 1164 | BlitScale(*scheduler, *image, *rescaled_image, info, aspect_mask, resolution, true); |
| 1161 | return true; | 1165 | return true; |
| 1162 | } | 1166 | } |
| 1163 | 1167 | ||
| @@ -1184,14 +1188,14 @@ bool Image::ScaleDown(bool save_as_backup) { | |||
| 1184 | 1188 | ||
| 1185 | const auto& resolution = runtime->resolution; | 1189 | const auto& resolution = runtime->resolution; |
| 1186 | vk::Image downscaled_image = | 1190 | vk::Image downscaled_image = |
| 1187 | MakeImage(runtime->device, info, resolution.up_scale, resolution.down_shift); | 1191 | MakeImage(runtime->device, info); |
| 1188 | MemoryCommit new_commit( | 1192 | MemoryCommit new_commit( |
| 1189 | runtime->memory_allocator.Commit(downscaled_image, MemoryUsage::DeviceLocal)); | 1193 | runtime->memory_allocator.Commit(downscaled_image, MemoryUsage::DeviceLocal)); |
| 1190 | 1194 | ||
| 1191 | if (aspect_mask == 0) { | 1195 | if (aspect_mask == 0) { |
| 1192 | aspect_mask = ImageAspectMask(info.format); | 1196 | aspect_mask = ImageAspectMask(info.format); |
| 1193 | } | 1197 | } |
| 1194 | BlitScale(*scheduler, *image, *downscaled_image, info, aspect_mask, resolution); | 1198 | BlitScale(*scheduler, *image, *downscaled_image, info, aspect_mask, resolution, false); |
| 1195 | 1199 | ||
| 1196 | if (save_as_backup) { | 1200 | if (save_as_backup) { |
| 1197 | backup_image = std::move(image); | 1201 | backup_image = std::move(image); |