Add kTextureRowPitchAlignment and Align helper
This commit is contained in:
parent
8867e5d8df
commit
98b781527f
|
@ -24,5 +24,6 @@ static constexpr uint32_t kMaxVertexAttributes = 16u;
|
||||||
static constexpr uint32_t kMaxVertexInputs = 16u;
|
static constexpr uint32_t kMaxVertexInputs = 16u;
|
||||||
static constexpr uint32_t kNumStages = 3;
|
static constexpr uint32_t kNumStages = 3;
|
||||||
static constexpr uint32_t kMaxColorAttachments = 4u;
|
static constexpr uint32_t kMaxColorAttachments = 4u;
|
||||||
|
static constexpr uint32_t kTextureRowPitchAlignment = 256u;
|
||||||
|
|
||||||
#endif // COMMON_CONSTANTS_H_
|
#endif // COMMON_CONSTANTS_H_
|
||||||
|
|
|
@ -60,3 +60,9 @@ void* AlignVoidPtr(void* ptr, size_t alignment) {
|
||||||
ASSERT(alignment != 0);
|
ASSERT(alignment != 0);
|
||||||
return reinterpret_cast<void*>((reinterpret_cast<intptr_t>(ptr) + (alignment - 1)) & ~(alignment - 1));
|
return reinterpret_cast<void*>((reinterpret_cast<intptr_t>(ptr) + (alignment - 1)) & ~(alignment - 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint32_t Align(uint32_t value, size_t alignment) {
|
||||||
|
ASSERT(IsPowerOfTwo(alignment));
|
||||||
|
ASSERT(alignment != 0);
|
||||||
|
return (value + (alignment - 1)) & ~(alignment - 1);
|
||||||
|
}
|
||||||
|
|
|
@ -25,6 +25,7 @@ bool IsPowerOfTwo(size_t n);
|
||||||
|
|
||||||
bool IsAligned(const void* ptr, size_t alignment);
|
bool IsAligned(const void* ptr, size_t alignment);
|
||||||
void* AlignVoidPtr(void* ptr, size_t alignment);
|
void* AlignVoidPtr(void* ptr, size_t alignment);
|
||||||
|
uint32_t Align(uint32_t value, size_t alignment);
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
T* AlignPtr(T* ptr, size_t alignment) {
|
T* AlignPtr(T* ptr, size_t alignment) {
|
||||||
|
|
Loading…
Reference in New Issue