5#ifndef FLUTTER_IMPELLER_CORE_HOST_BUFFER_H_
6#define FLUTTER_IMPELLER_CORE_HOST_BUFFER_H_
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),
92 template <
class BufferType,
93 class = std::enable_if_t<std::is_standard_layout_v<BufferType>>>
137 [[nodiscard]] std::tuple<Range, std::shared_ptr<DeviceBuffer>>
140 std::tuple<Range, std::shared_ptr<DeviceBuffer>>
143 std::tuple<Range, std::shared_ptr<DeviceBuffer>>
144 EmplaceInternal(
const void*
buffer,
size_t length,
size_t align);
146 size_t GetLength()
const {
return offset_; }
148 void MaybeCreateNewBuffer();
150 const std::shared_ptr<DeviceBuffer>& GetCurrentBuffer()
const;
154 explicit HostBuffer(
const std::shared_ptr<Allocator>& allocator);
160 std::shared_ptr<Allocator> allocator_;
163 size_t current_buffer_ = 0u;
165 size_t frame_index_ = 0u;
static sk_sp< Effect > Create()
void SetLabel(std::string label)
TestStateQuery GetStateForTest()
Retrieve internal buffer state for test expectations.
BufferView Emplace(const BufferType &buffer)
Emplace non-uniform data (like contiguous vertices) onto the host buffer.
BufferView EmplaceUniform(const UniformType &uniform)
Emplace uniform data onto the host buffer. Ensure that backend specific uniform alignment requirement...
BufferView EmplaceStorageBuffer(const StorageBufferType &buffer)
Emplace storage buffer data onto the host buffer. Ensure that backend specific uniform alignment requ...
std::function< void(uint8_t *buffer)> EmplaceProc
void Reset()
Resets the contents of the HostBuffer to nothing so it can be reused.
static const uint8_t buffer[]
static const constexpr size_t kHostBufferArenaSize
Approximately the same size as the max frames in flight.
constexpr size_t DefaultUniformAlignment()
Test only internal state.
size_t total_buffer_count