5 #ifndef FLUTTER_IMPELLER_CORE_HOST_BUFFER_H_
6 #define FLUTTER_IMPELLER_CORE_HOST_BUFFER_H_
11 #include <type_traits>
22 static std::shared_ptr<HostBuffer>
Create();
39 template <
class UniformType,
40 class = std::enable_if_t<std::is_standard_layout_v<UniformType>>>
42 const auto alignment =
44 return Emplace(
reinterpret_cast<const void*
>(&uniform),
61 class StorageBufferType,
62 class = std::enable_if_t<std::is_standard_layout_v<StorageBufferType>>>
64 const StorageBufferType& buffer) {
65 const auto alignment =
68 sizeof(StorageBufferType),
83 template <
class BufferType,
84 class = std::enable_if_t<std::is_standard_layout_v<BufferType>>>
86 return Emplace(
reinterpret_cast<const void*
>(&buffer),
128 std::shared_ptr<const DeviceBuffer> GetDeviceBuffer(
131 [[nodiscard]] std::pair<uint8_t*, Range>
Emplace(
const void* buffer,
134 std::pair<uint8_t*, Range>
Emplace(
size_t length,
138 std::pair<uint8_t*, Range>
Emplace(
const void* buffer,
144 mutable std::shared_ptr<DeviceBuffer> device_buffer;
145 mutable size_t device_buffer_generation = 0u;
146 size_t generation = 1u;
150 std::shared_ptr<HostBufferState> state_ = std::make_shared<HostBufferState>();
153 std::shared_ptr<const DeviceBuffer> GetDeviceBuffer(
167 #endif // FLUTTER_IMPELLER_CORE_HOST_BUFFER_H_