mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-21 10:49:14 +00:00
Inline CommandAllocator/Iterator
Inlining these hot functions decreases CPU time in perf tests for DrawCallPerf.Run/Vulkan by roughly 12% (55 to 47ns) and increases binary size by about 0.16% (~4kB). Bug: dawn:304 Change-Id: I84e5d011defe88d6f1492dcb54e421c3d1bf099f Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/14000 Commit-Queue: Austin Eng <enga@chromium.org> Reviewed-by: Corentin Wallez <cwallez@chromium.org>
This commit is contained in:
committed by
Commit Bot service account
parent
56b12422da
commit
ff8b3f4397
@@ -15,6 +15,8 @@
|
||||
#ifndef COMMON_MATH_H_
|
||||
#define COMMON_MATH_H_
|
||||
|
||||
#include "common/Assert.h"
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <cstring>
|
||||
@@ -35,13 +37,19 @@ bool IsAligned(uint32_t value, size_t alignment);
|
||||
uint32_t Align(uint32_t value, size_t alignment);
|
||||
|
||||
template <typename T>
|
||||
T* AlignPtr(T* ptr, size_t alignment) {
|
||||
return static_cast<T*>(AlignVoidPtr(ptr, alignment));
|
||||
DAWN_FORCE_INLINE T* AlignPtr(T* ptr, size_t alignment) {
|
||||
ASSERT(IsPowerOfTwo(alignment));
|
||||
ASSERT(alignment != 0);
|
||||
return reinterpret_cast<T*>((reinterpret_cast<size_t>(ptr) + (alignment - 1)) &
|
||||
~(alignment - 1));
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
const T* AlignPtr(const T* ptr, size_t alignment) {
|
||||
return static_cast<const T*>(AlignVoidPtr(const_cast<T*>(ptr), alignment));
|
||||
DAWN_FORCE_INLINE const T* AlignPtr(const T* ptr, size_t alignment) {
|
||||
ASSERT(IsPowerOfTwo(alignment));
|
||||
ASSERT(alignment != 0);
|
||||
return reinterpret_cast<const T*>((reinterpret_cast<size_t>(ptr) + (alignment - 1)) &
|
||||
~(alignment - 1));
|
||||
}
|
||||
|
||||
template <typename destType, typename sourceType>
|
||||
|
||||
Reference in New Issue
Block a user