Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Classes | Public Types | Public Member Functions | Static Public Member Functions | List of all members
impeller::HostBuffer Class Reference

#include <host_buffer.h>

Classes

struct  TestStateQuery
 Test only internal state. More...
 

Public Types

using EmplaceProc = std::function< void(uint8_t *buffer)>
 

Public Member Functions

virtual ~HostBuffer ()
 
void SetLabel (std::string label)
 
template<class UniformType , class = std::enable_if_t<std::is_standard_layout_v<UniformType>>>
BufferView EmplaceUniform (const UniformType &uniform)
 Emplace uniform data onto the host buffer. Ensure that backend specific uniform alignment requirements are respected.
 
template<class StorageBufferType , class = std::enable_if_t<std::is_standard_layout_v<StorageBufferType>>>
BufferView EmplaceStorageBuffer (const StorageBufferType &buffer)
 Emplace storage buffer data onto the host buffer. Ensure that backend specific uniform alignment requirements are respected.
 
template<class BufferType , class = std::enable_if_t<std::is_standard_layout_v<BufferType>>>
BufferView Emplace (const BufferType &buffer)
 Emplace non-uniform data (like contiguous vertices) onto the host buffer.
 
BufferView Emplace (const void *buffer, size_t length, size_t align)
 
BufferView Emplace (size_t length, size_t align, const EmplaceProc &cb)
 Emplaces undefined data onto the managed buffer and gives the caller a chance to update it using the specified callback. The buffer is guaranteed to have enough space for length bytes. It is the responsibility of the caller to not exceed the bounds of the buffer returned in the EmplaceProc.
 
void Reset ()
 Resets the contents of the HostBuffer to nothing so it can be reused.
 
TestStateQuery GetStateForTest ()
 Retrieve internal buffer state for test expectations.
 

Static Public Member Functions

static std::shared_ptr< HostBufferCreate (const std::shared_ptr< Allocator > &allocator)
 

Detailed Description

The host buffer class manages one more 1024 Kb blocks of device buffer allocations.

These are reset per-frame.

Definition at line 28 of file host_buffer.h.

Member Typedef Documentation

◆ EmplaceProc

using impeller::HostBuffer::EmplaceProc = std::function<void(uint8_t* buffer)>

Definition at line 105 of file host_buffer.h.

Constructor & Destructor Documentation

◆ ~HostBuffer()

impeller::HostBuffer::~HostBuffer ( )
virtualdefault

Member Function Documentation

◆ Create()

std::shared_ptr< HostBuffer > impeller::HostBuffer::Create ( const std::shared_ptr< Allocator > &  allocator)
static

Definition at line 20 of file host_buffer.cc.

21 {
22 return std::shared_ptr<HostBuffer>(new HostBuffer(allocator));
23}

◆ Emplace() [1/3]

template<class BufferType , class = std::enable_if_t<std::is_standard_layout_v<BufferType>>>
BufferView impeller::HostBuffer::Emplace ( const BufferType &  buffer)
inline

Emplace non-uniform data (like contiguous vertices) onto the host buffer.

Parameters
[in]bufferThe buffer data.
Template Parameters
BufferTypeThe type of the buffer data.
Returns
The buffer view.

Definition at line 94 of file host_buffer.h.

94 {
95 return Emplace(reinterpret_cast<const void*>(&buffer), // buffer
96 sizeof(BufferType), // size
97 alignof(BufferType) // alignment
98 );
99 }
BufferView Emplace(const BufferType &buffer)
Emplace non-uniform data (like contiguous vertices) onto the host buffer.
Definition host_buffer.h:94
static const uint8_t buffer[]

◆ Emplace() [2/3]

BufferView impeller::HostBuffer::Emplace ( const void *  buffer,
size_t  length,
size_t  align 
)

Definition at line 41 of file host_buffer.cc.

43 {
44 auto [range, device_buffer] = EmplaceInternal(buffer, length, align);
45 if (!device_buffer) {
46 return {};
47 }
48 return BufferView{std::move(device_buffer), range};
49}
size_t length

◆ Emplace() [3/3]

BufferView impeller::HostBuffer::Emplace ( size_t  length,
size_t  align,
const EmplaceProc cb 
)

Emplaces undefined data onto the managed buffer and gives the caller a chance to update it using the specified callback. The buffer is guaranteed to have enough space for length bytes. It is the responsibility of the caller to not exceed the bounds of the buffer returned in the EmplaceProc.

Parameters
[in]cbA callback that will be passed a ptr to the underlying host buffer.
Returns
The buffer view.

Definition at line 59 of file host_buffer.cc.

61 {
62 auto [range, device_buffer] = EmplaceInternal(length, align, cb);
63 if (!device_buffer) {
64 return {};
65 }
66 return BufferView{std::move(device_buffer), range};
67}

◆ EmplaceStorageBuffer()

template<class StorageBufferType , class = std::enable_if_t<std::is_standard_layout_v<StorageBufferType>>>
BufferView impeller::HostBuffer::EmplaceStorageBuffer ( const StorageBufferType &  buffer)
inline

Emplace storage buffer data onto the host buffer. Ensure that backend specific uniform alignment requirements are respected.

Parameters
[in]uniformThe storage buffer to emplace onto the buffer.
Template Parameters
StorageBufferTypeThe type of the shader storage buffer.
Returns
The buffer view.

Definition at line 72 of file host_buffer.h.

73 {
74 const auto alignment =
75 std::max(alignof(StorageBufferType), DefaultUniformAlignment());
76 return Emplace(&buffer, // buffer
77 sizeof(StorageBufferType), // size
78 alignment // alignment
79 );
80 }
constexpr size_t DefaultUniformAlignment()
Definition platform.h:15

◆ EmplaceUniform()

template<class UniformType , class = std::enable_if_t<std::is_standard_layout_v<UniformType>>>
BufferView impeller::HostBuffer::EmplaceUniform ( const UniformType &  uniform)
inline

Emplace uniform data onto the host buffer. Ensure that backend specific uniform alignment requirements are respected.

Parameters
[in]uniformThe uniform struct to emplace onto the buffer.
Template Parameters
UniformTypeThe type of the uniform struct.
Returns
The buffer view.

Definition at line 50 of file host_buffer.h.

50 {
51 const auto alignment =
52 std::max(alignof(UniformType), DefaultUniformAlignment());
53 return Emplace(reinterpret_cast<const void*>(&uniform), // buffer
54 sizeof(UniformType), // size
55 alignment // alignment
56 );
57 }

◆ GetStateForTest()

HostBuffer::TestStateQuery impeller::HostBuffer::GetStateForTest ( )

Retrieve internal buffer state for test expectations.

Definition at line 69 of file host_buffer.cc.

69 {
70 return HostBuffer::TestStateQuery{
71 .current_frame = frame_index_,
72 .current_buffer = current_buffer_,
73 .total_buffer_count = device_buffers_[frame_index_].size(),
74 };
75}

◆ Reset()

void impeller::HostBuffer::Reset ( )

Resets the contents of the HostBuffer to nothing so it can be reused.

Definition at line 195 of file host_buffer.cc.

195 {
196 // When resetting the host buffer state at the end of the frame, check if
197 // there are any unused buffers and remove them.
198 while (device_buffers_[frame_index_].size() > current_buffer_ + 1) {
199 device_buffers_[frame_index_].pop_back();
200 }
201
202 offset_ = 0u;
203 current_buffer_ = 0u;
204 frame_index_ = (frame_index_ + 1) % kHostBufferArenaSize;
205}
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
Definition switches.h:259
static const constexpr size_t kHostBufferArenaSize
Approximately the same size as the max frames in flight.
Definition host_buffer.h:22

◆ SetLabel()

void impeller::HostBuffer::SetLabel ( std::string  label)

Definition at line 37 of file host_buffer.cc.

37 {
38 label_ = std::move(label);
39}

The documentation for this class was generated from the following files: