Flutter Engine Uber Docs
Docs for the entire Flutter Engine repo.
 
Loading...
Searching...
No Matches
impeller::DeviceBufferGLES Class Referencefinal

#include <device_buffer_gles.h>

Inheritance diagram for impeller::DeviceBufferGLES:
impeller::DeviceBuffer impeller::BackendCast< DeviceBufferGLES, DeviceBuffer >

Public Types

enum class  BindingType {
  kArrayBuffer ,
  kElementArrayBuffer ,
  kUniformBuffer
}
 

Public Member Functions

 DeviceBufferGLES (DeviceBufferDescriptor desc, std::shared_ptr< ReactorGLES > reactor, std::unique_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 DeviceBufferDescriptorGetDeviceBufferDescriptor () 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.
 
- Static Public Member Functions inherited from impeller::BackendCast< DeviceBufferGLES, DeviceBuffer >
static DeviceBufferGLESCast (DeviceBuffer &base)
 
static const DeviceBufferGLESCast (const DeviceBuffer &base)
 
static DeviceBufferGLESCast (DeviceBuffer *base)
 
static const DeviceBufferGLESCast (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 19 of file device_buffer_gles.h.

Member Enumeration Documentation

◆ BindingType

Enumerator
kArrayBuffer 
kElementArrayBuffer 
kUniformBuffer 

Definition at line 35 of file device_buffer_gles.h.

Constructor & Destructor Documentation

◆ DeviceBufferGLES()

impeller::DeviceBufferGLES::DeviceBufferGLES ( DeviceBufferDescriptor  desc,
std::shared_ptr< ReactorGLES reactor,
std::unique_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)) {}
DeviceBuffer(DeviceBufferDescriptor desc)
std::shared_ptr< ReactorGLES > reactor

◆ ~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 91 of file device_buffer_gles.cc.

91 {
92 if (!reactor_) {
93 return false;
94 }
95
96 if (!handle_.has_value()) {
97 handle_ = reactor_->CreateUntrackedHandle(HandleType::kBuffer);
98#ifdef IMPELLER_DEBUG
99 if (handle_.has_value() && label_.has_value()) {
100 reactor_->SetDebugLabel(*handle_, *label_);
101 }
102#endif
103 }
104
105 auto buffer = reactor_->GetGLHandle(*handle_);
106 if (!buffer.has_value()) {
107 return false;
108 }
109
110 const auto target_type = ToTarget(type);
111 const auto& gl = reactor_->GetProcTable();
112
113 gl.BindBuffer(target_type, buffer.value());
114 if (!initialized_) {
115 gl.BufferData(target_type, backing_store_->GetLength().GetByteSize(),
116 nullptr, GL_DYNAMIC_DRAW);
117 initialized_ = true;
118 }
119
120 // Take and clear the dirty range BEFORE uploading. A Flush() from another
121 // thread during the upload then merges into a fresh dirty range that the
122 // next bind uploads, instead of being silently discarded by a clear that
123 // runs after the upload.
124 std::optional<Range> dirty;
125 {
126 Lock lock(dirty_range_mutex_);
127 std::swap(dirty_range_, dirty);
128 }
129 if (dirty.has_value()) {
130 gl.BufferSubData(target_type, dirty->offset, dirty->length,
131 backing_store_->GetBuffer() + dirty->offset);
132 }
133
134 return true;
135}
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir Path to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service The hostname IP address on which the Dart VM Service should be served If not defaults to or::depending on whether ipv6 is specified disable vm Disable the Dart VM Service The Dart VM Service is never available in release mode Bind to the IPv6 localhost address for the Dart VM Service Ignored if vm service host is set profile Make the profiler discard new samples once the profiler sample buffer is full When this flag is not the profiler sample buffer is used as a ring buffer
Definition switch_defs.h:98
static GLenum ToTarget(DeviceBufferGLES::BindingType type)
impeller::ShaderType type

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

◆ Flush()

void impeller::DeviceBufferGLES::Flush ( std::optional< Range range = std::nullopt) const
overridevirtual

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 Lock lock(dirty_range_mutex_);
67 if (!range.has_value()) {
68 dirty_range_ = Range{
69 0, static_cast<size_t>(backing_store_->GetLength().GetByteSize())};
70 } else {
71 if (dirty_range_.has_value()) {
72 dirty_range_ = dirty_range_->Merge(range.value());
73 } else {
74 dirty_range_ = range.value();
75 }
76 }
77}

References impeller::Range::Merge().

Referenced by impeller::testing::TEST(), and UpdateBufferData().

◆ GetBufferData()

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

Definition at line 155 of file device_buffer_gles.cc.

155 {
156 return backing_store_->GetBuffer();
157}

◆ 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 159 of file device_buffer_gles.cc.

161 {
162 if (update_buffer_data) {
163 update_buffer_data(backing_store_->GetBuffer(),
164 backing_store_->GetLength().GetByteSize());
165 Flush(Range{
166 0, static_cast<size_t>(backing_store_->GetLength().GetByteSize())});
167 }
168}
void Flush(std::optional< Range > range=std::nullopt) const override

References Flush().

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


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