Round up when calculating size of compressed texture in bytes

This commit is contained in:
Robin Kertels 2022-03-04 10:05:31 +01:00 committed by PixelyIon
parent d889550e84
commit 43879e2476
2 changed files with 10 additions and 1 deletions

View File

@ -105,6 +105,15 @@ namespace skyline::util {
return IsAligned(value, WORD_BIT / 8);
}
/**
* @return The value of division rounded up to the next integral
*/
template<typename Type>
requires std::is_integral_v<Type>
constexpr Type DivideCeil(Type dividend, Type divisor) {
return (dividend + divisor - 1) / divisor;
}
/**
* @param string The string to create a magic from
* @return The magic of the supplied string

View File

@ -80,7 +80,7 @@ namespace skyline::gpu {
* @return The size of the texture in bytes
*/
constexpr size_t GetSize(u32 width, u32 height, u32 depth = 1) const {
return (((width / blockWidth) * (height / blockHeight)) * bpb) * depth;
return util::DivideCeil(width, u32{blockWidth}) * util::DivideCeil(height, u32{blockHeight}) * bpb * depth;
}
constexpr size_t GetSize(Dimensions dimensions) const {