summaryrefslogtreecommitdiff
path: root/src/common/alignment.h
diff options
context:
space:
mode:
authorGravatar Jannik Vogel2016-03-11 16:15:36 +0100
committerGravatar Jannik Vogel2016-03-13 04:54:23 +0100
commita66c186e81ba88b8ce5a9ef041e3839454dd70ab (patch)
tree22939821529744351ef1fa1eb11b87c146774b48 /src/common/alignment.h
parentMerge pull request #1506 from lioncash/enum (diff)
downloadyuzu-a66c186e81ba88b8ce5a9ef041e3839454dd70ab.tar.gz
yuzu-a66c186e81ba88b8ce5a9ef041e3839454dd70ab.tar.xz
yuzu-a66c186e81ba88b8ce5a9ef041e3839454dd70ab.zip
PICA: Align vertex attributes
Diffstat (limited to 'src/common/alignment.h')
-rw-r--r--src/common/alignment.h22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/common/alignment.h b/src/common/alignment.h
new file mode 100644
index 000000000..b77da4a92
--- /dev/null
+++ b/src/common/alignment.h
@@ -0,0 +1,22 @@
1// This file is under the public domain.
2
3#pragma once
4
5#include <cstddef>
6#include <type_traits>
7
8namespace Common {
9
10template <typename T>
11constexpr T AlignUp(T value, size_t size) {
12 static_assert(std::is_unsigned<T>::value, "T must be an unsigned value.");
13 return static_cast<T>(value + (size - value % size) % size);
14}
15
16template <typename T>
17constexpr T AlignDown(T value, size_t size) {
18 static_assert(std::is_unsigned<T>::value, "T must be an unsigned value.");
19 return static_cast<T>(value - value % size);
20}
21
22} // namespace Common