diff options
author | Fernando Sahmkow <fsahmkow27@gmail.com> | 2021-08-27 23:24:05 +0200 |
---|---|---|
committer | Fernando Sahmkow <fsahmkow27@gmail.com> | 2021-11-16 22:11:29 +0100 |
commit | c5bbbf3902d97fc89775d6db5e5bebd3929ca24b (patch) | |
tree | 39a09874f5aac5d689b6d64ea2039b79d5ed0da9 /src/video_core/renderer_vulkan/vk_texture_cache.cpp | |
parent | shader, video_core: Fix GCC build errors (diff) | |
download | yuzu-c5bbbf3902d97fc89775d6db5e5bebd3929ca24b.tar yuzu-c5bbbf3902d97fc89775d6db5e5bebd3929ca24b.tar.gz yuzu-c5bbbf3902d97fc89775d6db5e5bebd3929ca24b.tar.bz2 yuzu-c5bbbf3902d97fc89775d6db5e5bebd3929ca24b.tar.lz yuzu-c5bbbf3902d97fc89775d6db5e5bebd3929ca24b.tar.xz yuzu-c5bbbf3902d97fc89775d6db5e5bebd3929ca24b.tar.zst yuzu-c5bbbf3902d97fc89775d6db5e5bebd3929ca24b.zip |
Diffstat (limited to 'src/video_core/renderer_vulkan/vk_texture_cache.cpp')
-rw-r--r-- | src/video_core/renderer_vulkan/vk_texture_cache.cpp | 46 |
1 files changed, 32 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 3400066a6..9afe49387 100644 --- a/src/video_core/renderer_vulkan/vk_texture_cache.cpp +++ b/src/video_core/renderer_vulkan/vk_texture_cache.cpp @@ -1053,6 +1053,10 @@ Image::~Image() = default; void Image::UploadMemory(const StagingBufferRef& map, std::span<const BufferImageCopy> copies) { // TODO: Move this to another API + const bool is_rescaled = True(flags & ImageFlagBits::Rescaled); + if (is_rescaled) { + ScaleDown(true); + } scheduler->RequestOutsideRenderPassOperationContext(); std::vector vk_copies = TransformBufferImageCopies(copies, map.offset, aspect_mask); const VkBuffer src_buffer = map.buffer; @@ -1063,6 +1067,9 @@ void Image::UploadMemory(const StagingBufferRef& map, std::span<const BufferImag vk_copies](vk::CommandBuffer cmdbuf) { CopyBufferToImage(cmdbuf, src_buffer, vk_image, vk_aspect_mask, is_initialized, vk_copies); }); + if (is_rescaled) { + ScaleUp(true); + } } void Image::DownloadMemory(const StagingBufferRef& map, std::span<const BufferImageCopy> copies) { @@ -1133,17 +1140,23 @@ bool Image::ScaleUp(bool save_as_backup) { } ASSERT(info.type != ImageType::Linear); scaling_count++; - ASSERT(scaling_count < 10); flags |= ImageFlagBits::Rescaled; - /*if (!runtime->is_rescaling_on) { - return; - }*/ + if (!runtime->is_rescaling_on) { + return true; + } + const auto& resolution = runtime->resolution; vk::Image rescaled_image = - MakeImage(runtime->device, info, resolution.up_scale, resolution.down_shift); - MemoryCommit new_commit( - runtime->memory_allocator.Commit(rescaled_image, MemoryUsage::DeviceLocal)); + has_backup ? std::move(backup_image) + : MakeImage(runtime->device, info, resolution.up_scale, resolution.down_shift); + MemoryCommit new_commit = has_backup ? std::move(backup_commit) + : MemoryCommit(runtime->memory_allocator.Commit( + rescaled_image, MemoryUsage::DeviceLocal)); + has_backup = false; + if (aspect_mask == 0) { + aspect_mask = ImageAspectMask(info.format); + } SCOPE_EXIT({ if (save_as_backup) { backup_image = std::move(image); @@ -1175,6 +1188,9 @@ bool Image::ScaleUp(bool save_as_backup) { } void Image::SwapBackup() { + if (!runtime->is_rescaling_on) { + return; + } ASSERT(has_backup); runtime->prescaled_images.Push(std::move(image)); runtime->prescaled_commits.Push(std::move(commit)); @@ -1190,16 +1206,18 @@ bool Image::ScaleDown(bool save_as_backup) { ASSERT(info.type != ImageType::Linear); flags &= ~ImageFlagBits::Rescaled; scaling_count++; - ASSERT(scaling_count < 10); - /*if (!runtime->is_rescaling_on) { - return false; - }*/ + if (!runtime->is_rescaling_on) { + return true; + } const auto& resolution = runtime->resolution; - vk::Image downscaled_image = MakeImage(runtime->device, info); - MemoryCommit new_commit( - runtime->memory_allocator.Commit(downscaled_image, MemoryUsage::DeviceLocal)); + vk::Image downscaled_image = + has_backup ? std::move(backup_image) : MakeImage(runtime->device, info); + MemoryCommit new_commit = has_backup ? std::move(backup_commit) + : MemoryCommit(runtime->memory_allocator.Commit( + downscaled_image, MemoryUsage::DeviceLocal)); + has_backup = false; if (aspect_mask == 0) { aspect_mask = ImageAspectMask(info.format); } |