diff options
| author | 2021-10-06 01:18:00 -0400 | |
|---|---|---|
| committer | 2021-11-16 22:11:30 +0100 | |
| commit | 31478c6c1b841b9a820742830b136775fafe270f (patch) | |
| tree | e8f5644dd6c570cf8ee08e5e23592983162a8ec4 /src | |
| parent | texture_cache: Refactor scaled image size calculation (diff) | |
| download | yuzu-31478c6c1b841b9a820742830b136775fafe270f.tar.gz yuzu-31478c6c1b841b9a820742830b136775fafe270f.tar.xz yuzu-31478c6c1b841b9a820742830b136775fafe270f.zip | |
video_core: Misc resolution scaling related refactoring
Diffstat (limited to 'src')
| -rw-r--r-- | src/common/settings.cpp | 2 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/gl_rasterizer.cpp | 4 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/gl_texture_cache.cpp | 31 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/gl_texture_cache.h | 11 | ||||
| -rw-r--r-- | src/video_core/renderer_vulkan/vk_state_tracker.h | 10 | ||||
| -rw-r--r-- | src/video_core/renderer_vulkan/vk_texture_cache.cpp | 31 | ||||
| -rw-r--r-- | src/video_core/renderer_vulkan/vk_texture_cache.h | 7 | ||||
| -rw-r--r-- | src/video_core/texture_cache/texture_cache.h | 2 |
8 files changed, 51 insertions, 47 deletions
diff --git a/src/common/settings.cpp b/src/common/settings.cpp index f0686a7c5..12fdb0f9b 100644 --- a/src/common/settings.cpp +++ b/src/common/settings.cpp | |||
| @@ -107,7 +107,7 @@ float Volume() { | |||
| 107 | } | 107 | } |
| 108 | 108 | ||
| 109 | void UpdateRescalingInfo() { | 109 | void UpdateRescalingInfo() { |
| 110 | auto setup = values.resolution_setup.GetValue(); | 110 | const auto setup = values.resolution_setup.GetValue(); |
| 111 | auto& info = values.resolution_info; | 111 | auto& info = values.resolution_info; |
| 112 | switch (setup) { | 112 | switch (setup) { |
| 113 | case ResolutionSetup::Res1_2X: | 113 | case ResolutionSetup::Res1_2X: |
diff --git a/src/video_core/renderer_opengl/gl_rasterizer.cpp b/src/video_core/renderer_opengl/gl_rasterizer.cpp index d94f1e89f..bb24a0656 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer.cpp +++ b/src/video_core/renderer_opengl/gl_rasterizer.cpp | |||
| @@ -554,7 +554,7 @@ void RasterizerOpenGL::SyncViewport() { | |||
| 554 | } | 554 | } |
| 555 | glFrontFace(mode); | 555 | glFrontFace(mode); |
| 556 | } | 556 | } |
| 557 | if (dirty_viewport || flags[Dirty::ClipControl]) { | 557 | if (dirty_viewport || dirty_clip_control) { |
| 558 | flags[Dirty::ClipControl] = false; | 558 | flags[Dirty::ClipControl] = false; |
| 559 | 559 | ||
| 560 | bool flip_y = false; | 560 | bool flip_y = false; |
| @@ -925,7 +925,7 @@ void RasterizerOpenGL::SyncScissorTest() { | |||
| 925 | const auto& regs = maxwell3d.regs; | 925 | const auto& regs = maxwell3d.regs; |
| 926 | 926 | ||
| 927 | const auto& resolution = Settings::values.resolution_info; | 927 | const auto& resolution = Settings::values.resolution_info; |
| 928 | const auto scale_up = [&](u32 value) -> u32 { | 928 | const auto scale_up = [resolution](u32 value) -> u32 { |
| 929 | if (value == 0) { | 929 | if (value == 0) { |
| 930 | return 0U; | 930 | return 0U; |
| 931 | } | 931 | } |
diff --git a/src/video_core/renderer_opengl/gl_texture_cache.cpp b/src/video_core/renderer_opengl/gl_texture_cache.cpp index fafee62ee..c68a51ebb 100644 --- a/src/video_core/renderer_opengl/gl_texture_cache.cpp +++ b/src/video_core/renderer_opengl/gl_texture_cache.cpp | |||
| @@ -405,7 +405,8 @@ ImageBufferMap::~ImageBufferMap() { | |||
| 405 | 405 | ||
| 406 | TextureCacheRuntime::TextureCacheRuntime(const Device& device_, ProgramManager& program_manager, | 406 | TextureCacheRuntime::TextureCacheRuntime(const Device& device_, ProgramManager& program_manager, |
| 407 | StateTracker& state_tracker_) | 407 | StateTracker& state_tracker_) |
| 408 | : device{device_}, state_tracker{state_tracker_}, util_shaders(program_manager) { | 408 | : device{device_}, state_tracker{state_tracker_}, |
| 409 | util_shaders(program_manager), resolution{Settings::values.resolution_info} { | ||
| 409 | static constexpr std::array TARGETS{GL_TEXTURE_1D_ARRAY, GL_TEXTURE_2D_ARRAY, GL_TEXTURE_3D}; | 410 | static constexpr std::array TARGETS{GL_TEXTURE_1D_ARRAY, GL_TEXTURE_2D_ARRAY, GL_TEXTURE_3D}; |
| 410 | for (size_t i = 0; i < TARGETS.size(); ++i) { | 411 | for (size_t i = 0; i < TARGETS.size(); ++i) { |
| 411 | const GLenum target = TARGETS[i]; | 412 | const GLenum target = TARGETS[i]; |
| @@ -473,7 +474,6 @@ TextureCacheRuntime::TextureCacheRuntime(const Device& device_, ProgramManager& | |||
| 473 | set_view(Shader::TextureType::ColorArray2D, null_image_view_2d_array.handle); | 474 | set_view(Shader::TextureType::ColorArray2D, null_image_view_2d_array.handle); |
| 474 | set_view(Shader::TextureType::ColorArrayCube, null_image_cube_array.handle); | 475 | set_view(Shader::TextureType::ColorArrayCube, null_image_cube_array.handle); |
| 475 | 476 | ||
| 476 | resolution = Settings::values.resolution_info; | ||
| 477 | if (resolution.active) { | 477 | if (resolution.active) { |
| 478 | for (size_t i = 0; i < rescale_draw_fbos.size(); ++i) { | 478 | for (size_t i = 0; i < rescale_draw_fbos.size(); ++i) { |
| 479 | rescale_draw_fbos[i].Create(); | 479 | rescale_draw_fbos[i].Create(); |
| @@ -681,7 +681,7 @@ Image::Image(TextureCacheRuntime& runtime_, const VideoCommon::ImageInfo& info_, | |||
| 681 | gl_type = tuple.type; | 681 | gl_type = tuple.type; |
| 682 | } | 682 | } |
| 683 | texture = MakeImage(info, gl_internal_format); | 683 | texture = MakeImage(info, gl_internal_format); |
| 684 | original_backup = texture.handle; | 684 | current_texture = texture.handle; |
| 685 | if (runtime->device.HasDebuggingToolAttached()) { | 685 | if (runtime->device.HasDebuggingToolAttached()) { |
| 686 | const std::string name = VideoCommon::Name(*this); | 686 | const std::string name = VideoCommon::Name(*this); |
| 687 | glObjectLabel(ImageTarget(info) == GL_TEXTURE_BUFFER ? GL_BUFFER : GL_TEXTURE, | 687 | glObjectLabel(ImageTarget(info) == GL_TEXTURE_BUFFER ? GL_BUFFER : GL_TEXTURE, |
| @@ -726,10 +726,6 @@ void Image::UploadMemory(const ImageBufferMap& map, | |||
| 726 | void Image::DownloadMemory(ImageBufferMap& map, | 726 | void Image::DownloadMemory(ImageBufferMap& map, |
| 727 | std::span<const VideoCommon::BufferImageCopy> copies) { | 727 | std::span<const VideoCommon::BufferImageCopy> copies) { |
| 728 | glMemoryBarrier(GL_PIXEL_BUFFER_BARRIER_BIT); // TODO: Move this to its own API | 728 | glMemoryBarrier(GL_PIXEL_BUFFER_BARRIER_BIT); // TODO: Move this to its own API |
| 729 | const bool is_rescaled = True(flags & ImageFlagBits::Rescaled); | ||
| 730 | if (is_rescaled) { | ||
| 731 | ScaleDown(); | ||
| 732 | } | ||
| 733 | glBindBuffer(GL_PIXEL_PACK_BUFFER, map.buffer); | 729 | glBindBuffer(GL_PIXEL_PACK_BUFFER, map.buffer); |
| 734 | glPixelStorei(GL_PACK_ALIGNMENT, 1); | 730 | glPixelStorei(GL_PACK_ALIGNMENT, 1); |
| 735 | 731 | ||
| @@ -747,9 +743,6 @@ void Image::DownloadMemory(ImageBufferMap& map, | |||
| 747 | } | 743 | } |
| 748 | CopyImageToBuffer(copy, map.offset); | 744 | CopyImageToBuffer(copy, map.offset); |
| 749 | } | 745 | } |
| 750 | if (is_rescaled) { | ||
| 751 | texture.handle = upscaled_backup.handle; | ||
| 752 | } | ||
| 753 | } | 746 | } |
| 754 | 747 | ||
| 755 | GLuint Image::StorageHandle() noexcept { | 748 | GLuint Image::StorageHandle() noexcept { |
| @@ -775,11 +768,11 @@ GLuint Image::StorageHandle() noexcept { | |||
| 775 | return store_view.handle; | 768 | return store_view.handle; |
| 776 | } | 769 | } |
| 777 | store_view.Create(); | 770 | store_view.Create(); |
| 778 | glTextureView(store_view.handle, ImageTarget(info), texture.handle, GL_RGBA8, 0, | 771 | glTextureView(store_view.handle, ImageTarget(info), current_texture, GL_RGBA8, 0, |
| 779 | info.resources.levels, 0, info.resources.layers); | 772 | info.resources.levels, 0, info.resources.layers); |
| 780 | return store_view.handle; | 773 | return store_view.handle; |
| 781 | default: | 774 | default: |
| 782 | return texture.handle; | 775 | return current_texture; |
| 783 | } | 776 | } |
| 784 | } | 777 | } |
| 785 | 778 | ||
| @@ -940,10 +933,10 @@ bool Image::Scale() { | |||
| 940 | const u32 original_width = info.size.width; | 933 | const u32 original_width = info.size.width; |
| 941 | const u32 original_height = info.size.height; | 934 | const u32 original_height = info.size.height; |
| 942 | 935 | ||
| 943 | auto dst_info = info; | ||
| 944 | dst_info.size.width = scaled_width; | ||
| 945 | dst_info.size.height = scaled_height; | ||
| 946 | if (!upscaled_backup.handle) { | 936 | if (!upscaled_backup.handle) { |
| 937 | auto dst_info = info; | ||
| 938 | dst_info.size.width = scaled_width; | ||
| 939 | dst_info.size.height = scaled_height; | ||
| 947 | upscaled_backup = MakeImage(dst_info, gl_internal_format); | 940 | upscaled_backup = MakeImage(dst_info, gl_internal_format); |
| 948 | } | 941 | } |
| 949 | const GLuint read_fbo = runtime->rescale_read_fbos[fbo_index].handle; | 942 | const GLuint read_fbo = runtime->rescale_read_fbos[fbo_index].handle; |
| @@ -955,14 +948,14 @@ bool Image::Scale() { | |||
| 955 | const u32 dst_level_width = std::max(1u, scaled_width >> level); | 948 | const u32 dst_level_width = std::max(1u, scaled_width >> level); |
| 956 | const u32 dst_level_height = std::max(1u, scaled_height >> level); | 949 | const u32 dst_level_height = std::max(1u, scaled_height >> level); |
| 957 | 950 | ||
| 958 | glNamedFramebufferTextureLayer(read_fbo, attachment, original_backup, level, layer); | 951 | glNamedFramebufferTextureLayer(read_fbo, attachment, texture.handle, level, layer); |
| 959 | glNamedFramebufferTextureLayer(draw_fbo, attachment, upscaled_backup.handle, level, | 952 | glNamedFramebufferTextureLayer(draw_fbo, attachment, upscaled_backup.handle, level, |
| 960 | layer); | 953 | layer); |
| 961 | glBlitNamedFramebuffer(read_fbo, draw_fbo, 0, 0, src_level_width, src_level_height, 0, | 954 | glBlitNamedFramebuffer(read_fbo, draw_fbo, 0, 0, src_level_width, src_level_height, 0, |
| 962 | 0, dst_level_width, dst_level_height, mask, filter); | 955 | 0, dst_level_width, dst_level_height, mask, filter); |
| 963 | } | 956 | } |
| 964 | } | 957 | } |
| 965 | texture.handle = upscaled_backup.handle; | 958 | current_texture = upscaled_backup.handle; |
| 966 | return true; | 959 | return true; |
| 967 | } | 960 | } |
| 968 | 961 | ||
| @@ -993,7 +986,7 @@ bool Image::ScaleDown() { | |||
| 993 | return false; | 986 | return false; |
| 994 | } | 987 | } |
| 995 | flags &= ~ImageFlagBits::Rescaled; | 988 | flags &= ~ImageFlagBits::Rescaled; |
| 996 | texture.handle = original_backup; | 989 | current_texture = texture.handle; |
| 997 | return true; | 990 | return true; |
| 998 | } | 991 | } |
| 999 | 992 | ||
| @@ -1010,7 +1003,7 @@ ImageView::ImageView(TextureCacheRuntime& runtime, const VideoCommon::ImageViewI | |||
| 1010 | flat_range = info.range; | 1003 | flat_range = info.range; |
| 1011 | set_object_label = device.HasDebuggingToolAttached(); | 1004 | set_object_label = device.HasDebuggingToolAttached(); |
| 1012 | is_render_target = info.IsRenderTarget(); | 1005 | is_render_target = info.IsRenderTarget(); |
| 1013 | original_texture = image.texture.handle; | 1006 | original_texture = image.Handle(); |
| 1014 | num_samples = image.info.num_samples; | 1007 | num_samples = image.info.num_samples; |
| 1015 | if (!is_render_target) { | 1008 | if (!is_render_target) { |
| 1016 | swizzle[0] = info.x_source; | 1009 | swizzle[0] = info.x_source; |
diff --git a/src/video_core/renderer_opengl/gl_texture_cache.h b/src/video_core/renderer_opengl/gl_texture_cache.h index 61f9b0259..cf7f37a16 100644 --- a/src/video_core/renderer_opengl/gl_texture_cache.h +++ b/src/video_core/renderer_opengl/gl_texture_cache.h | |||
| @@ -9,13 +9,16 @@ | |||
| 9 | 9 | ||
| 10 | #include <glad/glad.h> | 10 | #include <glad/glad.h> |
| 11 | 11 | ||
| 12 | #include "common/settings.h" | ||
| 13 | #include "shader_recompiler/shader_info.h" | 12 | #include "shader_recompiler/shader_info.h" |
| 14 | #include "video_core/renderer_opengl/gl_resource_manager.h" | 13 | #include "video_core/renderer_opengl/gl_resource_manager.h" |
| 15 | #include "video_core/renderer_opengl/util_shaders.h" | 14 | #include "video_core/renderer_opengl/util_shaders.h" |
| 16 | #include "video_core/texture_cache/image_view_base.h" | 15 | #include "video_core/texture_cache/image_view_base.h" |
| 17 | #include "video_core/texture_cache/texture_cache_base.h" | 16 | #include "video_core/texture_cache/texture_cache_base.h" |
| 18 | 17 | ||
| 18 | namespace Settings { | ||
| 19 | struct ResolutionScalingInfo; | ||
| 20 | } | ||
| 21 | |||
| 19 | namespace OpenGL { | 22 | namespace OpenGL { |
| 20 | 23 | ||
| 21 | class Device; | 24 | class Device; |
| @@ -155,7 +158,7 @@ private: | |||
| 155 | 158 | ||
| 156 | std::array<OGLFramebuffer, 3> rescale_draw_fbos; | 159 | std::array<OGLFramebuffer, 3> rescale_draw_fbos; |
| 157 | std::array<OGLFramebuffer, 3> rescale_read_fbos; | 160 | std::array<OGLFramebuffer, 3> rescale_read_fbos; |
| 158 | Settings::ResolutionScalingInfo resolution; | 161 | const Settings::ResolutionScalingInfo& resolution; |
| 159 | }; | 162 | }; |
| 160 | 163 | ||
| 161 | class Image : public VideoCommon::ImageBase { | 164 | class Image : public VideoCommon::ImageBase { |
| @@ -182,7 +185,7 @@ public: | |||
| 182 | GLuint StorageHandle() noexcept; | 185 | GLuint StorageHandle() noexcept; |
| 183 | 186 | ||
| 184 | GLuint Handle() const noexcept { | 187 | GLuint Handle() const noexcept { |
| 185 | return texture.handle; | 188 | return current_texture; |
| 186 | } | 189 | } |
| 187 | 190 | ||
| 188 | GLuint GlFormat() const noexcept { | 191 | GLuint GlFormat() const noexcept { |
| @@ -211,7 +214,7 @@ private: | |||
| 211 | GLenum gl_format = GL_NONE; | 214 | GLenum gl_format = GL_NONE; |
| 212 | GLenum gl_type = GL_NONE; | 215 | GLenum gl_type = GL_NONE; |
| 213 | TextureCacheRuntime* runtime{}; | 216 | TextureCacheRuntime* runtime{}; |
| 214 | GLuint original_backup{}; | 217 | GLuint current_texture{}; |
| 215 | }; | 218 | }; |
| 216 | 219 | ||
| 217 | class ImageView : public VideoCommon::ImageViewBase { | 220 | class ImageView : public VideoCommon::ImageViewBase { |
diff --git a/src/video_core/renderer_vulkan/vk_state_tracker.h b/src/video_core/renderer_vulkan/vk_state_tracker.h index ac2bbebe0..40a149832 100644 --- a/src/video_core/renderer_vulkan/vk_state_tracker.h +++ b/src/video_core/renderer_vulkan/vk_state_tracker.h | |||
| @@ -71,13 +71,15 @@ public: | |||
| 71 | } | 71 | } |
| 72 | 72 | ||
| 73 | bool TouchViewports() { | 73 | bool TouchViewports() { |
| 74 | return Exchange(Dirty::Viewports, false) || | 74 | const bool dirty_viewports = Exchange(Dirty::Viewports, false); |
| 75 | Exchange(VideoCommon::Dirty::RescaleViewports, false); | 75 | const bool rescale_viewports = Exchange(VideoCommon::Dirty::RescaleViewports, false); |
| 76 | return dirty_viewports || rescale_viewports; | ||
| 76 | } | 77 | } |
| 77 | 78 | ||
| 78 | bool TouchScissors() { | 79 | bool TouchScissors() { |
| 79 | return Exchange(Dirty::Scissors, false) || | 80 | const bool dirty_scissors = Exchange(Dirty::Scissors, false); |
| 80 | Exchange(VideoCommon::Dirty::RescaleScissors, false); | 81 | const bool rescale_scissors = Exchange(VideoCommon::Dirty::RescaleScissors, false); |
| 82 | return dirty_scissors || rescale_scissors; | ||
| 81 | } | 83 | } |
| 82 | 84 | ||
| 83 | bool TouchDepthBias() { | 85 | bool TouchDepthBias() { |
diff --git a/src/video_core/renderer_vulkan/vk_texture_cache.cpp b/src/video_core/renderer_vulkan/vk_texture_cache.cpp index 4f0bab274..930c7d569 100644 --- a/src/video_core/renderer_vulkan/vk_texture_cache.cpp +++ b/src/video_core/renderer_vulkan/vk_texture_cache.cpp | |||
| @@ -125,8 +125,7 @@ constexpr VkBorderColor ConvertBorderColor(const std::array<float, 4>& color) { | |||
| 125 | } | 125 | } |
| 126 | } | 126 | } |
| 127 | 127 | ||
| 128 | [[nodiscard]] VkImageCreateInfo MakeImageCreateInfo(const Device& device, const ImageInfo& info, | 128 | [[nodiscard]] VkImageCreateInfo MakeImageCreateInfo(const Device& device, const ImageInfo& info) { |
| 129 | u32 up, u32 down) { | ||
| 130 | const PixelFormat format = StorageFormat(info.format); | 129 | const PixelFormat format = StorageFormat(info.format); |
| 131 | const auto format_info = MaxwellToVK::SurfaceFormat(device, FormatType::Optimal, false, format); | 130 | const auto format_info = MaxwellToVK::SurfaceFormat(device, FormatType::Optimal, false, format); |
| 132 | VkImageCreateFlags flags = VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT; | 131 | VkImageCreateFlags flags = VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT; |
| @@ -137,9 +136,7 @@ constexpr VkBorderColor ConvertBorderColor(const std::array<float, 4>& color) { | |||
| 137 | if (info.type == ImageType::e3D) { | 136 | if (info.type == ImageType::e3D) { |
| 138 | flags |= VK_IMAGE_CREATE_2D_ARRAY_COMPATIBLE_BIT; | 137 | flags |= VK_IMAGE_CREATE_2D_ARRAY_COMPATIBLE_BIT; |
| 139 | } | 138 | } |
| 140 | const auto scale_up = [&](u32 value) { return std::max<u32>((value * up) >> down, 1U); }; | ||
| 141 | const auto [samples_x, samples_y] = VideoCommon::SamplesLog2(info.num_samples); | 139 | const auto [samples_x, samples_y] = VideoCommon::SamplesLog2(info.num_samples); |
| 142 | const bool is_2d = info.type == ImageType::e2D; | ||
| 143 | return VkImageCreateInfo{ | 140 | return VkImageCreateInfo{ |
| 144 | .sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO, | 141 | .sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO, |
| 145 | .pNext = nullptr, | 142 | .pNext = nullptr, |
| @@ -147,8 +144,8 @@ constexpr VkBorderColor ConvertBorderColor(const std::array<float, 4>& color) { | |||
| 147 | .imageType = ConvertImageType(info.type), | 144 | .imageType = ConvertImageType(info.type), |
| 148 | .format = format_info.format, | 145 | .format = format_info.format, |
| 149 | .extent{ | 146 | .extent{ |
| 150 | .width = scale_up(info.size.width) >> samples_x, | 147 | .width = info.size.width >> samples_x, |
| 151 | .height = (is_2d ? scale_up(info.size.height) : info.size.height) >> samples_y, | 148 | .height = info.size.height >> samples_y, |
| 152 | .depth = info.size.depth, | 149 | .depth = info.size.depth, |
| 153 | }, | 150 | }, |
| 154 | .mipLevels = static_cast<u32>(info.resources.levels), | 151 | .mipLevels = static_cast<u32>(info.resources.levels), |
| @@ -163,12 +160,11 @@ constexpr VkBorderColor ConvertBorderColor(const std::array<float, 4>& color) { | |||
| 163 | }; | 160 | }; |
| 164 | } | 161 | } |
| 165 | 162 | ||
| 166 | [[nodiscard]] vk::Image MakeImage(const Device& device, const ImageInfo& info, u32 up = 1, | 163 | [[nodiscard]] vk::Image MakeImage(const Device& device, const ImageInfo& info) { |
| 167 | u32 down = 0) { | ||
| 168 | if (info.type == ImageType::Buffer) { | 164 | if (info.type == ImageType::Buffer) { |
| 169 | return vk::Image{}; | 165 | return vk::Image{}; |
| 170 | } | 166 | } |
| 171 | return device.GetLogical().CreateImage(MakeImageCreateInfo(device, info, up, down)); | 167 | return device.GetLogical().CreateImage(MakeImageCreateInfo(device, info)); |
| 172 | } | 168 | } |
| 173 | 169 | ||
| 174 | [[nodiscard]] VkImageAspectFlags ImageAspectMask(PixelFormat format) { | 170 | [[nodiscard]] VkImageAspectFlags ImageAspectMask(PixelFormat format) { |
| @@ -860,10 +856,9 @@ void TextureCacheRuntime::BlitImage(Framebuffer* dst_framebuffer, ImageView& dst | |||
| 860 | cmdbuf.PipelineBarrier(VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, | 856 | cmdbuf.PipelineBarrier(VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, |
| 861 | 0, nullptr, nullptr, read_barriers); | 857 | 0, nullptr, nullptr, read_barriers); |
| 862 | if (is_resolve) { | 858 | if (is_resolve) { |
| 863 | VkImageResolve resolve_info = | ||
| 864 | MakeImageResolve(dst_region, src_region, dst_layers, src_layers); | ||
| 865 | cmdbuf.ResolveImage(src_image, VK_IMAGE_LAYOUT_GENERAL, dst_image, | 859 | cmdbuf.ResolveImage(src_image, VK_IMAGE_LAYOUT_GENERAL, dst_image, |
| 866 | VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, resolve_info); | 860 | VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, |
| 861 | MakeImageResolve(dst_region, src_region, dst_layers, src_layers)); | ||
| 867 | } else { | 862 | } else { |
| 868 | const bool is_linear = filter == Fermi2D::Filter::Bilinear; | 863 | const bool is_linear = filter == Fermi2D::Filter::Bilinear; |
| 869 | const VkFilter vk_filter = is_linear ? VK_FILTER_LINEAR : VK_FILTER_NEAREST; | 864 | const VkFilter vk_filter = is_linear ? VK_FILTER_LINEAR : VK_FILTER_NEAREST; |
| @@ -1143,7 +1138,17 @@ bool Image::ScaleUp() { | |||
| 1143 | } | 1138 | } |
| 1144 | const auto& device = runtime->device; | 1139 | const auto& device = runtime->device; |
| 1145 | if (!scaled_image) { | 1140 | if (!scaled_image) { |
| 1146 | scaled_image = MakeImage(device, info, resolution.up_scale, resolution.down_shift); | 1141 | const u32 up = resolution.up_scale; |
| 1142 | const u32 down = resolution.down_shift; | ||
| 1143 | const auto scale = [&](u32 value) { return std::max<u32>((value * up) >> down, 1U); }; | ||
| 1144 | |||
| 1145 | const bool is_2d = info.type == ImageType::e2D; | ||
| 1146 | const u32 scaled_width = scale(info.size.width); | ||
| 1147 | const u32 scaled_height = is_2d ? scale(info.size.height) : info.size.height; | ||
| 1148 | auto scaled_info = info; | ||
| 1149 | scaled_info.size.width = scaled_width; | ||
| 1150 | scaled_info.size.height = scaled_height; | ||
| 1151 | scaled_image = MakeImage(device, scaled_info); | ||
| 1147 | auto& allocator = runtime->memory_allocator; | 1152 | auto& allocator = runtime->memory_allocator; |
| 1148 | scaled_commit = MemoryCommit(allocator.Commit(scaled_image, MemoryUsage::DeviceLocal)); | 1153 | scaled_commit = MemoryCommit(allocator.Commit(scaled_image, MemoryUsage::DeviceLocal)); |
| 1149 | } | 1154 | } |
diff --git a/src/video_core/renderer_vulkan/vk_texture_cache.h b/src/video_core/renderer_vulkan/vk_texture_cache.h index e5060e3f1..5381343e9 100644 --- a/src/video_core/renderer_vulkan/vk_texture_cache.h +++ b/src/video_core/renderer_vulkan/vk_texture_cache.h | |||
| @@ -6,7 +6,6 @@ | |||
| 6 | 6 | ||
| 7 | #include <span> | 7 | #include <span> |
| 8 | 8 | ||
| 9 | #include "common/settings.h" | ||
| 10 | #include "shader_recompiler/shader_info.h" | 9 | #include "shader_recompiler/shader_info.h" |
| 11 | #include "video_core/renderer_vulkan/vk_staging_buffer_pool.h" | 10 | #include "video_core/renderer_vulkan/vk_staging_buffer_pool.h" |
| 12 | #include "video_core/texture_cache/image_view_base.h" | 11 | #include "video_core/texture_cache/image_view_base.h" |
| @@ -14,6 +13,10 @@ | |||
| 14 | #include "video_core/vulkan_common/vulkan_memory_allocator.h" | 13 | #include "video_core/vulkan_common/vulkan_memory_allocator.h" |
| 15 | #include "video_core/vulkan_common/vulkan_wrapper.h" | 14 | #include "video_core/vulkan_common/vulkan_wrapper.h" |
| 16 | 15 | ||
| 16 | namespace Settings { | ||
| 17 | struct ResolutionScalingInfo; | ||
| 18 | } | ||
| 19 | |||
| 17 | namespace Vulkan { | 20 | namespace Vulkan { |
| 18 | 21 | ||
| 19 | using VideoCommon::ImageId; | 22 | using VideoCommon::ImageId; |
| @@ -86,7 +89,7 @@ public: | |||
| 86 | BlitImageHelper& blit_image_helper; | 89 | BlitImageHelper& blit_image_helper; |
| 87 | ASTCDecoderPass& astc_decoder_pass; | 90 | ASTCDecoderPass& astc_decoder_pass; |
| 88 | RenderPassCache& render_pass_cache; | 91 | RenderPassCache& render_pass_cache; |
| 89 | Settings::ResolutionScalingInfo resolution; | 92 | const Settings::ResolutionScalingInfo& resolution; |
| 90 | }; | 93 | }; |
| 91 | 94 | ||
| 92 | class Image : public VideoCommon::ImageBase { | 95 | class Image : public VideoCommon::ImageBase { |
diff --git a/src/video_core/texture_cache/texture_cache.h b/src/video_core/texture_cache/texture_cache.h index b708e41b5..630c73005 100644 --- a/src/video_core/texture_cache/texture_cache.h +++ b/src/video_core/texture_cache/texture_cache.h | |||
| @@ -1726,9 +1726,7 @@ void TextureCache<P>::CopyImage(ImageId dst_id, ImageId src_id, std::vector<Imag | |||
| 1726 | }; | 1726 | }; |
| 1727 | for (auto& copy : copies) { | 1727 | for (auto& copy : copies) { |
| 1728 | copy.src_offset.x = scale_up(copy.src_offset.x); | 1728 | copy.src_offset.x = scale_up(copy.src_offset.x); |
| 1729 | |||
| 1730 | copy.dst_offset.x = scale_up(copy.dst_offset.x); | 1729 | copy.dst_offset.x = scale_up(copy.dst_offset.x); |
| 1731 | |||
| 1732 | copy.extent.width = scale_up(copy.extent.width); | 1730 | copy.extent.width = scale_up(copy.extent.width); |
| 1733 | if (both_2d) { | 1731 | if (both_2d) { |
| 1734 | copy.src_offset.y = scale_up(copy.src_offset.y); | 1732 | copy.src_offset.y = scale_up(copy.src_offset.y); |