summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorameerj <52414509+ameerj@users.noreply.github.com>2021-10-05 06:07:51 +0200
committerFernando Sahmkow <fsahmkow27@gmail.com>2021-11-16 22:11:30 +0100
commit88ef04dbaf26ab83ec85bfa3c68434c283c66e50 (patch)
treea665955df2300f63ac774a4101ec00959024a620
parentTexture Cache: Fix calculations when scaling. (diff)
downloadyuzu-88ef04dbaf26ab83ec85bfa3c68434c283c66e50.tar
yuzu-88ef04dbaf26ab83ec85bfa3c68434c283c66e50.tar.gz
yuzu-88ef04dbaf26ab83ec85bfa3c68434c283c66e50.tar.bz2
yuzu-88ef04dbaf26ab83ec85bfa3c68434c283c66e50.tar.lz
yuzu-88ef04dbaf26ab83ec85bfa3c68434c283c66e50.tar.xz
yuzu-88ef04dbaf26ab83ec85bfa3c68434c283c66e50.tar.zst
yuzu-88ef04dbaf26ab83ec85bfa3c68434c283c66e50.zip
-rw-r--r--src/video_core/texture_cache/texture_cache.h24
-rw-r--r--src/video_core/texture_cache/texture_cache_base.h1
2 files changed, 13 insertions, 12 deletions
diff --git a/src/video_core/texture_cache/texture_cache.h b/src/video_core/texture_cache/texture_cache.h
index 691198853..b708e41b5 100644
--- a/src/video_core/texture_cache/texture_cache.h
+++ b/src/video_core/texture_cache/texture_cache.h
@@ -853,17 +853,22 @@ void TextureCache<P>::InvalidateScale(Image& image) {
}
template <class P>
+u64 TextureCache<P>::GetScaledImageSizeBytes(Image& image) {
+ const f32 add_to_size = Settings::values.resolution_info.up_factor - 1.0f;
+ const bool sign = std::signbit(add_to_size);
+ const u32 image_size_bytes = std::max(image.guest_size_bytes, image.unswizzled_size_bytes);
+ const u64 tentative_size = static_cast<u64>(image_size_bytes * std::abs(add_to_size));
+ const u64 fitted_size = Common::AlignUp(tentative_size, 1024);
+ return sign ? -fitted_size : fitted_size;
+}
+
+template <class P>
bool TextureCache<P>::ScaleUp(Image& image) {
const bool rescaled = image.ScaleUp();
if (!rescaled) {
return false;
}
- const auto& add_to_size = Settings::values.resolution_info.up_factor - 1.0f;
- const auto sign = std::signbit(add_to_size);
- const u64 tentative_size = static_cast<u64>(
- std::max(image.guest_size_bytes, image.unswizzled_size_bytes) * std::abs(add_to_size));
- const u64 fitted_size = Common::AlignUp(tentative_size, 1024);
- total_used_memory += sign ? -fitted_size : fitted_size;
+ total_used_memory += GetScaledImageSizeBytes(image);
InvalidateScale(image);
return true;
}
@@ -874,12 +879,7 @@ bool TextureCache<P>::ScaleDown(Image& image) {
if (!rescaled) {
return false;
}
- const auto& add_to_size = Settings::values.resolution_info.up_factor - 1.0f;
- const auto sign = std::signbit(add_to_size);
- const u64 tentative_size = static_cast<u64>(
- std::max(image.guest_size_bytes, image.unswizzled_size_bytes) * std::abs(add_to_size));
- const u64 fitted_size = Common::AlignUp(tentative_size, 1024);
- total_used_memory += sign ? fitted_size : -fitted_size;
+ total_used_memory += GetScaledImageSizeBytes(image);
InvalidateScale(image);
return true;
}
diff --git a/src/video_core/texture_cache/texture_cache_base.h b/src/video_core/texture_cache/texture_cache_base.h
index 517a4c224..40e003b60 100644
--- a/src/video_core/texture_cache/texture_cache_base.h
+++ b/src/video_core/texture_cache/texture_cache_base.h
@@ -339,6 +339,7 @@ private:
void InvalidateScale(Image& image);
bool ScaleUp(Image& image);
bool ScaleDown(Image& image);
+ u64 GetScaledImageSizeBytes(Image& image);
Runtime& runtime;
VideoCore::RasterizerInterface& rasterizer;