5 #ifndef FLUTTER_IMPELLER_CORE_HOST_BUFFER_H_
6 #define FLUTTER_IMPELLER_CORE_HOST_BUFFER_H_
13 #include <type_traits>
30 static std::shared_ptr<HostBuffer>
Create(
31 const std::shared_ptr<Allocator>& allocator);
48 template <
class UniformType,
49 class = std::enable_if_t<std::is_standard_layout_v<UniformType>>>
51 const auto alignment =
53 return Emplace(
reinterpret_cast<const void*
>(&uniform),
70 class StorageBufferType,
71 class = std::enable_if_t<std::is_standard_layout_v<StorageBufferType>>>
73 const StorageBufferType& buffer) {
74 const auto alignment =
77 sizeof(StorageBufferType),
93 template <
class BufferType,
94 class = std::enable_if_t<std::is_standard_layout_v<BufferType>>>
96 size_t alignment = 0) {
97 return Emplace(
reinterpret_cast<const void*
>(&buffer),
99 std::max(alignment,
alignof(BufferType))
139 [[nodiscard]] std::tuple<Range, std::shared_ptr<DeviceBuffer>>
140 EmplaceInternal(
const void* buffer,
size_t length);
142 std::tuple<Range, std::shared_ptr<DeviceBuffer>>
143 EmplaceInternal(
size_t length,
size_t align,
const EmplaceProc& cb);
145 std::tuple<Range, std::shared_ptr<DeviceBuffer>>
146 EmplaceInternal(
const void* buffer,
size_t length,
size_t align);
148 size_t GetLength()
const {
return offset_; }
150 void MaybeCreateNewBuffer();
152 const std::shared_ptr<DeviceBuffer>& GetCurrentBuffer()
const;
156 explicit HostBuffer(
const std::shared_ptr<Allocator>& allocator);
162 std::shared_ptr<Allocator> allocator_;
165 size_t current_buffer_ = 0u;
167 size_t frame_index_ = 0u;
173 #endif // FLUTTER_IMPELLER_CORE_HOST_BUFFER_H_