mirror of
https://github.com/yuzu-emu/yuzu.git
synced 2024-07-04 23:31:19 +01:00
Texture Cache: fix scaling on upload and stop scaling on base resolution.
This commit is contained in:
parent
68e038404c
commit
c5bbbf3902
1 changed files with 32 additions and 14 deletions
|
@ -1053,6 +1053,10 @@ Image::~Image() = default;
|
||||||
|
|
||||||
void Image::UploadMemory(const StagingBufferRef& map, std::span<const BufferImageCopy> copies) {
|
void Image::UploadMemory(const StagingBufferRef& map, std::span<const BufferImageCopy> copies) {
|
||||||
// TODO: Move this to another API
|
// TODO: Move this to another API
|
||||||
|
const bool is_rescaled = True(flags & ImageFlagBits::Rescaled);
|
||||||
|
if (is_rescaled) {
|
||||||
|
ScaleDown(true);
|
||||||
|
}
|
||||||
scheduler->RequestOutsideRenderPassOperationContext();
|
scheduler->RequestOutsideRenderPassOperationContext();
|
||||||
std::vector vk_copies = TransformBufferImageCopies(copies, map.offset, aspect_mask);
|
std::vector vk_copies = TransformBufferImageCopies(copies, map.offset, aspect_mask);
|
||||||
const VkBuffer src_buffer = map.buffer;
|
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) {
|
vk_copies](vk::CommandBuffer cmdbuf) {
|
||||||
CopyBufferToImage(cmdbuf, src_buffer, vk_image, vk_aspect_mask, is_initialized, vk_copies);
|
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) {
|
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);
|
ASSERT(info.type != ImageType::Linear);
|
||||||
scaling_count++;
|
scaling_count++;
|
||||||
ASSERT(scaling_count < 10);
|
|
||||||
flags |= ImageFlagBits::Rescaled;
|
flags |= ImageFlagBits::Rescaled;
|
||||||
/*if (!runtime->is_rescaling_on) {
|
if (!runtime->is_rescaling_on) {
|
||||||
return;
|
return true;
|
||||||
}*/
|
}
|
||||||
|
|
||||||
const auto& resolution = runtime->resolution;
|
const auto& resolution = runtime->resolution;
|
||||||
vk::Image rescaled_image =
|
vk::Image rescaled_image =
|
||||||
MakeImage(runtime->device, info, resolution.up_scale, resolution.down_shift);
|
has_backup ? std::move(backup_image)
|
||||||
MemoryCommit new_commit(
|
: MakeImage(runtime->device, info, resolution.up_scale, resolution.down_shift);
|
||||||
runtime->memory_allocator.Commit(rescaled_image, MemoryUsage::DeviceLocal));
|
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({
|
SCOPE_EXIT({
|
||||||
if (save_as_backup) {
|
if (save_as_backup) {
|
||||||
backup_image = std::move(image);
|
backup_image = std::move(image);
|
||||||
|
@ -1175,6 +1188,9 @@ bool Image::ScaleUp(bool save_as_backup) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Image::SwapBackup() {
|
void Image::SwapBackup() {
|
||||||
|
if (!runtime->is_rescaling_on) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
ASSERT(has_backup);
|
ASSERT(has_backup);
|
||||||
runtime->prescaled_images.Push(std::move(image));
|
runtime->prescaled_images.Push(std::move(image));
|
||||||
runtime->prescaled_commits.Push(std::move(commit));
|
runtime->prescaled_commits.Push(std::move(commit));
|
||||||
|
@ -1190,16 +1206,18 @@ bool Image::ScaleDown(bool save_as_backup) {
|
||||||
ASSERT(info.type != ImageType::Linear);
|
ASSERT(info.type != ImageType::Linear);
|
||||||
flags &= ~ImageFlagBits::Rescaled;
|
flags &= ~ImageFlagBits::Rescaled;
|
||||||
scaling_count++;
|
scaling_count++;
|
||||||
ASSERT(scaling_count < 10);
|
if (!runtime->is_rescaling_on) {
|
||||||
/*if (!runtime->is_rescaling_on) {
|
return true;
|
||||||
return false;
|
}
|
||||||
}*/
|
|
||||||
|
|
||||||
const auto& resolution = runtime->resolution;
|
const auto& resolution = runtime->resolution;
|
||||||
vk::Image downscaled_image = MakeImage(runtime->device, info);
|
vk::Image downscaled_image =
|
||||||
MemoryCommit new_commit(
|
has_backup ? std::move(backup_image) : MakeImage(runtime->device, info);
|
||||||
runtime->memory_allocator.Commit(downscaled_image, MemoryUsage::DeviceLocal));
|
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) {
|
if (aspect_mask == 0) {
|
||||||
aspect_mask = ImageAspectMask(info.format);
|
aspect_mask = ImageAspectMask(info.format);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue