| Flutter Impeller |

Public Types | Public Member Functions | List of all members
impeller::DeviceBufferGLES Class Referencefinal

`#include <device_buffer_gles.h>`

Inheritance diagram for impeller::DeviceBufferGLES:

## Public Types
enum class | BindingType { kArrayBuffer , kElementArrayBuffer , kUniformBuffer }

## Public Member Functions
| DeviceBufferGLES (DeviceBufferDescriptor desc, std::shared_ptr< ReactorGLES > reactor, std::shared_ptr< Allocation > backing_store)
| ~DeviceBufferGLES () override
const uint8_t * | GetBufferData () const
void | UpdateBufferData (const std::function< void(uint8_t *, size_t length)> &update_buffer_data)
bool | BindAndUploadDataIfNecessary (BindingType type) const
void | Flush (std::optional< Range > range=std::nullopt) const override
std::optional< GLuint > | GetHandle () const
Public Member Functions inherited from impeller::DeviceBuffer
virtual | ~DeviceBuffer ()
bool | CopyHostBuffer (const uint8_t *source, Range source_range, size_t offset=0u)
const DeviceBufferDescriptor & | GetDeviceBufferDescriptor () const
virtual void | Invalidate (std::optional< Range > range=std::nullopt) const

## Additional Inherited Members
Static Public Member Functions inherited from impeller::DeviceBuffer
static BufferView | AsBufferView (std::shared_ptr< DeviceBuffer > buffer)
| Create a buffer view of this entire buffer. More...
Static Public Member Functions inherited from impeller::BackendCast< DeviceBufferGLES, DeviceBuffer >
static DeviceBufferGLES & | Cast (DeviceBuffer &base)
static const DeviceBufferGLES & | Cast (const DeviceBuffer &base)
static DeviceBufferGLES * | Cast (DeviceBuffer *base)
static const DeviceBufferGLES * | Cast (const DeviceBuffer *base)
Protected Member Functions inherited from impeller::DeviceBuffer
| DeviceBuffer (DeviceBufferDescriptor desc)
Protected Attributes inherited from impeller::DeviceBuffer
const DeviceBufferDescriptor | desc_

## Detailed Description

Definition at line 18 of file device_buffer_gles.h.

## Member Enumeration Documentation

## ◆ BindingType

enum impeller::DeviceBufferGLES::BindingType
| strong

Enumerator
kArrayBuffer |
kElementArrayBuffer |
kUniformBuffer |

Definition at line 34 of file device_buffer_gles.h.

34 {
35 kArrayBuffer,
36 kElementArrayBuffer,
37 kUniformBuffer,
38 };
impeller::DescriptorType::kUniformBuffer
@ kUniformBuffer

## Constructor & Destructor Documentation

## ◆ DeviceBufferGLES()

impeller::DeviceBufferGLES::DeviceBufferGLES | ( | DeviceBufferDescriptor | desc,
|  | std::shared_ptr< ReactorGLES > | reactor,
|  | std::shared_ptr< Allocation > | backing_store
| ) |  |

Definition at line 15 of file device_buffer_gles.cc.

18 : DeviceBuffer(desc),
19 reactor_(std::move(reactor)),
20 backing_store_(std::move(backing_store)) {}
impeller::DeviceBuffer::DeviceBuffer
DeviceBuffer(DeviceBufferDescriptor desc)
Definition: device_buffer.cc:9

## ◆ ~DeviceBufferGLES()

impeller::DeviceBufferGLES::~DeviceBufferGLES | ( |  | ) |
| override

Definition at line 23 of file device_buffer_gles.cc.

23 {
24 if (handle_.has_value() && !handle_->IsDead()) {
25 reactor_->CollectHandle(*handle_);
26 }
27 }

## Member Function Documentation

## ◆ BindAndUploadDataIfNecessary()

bool impeller::DeviceBufferGLES::BindAndUploadDataIfNecessary | ( | BindingType | type | ) | const

Definition at line 90 of file device_buffer_gles.cc.

90 {
91 if (!reactor_) {
92 return false;
93 }
94
95 if (!handle_.has_value()) {
96 handle_ = reactor_->CreateUntrackedHandle(HandleType::kBuffer);
97 #ifdef IMPELLER_DEBUG
98 if (handle_.has_value() && label_.has_value()) {
99 reactor_->SetDebugLabel(*handle_, *label_);
100 }
101 #endif
102 }
103
104 auto buffer = reactor_->GetGLHandle(*handle_);
105 if (!buffer.has_value()) {
106 return false;
107 }
108
109 const auto target_type = ToTarget(type);
110 const auto& gl = reactor_->GetProcTable();
111
112 gl.BindBuffer(target_type, buffer.value());
113 if (!initialized_) {
114 gl.BufferData(target_type, backing_store_->GetLength().GetByteSize(),
115 nullptr, GL_DYNAMIC_DRAW);
116 initialized_ = true;
117 }
118
119 if (dirty_range_.has_value()) {
120 auto range = dirty_range_.value();
121 gl.BufferSubData(target_type, range.offset, range.length,
122 backing_store_->GetBuffer() + range.offset);
123 dirty_range_ = std::nullopt;
124 }
125
126 return true;
127 }
type
GLenum type
Definition: blit_command_gles.cc:151
impeller::ToTarget
static GLenum ToTarget(DeviceBufferGLES::BindingType type)
Definition: device_buffer_gles.cc:78
impeller::HandleType::kBuffer
@ kBuffer

References impeller::kBuffer, impeller::ToTarget(), and type.

## ◆ Flush()

void impeller::DeviceBufferGLES::Flush | ( | std::optional< Range > | range = `std::nullopt` | ) | const
| override virtual

Make any pending writes visible to the GPU.

This method must be called if the device pointer provided by [OnGetContents] is written to without using [CopyHostBuffer]. On Devices with coherent host memory, this method will not perform extra work.

If the range is not provided, the entire buffer is flushed.

Reimplemented from impeller::DeviceBuffer.

Definition at line 65 of file device_buffer_gles.cc.

65 {
66 if (!range.has_value()) {
67 dirty_range_ = Range{
68 0, static_cast<size_t>(backing_store_->GetLength().GetByteSize())};
69 } else {
70 if (dirty_range_.has_value()) {
71 dirty_range_ = dirty_range_->Merge(range.value());
72 } else {
73 dirty_range_ = range.value();
74 }
75 }
76 }

Referenced by UpdateBufferData().

## ◆ GetBufferData()

const uint8_t * impeller::DeviceBufferGLES::GetBufferData | ( |  | ) | const

Definition at line 147 of file device_buffer_gles.cc.

147 {
148 return backing_store_->GetBuffer();
149 }

## ◆ GetHandle()

std::optional< GLuint > impeller::DeviceBufferGLES::GetHandle | ( |  | ) | const

Definition at line 57 of file device_buffer_gles.cc.

57 {
58 if (handle_.has_value()) {
59 return reactor_->GetGLHandle(*handle_);
60 } else {
61 return std::nullopt;
62 }
63 }

## ◆ UpdateBufferData()

void impeller::DeviceBufferGLES::UpdateBufferData | ( | const std::function< void(uint8_t *, size_t length)> & | update_buffer_data | ) |

Definition at line 151 of file device_buffer_gles.cc.

153 {
154 if (update_buffer_data) {
155 update_buffer_data(backing_store_->GetBuffer(),
156 backing_store_->GetLength().GetByteSize());
157 Flush(Range{
158 0, static_cast<size_t>(backing_store_->GetLength().GetByteSize())});
159 }
160 }
impeller::DeviceBufferGLES::Flush
void Flush(std::optional< Range > range=std::nullopt) const override
Definition: device_buffer_gles.cc:65

References Flush().

Referenced by impeller::BlitCopyTextureToBufferCommandGLES::Encode().

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

- impeller/renderer/backend/gles/device_buffer_gles.h
- impeller/renderer/backend/gles/device_buffer_gles.cc