summaryrefslogtreecommitdiff
path: root/src/common/alignment.h
diff options
context:
space:
mode:
authorGravatar ReinUsesLisp2019-05-10 04:17:48 -0300
committerGravatar ReinUsesLisp2019-06-20 21:36:12 -0300
commit345e73f2feb0701e3c3099d002a1c21fb524eae4 (patch)
treec8c934dfec804d04a29f8ee27124274f5f999fb8 /src/common/alignment.h
parenttexture_cache: Change internal cache from lists to vectors (diff)
downloadyuzu-345e73f2feb0701e3c3099d002a1c21fb524eae4.tar.gz
yuzu-345e73f2feb0701e3c3099d002a1c21fb524eae4.tar.xz
yuzu-345e73f2feb0701e3c3099d002a1c21fb524eae4.zip
video_core: Use un-shifted block sizes to avoid integer divisions
Instead of storing all block width, height and depths in their shifted form: block_width = 1U << block_shift; Store them like they are provided by the emulated hardware (their block_shift form). This way we can avoid doing the costly Common::AlignUp operation to align texture sizes and drop CPU integer divisions with bitwise logic (defined in Common::AlignBits).
Diffstat (limited to 'src/common/alignment.h')
-rw-r--r--src/common/alignment.h5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/common/alignment.h b/src/common/alignment.h
index d94a2291f..3379a6967 100644
--- a/src/common/alignment.h
+++ b/src/common/alignment.h
@@ -20,6 +20,11 @@ constexpr T AlignDown(T value, std::size_t size) {
20} 20}
21 21
22template <typename T> 22template <typename T>
23constexpr T AlignBits(T value, T align) {
24 return (value + ((1 << align) - 1)) >> align << align;
25}
26
27template <typename T>
23constexpr bool Is4KBAligned(T value) { 28constexpr bool Is4KBAligned(T value) {
24 static_assert(std::is_unsigned_v<T>, "T must be an unsigned value."); 29 static_assert(std::is_unsigned_v<T>, "T must be an unsigned value.");
25 return (value & 0xFFF) == 0; 30 return (value & 0xFFF) == 0;