mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-21 10:49:14 +00:00
CommandAllocator: Default initalize allocated data.
BUG=dawn:21 Change-Id: I98499385d7397ab431e1bbe00add7ef01941cca6 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/7160 Reviewed-by: Austin Eng <enga@chromium.org> Reviewed-by: Kai Ninomiya <kainino@chromium.org> Commit-Queue: Corentin Wallez <cwallez@chromium.org>
This commit is contained in:
committed by
Commit Bot service account
parent
97f08fa2e6
commit
2e56970932
@@ -113,14 +113,26 @@ namespace dawn_native {
|
||||
static_assert(sizeof(E) == sizeof(uint32_t), "");
|
||||
static_assert(alignof(E) == alignof(uint32_t), "");
|
||||
static_assert(alignof(T) <= kMaxSupportedAlignment, "");
|
||||
return reinterpret_cast<T*>(
|
||||
T* result = reinterpret_cast<T*>(
|
||||
Allocate(static_cast<uint32_t>(commandId), sizeof(T), alignof(T)));
|
||||
if (!result) {
|
||||
return nullptr;
|
||||
}
|
||||
new (result) T;
|
||||
return result;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
T* AllocateData(size_t count) {
|
||||
static_assert(alignof(T) <= kMaxSupportedAlignment, "");
|
||||
return reinterpret_cast<T*>(AllocateData(sizeof(T) * count, alignof(T)));
|
||||
T* result = reinterpret_cast<T*>(AllocateData(sizeof(T) * count, alignof(T)));
|
||||
if (!result) {
|
||||
return nullptr;
|
||||
}
|
||||
for (size_t i = 0; i < count; i++) {
|
||||
new (result + i) T;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
Reference in New Issue
Block a user