2
1
Fork 0
mirror of https://github.com/yuzu-emu/yuzu.git synced 2024-07-04 23:31:19 +01:00

Merge pull request #5836 from ReinUsesLisp/unaligned-constr-sched

vk_scheduler: Fix unaligned placement new expressions
This commit is contained in:
LC 2021-01-28 10:53:15 -05:00 committed by GitHub
commit 16818e952c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -6,10 +6,12 @@
#include <atomic> #include <atomic>
#include <condition_variable> #include <condition_variable>
#include <cstddef>
#include <memory> #include <memory>
#include <stack> #include <stack>
#include <thread> #include <thread>
#include <utility> #include <utility>
#include "common/alignment.h"
#include "common/common_types.h" #include "common/common_types.h"
#include "common/threadsafe_queue.h" #include "common/threadsafe_queue.h"
#include "video_core/vulkan_common/vulkan_wrapper.h" #include "video_core/vulkan_common/vulkan_wrapper.h"
@ -130,12 +132,11 @@ private:
using FuncType = TypedCommand<T>; using FuncType = TypedCommand<T>;
static_assert(sizeof(FuncType) < sizeof(data), "Lambda is too large"); static_assert(sizeof(FuncType) < sizeof(data), "Lambda is too large");
command_offset = Common::AlignUp(command_offset, alignof(FuncType));
if (command_offset > sizeof(data) - sizeof(FuncType)) { if (command_offset > sizeof(data) - sizeof(FuncType)) {
return false; return false;
} }
Command* const current_last = last;
Command* current_last = last;
last = new (data.data() + command_offset) FuncType(std::move(command)); last = new (data.data() + command_offset) FuncType(std::move(command));
if (current_last) { if (current_last) {
@ -143,7 +144,6 @@ private:
} else { } else {
first = last; first = last;
} }
command_offset += sizeof(FuncType); command_offset += sizeof(FuncType);
return true; return true;
} }
@ -156,8 +156,8 @@ private:
Command* first = nullptr; Command* first = nullptr;
Command* last = nullptr; Command* last = nullptr;
std::size_t command_offset = 0; size_t command_offset = 0;
std::array<u8, 0x8000> data{}; alignas(std::max_align_t) std::array<u8, 0x8000> data{};
}; };
struct State { struct State {