texture_cache: Refactor scaled image size calculation
This commit is contained in:
parent
237a43004f
commit
88ef04dbaf
@ -852,18 +852,23 @@ void TextureCache<P>::InvalidateScale(Image& image) {
|
|||||||
has_deleted_images = true;
|
has_deleted_images = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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>
|
template <class P>
|
||||||
bool TextureCache<P>::ScaleUp(Image& image) {
|
bool TextureCache<P>::ScaleUp(Image& image) {
|
||||||
const bool rescaled = image.ScaleUp();
|
const bool rescaled = image.ScaleUp();
|
||||||
if (!rescaled) {
|
if (!rescaled) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
const auto& add_to_size = Settings::values.resolution_info.up_factor - 1.0f;
|
total_used_memory += GetScaledImageSizeBytes(image);
|
||||||
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;
|
|
||||||
InvalidateScale(image);
|
InvalidateScale(image);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -874,12 +879,7 @@ bool TextureCache<P>::ScaleDown(Image& image) {
|
|||||||
if (!rescaled) {
|
if (!rescaled) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
const auto& add_to_size = Settings::values.resolution_info.up_factor - 1.0f;
|
total_used_memory += GetScaledImageSizeBytes(image);
|
||||||
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;
|
|
||||||
InvalidateScale(image);
|
InvalidateScale(image);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -339,6 +339,7 @@ private:
|
|||||||
void InvalidateScale(Image& image);
|
void InvalidateScale(Image& image);
|
||||||
bool ScaleUp(Image& image);
|
bool ScaleUp(Image& image);
|
||||||
bool ScaleDown(Image& image);
|
bool ScaleDown(Image& image);
|
||||||
|
u64 GetScaledImageSizeBytes(Image& image);
|
||||||
|
|
||||||
Runtime& runtime;
|
Runtime& runtime;
|
||||||
VideoCore::RasterizerInterface& rasterizer;
|
VideoCore::RasterizerInterface& rasterizer;
|
||||||
|
Loading…
Reference in New Issue
Block a user