diff options
| author | 2021-01-27 22:19:59 -0300 | |
|---|---|---|
| committer | 2021-01-27 22:28:22 -0300 | |
| commit | 9e88ad8da9c698f38e25e3d9b23feb19b30f68bd (patch) | |
| tree | 40ad268d89255944d552a044ab692e60b0f622c4 | |
| parent | Merge pull request #5778 from ReinUsesLisp/shader-dir (diff) | |
| download | yuzu-9e88ad8da9c698f38e25e3d9b23feb19b30f68bd.tar.gz yuzu-9e88ad8da9c698f38e25e3d9b23feb19b30f68bd.tar.xz yuzu-9e88ad8da9c698f38e25e3d9b23feb19b30f68bd.zip | |
vk_scheduler: Fix unaligned placement new expressions
We were accidentaly creating an object in an unaligned memory address.
Fix this by manually aligning the offset.
| -rw-r--r-- | src/video_core/renderer_vulkan/vk_scheduler.h | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/video_core/renderer_vulkan/vk_scheduler.h b/src/video_core/renderer_vulkan/vk_scheduler.h index 4cd43e425..15f2987eb 100644 --- a/src/video_core/renderer_vulkan/vk_scheduler.h +++ b/src/video_core/renderer_vulkan/vk_scheduler.h | |||
| @@ -6,10 +6,12 @@ | |||
| 6 | 6 | ||
| 7 | #include <atomic> | 7 | #include <atomic> |
| 8 | #include <condition_variable> | 8 | #include <condition_variable> |
| 9 | #include <cstddef> | ||
| 9 | #include <memory> | 10 | #include <memory> |
| 10 | #include <stack> | 11 | #include <stack> |
| 11 | #include <thread> | 12 | #include <thread> |
| 12 | #include <utility> | 13 | #include <utility> |
| 14 | #include "common/alignment.h" | ||
| 13 | #include "common/common_types.h" | 15 | #include "common/common_types.h" |
| 14 | #include "common/threadsafe_queue.h" | 16 | #include "common/threadsafe_queue.h" |
| 15 | #include "video_core/vulkan_common/vulkan_wrapper.h" | 17 | #include "video_core/vulkan_common/vulkan_wrapper.h" |
| @@ -130,12 +132,11 @@ private: | |||
| 130 | using FuncType = TypedCommand<T>; | 132 | using FuncType = TypedCommand<T>; |
| 131 | static_assert(sizeof(FuncType) < sizeof(data), "Lambda is too large"); | 133 | static_assert(sizeof(FuncType) < sizeof(data), "Lambda is too large"); |
| 132 | 134 | ||
| 135 | command_offset = Common::AlignUp(command_offset, alignof(FuncType)); | ||
| 133 | if (command_offset > sizeof(data) - sizeof(FuncType)) { | 136 | if (command_offset > sizeof(data) - sizeof(FuncType)) { |
| 134 | return false; | 137 | return false; |
| 135 | } | 138 | } |
| 136 | 139 | Command* const current_last = last; | |
| 137 | Command* current_last = last; | ||
| 138 | |||
| 139 | last = new (data.data() + command_offset) FuncType(std::move(command)); | 140 | last = new (data.data() + command_offset) FuncType(std::move(command)); |
| 140 | 141 | ||
| 141 | if (current_last) { | 142 | if (current_last) { |
| @@ -143,7 +144,6 @@ private: | |||
| 143 | } else { | 144 | } else { |
| 144 | first = last; | 145 | first = last; |
| 145 | } | 146 | } |
| 146 | |||
| 147 | command_offset += sizeof(FuncType); | 147 | command_offset += sizeof(FuncType); |
| 148 | return true; | 148 | return true; |
| 149 | } | 149 | } |
| @@ -156,8 +156,8 @@ private: | |||
| 156 | Command* first = nullptr; | 156 | Command* first = nullptr; |
| 157 | Command* last = nullptr; | 157 | Command* last = nullptr; |
| 158 | 158 | ||
| 159 | std::size_t command_offset = 0; | 159 | size_t command_offset = 0; |
| 160 | std::array<u8, 0x8000> data{}; | 160 | alignas(std::max_align_t) std::array<u8, 0x8000> data{}; |
| 161 | }; | 161 | }; |
| 162 | 162 | ||
| 163 | struct State { | 163 | struct State { |